/* DriveTap design system — Partners */
:root {
  --midnight: #0B1020;
  --surface: #131A2A;
  --surface-2: #1B2438;
  --emerald: #2F6BFF;       /* brand blue accent (legacy key name) */
  --emerald-dim: #0038A8;   /* royal */
  --amber: #FCD116;         /* flag sun yellow */
  --royal: #0038A8;         /* PH flag blue */
  --flag-red: #CE1126;      /* PH flag red */
  --sun: #FCD116;           /* PH flag sun */
  --text: #E8EDF6;
  --muted: #8A97AD;
  --border: #232E44;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --body-glow: #14203a;
  --sidebar-grad-1: #0d1424;
  --sidebar-grad-2: #0b1020;
}

/* Light theme — everything below already reads through the tokens above, so
   this is the whole app's light palette in one place. Applied via
   data-theme="light" on <html>, set by the inline script in _Layout before
   first paint (avoids a flash of the wrong theme) and toggled by
   dtToggleTheme(). Login stays dark-only — it's the cinematic video
   background, not the app shell the toggle is for. */
:root[data-theme="light"] {
  --midnight: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EDF0F8;
  --text: #101528;
  --muted: #5B6472;
  --border: #DDE2EE;
  --shadow: 0 10px 24px rgba(20,32,58,.10);
  --body-glow: #E4EAFB;
  --sidebar-grad-1: #FFFFFF;
  --sidebar-grad-2: #F4F6FB;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, var(--body-glow) 0%, var(--midnight) 55%);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
}
a { color: inherit; text-decoration: none; }

.layout { display: block; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-grad-1), var(--sidebar-grad-2));
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  /* Fixed (not sticky/grid-stretch) so it's always pinned to the viewport,
     independent of how tall .main's content grows, and so it establishes a
     real containing block for the sign-out footer below — that footer is
     position:absolute with no positioned ancestor otherwise, which anchored
     it to the whole document instead of the sidebar: on any page tall enough
     to scroll, it drifted down the page and spanned the full viewport width,
     overlapping main-content buttons instead of sitting under the nav links. */
  position: fixed;
  top: 0;
  left: 0;
  width: 248px;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--royal), var(--flag-red));
  display: grid; place-items: center; font-weight: 800; color: #ffffff;
}
.brand b { font-size: 18px; letter-spacing: .3px; }
.brand small { color: var(--muted); display: block; font-weight: 500; }

.theme-toggle {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; font-size: 13px; flex: none;
}
.theme-toggle:hover { color: var(--text); }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 600;
  margin-bottom: 4px;
}
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { box-shadow: inset 3px 0 0 var(--emerald); }
.nav a i { width: 20px; text-align: center; margin-right: 2px; }

.main { margin-left: 248px; padding: 26px 30px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .pill { background: var(--surface-2); border: 1px solid var(--border); padding: 7px 12px; border-radius: 999px; color: var(--muted); }
.pill .dot { color: var(--emerald); }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat .value.emerald { color: var(--emerald); }
.stat .value.amber { color: var(--amber); }

.two-col { grid-template-columns: 1.4fr 1fr; align-items: start; }
#map { height: 360px; border-radius: 12px; overflow: hidden; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.green { background: rgba(47,107,255,.14); color: var(--emerald); }
.badge.amber { background: rgba(255,179,0,.14); color: var(--amber); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.zero { background: rgba(47,107,255,.2); color: var(--emerald); }
.badge.red { background: rgba(239,68,68,.16); color: #f87171; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 11px; font-weight: 700; border: none; cursor: pointer;
  background: var(--emerald); color: #ffffff;
}
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.4); color: #f87171; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn:hover { filter: brightness(1.05); }

/* Filter toolbar shared by every grid page: search + dropdowns + Download PDF. */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar input[type=search] { width: 230px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.toolbar .spacer { flex: 1; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions form { margin: 0; }

input[type=number], input[type=text], input[type=date], select, textarea {
  background: var(--midnight); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 10px; width: 100%; font-size: 13px; font-family: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
label.fld { display: block; }
label.fld span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }

/* ------------------------------- Support -------------------------------- */
.msg { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 10px; }
.msg.staff { border-color: var(--emerald-dim); background: rgba(47,107,255,.08); }
.msg .meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.msg .body { white-space: pre-wrap; line-height: 1.5; }

.flash { background: rgba(47,107,255,.12); border: 1px solid var(--emerald-dim); color: var(--emerald); padding: 11px 14px; border-radius: 11px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.policy-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.policy-line b { color: var(--emerald); }

/* ---------------------------- Auth / login ---------------------------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; overflow: hidden;
  background: var(--midnight);
}
.auth-bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .5; z-index: 0;
}
.auth-bg-overlay {
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(680px 360px at 50% -6%, rgba(47,107,255,.22), transparent 60%),
    radial-gradient(820px 460px at 88% 112%, rgba(206,17,38,.18), transparent 60%),
    linear-gradient(180deg, rgba(11,16,32,.55), rgba(11,16,32,.85));
}
.auth-card {
  width: 100%; max-width: 384px; position: relative; z-index: 2;
  background: linear-gradient(180deg, rgba(27,36,56,.72), rgba(19,26,42,.92));
  border: 1px solid var(--border); border-radius: 22px; padding: 32px 28px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: auth-rise .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes auth-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-logo {
  display: block; width: 76px; height: 76px; object-fit: contain;
  margin: 0 auto 16px;
  filter: drop-shadow(0 12px 20px rgba(47,107,255,.35));
}
.auth-title { text-align: center; font-size: 23px; font-weight: 800; margin: 0; letter-spacing: .2px; }
.auth-sub { text-align: center; color: var(--muted); margin: 5px 0 24px; }
.auth-field { margin-bottom: 14px; }
.auth-field > label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.auth-control {
  display: flex; align-items: center; gap: 10px;
  background: var(--midnight); border: 1px solid var(--border); border-radius: 13px; padding: 0 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-control:focus-within { border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(47,107,255,.16); }
.auth-control .ico { font-size: 15px; opacity: .8; }
.auth-control input {
  background: transparent; border: 0; outline: none; color: var(--text);
  padding: 13px 0; width: 100%; font-size: 14.5px;
}
.auth-btn {
  width: 100%; border: 0; cursor: pointer; margin-top: 8px; padding: 14px 16px; border-radius: 14px;
  font-weight: 800; font-size: 15px; color: #ffffff;
  background: linear-gradient(135deg, var(--royal), var(--flag-red));
  box-shadow: 0 12px 26px rgba(47,107,255,.34);
  transition: transform .06s ease, filter .15s ease;
}
.auth-btn:hover { filter: brightness(1.06); }
.auth-btn:active { transform: translateY(1px); }
.auth-error {
  background: rgba(255,90,95,.12); border: 1px solid rgba(255,90,95,.4); color: #ff9094;
  border-radius: 11px; padding: 10px 13px; font-size: 13px; margin-bottom: 16px;
}
.auth-error ul { margin: 0; padding-left: 18px; } .auth-error li { list-style: none; margin-left: -18px; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: 18px 0 0; }
.auth-hint code { background: var(--surface-2); padding: 2px 7px; border-radius: 7px; color: var(--text); font-size: 12px; }
