/* ──────────────────────────────────────────────────────────────────────
   Rink Tracker — design tokens + shell + identity. Polish pass at step 8.
   ────────────────────────────────────────────────────────────────────── */
:root {
  --bg:         #0a1320;
  --surface:    #111d2e;
  --surface-2:  #1a2a40;
  --surface-3:  #233448;
  --border:     #233448;
  --border-strong: #2e4866;

  --text:       #e7eef7;
  --muted:      #8aa0bd;

  --accent:       #4ec5ff;
  --accent-glow:  rgba(78, 197, 255, 0.35);
  --warn:         #ffb14e;
  --danger:       #ff4e6e;
  --good:         #4eff9a;
  --ice:          #aee7ff;

  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-lift:  0 8px 32px rgba(0,0,0,.5);

  /* iOS safe-area */
  --sa-top:    env(safe-area-inset-top, 0px);
  --sa-right:  env(safe-area-inset-right, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left:   env(safe-area-inset-left, 0px);

  /* Shell metrics */
  --header-h: 56px;
  --tabnav-h: 56px;
  /* Floating-dock gap from viewport bottom (mobile only — desktop dock is at top). */
  --dock-gap-bottom: 12px;
}

* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0;
  -webkit-tap-highlight-color: transparent;
}
html { touch-action: manipulation; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ──────────────────────────────────────────────────────────────────────
   SHELL — header (top) + tab-nav (top on desktop, bottom dock on mobile)
   ────────────────────────────────────────────────────────────────────── */
.shell-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--header-h);
  padding: 0 14px;
  padding-top: var(--sa-top);
  padding-left:  calc(14px + var(--sa-left));
  padding-right: calc(14px + var(--sa-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}
.shell-brand { display: flex; align-items: center; gap: 8px; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}
.brand-name { font-weight: 700; letter-spacing: 0.01em; }

.shell-controls { display: flex; align-items: center; gap: 8px; }

.rink-switch {
  display: inline-flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 2px;
}
.rink-opt {
  background: transparent; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; color: var(--muted); min-height: 32px;
}
.rink-opt.active {
  background: var(--accent); color: #001627; font-weight: 700;
}

.ident-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px 6px 8px; font-size: 12px;
  cursor: pointer; min-height: 36px; max-width: 140px;
  white-space: nowrap; overflow: hidden;
}
.ident-chip:hover { background: var(--surface-3); }
.ident-chip:active { transform: scale(.97); }
.ident-chip .ident-chip-icon { color: var(--muted); font-size: 9px; line-height: 1; }
.ident-chip.is-admin { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.ident-chip.is-admin .ident-chip-icon { color: var(--accent); }
.ident-chip .ident-chip-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* TAB NAV — top on desktop, bottom dock on mobile */
.tab-nav {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; align-items: stretch; overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--tabnav-h);
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 1 0 auto; min-width: 80px;
  padding: 0 14px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active {
  color: var(--text); border-bottom-color: var(--accent);
}
.tab:hover { color: var(--text); }

@media (max-width: 720px) {
  .tab-nav {
    position: fixed; top: auto;
    left: calc(12px + var(--sa-left));
    right: calc(12px + var(--sa-right));
    bottom: calc(var(--dock-gap-bottom) + var(--sa-bottom));
    height: var(--tabnav-h);
    padding: 6px;
    background: rgba(17, 29, 46, 0.78);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
    z-index: 30;
  }
  .tab {
    border-bottom: none; border-top: none;
    flex: 1 0 0; min-width: 0;
    padding: 0 4px; font-size: 11px;
    margin: 0 1px;
    border-radius: 14px;
    transition: background .12s ease, color .12s ease;
  }
  .tab.active {
    border-top: none;
    background: rgba(78, 197, 255, 0.16);
    color: var(--accent);
  }
  .tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.04);
  }
  .tab:active { transform: scale(.97); }
}

