/* ============ X3 COMPASS · APP SHELL · mirrors app.x3fleetsafety.com ============ */
:root {
  --navy:        #003D7A;
  --navy-dark:   #002F5C;
  --navy-light:  #1A68B3;
  --ink:         #0F1E38;
  --gold:        #FFD500;
  --gold-dark:   #E6C000;
  --gold-light:  #FFDE33;
  --bg:          #F8FAFC;
  --bg-2:        #F1F5F9;
  --paper:       #FFFFFF;
  --text:        #0F1E38;
  --muted:       #475569;
  --muted-2:     #94A3B8;
  --border:      #E2E8F0;
  --border-2:    #CBD5E1;
  --green:       #166534;
  --green-bg:    #DCFCE7;
  --amber:       #B45309;
  --amber-bg:    #FEF3C7;
  --red:         #B91C1C;
  --red-bg:      #FEE2E2;
  --teal:        #2DD4BF;
  --radius:      12px;
  --radius-lg:   16px;
  --shadow:      0 1px 2px rgba(15,30,56,.04), 0 4px 16px rgba(15,30,56,.06);
  --shadow-lg:   0 8px 32px rgba(15,30,56,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-light); }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.012em; line-height: 1.2; margin: 0 0 .35em; }

/* ============ AUTH PAGES ============ */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  padding: 24px;
}
.auth-card {
  background: var(--paper); border-radius: var(--radius-lg);
  padding: 36px 32px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-brand .mark {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.auth-brand .name-w .name { font-size: 18px; font-weight: 800; color: var(--navy); letter-spacing: .02em; }
.auth-brand .name-w .tag {
  font-size: 10px; color: var(--navy); font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; margin-top: 2px;
}

.auth-tabs {
  display: flex; gap: 0; margin-bottom: 22px; padding: 4px; background: var(--bg-2);
  border-radius: 10px;
}
.auth-tab {
  flex: 1; padding: 10px 14px; border-radius: 7px; font-size: 14px; font-weight: 700;
  color: var(--muted); text-align: center; cursor: pointer; border: none; background: transparent;
}
.auth-tab.active { background: var(--paper); color: var(--navy); box-shadow: 0 1px 3px rgba(15,30,56,.08); }

.auth-card h1 { font-size: 22px; font-weight: 800; margin: 0 0 6px; color: var(--navy); }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border-2);
  color: var(--text); font-size: 15px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0,61,122,.12); }
.btn-primary {
  width: 100%; padding: 13px 18px; border-radius: 8px; border: none;
  background: var(--gold); color: var(--navy);
  font-weight: 800; font-size: 15px; cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.btn-primary:hover { background: var(--gold-dark); }
.auth-foot { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--navy); font-weight: 700; }
.auth-back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }

/* ============ APP SHELL ============ */
.app-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
@media (max-width: 980px) { .app-shell { grid-template-columns: 64px 1fr; } }

