:root {
  --navy: #0f2747;
  --navy-dark: #081729;
  --navy-light: #1c3a63;
  --gold: #c9a227;
  --gold-light: #e3c466;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #dde1e7;
  --gray-500: #667085;
  --gray-700: #344054;
  --gray-900: #101828;
  --good: #2f9e5b;
  --warn: #d99a1d;
  --bad: #c0362c;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(15, 39, 71, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 39, 71, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
}

.hidden { display: none !important; }

a { color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--gold); color: var(--navy-dark); }
.btn-primary:hover { background: var(--gold-light); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-dark), var(--navy));
  padding: 24px;
}
.login-card {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-logo { font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.login-logo strong { color: var(--gold); }
.login-logo span { font-weight: 500; color: var(--gray-500); font-size: 0.9rem; margin-left: 6px; }
.login-sub { color: var(--gray-500); font-size: 0.92rem; margin: 0 0 6px; }
.login-card input {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,39,71,0.1); }
.login-error { color: var(--bad); font-size: 0.88rem; font-weight: 600; min-height: 1.2em; margin: 0; }

/* ---------- Dashboard layout ---------- */
.topbar {
  background: var(--navy-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-title strong { color: var(--gold); }
.topbar-title span { color: #9aa8c2; font-weight: 500; font-size: 0.85rem; margin-left: 6px; }
.topbar-actions { display: flex; gap: 10px; }
.topbar .btn-ghost { color: #e6ebf3; border-color: rgba(255,255,255,0.25); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,0.08); }

.content { max-width: 1160px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 12px;
}
.stat-card {
  background: #ffffff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-label { margin: 0 0 6px; font-size: 0.85rem; color: var(--gray-500); font-weight: 600; }
.stat-value { margin: 0; font-size: 2rem; font-weight: 700; color: var(--navy-dark); }
.stats-error { color: var(--bad); font-size: 0.88rem; font-weight: 600; margin: 6px 0 18px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--gray-200); margin-bottom: 22px; }
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 6px;
  margin-right: 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  font-family: inherit;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--navy-dark); border-bottom-color: var(--gold); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 1.2rem; color: var(--navy-dark); }
.panel-error { color: var(--bad); font-size: 0.88rem; font-weight: 600; min-height: 1.1em; }

/* ---------- Table ---------- */
.table-wrap {
  background: #ffffff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
.empty-row { color: var(--gray-500); text-align: center; white-space: normal; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.badge-good { background: rgba(47,158,91,0.12); color: #1d6b3e; }
.badge-bad { background: rgba(192,54,44,0.1); color: var(--bad); }
.badge-neutral { background: var(--gray-100); color: var(--gray-500); }
.cell-wrap { white-space: normal; max-width: 280px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8,23,41,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 30px 30px 26px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0; color: var(--navy-dark); font-size: 1.2rem; }
.modal-sub { margin: 0; color: var(--gray-500); font-size: 0.9rem; }
.modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal .form-field { display: flex; flex-direction: column; gap: 5px; }
.modal label { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.modal input, .modal select {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-family: inherit;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,39,71,0.1); }
.modal-error { color: var(--bad); font-size: 0.85rem; font-weight: 600; margin: 0; min-height: 1.1em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.password-reveal {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 14px 16px;
}
.password-reveal code { font-size: 1.05rem; font-weight: 700; color: var(--navy-dark); letter-spacing: 0.02em; }

@media (max-width: 760px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal .form-row { grid-template-columns: 1fr; }
}
