/* ─── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 6px 10px rgba(0,0,0,0.05);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Screens ─────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ─── Login ───────────────────────────────────────────────────────── */
#login-screen {
  display: none;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#login-screen.active {
  display: flex;
}

.login-container {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.logo-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}
.login-subtitle {
  color: var(--gray-500);
  font-size: 14px;
  margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 20px;
}
.login-form label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--gray-50);
}
.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: white;
}

.login-help {
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 24px;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-loader { display: inline-flex; align-items: center; gap: 8px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Messages ────────────────────────────────────────────────────── */
.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.success-msg {
  background: var(--success-light);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.hidden { display: none !important; }

/* ─── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-logo { font-size: 24px; }
.topbar-title { font-weight: 700; font-size: 16px; color: var(--gray-900); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-user {
  font-size: 14px;
  color: var(--gray-500);
}

/* ─── Dashboard ───────────────────────────────────────────────────── */
.dashboard {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.dashboard-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}
.date-display {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 2px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--danger-light);
  color: var(--danger);
}
.status-badge.updated {
  background: var(--success-light);
  color: var(--success);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── BNR Card ────────────────────────────────────────────────────── */
.bnr-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.bnr-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}
.bnr-rates {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.bnr-rate-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
}
.bnr-rate-item .currency {
  font-weight: 600;
  color: var(--gray-600);
}
.bnr-rate-item .value {
  font-weight: 700;
  color: var(--gray-900);
  font-size: 16px;
}
.bnr-loading { color: var(--gray-400); font-size: 14px; }

/* ─── Rates Card ──────────────────────────────────────────────────── */
.rates-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.rates-card-header {
  margin-bottom: 20px;
}
.rates-card-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.rates-card-header p {
  font-size: 14px;
  color: var(--gray-500);
}

/* Rates table-style form */
.rates-table {
  margin-bottom: 20px;
}
.rates-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
}
.rates-row.rates-header {
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 8px;
}
.rates-header .rates-cell {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.currency-label {
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
}
.flag { font-size: 20px; }

.rate-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: 'Inter', monospace;
  font-weight: 600;
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--gray-50);
  -moz-appearance: textfield;
}
.rate-input::-webkit-inner-spin-button,
.rate-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.rate-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: white;
}
.rate-input.filled {
  background: white;
  border-color: var(--gray-300);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.last-update {
  font-size: 13px;
  color: var(--gray-400);
}

/* ─── History Card ────────────────────────────────────────────────── */
.history-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.history-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.history-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.history th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: right;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 2px solid var(--gray-200);
}
table.history th:first-child { text-align: left; }
table.history td {
  padding: 10px 12px;
  text-align: right;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.history td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--gray-900);
}
table.history tr:hover td { background: var(--gray-50); }

.loading-text {
  color: var(--gray-400);
  text-align: center;
  padding: 20px;
  font-size: 14px;
}
.empty-text {
  color: var(--gray-400);
  text-align: center;
  padding: 20px;
  font-size: 14px;
}

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .login-container { padding: 28px 20px; }
  .topbar { padding: 10px 16px; }
  .topbar-user { display: none; }
  .dashboard { padding: 16px 12px 40px; }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
  .rates-row {
    grid-template-columns: 80px 1fr 1fr;
    gap: 8px;
  }
  .rate-input { padding: 8px 10px; font-size: 14px; }
  .bnr-rates { gap: 12px; }
}