.shell-main {
  min-height: calc(100dvh - var(--header-h) - var(--tabnav-h));
  padding: 14px;
  padding-left: calc(14px + var(--sa-left));
  padding-right: calc(14px + var(--sa-right));
}
@media (max-width: 720px) {
  .shell-main {
    min-height: calc(100dvh - var(--header-h));
    padding-bottom: calc(14px + var(--tabnav-h) + var(--dock-gap-bottom) + var(--sa-bottom) + 12px);
  }
}
.tab-loading {
  padding: 40px 0; text-align: center; color: var(--muted); font-size: 13px;
}

/* ──────────────────────────────────────────────────────────────────────
   TAB PLACEHOLDERS — minimal until each tab ships
   ────────────────────────────────────────────────────────────────────── */
.tab-stub {
  max-width: 560px; margin: 32px auto; padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  text-align: center;
}
.tab-stub h1 { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.tab-stub p { margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.tab-stub .stub-tag {
  display: inline-block; margin-top: 14px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ──────────────────────────────────────────────────────────────────────
   BUTTONS, FORMS — shared
   ────────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #001627; border: none;
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 700;
  cursor: pointer; min-height: 44px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }

.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; min-height: 44px;
}
.btn-ghost:hover { background: var(--surface-3); }
.btn-ghost:active { transform: scale(.97); }

.btn-link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; font-size: 12px; padding: 6px 0; min-height: 44px;
}
.btn-link:hover { text-decoration: underline; }

.ctl {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ──────────────────────────────────────────────────────────────────────
   IDENTITY + ADMIN DIALOGS
   ────────────────────────────────────────────────────────────────────── */
.identity-dialog, .admin-dialog {
  width: min(420px, calc(100vw - 24px));
  margin: auto; padding: 0; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); border-radius: 14px;
  box-shadow: var(--shadow-lift);
}
.identity-dialog::backdrop, .admin-dialog::backdrop {
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
}
.identity-dialog form, .admin-dialog form {
  margin: 0; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px calc(16px + var(--sa-bottom));
}
.ident-header h2, .admin-header h2 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.ident-sub, .admin-sub { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.ident-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 38vh; overflow-y: auto;
  padding: 2px; margin: 0 -2px;
}
.ident-loading, .ident-empty {
  padding: 14px; text-align: center; color: var(--muted); font-size: 12px;
}
.ident-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font: inherit; cursor: pointer;
  min-height: 44px; text-align: left;
}
.ident-row:hover { background: var(--surface-3); }
.ident-row.is-me { border-color: var(--accent); }
.ident-row-name { font-weight: 600; }
.ident-row-badge {
  background: var(--accent); color: #001627; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px;
}
.ident-add { display: flex; gap: 8px; }
.ident-add input {
  flex: 1; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  -webkit-appearance: none; appearance: none;
}
.ident-add input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.ident-status, .admin-status {
  font-size: 12px; color: var(--muted); min-height: 16px;
}
.ident-status.err, .admin-status.err { color: var(--danger); }
.ident-status.ok,  .admin-status.ok  { color: var(--good); }

.ident-footer, .admin-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--border);
}

.admin-ctl { gap: 6px; text-transform: none; }
.admin-ctl > span:first-child {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.admin-ctl select, .admin-ctl input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 16px; min-height: 44px;
  color-scheme: dark;
  -webkit-appearance: none; appearance: none;
}
.admin-ctl input:focus, .admin-ctl select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}

@media (max-width: 480px) {
  .identity-dialog, .admin-dialog { width: calc(100vw - 16px); border-radius: 12px; }
  .ident-list { max-height: 50vh; }
}

/* ──────────────────────────────────────────────────────────────────────
   HEATMAP TAB — controls + canvas + side panel + entry dialog.
   Ported from ice-tracker; UI polish pass at step 8.
   ────────────────────────────────────────────────────────────────────── */
.heatmap-tab {
  display: flex; flex-direction: column;
  gap: 10px;
  margin: -14px;
  margin-bottom: 0;
}

