:root {
  --navy: #14213d;
  --navy-700: #1d2d50;
  --navy-600: #2a3f6e;
  --ink: #1a1d24;
  --ink-soft: #4a5160;
  --paper: #f7f5f0;
  --card: #ffffff;
  --line: #e6e2d8;
  --gold: #b8860b;
  --gold-soft: #f3e9cf;
  --green: #1f7a4d;
  --green-soft: #e3f3ea;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --blue: #1a5fb4;
  --blue-soft: #e6eefb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.06);
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--navy);
  color: #cdd5e6;
  padding: 22px 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand {
  padding: 0 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
.brand .logo {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; color: #fff;
  letter-spacing: .5px;
}
.brand .logo span { color: var(--gold); }
.brand small { display: block; color: #8e99b5; font-size: 11.5px; margin-top: 2px; letter-spacing:.4px; }

.nav-group { padding: 6px 12px; }
.nav-group .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
  color: #6f7ba0; padding: 14px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0; border-radius: 8px;
  color: #cdd5e6; font-size: 14px; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--gold); color: #1a1404; font-weight: 600; }
.nav a .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 14px 22px 0; font-size: 11.5px; color: #6f7ba0; }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 28px; height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 14px; }
.userbox .who { text-align: right; line-height: 1.25; }
.userbox .who b { font-size: 13.5px; }
.userbox .who small { color: var(--ink-soft); font-size: 11.5px; display:block; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.role-pill {
  font-size: 10.5px; padding: 2px 9px; border-radius: 20px;
  background: var(--gold-soft); color: #6b4e00; font-weight: 600; letter-spacing:.3px;
}

/* ---------- Content ---------- */
.content { padding: 28px; }
.page-title { font-family: var(--font-display); font-size: 26px; margin-bottom: 4px; }
.page-sub { color: var(--ink-soft); margin-bottom: 22px; font-size: 14px; }

/* ---------- Cards / KPI ---------- */
.grid { display: grid; gap: 18px; }
.grid.kpi { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .body { padding: 20px; }
.kpi-card { padding: 20px; position: relative; overflow: hidden; }
.kpi-card .k-label { color: var(--ink-soft); font-size: 13px; }
.kpi-card .k-value { font-size: 30px; font-weight: 700; font-family: var(--font-display); margin-top: 6px; }
.kpi-card .k-accent { position:absolute; right:-10px; top:-10px; font-size:64px; opacity:.06; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 30px 0 14px;
}
.section-head h2 { font-size: 17px; font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 14px; }
thead th {
  text-align: left; padding: 11px 14px; background: #f0ede6;
  color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: #faf8f3; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); text-decoration: none; }
.btn-gold { background: var(--gold); color: #1a1404; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f7f5f0; text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 5px; }
input, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { margin-bottom: 0; }

/* ---------- Flash / alerts ---------- */
.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.alert.success { background: var(--green-soft); border-color: #bfe3cd; color: #145c39; }
.alert.error   { background: var(--red-soft); border-color: #f3c4bf; color: #8a1c16; }

/* ---------- Badges ---------- */
.badge { font-size: 11.5px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.gold  { background: var(--gold-soft); color: #6b4e00; }
.badge.gray  { background: #eee; color: #555; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
}
.login-art {
  background: linear-gradient(160deg, var(--navy) 0%, #0d1730 100%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-art::after {
  content: ""; position: absolute; right: -80px; bottom: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(184,134,11,.35), transparent 70%);
}
.login-art .logo { font-family: var(--font-display); font-size: 42px; font-weight: 700; }
.login-art .logo span { color: var(--gold); }
.login-art p { color: #aab4d0; margin-top: 14px; max-width: 380px; line-height: 1.7; }
.login-art ul { margin-top: 26px; list-style: none; color: #c7cee0; }
.login-art ul li { padding: 5px 0; display: flex; gap: 10px; align-items: center; }
.login-art ul li::before { content: "✦"; color: var(--gold); }
.login-form-side { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-family: var(--font-display); font-size: 28px; margin-bottom: 4px; }
.login-card .lead { color: var(--ink-soft); margin-bottom: 26px; }

/* ---------- Error pages ---------- */
.err { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 40px; }
.err .code { font-family: var(--font-display); font-size: 96px; color: var(--navy); }
.err h2 { margin: 6px 0 10px; }
.err p { color: var(--ink-soft); margin-bottom: 22px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
