/* ============================================================================
   delivery.edgeevolve.com — design system (Edge Evolve corporate theme)
   Light, flat, brand-correct: Navy #15263F structural, Gold #F4B72A accent-only,
   white/light-grey surfaces, Arial. CSP-safe (no external fonts/CDNs, no gradients).
   ========================================================================== */
:root {
  /* brand */
  --navy: #15263f;
  --navy-2: #1e3252;         /* hover/raised navy */
  --gold: #f4b72a;           /* accent ONLY — rules, bands, rails; never body text */
  --light-gold: #fdf0d5;     /* soft highlight / on-hold badge fill */

  /* surfaces — warm ivory/greige neutrals (biased toward the gold) for a warmer, classier feel */
  --bg: #f3f1ea;             /* warm paper */
  --surface: #fffdf8;        /* warm white cards */
  --surface-2: #f6f3ea;      /* alt rows / subtle fills */
  --raised: #ece7dc;         /* tracks, inset */
  --line: #e7e1d3;
  --line-2: #dbd4c4;

  /* ink (warm-tinted greys so text sits on the warm ground) */
  --text: #15263f;           /* headings / primary — navy */
  --text-2: #3b3f49;         /* body */
  --muted: #736f6a;
  --faint: #a49f96;

  /* status (derived, CVD-validated on white; always shown with a label) */
  --intake: #2563eb; --active: #16a34a; --hold: #d97706; --closed: #64748b; --danger: #dc2626;
  /* --critical: chart/severity red — deeper than --danger so it clears amber (dataviz ΔE≥15) */
  --critical: #b91c1c;

  --radius: 12px; --radius-sm: 8px; --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(21,38,63,.06), 0 10px 24px -16px rgba(21,38,63,.20);
  --shadow-lg: 0 14px 40px -14px rgba(21,38,63,.28);
  --ring: 0 0 0 3px rgba(21,38,63,.18);
  --t: 150ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: Arial, "Helvetica Neue", Helvetica, system-ui, sans-serif;
  font-size: 15px; line-height: 1.55; color: var(--text-2); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-2); }
