/* =====================================================================
   Colton Ops — shared styles
   Brand: navy #1f3c72 (primary), red #df2742 (sparingly: critical only)
   Color languages (from Notion):
     status  = navy (active) / red (critical) / neutral grays
     place   = department tints inside records (shop, detail, parts, finance)
   ===================================================================== */

:root {
  /* brand */
  --navy: #1f3c72;
  --navy-600: #2a4d8f;
  --navy-050: #eef2f9;
  --red: #df2742;
  --red-050: #fdecef;

  /* neutrals */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #18212f;
  --ink-2: #4a5568;
  --muted: #6b7686;
  --line: #dde2ea;
  --line-strong: #c7cfdb;

  /* status helpers (not brand) */
  --ok: #1e7d4f;
  --ok-050: #e7f5ee;
  --warn: #9a6400;
  --warn-050: #fdf4e3;

  /* department tints (record sections + dashboard blocks) */
  --dept-finance: #e9f5ec;
  --dept-detail: #e8f0fb;
  --dept-shop: #f3ece6;
  --dept-front: #fdf0e3;
  --dept-back: #fbf6dc;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 56px;
  color-scheme: light;
}

/* Dark mode: follows the device unless the person picked Light or Dark
   (saved per person; html[data-theme] is set by app.js). */