/* ============ SIDEBAR ============ */
.side {
  background: var(--paper); border-right: 1px solid var(--border);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 6px 18px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.side-brand .mark {
  width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 900; font-size: 15px;
}
.side-brand .name-w { display: flex; flex-direction: column; min-width: 0; }
.side-brand .name { color: var(--navy); font-weight: 800; font-size: 15px; line-height: 1.1; letter-spacing: .02em; }
.side-brand .tag { color: var(--navy); font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }
@media (max-width: 980px) { .side-brand .name-w { display: none; } }

.side-section {
  color: var(--muted-2); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; font-weight: 800; padding: 14px 10px 6px;
}
@media (max-width: 980px) { .side-section { display: none; } }

.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--ink); font-size: 14px; font-weight: 600;
  transition: background .1s ease;
}
.side-link:hover { background: var(--bg-2); color: var(--navy); }
.side-link.active { background: var(--bg-2); color: var(--navy); font-weight: 700; }
.side-link .ic { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
@media (max-width: 980px) { .side-link .lbl { display: none; } .side-link { justify-content: center; } }

/* ============ MAIN ============ */
.main { background: var(--bg); min-width: 0; }
.top {
  background: var(--paper); border-bottom: 1px solid var(--border);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.top-l h1 { font-size: 18px; font-weight: 800; color: var(--navy); margin: 0; }
.top-l .crumbs { color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-r { display: flex; align-items: center; gap: 14px; }
.top-user { display: flex; align-items: center; gap: 10px; }
.top-user .av {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-2); color: var(--navy);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  border: 1px solid var(--border);
}
.top-user .nm { color: var(--navy); font-weight: 700; font-size: 13px; line-height: 1.1; }
.top-user .ro { color: var(--muted); font-size: 11px; }
.btn-signout {
  padding: 8px 14px; border: 1px solid var(--border-2); background: var(--paper);
  color: var(--ink); font-size: 13px; font-weight: 600; border-radius: 8px; cursor: pointer;
}
.btn-signout:hover { border-color: var(--navy); color: var(--navy); }

.body { padding: 24px 28px 40px; }

/* ============ COMPLIANCE COMMAND CENTER ============ */
.ccc {
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  color: #fff; border-radius: var(--radius); padding: 22px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 18px;
}
.ccc-l { display: flex; align-items: center; gap: 16px; }
.ccc-mark {
  width: 56px; height: 56px; border-radius: 10px;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
}
.ccc h2 { color: #fff; font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.01em; }
.ccc .sub { color: rgba(255,255,255,.78); font-size: 13px; }
.ccc-r { text-align: right; }
.health-pill {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  background: var(--green-bg); color: var(--green); font-weight: 800; font-size: 13px;
}
.health-pill.warn { background: var(--amber-bg); color: var(--amber); }
.health-pill.bad  { background: var(--red-bg);   color: var(--red); }
.ccc-time { color: rgba(255,255,255,.6); font-size: 11px; margin-top: 6px; }

/* ============ KPI TILES ============ */
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 1280px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 14px; position: relative;
}
.kpi.ok    { background: linear-gradient(180deg, #ECFDF5 0%, var(--paper) 60%); border-color: #BBF7D0; }
.kpi.warn  { background: linear-gradient(180deg, #FFFBEB 0%, var(--paper) 60%); border-color: #FDE68A; }
.kpi.bad   { background: linear-gradient(180deg, #FEF2F2 0%, var(--paper) 60%); border-color: #FECACA; }
.kpi.neutral { background: linear-gradient(180deg, #EFF6FF 0%, var(--paper) 60%); border-color: #BFDBFE; }
.kpi.gold-bg { background: linear-gradient(180deg, #FFFBEB 0%, var(--paper) 60%); border-color: #FDE68A; }
.kpi-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kpi-ic {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center; font-size: 14px;
  background: var(--paper); border: 1px solid var(--border);
}
.kpi-l { color: var(--ink); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 800; }
.kpi-v { color: var(--ink); font-size: 32px; font-weight: 900; line-height: 1; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ============ TWO-COLUMN: COMPLIANCE + CSA ============ */
.row-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
@media (max-width: 1080px) { .row-overview { grid-template-columns: 1fr; } }

.panel {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.panel-h {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.panel-h h3 { color: var(--navy); font-size: 16px; font-weight: 800; margin: 0; }
.panel-h .panel-r { color: var(--muted); font-size: 12px; }
.panel-h .panel-r .btn-link {
  padding: 6px 12px; border: 1px solid var(--border-2); border-radius: 7px;
  color: var(--ink); font-size: 12px; font-weight: 700; background: var(--paper);
}

.donut-row { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: center; }
@media (max-width: 540px) { .donut-row { grid-template-columns: 1fr; } }
.donut { position: relative; width: 180px; height: 180px; }
.donut .center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.donut .pct { font-size: 38px; font-weight: 900; color: var(--ink); line-height: 1; }
.donut .lbl { color: var(--muted-2); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; margin-top: 4px; }
.donut .msg { color: var(--amber); font-size: 11px; font-weight: 700; margin-top: 6px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { font-size: 13px; }
.bar-h { display: flex; justify-content: space-between; margin-bottom: 4px; }
.bar-h .b-name { color: var(--ink); font-weight: 600; }
.bar-h .b-val  { color: var(--ink); font-weight: 800; }
.bar { height: 7px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.bar > i.ok   { background: #10B981; }
.bar > i.warn { background: #F59E0B; }
.bar > i.bad  { background: #EF4444; }

/* CSA panel */
.csa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .csa-grid { grid-template-columns: 1fr; } }
.csa-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px;
}
.csa-card.ok   { background: #ECFDF5; border-color: #BBF7D0; }
.csa-card.warn { background: #FFFBEB; border-color: #FDE68A; }
.csa-card.bad  { background: #FEF2F2; border-color: #FECACA; }
.csa-l { color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 800; }
.csa-v { font-size: 20px; font-weight: 900; color: var(--ink); margin-top: 4px; }
.csa-v .u { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 4px; }
.csa-v.na { color: var(--muted-2); font-size: 18px; }
.csa-t { color: var(--muted); font-size: 11px; margin-top: 2px; }
.csa-foot { color: var(--muted); font-size: 12px; text-align: right; margin-top: 6px; }

/* ============ ACTION ITEMS ============ */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 14px;
}
.section-title h2 {
  font-size: 13px; font-weight: 800; color: var(--navy); margin: 0;
  letter-spacing: .14em; text-transform: uppercase;
}
.section-title .gen { color: var(--muted); font-size: 12px; }

.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1280px) { .action-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .action-grid { grid-template-columns: 1fr; } }
.action-card {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column;
}
.action-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.action-h .ic { font-size: 16px; }
.action-h h3 {
  color: var(--navy); font-size: 13px; font-weight: 800; margin: 0;
  letter-spacing: .04em; text-transform: uppercase;
}
.action-cfr {
  color: var(--muted); font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-bottom: 12px;
}
.action-items { flex: 1; }
.action-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 12.5px; gap: 10px;
}
.action-item:last-child { border-bottom: none; }
.action-item .l b { color: var(--ink); display: block; font-weight: 700; font-size: 13px; }
.action-item .l .meta { color: var(--muted); font-size: 11px; margin-top: 1px; }
.action-pill {
  padding: 3px 9px; border-radius: 5px; font-size: 10px; font-weight: 800;
  letter-spacing: .06em; white-space: nowrap; flex-shrink: 0;
}
.action-pill.overdue { background: var(--amber-bg); color: var(--amber); }
.action-pill.classify, .action-pill.report, .action-pill.eldt { background: var(--amber-bg); color: var(--amber); }
.action-pill.warn { background: var(--amber-bg); color: var(--amber); }
.action-pill.danger { background: var(--red-bg); color: var(--red); }
.action-foot {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  color: var(--navy); font-size: 13px; font-weight: 700;
}
.action-foot a { color: var(--navy); }
.action-foot a:hover { color: var(--navy-light); }

/* ============ COMPASS AGENT BUBBLE (floating) ============ */
.agent-bubble {
  position: fixed; bottom: 18px; right: 18px; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  display: grid; place-items: center; color: var(--gold); font-size: 22px; font-weight: 900;
  box-shadow: 0 10px 28px rgba(0,61,122,.35); cursor: pointer;
  border: 2px solid var(--gold);
}

/* ============ CHAT PAGE ============ */
.chat-shell { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; background: var(--bg); }
.chat-top { padding: 16px 28px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; background: var(--paper); }
.chat-top .skill-name { color: var(--navy); font-weight: 800; font-size: 16px; }
.chat-top .skill-sub { color: var(--muted); font-size: 12px; }
.chat-top .cfr { font-size: 11px; color: var(--navy); background: #EFF6FF; padding: 3px 10px; border-radius: 999px; font-family: ui-monospace, monospace; font-weight: 700; }
.chat-body { overflow-y: auto; padding: 24px; max-width: 880px; margin: 0 auto; width: 100%; }
.msg-block { margin-bottom: 18px; }
.msg-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.msg-h .av {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.msg-h.bot .av  { background: var(--navy); color: var(--gold); }
.msg-h.user .av { background: var(--gold); color: var(--navy); }
.bubble { padding: 14px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.msg-block.bot .bubble  { background: var(--paper); border: 1px solid var(--border); color: var(--ink); }
.msg-block.user .bubble { background: var(--navy); color: #fff; }
.bubble .cfr-inline { font-family: ui-monospace, monospace; font-size: 12px; color: var(--navy); background: #EFF6FF; padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.chat-input { padding: 16px 24px 22px; border-top: 1px solid var(--border); background: var(--paper); }
.chat-input-row {
  max-width: 880px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 6px 6px 6px 14px;
}
.chat-input-row textarea {
  flex: 1; background: transparent; border: none; color: var(--ink);
  font-family: inherit; font-size: 15px; resize: none; padding: 8px 0;
  min-height: 24px; max-height: 200px; outline: none;
}
.chat-send {
  width: 38px; height: 38px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--gold); color: var(--navy);
  font-weight: 800; font-size: 14px;
}
.suggestions { max-width: 880px; margin: 8px auto 0; display: flex; gap: 8px; flex-wrap: wrap; }
.suggestion {
  padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--ink); font-weight: 600;
  background: var(--paper); border: 1px solid var(--border-2); cursor: pointer;
}
.suggestion:hover { border-color: var(--navy); color: var(--navy); }
