/* ZoneTrack — staff UI
   Design: a code-enforcement office's working tool.
   Signature element: the case reference rendered as a "file stamp"
   (monospace, tracked, with a colored status tab) — the office's real artifact.
*/

:root {
  --ink:        #1b2436;   /* structural navy            */
  --ink-soft:   #38435a;
  --paper:      #f4f2ec;   /* parchment-tinted backdrop  */
  --card:       #ffffff;
  --line:       #e4e0d6;
  --muted:      #6b7280;
  --accent:     #4f5bd5;   /* action indigo              */
  --accent-ink: #3a44ad;

  --open:       #2f6df0;
  --invest:     #d98a1f;
  --violation:  #d2453c;
  --closed:     #3f8f4f;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(27,36,54,.06), 0 6px 20px rgba(27,36,54,.05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--ink);
  color: #c4cbdb;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.brand .mark { font-weight: 800; letter-spacing: -.02em; font-size: 20px; color: #fff; }
.brand .mark .z { color: #8b9ee8; }
.brand .sub { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: #7c87a0; margin-top: 4px; }

.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: #6a7488; margin: 16px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: #c4cbdb;
  font-weight: 500; transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 16px; height: 16px; flex: none; opacity: .9; }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: 12px; color: #8893a8; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .who a { color: #8b9ee8; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.7);
  position: sticky; top: 0; backdrop-filter: blur(6px); z-index: 5;
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.content { padding: 26px 28px 60px; }

/* ---------- Messages / flash ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; background: #eef6ec; color: #2c5d33; border: 1px solid #cfe6cf; }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background: var(--accent); }
.stat.s-open::before { background: var(--open); }
.stat.s-pending::before { background: var(--violation); }
.stat.s-prop::before { background: var(--invest); }
.stat.s-staff::before { background: var(--closed); }
.stat .n { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- Section ---------- */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); margin: 0; }
.section-head .eyebrow { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-h { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.panel-b { padding: 6px 0; }

/* ---------- The signature: case-file stamp ---------- */
.stamp { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fbfaf7; }
.stamp .tab { width: 5px; background: var(--muted); }
.stamp.t-open .tab, .pill.t-open { background: var(--open); }
.stamp.t-invest .tab { background: var(--invest); }
.stamp.t-violation .tab { background: var(--violation); }
.stamp.t-closed .tab { background: var(--closed); }
.stamp .ref { font-family: var(--mono); font-size: 12.5px; letter-spacing: .03em; padding: 4px 9px; color: var(--ink); font-weight: 600; }

/* ---------- Pills ---------- */
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.pill.t-open      { background: #e7f0ff; color: #1c54c9; }
.pill.t-invest    { background: #fdf0db; color: #9a5e10; }
.pill.t-violation { background: #fde7e5; color: #b3322a; }
.pill.t-closed    { background: #e6f3e8; color: #2f6a3a; }
.pill.t-neutral   { background: #eceae3; color: #5a5347; }

.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.prio .dot { width: 8px; height: 8px; border-radius: 50%; }
.prio.high .dot   { background: var(--violation); }
.prio.medium .dot { background: var(--invest); }
.prio.low .dot    { background: var(--closed); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.row-link { cursor: pointer; transition: background .1s; }
.table tr.row-link:hover { background: #faf8f3; }
.table .addr { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 12.5px; }

/* ---------- Filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.input, .select { font: inherit; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.input { min-width: 240px; }
.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; background: var(--accent); color: #fff; cursor: pointer; }
.btn:hover { background: var(--accent-ink); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn.ghost:hover { background: #faf8f3; }

/* ---------- Detail ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; padding: 16px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; }
.prose { padding: 0 16px 16px; color: var(--ink-soft); }

/* ---------- Workload bars ---------- */
.work { padding: 10px 16px; }
.work-row { display: grid; grid-template-columns: 150px 1fr 34px; align-items: center; gap: 12px; padding: 7px 0; }
.work-row .name { font-size: 13.5px; font-weight: 500; }
.work-bar { height: 8px; background: #ece9e1; border-radius: 999px; overflow: hidden; }
.work-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.work-row .ct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Empty ---------- */
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--ink); }
.login-card { background: var(--card); border-radius: 14px; padding: 34px 32px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .mark { font-weight: 800; font-size: 24px; letter-spacing: -.02em; }
.login-card .mark .z { color: var(--accent); }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.login-card .input { width: 100%; min-width: 0; }
.login-card .btn { width: 100%; margin-top: 22px; padding: 11px; }
.login-err { background: #fde7e5; color: #b3322a; border: 1px solid #f3c9c5; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar .brand, .sidebar .nav-group, .sidebar .spacer, .sidebar .who { display: none; }
  .nav-item { padding: 8px 10px; font-size: 13px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== Added: CRUD forms, reports, call log ===== */

/* Forms */
.zform { padding: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field .req { color: var(--violation); }
.zform .input, .zform .select, .zform .textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.zform .textarea { resize: vertical; min-height: 84px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--violation); }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12.5px; color: var(--violation); margin-top: 4px; }
.form-errors { background: #fde7e5; color: #b3322a; border: 1px solid #f3c9c5; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* Danger button */
.btn.danger { background: #fff; border-color: #f0c8c4; color: #b3322a; }
.btn.danger:hover { background: #fde7e5; }

/* Row actions (edit/delete inline) */
.rowact { white-space: nowrap; text-align: right; }
.rowact a { font-size: 12.5px; font-weight: 600; color: var(--accent); padding: 0 6px; }
.rowact a.del, .rowact a.del:hover { color: var(--violation); }
.rowact a:hover { text-decoration: underline; }

/* Segmented control */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg-btn { padding: 8px 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); border-right: 1px solid var(--line); }
.seg-btn:last-child { border-right: none; }
.seg-btn.on { background: var(--accent); color: #fff; }
.seg-btn:hover:not(.on) { background: #faf8f3; }

/* Stacked bar (activity report) */
.legend { display: flex; gap: 18px; padding: 12px 16px 4px; font-size: 12.5px; color: var(--muted); }
.legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sbar { display: flex; height: 16px; background: #ece9e1; border-radius: 5px; overflow: hidden; min-width: 60px; }
.sbar span { display: block; height: 100%; }
.sbar .seg-c { background: var(--open); }
.sbar .seg-m { background: var(--invest); }
.sbar .seg-v { background: var(--violation); }
.total-row td { border-top: 2px solid var(--line); font-weight: 700; }

/* Hours-saved hero */
.hero-saved {
  display: flex; align-items: center; gap: 22px; background: var(--ink); color: #fff;
  border-radius: 12px; padding: 26px 30px; box-shadow: var(--shadow);
}
.hero-saved .hs-num { font-size: 56px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: #8b9ee8; }
.hero-saved .hs-lbl { font-size: 16px; font-weight: 600; line-height: 1.4; }
.hero-saved .hs-lbl span { font-size: 12.5px; font-weight: 400; color: #aab2c7; text-transform: uppercase; letter-spacing: .08em; }