:root[data-theme="dark"] {
    --navy: #7ea2e0;
    --navy-600: #9bb8ea;
    --navy-050: #1b2740;
    --red: #f2566d;
    --red-050: #3a1820;
    --bg: #0f141b;
    --surface: #171d26;
    --surface-2: #1c2330;
    --ink: #e6ebf2;
    --ink-2: #b8c2d0;
    --muted: #8a96a8;
    --line: #2a3342;
    --line-strong: #364154;
    --ok: #4cc38a;
    --ok-050: #12291f;
    --warn: #e2b04a;
    --warn-050: #2d2412;
    --dept-finance: #15261b;
    --dept-detail: #152238;
    --dept-shop: #2a221b;
    --dept-front: #2d2216;
    --dept-back: #2a2714;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #7ea2e0;
    --navy-600: #9bb8ea;
    --navy-050: #1b2740;
    --red: #f2566d;
    --red-050: #3a1820;
    --bg: #0f141b;
    --surface: #171d26;
    --surface-2: #1c2330;
    --ink: #e6ebf2;
    --ink-2: #b8c2d0;
    --muted: #8a96a8;
    --line: #2a3342;
    --line-strong: #364154;
    --ok: #4cc38a;
    --ok-050: #12291f;
    --warn: #e2b04a;
    --warn-050: #2d2412;
    --dept-finance: #15261b;
    --dept-detail: #152238;
    --dept-shop: #2a221b;
    --dept-front: #2d2216;
    --dept-back: #2a2714;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: #1f3c72;           /* always brand navy, light or dark */
  color: #fff;
  border-bottom: 3px solid #df2742;
}
.topnav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; color: #fff; text-decoration: none; }
.topnav .brand img { width: 28px; height: 28px; border-radius: 6px; }
.topnav nav { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; }
.topnav nav a {
  color: rgba(255,255,255,.82); text-decoration: none;
  padding: 7px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.topnav nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topnav nav a[aria-current="page"] { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.topnav .spacer { flex: 1; }
.topnav .user { position: relative; }
.topnav .user > button {
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  height: 34px; padding: 0 12px; border-radius: 17px; font: inherit; font-size: 14px; cursor: pointer;
}
.menu {
  position: absolute; right: 0; top: 42px; min-width: 200px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 30;
}
.menu .who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button, .menu a {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 10px; border-radius: 7px; font: inherit; color: var(--ink); cursor: pointer; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }

/* feed banner (stale IDS data, etc.) */
.banner {
  padding: 8px 16px; font-size: 13px;
  background: var(--warn-050); color: var(--warn); border-bottom: 1px solid var(--line);
}

/* ---------- layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .spacer { flex: 1; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: #1f3c72; border-color: #1f3c72; color: #fff; }
.btn.primary:hover { background: #2a4d8f; }
.btn.danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }

label.field { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 0; }
label.field > span { display: block; margin-bottom: 5px; font-weight: 550; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iPhone zoom */
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy);
}

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip.active { background: var(--navy-050); color: var(--navy); border-color: transparent; }
.chip.ok { background: var(--ok-050); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-050); color: var(--warn); border-color: transparent; }
.chip.critical { background: var(--red-050); color: var(--red); border-color: transparent; }
.chip.solid { background: #1f3c72; color: #fff; border-color: transparent; }

/* department sections (inside records) */
.dept { border-radius: var(--radius); padding: 14px; border: 1px solid var(--line); }
.dept > h3 { margin-bottom: 10px; }
.dept.finance { background: var(--dept-finance); }
.dept.detail  { background: var(--dept-detail); }
.dept.shop    { background: var(--dept-shop); }
.dept.front   { background: var(--dept-front); }
.dept.back    { background: var(--dept-back); }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: #18212f; color: #fff; padding: 11px 14px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; border: 1px solid rgba(255,255,255,.14);
}
.toast.error { background: #df2742; }

/* ---------- dialog ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(94vw, 520px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 16, 28, .45); }
dialog .dlg-head { padding: 16px 18px 0; }
dialog .dlg-body { padding: 8px 18px 4px; }
dialog .dlg-foot { padding: 14px 18px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(100%, 400px); }
.auth-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-card .logo img { width: 44px; height: 44px; border-radius: 10px; }
.msg { margin-top: 12px; font-size: 14px; }
.msg.error { color: var(--red); }

/* ---------- home tiles ---------- */
.tile { display: block; text-decoration: none; color: inherit; }
.tile .card { height: 100%; transition: border-color .15s; }
.tile:hover .card { border-color: var(--navy); }
.tile p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.tile.soon { pointer-events: none; opacity: .6; }

@media (max-width: 640px) {
  .topnav { gap: 8px; padding: 0 10px; }
  .topnav .brand span { display: none; }
  .page { padding: 14px 12px 40px; }
}

/* ---------- slide-over drawer (record detail) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10,16,28,.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(100vw, 760px); z-index: 41;
  background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 16px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
}
.drawer-head .title { font-size: 20px; font-weight: 750; }
.drawer-head .sub { color: var(--muted); font-size: 13px; }
.drawer-head .close { grid-row: 1 / span 2; grid-column: 2; align-self: start; }
.drawer-body { overflow-y: auto; padding: 14px 16px 60px; display: grid; gap: 12px; align-content: start; }
.sect { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.sect > h3, .dept > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sect > h3 .spacer, .dept > h3 .spacer { flex: 1; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 12px; }
.fields label.field { margin: 0; }
.dayNote { border: 2px solid #1f3c72; background: var(--navy-050); }
.dayNote textarea { min-height: 64px; background: var(--surface); }
.dayNote h3 { color: var(--navy); }
.saved { font-size: 11px; color: var(--ok); font-weight: 600; text-transform: none; letter-spacing: 0; }
.pill-select { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-select button {
  height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer;
}
.pill-select button[aria-pressed="true"] { background: #1f3c72; border-color: #1f3c72; color: #fff; font-weight: 600; }
.pill-select.small button { height: 28px; padding: 0 10px; font-size: 12px; }
.checks { display: grid; gap: 6px; }
.checkrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.checkrow input[type=checkbox] { width: 20px; height: 20px; accent-color: #1f3c72; }
.checkrow .meta { margin-left: auto; font-size: 12px; color: var(--muted); }
.checkrow.na { opacity: .55; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 4px 6px; }
.tbl td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl td input, .tbl td select { min-height: 34px; padding: 5px 8px; font-size: 14px; }
.tbl .x { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.tbl .x:hover { color: var(--red); }
.inline-add { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-add input { flex: 1 1 160px; }
.flagline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 10px; }
.tri { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.tri button { border: 0; background: var(--surface); padding: 4px 9px; font: inherit; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.tri button + button { border-left: 1px solid var(--line); }
.tri button[aria-pressed="true"] { background: #1f3c72; color: #fff; }
.hist { font-size: 13px; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.hist div { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.hist .when { color: var(--muted); font-size: 12px; }
details > summary { cursor: pointer; font-weight: 650; font-size: 14px; }
.notegrid { display: grid; gap: 10px; }
.notebox label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.notebox textarea { margin-top: 4px; min-height: 60px; }
.linkbtn { border: 0; background: none; color: var(--navy); font: inherit; font-size: 12px; cursor: pointer; padding: 0; text-transform: none; letter-spacing: 0; font-weight: 600; }
@media (max-width: 640px) {
  .drawer { width: 100vw; }
  .tbl thead { display: none; }
  .tbl tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
  .tbl td { border: 0; padding: 0; }
  .tbl td.wide { grid-column: 1 / -1; }
}

/* ---------- theme switch (user menu) ---------- */
.menu .theme { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .theme > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.menu .themeseg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.menu .themeseg button { flex: 1; width: auto; text-align: center; padding: 5px 8px; border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.menu .themeseg button:hover { background: var(--surface); }
.menu .themeseg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
