@font-face {
  font-family: Inter;
  src: url("/static/fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --navy: #0B1F3A;
  --navy-2: #13305A;
  --acc: #F2A33A;
  --bg: #F3F6FA;
  --ink: #0B1F3A;
  --muted: #5B6B85;
  --faint: #8A97AB;
  --line: #E3E9F2;
  --line-2: #D3DBE8;
  --card: #fff;
  --neg: #C0392B;
  --ok: #2FAE66;
  --soft: #C9D4E6;
  --sky: #7C9CC9;
  --font: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
button, input, select, textarea { font-family: inherit; }

/* ===== Logo ===== */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--acc); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex: none;
}

/* ===== Login ===== */
.login-body {
  min-height: 100vh; display: flex; background: var(--navy);
}
.login-left {
  flex: 1; padding: 64px; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
}
.login-left h2 { font-size: 40px; line-height: 1.15; max-width: 460px; font-weight: 700; color: #fff; }
.login-left .lead { color: #A9B8D0; margin-top: 16px; font-size: 17px; max-width: 420px; line-height: 1.5; }
.stats { display: flex; gap: 36px; }
.stats div b { display: block; font-size: 28px; color: var(--acc); }
.stats div span { font-size: 13px; color: #A9B8D0; }
.login-right {
  width: 520px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
.login-card { width: 380px; max-width: 100%; }
.login-card h1 { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.sub {
  color: var(--acc); font-weight: 600; margin: 6px 0 34px;
  font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
}
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #3C4C66; }
.login-card input[type=text],
.login-card input[type=email],
.login-card input[type=password] {
  width: 100%; height: 46px; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 0 14px; margin-bottom: 18px; font-size: 15px; color: var(--navy);
  background: #F8FAFD;
}
.login-card input::placeholder { color: #9AA7BB; }
.login-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin: -4px 0 6px; gap: 10px;
}
.login-row label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; color: var(--muted); }
.login-row a, .reset-hint { color: var(--muted); text-decoration: none; cursor: pointer; }
.login-row a:hover, .reset-hint:hover { text-decoration: underline; }
.btn-sign {
  width: 100%; height: 48px; border: 0; border-radius: 10px;
  background: var(--navy); color: #fff; font-weight: 600; font-size: 16px;
  cursor: pointer; margin-top: 8px;
}
.btn-sign:hover { background: var(--navy-2); }
.login-note {
  margin-top: 28px; display: flex; gap: 10px; align-items: center;
  font-size: 13px; color: var(--muted); background: var(--bg);
  border-radius: 10px; padding: 12px 14px;
}
.lock { width: 18px; height: 18px; border-radius: 5px; background: var(--navy); flex: none; }
.login-domain { margin-top: 22px; font-size: 12px; color: var(--faint); text-align: center; }
.setup-msg { font-size: 18px; text-align: center; margin: 24px 0; color: var(--navy); }
.callout { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.callout.warn { background: #FDECEC; color: var(--neg); }
.callout.ok { background: #E8F8EE; color: #1f6b3a; }

@media (max-width: 800px) {
  .login-body { flex-direction: column; }
  .login-left {
    flex: none; padding: 22px 20px 18px;
    justify-content: flex-start; gap: 14px;
  }
  .login-left h2 { font-size: 26px; max-width: none; }
  .login-left .lead { font-size: 14px; margin-top: 8px; }
  .login-left .hero { display: none; }
  .stats { gap: 20px; }
  .stats div b { font-size: 22px; }
  .login-right { width: 100%; flex: 1; align-items: flex-start; padding: 28px 20px 40px; }
}

/* ===== App chrome ===== */
.app { min-height: 100vh; background: var(--bg); }
.sidebar {
  display: none;
  position: fixed; inset: 0 auto 0 0;
  width: 228px; background: var(--navy); color: #fff;
  padding: 22px 16px; flex-direction: column; z-index: 20;
}
.sidebar .logo { margin-bottom: 28px; font-size: 15px; color: #fff; }
.side-nav { display: flex; flex-direction: column; overflow: auto; }
.nv {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 9px;
  color: #B6C4DB; font-size: 14.5px; margin-bottom: 3px;
  text-decoration: none;
}
.nv i {
  width: 16px; height: 16px; border-radius: 4px;
  border: 2px solid #5B7399; display: inline-block; flex: none;
}
.nv.on, .nv.active { background: var(--navy-2); color: #fff; }
.nv.on i, .nv.active i { border-color: var(--acc); background: var(--acc); }
.nv b, .badge {
  margin-left: auto; background: var(--acc); color: var(--navy);
  border-radius: 20px; font-size: 11px; font-weight: 700; padding: 2px 8px;
}
.sidebar .me {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  font-size: 13px; color: #B6C4DB; padding-top: 16px;
}
.av {
  width: 34px; height: 34px; border-radius: 50%;
  background: #2A4A7C; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none;
}
.me .out { font-size: 11px; color: #7F93B3; background: none; border: 0; color: #7F93B3; cursor: pointer; padding: 0; font-family: inherit; }
.me .out:hover { text-decoration: underline; }

.desktop-top {
  display: none;
  height: 64px; background: #fff; border-bottom: 1px solid var(--line);
  align-items: center; padding: 0 28px; gap: 20px;
}
.search {
  flex: 1; max-width: 460px; height: 40px; border-radius: 10px;
  background: var(--bg); display: flex; align-items: center; padding: 0 14px;
  color: var(--faint); font-size: 14px; border: 0; width: 100%;
}
.pv { font-size: 12px; color: var(--muted); margin-left: auto; }
.bell {
  position: relative; width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 18px; text-decoration: none; color: var(--navy); flex: none;
}
.bell em {
  position: absolute; top: -5px; right: -5px;
  background: var(--acc); color: var(--navy);
  font-style: normal; font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 1px 6px;
}

.mobile-top { display: none; }
.phone-hdr {
  display: flex; background: var(--navy); color: #fff;
  padding: 8px 20px 22px; justify-content: space-between; align-items: center;
  padding-top: max(8px, env(safe-area-inset-top));
}
.phone-hdr h1 { font-size: 24px; color: #fff; font-weight: 700; }
.phone-hdr .subd { font-size: 12px; color: #A9B8D0; margin-top: 2px; }
.phone-hdr .bell { width: 38px; height: 38px; background: var(--navy-2); color: #fff; }

.tabbar {
  display: flex;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  height: 84px; background: #fff; border-top: 1px solid var(--line);
  padding: 8px 6px 0; padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.tb {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 5px; font-size: 11px; color: var(--faint);
  text-decoration: none; background: none; border: 0; cursor: pointer; font-family: inherit;
  padding-top: 4px;
}
.tb i { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #B6C1D2; display: block; }
.tb.on, .tb.active { color: var(--navy); font-weight: 600; }
.tb.on i, .tb.active i { background: var(--acc); border-color: var(--acc); }

.drawer {
  position: fixed; inset: 0 18% 0 0; z-index: 30;
  background: var(--navy); color: #fff; padding: 20px 16px; overflow: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; color: #fff; margin-bottom: 12px; }
.drawer .nv { color: #B6C4DB; }
.drawer-bg { position: fixed; inset: 0; background: rgba(11,31,58,.45); z-index: 25; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: inherit;
  width: 40px; height: 40px; font-size: 20px; cursor: pointer; border-radius: 8px;
}

main.cont { padding: 20px 16px 110px; display: flex; flex-direction: column; gap: 16px; }
h1.page { font-size: 22px; font-weight: 700; }
.hd { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hd span, .meta { font-size: 13px; color: var(--muted); }

/* ===== Cards / KPIs ===== */
.k { display: grid; grid-template-columns: 1fr; gap: 12px; }
.c {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.c h3, .kcap {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.sm { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.neg { color: var(--neg); font-weight: 600; }
.pb { height: 8px; background: var(--line); border-radius: 6px; margin-top: 10px; overflow: hidden; }
.pb i, .pb > span { display: block; height: 100%; background: var(--navy); border-radius: 6px; }
.mid { display: flex; flex-direction: column; gap: 14px; }
.ch { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ch h3 { margin: 0; }

/* Approvals rows */
.ar { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid #EEF2F8; font-size: 13.5px; flex-wrap: wrap; }
.age { width: 46px; font-weight: 600; color: var(--navy-2); }
.abot { width: 130px; color: var(--muted); }
.it { flex: 1; min-width: 140px; }
.it small { display: block; color: var(--faint); font-size: 11.5px; }
.bt u, .bt .abtn, a.abtn, button.abtn {
  text-decoration: none; display: inline-block;
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  margin-left: 6px; border: 1px solid var(--line-2); color: var(--navy);
  background: #fff; cursor: pointer; font-family: inherit;
}
.bt .ap, button.abtn.ap { background: var(--navy); color: #fff; border-color: var(--navy); }
.bt .rj, button.abtn.rj { color: var(--neg); border-color: #F0CFCB; background: #fff; }
.bt .abtn:disabled { opacity: .5; }

.lg { font-size: 11.5px; color: var(--muted); display: flex; gap: 12px; }
.lg i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* Donut */
.don { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ring {
  width: 126px; height: 126px; border-radius: 50%;
  position: relative; flex: none;
}
.ring:after { content: ""; position: absolute; inset: 26px; background: #fff; border-radius: 50%; }
.ring b {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 1; font-size: 24px; font-weight: 700;
}
.ring b small { font-size: 10px; color: var(--muted); font-weight: 500; }
.dl { font-size: 12.5px; display: grid; gap: 5px; }
.dl i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; }
.strip { display: flex; flex-wrap: wrap; gap: 8px; }
.bb {
  font-size: 12.5px; background: var(--bg); border-radius: 20px;
  padding: 6px 12px; display: flex; align-items: center; gap: 7px;
}
.d { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.d.g { background: #2FAE66; }
.d.a { background: var(--acc); }
.d.r { background: var(--neg); }
.d.x { background: #B6C1D2; }

/* Generic */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 10px;
  font: 600 16px/1 var(--font);
  min-height: 48px; min-width: 108px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.sm, .phone-review {
  min-height: 0; min-width: 0; height: auto;
  background: var(--navy); color: #fff; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn.primary { background: var(--navy); }
.btn.ghost { background: transparent; border: 1px solid currentColor; color: inherit; }
.btn:disabled { opacity: .5; cursor: default; }
.pill {
  display: inline-block; background: var(--acc); color: var(--navy);
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
}
.pill.ok { background: #E8F8EE; color: #1f6b3a; }
.pill.warn { background: #FDECEC; color: var(--neg); }
.pill.info { background: #EEF3FA; color: var(--navy); }
.pill.bad { background: #FDECEC; color: var(--neg); }

.banner { padding: 10px 14px; border-radius: 10px; background: #FDECEC; color: var(--neg); }
.empty { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13.5px; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #F8FAFD; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin: 0 0 14px;
}
.card.sent, .card.pending { outline: 2px solid #cfe9d8; }
.card.done { opacity: .78; }
.line { color: var(--muted); font-size: 14px; margin: 2px 0; }
.src { font-size: 12px; color: var(--faint); word-break: break-all; }
.preview {
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); padding: 10px 12px; border-radius: 8px;
  font-size: 13px; max-height: 220px; overflow: auto; margin-top: 8px;
}
.draft-flag {
  display: inline-block; margin: 6px 0; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: #EEF3FA; color: var(--navy);
}
textarea, select, input[type=file], input[type=text]:not(.search) {
  width: 100%; font: inherit; padding: 10px 14px; border: 1px solid var(--line-2);
  border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 44px; }
.note-label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.filters a {
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-2);
  text-decoration: none; color: var(--ink); min-height: 40px;
  display: inline-flex; align-items: center; background: #fff; font-size: 13px;
}
.filters a.active { background: var(--navy); color: #fff; border-color: transparent; }
.result { margin-top: 10px; font-weight: 600; font-size: 13px; }
.result.ok { color: #1f6b3a; }
.result.err { color: var(--neg); }

.files { list-style: none; display: grid; gap: 10px; }
.file { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.file a { color: var(--navy); font-weight: 600; text-decoration: none; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--line); display: block; }
.pdf-chip {
  width: 96px; height: 72px; display: flex; align-items: center; justify-content: center;
  background: var(--navy); color: #fff !important; border-radius: 6px; font-weight: 700;
}
.viewer { margin: 8px 0 16px; background: #111; border-radius: 12px; overflow: hidden; }
.viewer h2 { color: #fff; padding: 12px 16px; margin: 0; font-size: 16px; }
.viewer iframe, .viewer img { width: 100%; border: 0; display: block; background: #fff; }
.viewer iframe { height: 70vh; min-height: 420px; }
.viewer img { max-height: 70vh; object-fit: contain; margin: 0 auto; }
form.upload { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; }
form.upload label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
ul.plain, ol.moves { padding-left: 18px; }
.org-bot { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; margin: 6px 0; }
.org-depts { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.org-dept { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.org-dept h3 { font-size: 15px; margin-bottom: 8px; }
.map { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.map svg { width: 100%; max-height: 420px; background: #EEF3FA; border-radius: 8px; }
.map .home { fill: var(--acc); }
.map .pt { fill: var(--navy); opacity: .8; }
.hbar { display: grid; grid-template-columns: minmax(7em, 1.4fr) 3fr auto; gap: 8px; align-items: center; margin: 6px 0; }
.hbar .track { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--navy); }
.sec { margin: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-head h2, h2 { font-size: 16px; color: var(--navy); font-weight: 700; }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

.today-desktop { display: none; }
.today-phone { display: flex; flex-direction: column; gap: 12px; }
.phone-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.status-bar { display: none; } /* real phones have their own; not faked */

@media (max-width: 800px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    border: 1px solid var(--line); border-radius: 14px;
    margin-bottom: 12px; padding: 8px 4px; background: #fff;
  }
  table.responsive td {
    display: flex; justify-content: space-between; gap: 12px;
    border: 0; padding: 6px 12px;
  }
  table.responsive td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; font-weight: 600; flex: 0 0 40%;
  }
  .ar .bt { width: 100%; margin-top: 6px; }
}

@media (min-width: 901px) {
  .sidebar { display: flex; }
  .desktop-top { display: flex; margin-left: 228px; width: calc(100% - 228px); }
  .phone-hdr, .tabbar { display: none; }
  .drawer, .drawer-bg { display: none !important; }
  main.cont { margin-left: 228px; padding: 20px 28px 40px; }
  .k { grid-template-columns: repeat(5, 1fr); gap: 14px; }
  .mid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; }
  .mid.flip { grid-template-columns: 1fr 1.55fr; }
  .today-desktop { display: block; }
  .today-phone { display: none; }
  .org-depts { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .c h3 { font-size: 12px; }
  .big { font-size: 28px; }
}
@media (max-width: 900px) {
  .phone-hdr { display: flex; }
  .big { font-size: 32px; }
  .c { border-radius: 16px; padding: 16px; }
  .c h3 { font-size: 11.5px; margin-bottom: 6px; }
}

/* live freshness label + connection pill (v3) */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.desktop-top .live { margin-left: 16px; }
.phone-hdr .live { color: #A9B8D0; font-size: 12px; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: #2BB673; display: inline-block; font-style: normal; }
.live.stale .dot { background: #E5A50A; }
.live.off .dot { background: #D64545; }
.net { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: 60;
  background: #0B1F3A; color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.net button { margin-left: 8px; background: #fff; color: #0B1F3A; border: 0; border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }

/* v4: signed dealers card + sortable table */
@media (min-width: 901px) { .k { grid-template-columns: repeat(6, 1fr); } }
.sort-th { all: unset; cursor: pointer; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-th i { font-style: normal; font-size: 10px; opacity: .4; }
.sort-th i::after { content: "↕"; }
.sort-th.on i { opacity: 1; }
.sort-th.on[data-cur="asc"] i::after { content: "▲"; }
.sort-th.on[data-cur="desc"] i::after { content: "▼"; }
.sort-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.sort-pick select { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy); }
@media (min-width: 801px) { .sort-pick { display: none; } }