.hm-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.hm-controls.hm-disabled { opacity: 0.4; pointer-events: none; }

.hm-date-select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font: inherit; min-height: 40px; min-width: 180px;
  color-scheme: dark;
}

.hm-mode-strip {
  display: inline-flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
  max-width: 100%;
}
.hm-mode-strip::-webkit-scrollbar { display: none; }
.hm-mode {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); min-height: 40px;
  white-space: nowrap;
}
.hm-mode.active {
  background: var(--accent); color: #001627;
}
.hm-mode:hover:not(.active) { color: var(--text); }

.hm-mesh-toggle {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px 6px 10px; cursor: pointer; min-height: 40px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
}
.hm-mesh-toggle .hm-mesh-icon {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong);
  transition: background .15s ease, box-shadow .15s ease;
}
.hm-mesh-toggle.active {
  border-color: var(--accent); color: var(--text);
}
.hm-mesh-toggle.active .hm-mesh-icon {
  background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
}

.hm-queued-badge {
  background: var(--warn); color: #001627; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; font-size: 11px;
  animation: hm-queued-pulse 1.6s ease-in-out infinite;
}
@keyframes hm-queued-pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .55; }
}

.hm-entry-btn {
  background: var(--accent); color: #001627; border: none;
  padding: 0 16px; border-radius: 8px; font: inherit; font-weight: 700;
  cursor: pointer; min-height: 40px;
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto;
}
.hm-entry-btn:hover { filter: brightness(1.08); }
.hm-entry-plus { font-size: 18px; line-height: 1; }

