/* ==========================================================================
   H&S Tracker - design system
   Plain CSS, no utility framework, no color-mix(), no emoji.
   Palette: deep teal for the product, amber for attention, red for danger.
   ========================================================================== */

:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #0f766e;
  --brand-2: #115e59;
  --brand-soft: #e6f4f1;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;
  --nav: #0b1220;
  --nav-2: #111c2f;
  --nav-line: #1e293b;
  --nav-text: #cbd5e1;
  --nav-muted: #7c8ba1;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 268px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 10px; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12.5px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #99f6e4; outline-offset: 2px; border-radius: 6px; }
::selection { background: #99f6e4; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--nav);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--nav-line); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(145deg, #14b8a6, #0f766e);
  display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 16px -6px rgba(20,184,166,.7);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text strong { display: block; color: #f8fafc; font-size: 15px; letter-spacing: -.01em; }
.brand-text span { display: block; color: var(--nav-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 14px; padding: 8px 10px; min-height: 36px;
  background: rgba(148, 163, 184, .08);
  border: 1px solid var(--nav-line); border-radius: 9px;
  color: var(--nav-muted); font: inherit; font-size: 12.5px; text-align: left;
  cursor: pointer;
}
.sidebar-search:hover { background: rgba(148, 163, 184, .14); color: #e2e8f0; }
.sidebar-search .sidebar-search-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-search kbd {
  font: inherit; font-size: 11px; line-height: 1; padding: 3px 6px;
  border-radius: 5px; background: rgba(15, 23, 42, .6);
  border: 1px solid var(--nav-line); color: var(--nav-muted);
}

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 18px; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--nav-muted); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin: 2px 0; border-radius: 11px;
  color: var(--nav-text); cursor: pointer; border: 0; background: transparent;
  width: 100%; text-align: left; position: relative;
}
.nav-item:hover { background: rgba(148, 163, 184, .1); text-decoration: none; color: #f1f5f9; }
.nav-item.active { background: rgba(20, 184, 166, .14); color: #ffffff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: #2dd4bf;
}
.nav-icon {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px;
  /* The pictograms are drawn for light backgrounds; a pale tile keeps them legible
     on the dark rail instead of recolouring the artwork. */
  background: #f8fafc; box-shadow: 0 1px 2px rgba(2, 6, 23, .35);
  display: grid; place-items: center; overflow: hidden;
}
.nav-icon img, .nav-icon svg { width: 27px; height: 27px; object-fit: contain; }
.nav-item.active .nav-icon { background: #ecfeff; box-shadow: 0 0 0 1px rgba(45, 212, 191, .7), 0 1px 2px rgba(2, 6, 23, .35); }
.nav-label { font-size: 14px; font-weight: 500; }
.nav-count {
  margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: rgba(148, 163, 184, .18); color: #e2e8f0;
}
.nav-count.hot { background: #b91c1c; color: #fff; }

.sidebar-foot { border-top: 1px solid var(--nav-line); padding: 12px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #134e4a; color: #ccfbf1; letter-spacing: .02em;
}
.who-meta { min-width: 0; flex: 1; }
.who-meta strong { display: block; font-size: 13px; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-meta span { display: block; font-size: 11.5px; color: var(--nav-muted); text-transform: capitalize; }
.icon-btn {
  border: 0; background: transparent; color: var(--nav-muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(148,163,184,.14); color: #f8fafc; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 26px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; font-weight: 650; }
.topbar-sub { color: var(--muted); font-size: 12.5px; }
.topbar-spacer { flex: 1; }
.menu-btn { display: none; }

.content { padding: 24px 26px 60px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head p { color: var(--muted); margin: 4px 0 0; max-width: 70ch; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 12px; padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* ------------------------------------------------------------------ stats */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat-foot { margin-top: 6px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-2); }
.stat.teal::after { background: #14b8a6; }
.stat.amber::after { background: #f59e0b; }
.stat.red::after { background: #ef4444; }
.stat.violet::after { background: #8b5cf6; }
.stat.blue::after { background: #3b82f6; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 650; line-height: 1.6;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge.teal { background: var(--brand-soft); color: var(--brand-2); border-color: #b7e4dc; }
.badge.green { background: var(--ok-soft); color: #166534; border-color: #bbf7d0; }
.badge.amber { background: var(--amber-soft); color: #92400e; border-color: #fde68a; }
.badge.red { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.badge.blue { background: var(--info-soft); color: #1e40af; border-color: #bfdbfe; }
.badge.violet { background: var(--violet-soft); color: #5b21b6; border-color: #ddd6fe; }
.badge.outline { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--line-2); background: #fff;
  font-size: 13px; cursor: pointer; user-select: none;
}
.chip:hover { border-color: var(--muted-2); }
.chip.on { background: var(--brand-soft); border-color: #7dd3c7; color: var(--brand-2); font-weight: 600; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #f8fafc; border-color: var(--muted-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; }
.btn-soft { background: var(--brand-soft); border-color: #b7e4dc; color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2f7; color: var(--ink); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; border-right-width: 1px; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.14); }
.textarea { min-height: 110px; resize: vertical; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input[type="file"] { padding: 7px; min-height: 0; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--brand); }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.radio-card { position: relative; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card span {
  display: flex; flex-direction: column; gap: 2px; padding: 11px 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.radio-card small { font-weight: 400; color: var(--muted); }
.radio-card input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.radio-card.stop input:checked + span { border-color: var(--danger); background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: #cbd5e1; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #fbfcfe; white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------------------------ tabs  */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 13px; border: 0; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 13.5px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand-2); border-bottom-color: var(--brand); }

/* --------------------------------------------------------- folder tabs  */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 14px; }
.cat-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer;
}
.cat-tab:hover { border-color: var(--brand); color: var(--brand-2); }
.cat-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cat-tab .cat-n { font-size: 11.5px; font-weight: 700; opacity: .75; }
.map-zone-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }
.zone-n { font-size: 12px; font-weight: 700; color: #0f172a; background: rgba(255,255,255,.85);
          border-radius: 999px; padding: 1px 7px; }

/* ----------------------------------------------------------------- modal  */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 100;
  display: grid; place-items: center; padding: 20px; overflow-y: auto;
  animation: fade .12s ease-out;
}
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(640px, 100%); max-height: 92vh; display: flex; flex-direction: column;
  animation: pop .14s ease-out;
}
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ----------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; max-width: 380px; }
.toast {
  background: #0f172a; color: #f8fafc; padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start;
  animation: slide .16s ease-out;
}
.toast.ok { background: #065f46; }
.toast.err { background: #7f1d1d; }
.toast.warn { background: #78350f; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* ----------------------------------------------------------------- photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.photo {
  position: relative; border-radius: 11px; overflow: hidden; border: 1px solid var(--line);
  aspect-ratio: 4 / 3; background: #f1f5f9;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 11.5px;
  color: #fff; background: linear-gradient(transparent, rgba(15,23,42,.8));
}
.photo .del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px;
  border: 0; background: rgba(15,23,42,.65); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.dropzone {
  border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 18px; text-align: center;
  color: var(--muted); background: #fbfcfe; cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-2); }

/* ------------------------------------------------------------- heatmap/map */
.map-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #eef2f7; }
.map-wrap img { display: block; width: 100%; height: auto; }
.zone-hot {
  position: absolute; border-radius: 4px; border: 1.5px solid rgba(15,23,42,.35);
  cursor: pointer; transition: opacity .12s;
}
.zone-hot:hover { opacity: .85; }
.zone-label {
  position: absolute; font-size: 10px; font-weight: 700; color: #0f172a;
  transform: translate(-50%, -50%); pointer-events: none; text-shadow: 0 1px 0 #fff;
}

/* ----------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

/* ----------------------------------------------------------------- timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; border: 2px solid var(--line-2);
}
.tl-item.done::before { border-color: var(--brand); background: var(--brand); }
.tl-item.warn::before { border-color: #f59e0b; background: #f59e0b; }
.tl-item.bad::before { border-color: #ef4444; background: #ef4444; }
.tl-time { font-size: 11.5px; color: var(--muted); }
.tl-text { font-size: 13.5px; }

/* ----------------------------------------------------------------- empty  */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty img { width: 74px; height: 74px; opacity: .85; margin-bottom: 8px; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }

.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%); background-size: 400% 100%; animation: shim 1.2s infinite; border-radius: 8px; }
@keyframes shim { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.loading-line { height: 14px; margin: 10px 0; }

/* ------------------------------------------------------------------ misc  */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.progress { height: 7px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.callout { border-radius: 11px; padding: 12px 14px; font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; }
.callout.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.callout.danger { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.callout.info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.callout.ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.callout p:last-child { margin-bottom: 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
.spinner.dark { border-color: #cbd5e1; border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-modal .searchbox { margin-bottom: 12px; }
.search-out { max-height: min(52vh, 520px); overflow-y: auto; margin: 0 -4px; }
.search-hint { color: var(--muted); font-size: 13px; padding: 10px 4px; }
.search-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); padding: 10px 6px 4px;
}
.search-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 8px; color: inherit; text-decoration: none;
}
.search-row:hover, .search-row.on { background: #eef2f7; text-decoration: none; }
.search-kind { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #e2e8f0; color: #334155; flex: 0 0 auto; }
.search-num { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.search-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.search-zone { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.searchbox { position: relative; }
.searchbox input { padding-left: 36px; }
.searchbox svg { position: absolute; left: 11px; top: 12px; width: 16px; height: 16px; color: var(--muted); }

/* ------------------------------------------------------------------ login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-art {
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(45,212,191,.22), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(59,130,246,.18), transparent 60%),
    #0b1220;
  color: #e2e8f0; padding: 46px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-art h1 { font-size: 34px; color: #f8fafc; max-width: 18ch; line-height: 1.15; }
.auth-art p { color: #94a3b8; max-width: 46ch; }
.auth-points { display: grid; gap: 14px; margin-top: 26px; }
.auth-point { display: flex; gap: 12px; align-items: flex-start; }
.auth-point img {
  width: 38px; height: 38px; border-radius: 9px; padding: 4px;
  /* The pictograms are drawn for light backgrounds; on the dark panel they sit on a
     pale tile so the artwork stays readable and is not recoloured. */
  background: #f8fafc; box-shadow: 0 1px 3px rgba(2, 6, 23, .4);
}
.auth-point strong { color: #e2e8f0; display: block; font-size: 14px; }
.auth-point span { color: #94a3b8; font-size: 13px; }
.auth-art-foot { margin-top: auto; font-size: 11.5px; color: #64748b; }
.auth-art-foot a { color: #94a3b8; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 24px; margin-bottom: 4px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }

.footer-note { color: var(--muted); font-size: 12px; padding: 24px 4px; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .content { padding: 18px 14px 60px; }
  .topbar { padding: 10px 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
}
@media print {
  .sidebar, .topbar, .btn, .tabs, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #cbd5e1; }
}

/* ==========================================================================
   Boot state, skip link and the public portal
   The portal is a separate page for people without an account: one column,
   large touch targets, readable outdoors, no sidebar.
   ========================================================================== */
.boot {
  min-height: 60vh; display: grid; place-items: center; gap: 14px;
  padding: 40px 20px; text-align: center;
}
.boot-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #cbd5e1; border-top-color: var(--brand);
  animation: spin 900ms linear infinite; display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-mark { animation: none; }
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 300;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

.portal-body { background: #eef2f6; }
.portal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 18px 18px 6px;
}
.portal-head .brand { display: flex; align-items: center; gap: 10px; }
.portal-head .brand-text { display: grid; line-height: 1.2; }
.portal-head .brand-text strong { font-size: 15px; }
.portal-head .brand-text span { font-size: 12px; color: var(--muted); }

.portal-main { max-width: 760px; margin: 0 auto; padding: 10px 18px 28px; }
.portal-hero { padding: 18px 4px 20px; }
.portal-hero h1 { font-size: 27px; margin: 0 0 8px; letter-spacing: -0.5px; }
.portal-hero p { margin: 0; font-size: 15px; }
.portal-hero .chip { margin-top: 12px; }

.portal-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.portal-done { text-align: center; }
.portal-done h1 { font-size: 23px; margin: 10px 0 8px; }
.done-icon { display: flex; justify-content: center; }

.portal-step {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.portal-step:first-of-type { padding-top: 4px; }
.portal-step:last-of-type { border-bottom: 0; }
.portal-step strong { font-size: 15px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-2); font-weight: 700; font-size: 13px;
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.photo-grid .photo { aspect-ratio: 1; border-radius: 12px; overflow: hidden; position: relative; background: #e2e8f0; }
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .photo .del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(15, 23, 42, .72); display: grid; place-items: center; cursor: pointer;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--line-2); border-radius: 12px;
  display: grid; place-items: center; gap: 6px; text-align: center; padding: 10px;
  color: var(--muted); cursor: pointer; background: #f8fafc;
}
.photo-add:hover { border-color: var(--brand); color: var(--brand); }

.choices { display: grid; gap: 9px; }
.choice {
  display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: #fff;
}
.choice:has(input:checked) { border-color: #7dd3c7; background: var(--brand-soft); }
.choice input { margin-top: 2px; accent-color: var(--brand); width: 18px; height: 18px; }
.choice span { display: grid; gap: 2px; }
.choice strong { font-size: 14px; }
.choice em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.choice:has(input[value="stop"]:checked) { border-color: #fca5a5; background: var(--danger-soft); }

.check span { display: grid; gap: 2px; }
.check em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.check:has(input:checked) { color: var(--danger); }

.btn-lg { min-height: 50px; font-size: 15.5px; border-radius: 12px; }
.kv-center { grid-template-columns: auto auto; justify-content: center; gap: 8px 18px; margin: 18px 0 4px; text-align: left; }

.portal-foot {
  max-width: 760px; margin: 0 auto; padding: 6px 18px 34px; display: grid; gap: 4px;
}
.portal-foot p { margin: 0; }
.portal-foot a { color: var(--brand-2); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: 6px; top: 16px; bottom: -14px; width: 2px; background: var(--line);
}
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); margin-top: 4px; }
.timeline p { margin: 4px 0 0; }

/* Horizontal bars, rendered as markup so the label stays readable at any width */
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 38px; align-items: center; gap: 10px; }
.bar-label {
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.bar-track { height: 10px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-value { font-size: 12.5px; font-weight: 650; color: var(--ink); text-align: right; }

/* keep all eleven sidebar entries visible on a 720p screen */
.nav-item { padding: 7px 11px; }
.nav-group-label { padding: 10px 12px 4px; }

/* Eleven entries plus the admin group have to fit a 700 px laptop window
   without a scrollbar; the sidebar stays scrollable for shorter screens. */
.nav-item { padding: 6px 11px; }
.nav-icon { width: 27px; height: 27px; border-radius: 7px; }
.nav-icon img, .nav-icon svg { width: 23px; height: 23px; }
.nav-label { font-size: 13.5px; }
.nav-group-label { padding: 9px 12px 3px; font-size: 10px; }
.sidebar-head { padding: 14px 18px 12px; }

/* Dense enough that fourteen entries fit above the fold on a 1366x768 laptop */
.nav { padding: 8px 10px 12px; }
.nav-item { padding: 4px 10px; margin: 1px 0; gap: 10px; }
.nav-icon { width: 25px; height: 25px; }
.nav-icon img, .nav-icon svg { width: 22px; height: 22px; }
.nav-label { font-size: 13px; }
.nav-group-label { padding: 7px 12px 2px; }

.nav-item { padding: 3px 10px; }
.nav-icon { width: 24px; height: 24px; }
.nav-icon img, .nav-icon svg { width: 21px; height: 21px; }
.nav-label { font-size: 13px; line-height: 1.25; }
.nav-group-label { padding: 6px 12px 2px; font-size: 9.5px; line-height: 1.1; }

.nav { padding: 6px 10px 8px; }
.nav-item { padding: 2px 10px; margin: 0; }

/* ------------------------------------------------------- floor plan editor */
/* The editor draws on a wrapper the size of the picture: an <img> for the
 * drawing and an SVG on top for the rectangles. Percent coordinates in the
 * SVG (viewBox 0 0 100 100) mean the same numbers as the database, so a drag
 * is one subtraction and a save is one number. */
.plan-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #eef2f7; touch-action: none; }
.plan-wrap img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.plan-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.plan-tag {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #0f172a; pointer-events: none;
  text-shadow: 0 1px 0 #fff, 0 0 3px #fff;
}

/* Dashboard built from widgets. Twelve columns so a card can be a third, two
 * thirds or the full width, and a phone always gets one column. */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.dash-w { min-width: 0; }
.dash-w.s1 { grid-column: span 3; }
.dash-w.s2 { grid-column: span 6; }
.dash-w.s3 { grid-column: span 12; }
.dash-grid .stat { height: 100%; }
@media (max-width: 1100px) { .dash-w.s1, .dash-w.s2, .dash-w.s3 { grid-column: span 6; } }
@media (max-width: 700px) { .dash-w.s1, .dash-w.s2, .dash-w.s3 { grid-column: span 12; } }

/* `hidden` must win. A block with a grid or flex display ignored the attribute
 * and showed every optional field at once - the reason and the next visit date
 * appeared even when "not fixed" was unticked. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------- maps
 * Three maps share one set of shapes: a coloured rectangle over the zone, a
 * small tag that names it, and a list of the work inside the selected zone.
 * The tag has to stay readable on a photo of a floor plan, hence the white
 * plate under the text. */
.zone-hot { padding: 0; font: inherit; appearance: none; }
.zone-hot.sel { box-shadow: 0 0 0 3px rgba(15,23,42,.18); }
.zone-tag {
  position: absolute; transform: translate(-1px, -100%);
  font-size: 10.5px; font-weight: 700; color: #0f172a;
  background: rgba(255,255,255,.92); border: 1px solid rgba(15,23,42,.15);
  border-radius: 4px 4px 4px 0; padding: 1px 5px; pointer-events: none; white-space: nowrap;
}
.zone-list { display: grid; gap: 2px; }
.zone-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 4px;
  border-bottom: 1px solid #f1f5f9; color: inherit; text-decoration: none;
}
.zone-row:hover { background: #f8fafc; }
.zone-row .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
