:root {
  --navy: #1B2A4A;
  --navy-light: #26385f;
  --gold: #C8A951;
  --gold-dark: #ad8f3f;
  --blue: #5B9BD5;
  --steel: #4F7192;
  --bg: #EEF3F8;
  --white: #ffffff;
  --ink: #1B2A4A;
  --ink-soft: #5b6b85;
  --border: #dde5ef;
  --green: #2f7d4f;
  --green-bg: #e6f4ea;
  --amber: #92650f;
  --amber-bg: #fbf0da;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27,42,74,0.06), 0 4px 14px rgba(27,42,74,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lato', -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 15px;
}

h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; color: var(--navy); margin: 0 0 4px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar {
  background-image: linear-gradient(100deg, rgba(15,23,44,0.93) 0%, rgba(27,42,74,0.90) 45%, rgba(27,42,74,0.80) 100%), url('/assets/header-bg.jpg');
  background-size: cover;
  background-position: center;
  border-bottom: 3px solid var(--gold);
  position: sticky; top: 0; z-index: 200;
}
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 14px 24px 0; }

.topbar-row-top {
  display: flex; align-items: center; gap: 16px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; flex: 1 1 0%; }
.brand-logo { height: 76px; width: auto; max-width: 240px; display: block; object-fit: contain; }
.brand-mark {
  background: var(--gold); color: var(--navy); font-weight: 700;
  width: 44px; height: 44px; border-radius: 10px;
  align-items: center; justify-content: center; font-size: 16px;
}
.topbar-title {
  font-family: 'Playfair Display', serif; font-weight: 700; font-size: 22px;
  color: var(--white); text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  letter-spacing: 0.02em; text-align: center; white-space: nowrap;
  flex: 0 0 auto;
}
.user-menu { display: flex; align-items: center; gap: 14px; flex: 1 1 0%; justify-content: flex-end; }
.user-email { color: #e4e9f4; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,0.35); }
.btn-logout {
  color: var(--white); background: rgba(255,255,255,0.12); padding: 7px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.tabs {
  display: flex; justify-content: center; gap: 6px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.tabs a {
  color: #e4e9f4; padding: 15px 16px; font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.tabs a:hover { color: var(--white); }
.tabs a.active { color: var(--white); border-bottom-color: var(--gold); }
.tab-icon { width: 21px; height: 21px; flex-shrink: 0; opacity: 0.95; }

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-footer { text-align: center; padding: 24px; color: var(--ink-soft); font-size: 12px; }

.subtabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.subtabs a {
  padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtabs a.active { color: var(--navy); border-bottom-color: var(--navy); }

/* ---------- Cards / metrics ---------- */
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border-top: 3px solid var(--gold);
}
.metric-card .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; }
.metric-card .value { font-family: 'Playfair Display', serif; font-size: 26px; color: var(--navy); margin-top: 4px; }

.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg); color: var(--navy); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
tbody tr:hover { background: #f6f9fc; }
td.wrap, th.wrap { white-space: normal; min-width: 160px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.total-row td { font-weight: 700; background: var(--bg); border-top: 2px solid var(--navy); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-grey { background: #eef1f6; color: var(--ink-soft); }
.badge-blue { background: #e7f0fa; color: var(--blue); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 7px; font-weight: 700; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #f7d3cf; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 5px 8px; font-size: 12px; }

input, select, textarea {
  font-family: inherit; font-size: 13.5px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--white); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
label { font-size: 12px; font-weight: 700; color: var(--ink-soft); display: block; margin-bottom: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 14px; }
.field { margin-bottom: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }

.row-form td { background: #fbfcfe; padding: 6px; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

.search-box { max-width: 260px; }

.alert { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, var(--navy), #101d38); }
.login-card {
  background: var(--white); border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center;
}
.login-brand { margin-bottom: 26px; }
.login-mark {
  background: var(--gold); color: var(--navy); font-weight: 700; width: 48px; height: 48px;
  border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px;
  margin: 0 auto 14px;
}
.login-card h1 { font-size: 20px; }
.btn-google {
  width: 100%; background: var(--white); border: 1px solid var(--border); color: var(--ink);
  padding: 11px 16px; margin-top: 10px;
}
.btn-google:hover { background: var(--bg); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .topbar-inner { padding: 10px 16px 0; }
  .topbar-row-top { gap: 10px; padding-bottom: 10px; }
  .topbar-title { font-size: 15px; }
  .brand-logo { height: 40px; }
  .user-menu { gap: 8px; }
  .tabs { justify-content: flex-start; overflow-x: auto; }
  .page { padding: 18px 14px 40px; }
}
@media (max-width: 520px) {
  .user-email { display: none; }
}