.hm-context {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.plan-ctl { flex-direction: row; align-items: center; gap: 10px; text-transform: none; }
.plan-ctl > span:first-child {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.plan-ctl input[type=range] { width: 160px; accent-color: var(--accent); }
.plan-ctl .plan-value {
  display: inline-block; min-width: 44px; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600;
}
.delta-ctl select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font: inherit; min-width: 220px;
  color-scheme: dark;
}

.hm-empty {
  padding: 24px;
}

.hm-main {
  display: grid; grid-template-columns: 1fr 360px;
  gap: 0;
  min-height: calc(100dvh - var(--header-h) - var(--tabnav-h) - 110px);
}
@media (max-width: 900px) {
  .hm-main { grid-template-columns: 1fr; }
}

.hm-canvas-pane {
  display: flex; flex-direction: column; padding: 14px; gap: 8px;
  min-width: 0; min-height: 0;
}
.hm-canvas-wrap {
  flex: 1; position: relative;
  background: linear-gradient(180deg, #0e1a2c, #0a1320);
  border-radius: 12px; border: 1px solid var(--border);
  overflow: hidden; min-height: 320px;
  display: flex; align-items: center; justify-content: center;
}
.hm-canvas-wrap #rink { display: block; max-width: 100%; max-height: 100%; cursor: crosshair; }

.hm-legend {
  position: absolute; bottom: 12px; right: 12px;
  background: rgba(10,19,32,.85); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
  font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; gap: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hm-legend .hm-scale {
  width: 160px; height: 8px; border-radius: 4px;
}
.hm-legend .hm-scale-labels {
  display: flex; justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.hm-status {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12px; color: var(--muted);
  padding: 4px 6px;
  font-variant-numeric: tabular-nums;
}
.hm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.hm-chip .k { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.hm-chip .v { color: var(--text); font-weight: 600; }
.hm-chip .v.warn   { color: var(--warn); }
.hm-chip .v.danger { color: var(--danger); }

.hm-side-pane {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.hm-empty-tap {
  color: var(--muted); padding: 24px 8px; text-align: center;
  border: 1px dashed var(--border); border-radius: 10px;
  font-size: 13px;
}
.hm-side-pane h2 { margin: 0; font-size: 16px; }
.hm-side-pane h3 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.hm-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.hm-kv .k { color: var(--muted); }
.hm-kv .v { font-variant-numeric: tabular-nums; }

.hm-spark { width: 100%; height: 80px; background: var(--surface-2); border-radius: 6px; }

.hm-history {
  display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.hm-history .row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 4px 6px; border-radius: 4px; }
.hm-history .row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.hm-history .d { color: var(--muted); }

.flag { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); }

.hm-sheet-peek { display: none; }
.hm-sheet-backdrop { display: none; }

@media (hover: none) { .hm-canvas-wrap #rink { cursor: pointer; } }

/* ── Heatmap mobile (≤640px): bottom-sheet pattern ───────────────────── */
@media (max-width: 640px) {
  .heatmap-tab { gap: 0; }
  .hm-controls { padding: 8px 10px; gap: 6px; }
  .hm-mode { padding: 7px 10px; font-size: 12.5px; min-height: 38px; }
  .hm-entry-btn { padding: 0 12px; min-height: 40px; }
  .hm-mesh-toggle { padding: 6px 10px; min-height: 40px; }

  .hm-main {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - var(--header-h) - var(--tabnav-h) - 80px);
  }
  .hm-canvas-pane {
    padding: 8px;
    padding-bottom: calc(72px + var(--dock-gap-bottom) + var(--sa-bottom));
    min-height: calc(100dvh - var(--header-h) - var(--tabnav-h) - 130px);
  }
  .hm-canvas-wrap { min-height: 280px; border-radius: 10px; }

  /* Backdrop sits ABOVE shell header & dock (both z=30) so any tap outside the
     sheet dismisses it. Sheet itself sits one above the backdrop. */
  .hm-sheet-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    z-index: 31;
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  .hm-sheet-backdrop.active { opacity: 1; pointer-events: auto; }

  .hm-side-pane {
    position: fixed; left: 0; right: 0;
    bottom: calc(var(--tabnav-h) + var(--dock-gap-bottom) + var(--sa-bottom) + 8px);
    height: 70dvh; max-height: 70dvh;
    border-left: none; border-top: 1px solid var(--border);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    transform: translateY(calc(100% - 64px));
    transition: transform .28s cubic-bezier(.2,.7,.3,1),
                clip-path .28s cubic-bezier(.2,.7,.3,1);
    /* When collapsed: clip the sheet to its top 64px so the (stacked-below) floating
       dock at y=tabnav+gap remains visible. Without this, the sheet box at z=32
       extends past the dock area at z=30 and occludes it visually. */
    clip-path: inset(0 0 calc(100% - 64px) 0);
    box-shadow: var(--shadow-lift);
    overflow: hidden;
    overscroll-behavior: contain;
    will-change: transform, clip-path;
    z-index: 32;
    padding: 0 16px calc(16px + var(--sa-bottom));
    background: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .hm-side-pane::before {
    content: ""; display: block;
    width: 40px; height: 4px; background: var(--border-strong);
    border-radius: 2px; margin: 8px auto 4px;
  }
  .hm-side-pane.expanded {
    transform: translateY(0);
    clip-path: inset(0);
    overflow-y: auto;
  }
  .hm-sheet-peek {
    display: flex !important;
    align-items: center; justify-content: space-between;
    padding: 4px 6px 12px; font-size: 13px; color: var(--muted);
    cursor: pointer; min-height: 44px;
    -webkit-user-select: none; user-select: none;
  }
  .hm-sheet-peek::after {
    content: "▴"; font-size: 14px; color: var(--muted);
    transition: transform .25s ease;
  }
  .hm-side-pane.expanded .hm-sheet-peek::after { transform: rotate(180deg); }

  .plan-ctl input[type=range] { width: 110px; }
  .hm-legend { bottom: 6px; right: 6px; padding: 6px 8px; font-size: 10px; }
  .hm-legend .hm-scale { width: 100px; height: 6px; }
}

/* ── Heatmap entry dialog ────────────────────────────────────────────── */
.hm-entry-dialog {
  width: min(680px, 100vw); height: 100dvh;
  max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 0; border: none;
  background: var(--bg); color: var(--text);
  position: fixed; right: 0; top: 0; left: auto;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.hm-entry-dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
@media (max-width: 700px) {
  .hm-entry-dialog { width: 100vw; height: 100dvh; border-left: none; }
}
.hm-entry-dialog form {
  display: flex; flex-direction: column; height: 100%;
  margin: 0;
}
.hm-entry-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--sa-top)) 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.hm-entry-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hm-entry-title span { font-size: 18px; font-weight: 600; }
.hm-entry-title small { color: var(--muted); font-size: 12px; }
.hm-entry-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.hm-entry-controls input[type="date"] {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 6px; font: inherit; min-height: 44px;
  color-scheme: dark;
}
.hm-entry-status {
  padding: 8px 16px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.hm-entry-status:empty { display: none; }
.hm-entry-status.ok { color: var(--good); }
.hm-entry-status.err { color: var(--danger); }

.hm-entry-grid {
  flex: 1; overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px calc(12px + var(--sa-bottom));
  display: flex; flex-direction: column; gap: 6px;
}
.hm-entry-row {
  display: grid; grid-template-columns: 56px 1fr 1fr;
  gap: 10px; align-items: center;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.hm-entry-row.has-data { border-color: rgba(78, 197, 255, 0.4); }
.hm-entry-row .pt {
  display: flex; align-items: center; justify-content: center;
  height: 44px; font-weight: 700; color: var(--accent);
  background: var(--surface-2); border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.hm-entry-row label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
.hm-entry-row input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font: inherit; font-size: 16px;
  font-variant-numeric: tabular-nums; min-height: 44px;
  -webkit-appearance: none; appearance: none;
}
.hm-entry-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hm-entry-row input.warn { border-color: var(--warn); }
.hm-entry-row input.danger { border-color: var(--danger); }

/* ──────────────────────────────────────────────────────────────────────
   ISSUES TAB — list, FAB, new-issue sheet, detail dialog (step 3)
   ────────────────────────────────────────────────────────────────────── */
.issues-tab { margin: -14px; display: flex; flex-direction: column; }

.iss-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.iss-filter-strip {
  display: inline-flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 2px;
}
.iss-filter {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); min-height: 36px;
}
.iss-filter.active { background: var(--accent); color: #001627; }
.iss-filter:hover:not(.active) { color: var(--text); }
.iss-counter { color: var(--muted); font-size: 12px; }

.iss-loading {
  padding: 32px 12px; text-align: center; color: var(--muted); font-size: 13px;
}
.iss-error {
  padding: 16px; color: var(--danger); font-size: 13px;
}

.iss-list {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  padding-bottom: calc(96px + var(--dock-gap-bottom) + var(--sa-bottom));
}
.iss-empty { padding: 14px; }

/* Issue card */
.iss-card {
  display: flex; align-items: stretch; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; min-height: 88px;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  transition: border-color .15s ease, transform .1s ease;
}
.iss-card:hover { border-color: var(--border-strong); }
.iss-card:active { transform: scale(.99); }

.iss-card-thumb-wrap {
  flex: 0 0 auto; position: relative;
}
.iss-card-thumb {
  width: 80px; height: 80px; border-radius: 8px;
  background: var(--surface-2); object-fit: cover;
  display: block;
}
.iss-card-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 24px;
  border: 1px dashed var(--border-strong);
}
.iss-card-photo-count {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(10, 19, 32, .85);
  color: var(--text); font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
}

.iss-card-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px; justify-content: space-between;
}
.iss-card-top {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px;
}
.iss-card-title {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.iss-card-bottom {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--muted);
}
.iss-card-author { font-weight: 600; color: var(--text); }
.iss-card-loc {
  color: var(--muted); font-size: 11px;
}

/* Severity + status pills */
.iss-sev-pill, .iss-status-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid transparent;
}
.iss-sev-low  { background: rgba(78, 197, 255, .14); color: #4ec5ff; border-color: rgba(78,197,255,.4); }
.iss-sev-med  { background: rgba(255, 177, 78, .16); color: var(--warn); border-color: rgba(255,177,78,.4); }
.iss-sev-high { background: rgba(255, 78, 110, .18); color: var(--danger); border-color: rgba(255,78,110,.5); }
.iss-status-open        { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.iss-status-in_progress { background: rgba(78, 197, 255, .14); color: #4ec5ff; border-color: rgba(78,197,255,.4); }
.iss-status-resolved    { background: rgba(78, 255, 154, .14); color: var(--good); border-color: rgba(78,255,154,.4); }

/* FAB */
.iss-fab {
  position: fixed;
  right: calc(20px + var(--sa-right));
  bottom: calc(20px + var(--tabnav-h) + var(--dock-gap-bottom) + var(--sa-bottom));
  z-index: 35;
  background: var(--accent); color: #001627;
  border: none; border-radius: 999px;
  padding: 14px 22px;
  font: inherit; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  min-height: 56px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 0 1px rgba(78,197,255,.3);
}
.iss-fab:hover { filter: brightness(1.08); }
.iss-fab:active { transform: scale(.96); }
.iss-fab-plus { font-size: 22px; line-height: 1; }
@media (min-width: 721px) {
  .iss-fab { bottom: calc(28px + var(--sa-bottom)); }
}

/* New-issue dialog (full-height sheet on phones, side-panel on desktop) */
.iss-new-dialog, .iss-detail-dialog {
  width: min(560px, 100vw); height: 100dvh;
  max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 0; border: none;
  background: var(--bg); color: var(--text);
  position: fixed; right: 0; top: 0; left: auto;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.iss-new-dialog::backdrop, .iss-detail-dialog::backdrop {
  background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
}
@media (max-width: 580px) {
  .iss-new-dialog, .iss-detail-dialog { width: 100vw; border-left: none; }
}
.iss-new-dialog form, .iss-detail-dialog form {
  display: flex; flex-direction: column; height: 100%;
  margin: 0;
}
.iss-new-header, .iss-detail-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--sa-top)) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.iss-new-header { justify-content: space-between; flex-wrap: wrap; }
.iss-new-title { display: flex; flex-direction: column; gap: 2px; }
.iss-new-title span:first-child { font-size: 18px; font-weight: 700; }
.iss-new-title small { color: var(--muted); font-size: 12px; }
.iss-new-actions { display: flex; gap: 8px; }

.iss-new-body {
  flex: 1; overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  padding-bottom: calc(16px + var(--sa-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

.iss-ctl { display: flex; flex-direction: column; gap: 6px; }
.iss-ctl > span:first-child {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.iss-ctl-aux { color: var(--muted); font-style: italic; text-transform: none; letter-spacing: 0; font-weight: 400; }
.iss-ctl input[type=text],
.iss-ctl textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 16px; min-height: 44px;
  -webkit-appearance: none; appearance: none; resize: vertical;
}
.iss-ctl input[type=text]:focus,
.iss-ctl textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Severity pills (form control) */
.iss-sev-strip {
  display: inline-flex; gap: 4px;
}
.iss-sev {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; min-height: 44px;
  font: inherit; font-size: 13px; font-weight: 600;
  text-transform: capitalize;
}
.iss-sev:hover { background: var(--surface-3); color: var(--text); }
.iss-sev.active { color: #001627; }
.iss-sev[data-sev="low"].active  { background: #4ec5ff; border-color: #4ec5ff; }
.iss-sev[data-sev="med"].active  { background: var(--warn); border-color: var(--warn); }
.iss-sev[data-sev="high"].active { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Photo picker */
.iss-photo-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.iss-photo-add {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 12px 16px; cursor: pointer; min-height: 60px;
  font: inherit; font-size: 13px; font-weight: 600;
}
.iss-photo-add:hover { border-color: var(--accent); color: var(--accent); }
.iss-photo-add-icon { font-size: 18px; }
.iss-photo-previews { display: flex; gap: 8px; flex-wrap: wrap; }
.iss-photo-prev {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.iss-photo-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iss-photo-prev-x {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px;
  background: rgba(10, 19, 32, .85); color: var(--text);
  border: none; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 22px; padding: 0;
}
.iss-photo-prev-x:hover { background: var(--danger); }

/* Pin toggle + canvas */
.iss-pin-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; cursor: pointer; min-height: 48px;
  font: inherit; font-size: 13px; font-weight: 600;
}
.iss-pin-toggle:hover { border-color: var(--accent); }
.iss-pin-toggle.active { border-color: var(--accent); color: var(--accent); }
.iss-pin-pane {
  margin-top: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.iss-pin-canvas-wrap {
  background: linear-gradient(180deg, #0e1a2c, #0a1320);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
.iss-pin-canvas-wrap canvas { display: block; cursor: crosshair; touch-action: manipulation; }
.iss-pin-status { font-size: 12px; color: var(--muted); padding: 2px 4px; }
.iss-pin-clear { align-self: flex-start; }

.iss-new-status { font-size: 12px; color: var(--muted); min-height: 16px; padding: 2px 4px; }
.iss-new-status.ok  { color: var(--good); }
.iss-new-status.err { color: var(--danger); }

/* Detail dialog */
.iss-detail-header { gap: 12px; flex-wrap: wrap; }
.iss-back {
  width: 44px; min-width: 44px; height: 44px;
  padding: 0; font-size: 20px; line-height: 1;
}
.iss-detail-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.iss-detail-title {
  margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3;
  overflow: hidden;
}
.iss-detail-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.iss-detail-meta-author { margin-left: auto; }

.iss-detail-body {
  flex: 1; overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px calc(20px + var(--sa-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.iss-detail-body-text { margin: 0; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }

.iss-detail-photos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.iss-detail-photo {
  position: relative;
  aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
}
.iss-detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iss-detail-photo-x {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px;
  background: rgba(10, 19, 32, .85); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 26px; padding: 0;
}
.iss-detail-photo-x:hover { background: var(--danger); border-color: var(--danger); }

.iss-detail-controls {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
}
.iss-detail-control { display: flex; flex-direction: column; gap: 6px; }
.iss-detail-control-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.iss-status-strip { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.iss-status-strip .iss-status-pill {
  cursor: pointer; padding: 8px 14px; font-size: 11px; min-height: 38px;
  border-width: 1px;
}
.iss-status-strip .iss-status-pill.active { box-shadow: 0 0 0 2px var(--accent); }

.iss-detail-comment-row {
  flex-direction: row; gap: 8px; align-items: flex-end;
}
.iss-detail-comment-row textarea {
  flex: 1;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 16px; min-height: 44px; resize: vertical;
}
.iss-detail-comment-btn { min-height: 44px; padding: 0 16px; }
.iss-detail-status { font-size: 12px; color: var(--muted); min-height: 16px; }
.iss-detail-status.err { color: var(--danger); }

.iss-detail-timeline { padding-top: 4px; }
.iss-detail-timeline h3 {
  margin: 0 0 8px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.iss-detail-timeline ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.iss-rev {
  background: var(--surface-2);
  border-left: 2px solid var(--border-strong);
  padding: 8px 10px; border-radius: 0 8px 8px 0;
  font-size: 12px; line-height: 1.4;
  color: var(--muted);
}
.iss-rev-who { color: var(--text); font-weight: 600; }
.iss-rev-when { color: var(--muted); margin-left: 6px; font-size: 11px; }
.iss-rev-comment { color: var(--text); }
.iss-rev-status_changed   { border-left-color: #4ec5ff; }
.iss-rev-severity_changed { border-left-color: var(--warn); }
.iss-rev-photo_added,
.iss-rev-photo_removed    { border-left-color: var(--accent); }
.iss-rev-comment          { border-left-color: var(--good); }
.iss-rev-created          { border-left-color: var(--accent); }