h1,h2,h3 { margin: 0 0 .5rem; line-height: 1.2; color: var(--text); font-weight: 700; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.mb { margin-bottom: 1rem; } .mt { margin-top: 1rem; } .mb0 { margin-bottom: 0; }
::selection { background: rgba(244,183,42,.35); }

/* scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* ---- top bar (navy band + thin gold rule = letterhead signature) ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.5rem;
  background: var(--navy); border-bottom: 2px solid var(--gold);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.01em; color: #fff; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--gold); }
.brand .logo svg { width: 18px; height: 18px; }
.brand small { color: rgba(255,255,255,.62); font-weight: 400; }
.nav { display: flex; gap: .25rem; }
.nav a {
  display: flex; align-items: center; gap: .45rem; padding: .45rem .8rem; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75); font-weight: 600; transition: var(--t);
}
.nav a svg { width: 17px; height: 17px; opacity: .9; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.10); }
.nav a.active { color: var(--navy); background: var(--gold); }
.spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: .5rem; color: rgba(255,255,255,.85); font-size: .9rem; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--navy); font-weight: 700; font-size: .8rem; }
.topbar .btn.ghost { color: rgba(255,255,255,.82); }
.topbar .btn.ghost:hover { color: #fff; background: rgba(255,255,255,.12); }

/* ---- layout ---- */
.container { max-width: 1120px; margin: 0 auto; padding: 2.25rem 1.5rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-head h1 { display: inline-block; border-bottom: 3px solid var(--gold); padding-bottom: .3rem; }
.page-head .sub { color: var(--muted); margin-top: .5rem; }
.grid { display: grid; gap: 1rem; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 860px){ .cols-4 { grid-template-columns: repeat(2,1fr);} .cols-3 { grid-template-columns: repeat(3,1fr);} .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 520px){ .cols-4 { grid-template-columns: 1fr 1fr; } .nav a span { display:none; } }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 1.15rem 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }
.card-body { padding: 1.1rem 1.25rem; }

/* ---- stat tiles ---- */
.tile { position: relative; overflow: hidden; padding: 1.15rem 1.25rem; }
.tile::before { content:""; position:absolute; left:0; top:0; bottom:0; width:3px; background: var(--navy); }
.tile .label { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.tile .num { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; margin-top: .1rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.tile .foot { color: var(--faint); font-size: .8rem; }

/* ---- bar chart (server-rendered SVG, status breakdown) ---- */
.bars { display: flex; flex-direction: column; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: .75rem; }
.bar-row .name { color: var(--text-2); font-size: .88rem; display:flex; align-items:center; gap:.45rem; }
.bar-track { height: 10px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.bar-row .val { color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.5rem; text-align: right; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: var(--radius-pill);
  font-size: .76rem; font-weight: 700; border: 1px solid transparent; }
.badge .dot { width: 6px; height: 6px; background: currentColor; }
.badge.intake { background: #e7effd; color: #1d4ed8; border-color: #cadefb; }
.badge.active { background: #e6f6ec; color: #15803d; border-color: #bfe8cd; }
.badge.on_hold{ background: var(--light-gold); color: #92600b; border-color: #f2dca3; }
.badge.closed { background: #efeadf; color: #5b544a; border-color: #ddd5c6; }
.badge.danger { background: #fdeaea; color: #b91c1c; border-color: #f5c6c6; }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; padding: .7rem 1rem; color: #fff; background: var(--navy);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
thead th:first-child { border-top-left-radius: 0; }
tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: #efe9df; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-variant-numeric: tabular-nums; }
.code-link { font-weight: 700; color: var(--navy); letter-spacing: -.01em; }

/* ---- forms ---- */
label { display: block; font-size: .82rem; color: var(--text-2); margin: .9rem 0 .3rem; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: .6rem .75rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); transition: var(--t);
}
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: var(--ring); }
select { appearance: none; padding-right: 2rem; }
.field-search { position: relative; }
.field-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.field-search input { padding-left: 38px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .95rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--navy); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: var(--t); white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--line-2); transform: translateY(-1px); color: var(--navy); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--navy); background: var(--surface-2); }
.btn.sm { padding: .35rem .65rem; font-size: .82rem; }

/* ---- misc utility ---- */
.row { display: flex; gap: .6rem; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem 1.5rem; }
.kv .k { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-bottom: .15rem; }
.kv .v { color: var(--text); }
.breadcrumb { color: var(--muted); font-size: .9rem; margin-bottom: .9rem; }
.breadcrumb a { color: var(--muted); } .breadcrumb a:hover { color: var(--navy); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .55; margin-bottom: .5rem; }

/* HTMX loading indicator */
.htmx-indicator { opacity: 0; transition: opacity var(--t); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spin { width: 15px; height: 15px; border: 2px solid var(--line-2); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
tbody.htmx-request { opacity: .5; transition: opacity var(--t); }

/* ---- messages / toasts ---- */
.messages { position: fixed; top: 74px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: .5rem; list-style: none; margin: 0; padding: 0; max-width: 360px; }
.messages li { padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); animation: toast .3s ease both; }
.messages li.success { border-left: 3px solid var(--active); }
.messages li.error { border-left: 3px solid var(--danger); }
@keyframes toast { from { opacity: 0; transform: translateX(12px); } }

/* ---- auth ---- */
.auth-wrap { min-height: 82vh; display: grid; place-items: center; }
.auth { width: 100%; max-width: 380px; }
.auth .logo-lg { width: 52px; height: 52px; border-radius: 13px; display: grid; place-items: center; background: var(--gold); margin-bottom: 1rem; }
.auth .logo-lg svg { width: 28px; height: 28px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .4rem 0; font-size: .86rem; }

/* ---- dashboard status colors (tiles, SVG bar fills, dots) ---- */
.tile.total::before { background: var(--navy); }
.tile.intake::before { background: var(--intake); }
.tile.active::before { background: var(--active); }
.tile.on_hold::before { background: var(--hold); }
.barsvg { width: 100%; height: 100%; display: block; }
.barsvg .fill.intake { fill: var(--intake); }
.barsvg .fill.active { fill: var(--active); }
.barsvg .fill.on_hold { fill: var(--hold); }
.barsvg .fill.closed { fill: var(--closed); }
.barsvg .fill.danger { fill: var(--critical); }
.dot.intake { background: var(--intake); }
.dot.active { background: var(--active); }
.dot.on_hold { background: var(--hold); }
.dot.closed { background: var(--closed); }
.dot.danger { background: var(--critical); }

/* ---- misc layout ---- */
.card-head .field-search { width: min(440px, 62%); }
.row select, .row .btn { width: auto; }
.row select { min-width: 150px; }
.form-narrow { max-width: 560px; }
.auth form .btn.primary { width: 100%; justify-content: center; }
.recent-row { padding: .65rem .25rem; border-bottom: 1px solid var(--line); transition: var(--t); }
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: var(--surface-2); border-radius: 8px; }
.recent-row:hover .code-link { color: var(--navy-2); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
