/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "ss02", "cv01";
}
#app {
  max-width: 640px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
input, textarea { font: inherit; color: inherit; background: transparent; border: 0; outline: 0; width: 100%; }
h1, h2, h3 { margin: 0; }
a { color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Linen tokens (light) ──────────────────────────────────── */
:root {
  --bg:            #F4EEDF;
  --bg-2:          #EAE2D0;
  --surface:       #FAF5E7;
  --surface-elev:  #FFFCF1;
  --ink:           #2A2218;
  --ink-soft:      #756753;
  --line:          rgba(42,34,24,0.10);
  --line-strong:   rgba(42,34,24,0.22);
  --accent:        #5E7757;
  --accent-soft:   #DCE3CD;
  --accent-strong: #4A6044;
  --ok:            #5E7757;
  --warn:          #B25731;
  --warn-soft:     #F2D2BD;
  --err:           #2A2218;
  --name-col: 130px;
  --act-col:  120px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #1B1611;
    --bg-2:          #221C15;
    --surface:       #221D17;
    --surface-elev:  #2A241B;
    --ink:           #EFE8D9;
    --ink-soft:      #A89A82;
    --line:          rgba(239,232,217,0.10);
    --line-strong:   rgba(239,232,217,0.22);
    --accent:        #A2BB94;
    --accent-soft:   #3D4938;
    --accent-strong: #B6CDA6;
    --warn:          #D9866A;
    --warn-soft:     #4B2E22;
    --err:           #EFE8D9;
  }
}

/* ── Typography helpers ────────────────────────────────────── */
.mono { font-family: "JetBrains Mono", monospace; }
h1, h2, h3 {
  font-family: "Manrope", sans-serif;
  letter-spacing: -0.015em;
  font-feature-settings: "ss01";
}
h2 em {
  font-family: "Newsreader", serif;
  font-style: italic;
  font-weight: 300;
  letter-spacing: -0.01em;
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screen transitions ────────────────────────────────────── */
.screen { animation: fadeUp .28s cubic-bezier(.2,.7,.2,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

/* ── App shell layout ──────────────────────────────────────── */
.app-header {
  display: flex;
  /* padding: 12px 20px 18px; */
  flex-shrink: 0;
  gap: 16px;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
}
.app-header h1 { font-size: 26px; font-weight: 700; line-height: 1.1; }
.app-header .crumb {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.sync-ago {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.02em;
  color: var(--ink-soft);
  align-self: center;
}
.app-header .net-pill {
  background: var(--accent-soft); color: var(--accent-strong);
  border: 0; font-family: "JetBrains Mono", monospace;
  font-size: 10px; padding: 5px 9px; border-radius: 99px;
  letter-spacing: 0.04em; cursor: default;
}
.app-header .net-pill.off { background: var(--warn-soft); color: var(--warn); }
.app-header .date-switch {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; font-family: "JetBrains Mono", monospace;
  font-size: 11px; padding: 4px 6px;
  box-shadow: 0 1px 1px rgba(20,15,5,0.04);
  display: flex; align-items: center; gap: 2px; width: fit-content;
}
.date-label { font-family: "JetBrains Mono", monospace; font-weight: 500; }
.app-header .date-switch button { padding: 2px 4px; display: inline-flex; align-items: center; }
.app-header .date-switch .date-btn {
  padding: 0 6px;
  display: inline-flex; align-items: center; gap: 6px;
}
.app-header .date-switch .date-btn svg { opacity: 0.7; }

.app-subheader {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
}

/* ── Scrollable body ───────────────────────────────────────── */
.body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: clip;
  display: flex; flex-direction: column; gap: 14px;
}
.body.settings-pane, .body.history-list { gap: 18px; }
.body.entry { gap: 14px; }
.body.settings-sub { gap: 18px; }

/* ── Tab bar ───────────────────────────────────────────────── */
.tab-bar {
  flex-shrink: 0;
  height: 76px;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 14px 22px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab-bar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.tab-bar button.active::after {
    content: "";
    width: 6px;
    aspect-ratio: 1;
    background-color: var(--ink-soft);
    border-radius: 16px;
}

.tab-bar button.active { color: var(--ink); }
.tab-bar .icon {
  background: transparent; border: 0;
  width: 24px; height: 24px; display: grid; place-items: center;
}
.tab-bar button.active .icon { color: var(--accent); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; min-height: 52px;
  font-family: "Manrope", sans-serif; font-size: 15px; font-weight: 600;
  letter-spacing: -0.005em; width: 100%;
  background: var(--surface-elev); border: 1px solid var(--line-strong);
  border-radius: 99px; box-shadow: 0 1px 2px rgba(20,15,5,0.04);
  transition: background .15s ease, color .15s ease, transform .12s ease, box-shadow .18s ease;
}
.btn:hover { background: var(--bg-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 10px -3px rgba(20,15,5,0.22);
}
.btn.primary:hover {
  background: color-mix(in oklab, var(--ink) 92%, var(--bg));
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 6px 14px -3px rgba(20,15,5,0.28);
}
.btn.primary:active { transform: translateY(0); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-row { display: flex; gap: 10px; }
.entry-actions { display: flex; gap: 8px; margin-top: 4px; }
.entry-actions .btn { flex: 1; }
.entry-actions .entry-share { flex-shrink: 0; }
.btn-row .btn { flex: 1 1 0; min-width: 0; }

/* ── Banners ───────────────────────────────────────────────── */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px; border: 0; border-radius: 14px;
  font-family: "Manrope", sans-serif;
}
.banner .bi { display: inline-flex; flex-shrink: 0; margin-top: 1px; }
.banner-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.banner-title { font-weight: 600; letter-spacing: -0.005em; }
.banner-sub { font-weight: 500; font-size: 12px; line-height: 1.4; }
.banner-action {
  background: var(--accent-strong); border: 1px solid var(--line-strong);
  border-radius: 99px; font-family: "JetBrains Mono", monospace;
  font-size: 11px; padding: 7px 12px; color: var(--surface-elev);
  flex-shrink: 0; align-self: center; white-space: nowrap;
  transition: background .12s ease;
}
.banner-info { background: var(--accent-soft); }
.banner-info .bi { color: var(--accent-strong); }
.banner-info .banner-sub { color: var(--accent-strong); opacity: 0.85; }
.banner-warn { background: var(--warn-soft); }
.banner-warn .bi { color: var(--warn); }
.banner-warn .banner-sub { color: var(--warn); opacity: 0.85; }
.banner-err { background: var(--warn); color: var(--bg); }
.banner-err .banner-sub { color: var(--bg); opacity: 0.7; }
.banner-err .bi { color: var(--warn-soft); }
.banner-err .banner-action {
  background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); color: var(--bg);
}

/* ── Entry grid ────────────────────────────────────────────── */
.grid-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20,15,5,0.04), 0 10px 20px -12px rgba(20,15,5,0.08);
}
.grid-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-elev);
}
.toolbar-label { font-size: 10px; letter-spacing: 0.06em; color: var(--ink-soft); }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 99px; background: transparent; color: var(--ink-soft);
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.96); }
.header-action {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: "JetBrains Mono", monospace; letter-spacing: 0.01em;
  color: var(--ink-soft); background: none; border: none; cursor: pointer; padding: 4px 0;
}
.header-action:hover { color: var(--ink); }
.member-count {
  font-size: 0.7em; color: var(--ink-soft);
  font-family: "JetBrains Mono", monospace; font-weight: 400;
}

/* ── Export data range chips ───────────────────────────────── */
.range-chips {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}
.range-chip {
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  padding: 6px 16px; border-radius: 99px;
  border: 1.5px solid var(--line-strong);
  background: none; color: var(--ink-soft); cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.range-chip.active {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.range-chip:hover:not(.active) { color: var(--ink); border-color: var(--ink-soft); }

.grid-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface);
}
.grid-wrap.readonly { opacity: 0.92; pointer-events: none; }
.grid {
  display: grid; align-items: stretch;
  grid-template-columns: var(--name-col) repeat(6, var(--act-col));
  min-width: calc(var(--name-col) + 6 * var(--act-col));
}
.grid .hd, .grid .cell, .grid .name {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.grid .hd {
  background: var(--surface); position: sticky; top: 0; z-index: 2;
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 var(--line);
  white-space: nowrap; padding: 0 8px;
}
.grid .hd:not(.hd-name) { border-left: 1px solid var(--line); }
.grid .hd-name { justify-content: flex-start; padding-left: 14px; }
.grid .name {
  font-family: "Manrope", sans-serif; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--line); padding-left: 14px;
  justify-content: flex-start; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid .cell {
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
}
.grid .check {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); background: var(--bg);
  border-radius: 8px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.grid .check:hover { border-color: var(--ink); }
.grid .check.on {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(94,119,87,0.3);
}
.grid .check.on::after {
  content: ""; width: 11px; height: 6px;
  border-left: 2.5px solid var(--surface); border-bottom: 2.5px solid var(--surface);
  transform: rotate(-50deg) translate(1px, -2px);
}
.grid.readonly .check.ro {
  width: 22px; height: 22px;
  border: 1.5px solid var(--line-strong); background: var(--bg); border-radius: 7px;
  cursor: default; pointer-events: none;
}
.grid.readonly .check.ro.on {
  background: var(--accent); border-color: var(--accent);
}
.grid.readonly .check.ro.on::after {
  content: ""; display: block;
  width: 10px; height: 5px;
  border-left: 2.5px solid var(--surface); border-bottom: 2.5px solid var(--surface);
  transform: rotate(-50deg);
}

/* ── Stats card ────────────────────────────────────────────── */
.stats {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 12px; box-shadow: 0 1px 2px rgba(20,15,5,0.04);
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.stats .stat { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.stats .stat .num {
  font-family: "Newsreader", serif; font-weight: 400; font-size: 34px;
  line-height: 1; font-feature-settings: "lnum"; letter-spacing: -0.02em;
}
.stats .stat .lbl {
  font-family: "JetBrains Mono", monospace; font-size: 10px;
  letter-spacing: 0.08em; color: var(--ink-soft);
}
.stats .stat + .stat { border-left: 1px solid var(--line); }
.stats.just-synced { animation: statsGlow 2.4s ease-out both; }
@keyframes statsGlow {
  0%   { box-shadow: 0 0 0 0 transparent; }
  20%  { box-shadow: 0 0 0 4px var(--accent-soft); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Celebration banner ────────────────────────────────────── */
.celebration-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; position: relative; overflow: hidden;
  background: var(--accent-soft); border-radius: 14px;
  color: var(--ink); font-family: "Manrope", sans-serif;
  animation: cbRise .5s cubic-bezier(.2,.7,.2,1) both;
}
.celebration-banner .cb-check {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  flex-shrink: 0; border-radius: 99px;
  background: var(--accent); color: var(--surface-elev);
}
.celebration-banner .banner-title { font-weight: 600; letter-spacing: -0.005em; }
.celebration-banner .banner-sub { color: var(--accent-strong); opacity: 0.9; }
.celebration-banner .cb-share {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px;
  font: 600 12px "Manrope", sans-serif; letter-spacing: -0.005em; flex-shrink: 0;
  background: var(--accent-strong); color: var(--surface-elev); border: 0;
  cursor: pointer;
}
.celebration-banner .cb-share:hover { transform: translateY(-1px); }
.celebration-banner .cb-confetti {
  position: absolute; right: 70px; top: 0; bottom: 0; width: 60px; pointer-events: none;
}
.celebration-banner .cb-confetti span {
  position: absolute; width: 6px; height: 6px; border-radius: 99px;
  opacity: 0; animation: cbDot .9s cubic-bezier(.4,1.2,.5,1) both;
}
.cb-confetti span:nth-child(odd)  { background: var(--accent); }
.cb-confetti span:nth-child(even) { background: var(--accent-strong); }
.cb-confetti span:nth-child(1) { right:  6px; top: 18%; animation-delay: .05s; }
.cb-confetti span:nth-child(2) { right: 24px; top:  6%; animation-delay: .12s; }
.cb-confetti span:nth-child(3) { right: 42px; top: 28%; animation-delay: .18s; }
.cb-confetti span:nth-child(4) { right: 58px; top:  4%; animation-delay: .26s; }
.cb-confetti span:nth-child(5) { right: 10px; top: 64%; animation-delay: .10s; }
.cb-confetti span:nth-child(6) { right: 28px; top: 78%; animation-delay: .16s; }
.cb-confetti span:nth-child(7) { right: 48px; top: 64%; animation-delay: .22s; }
.cb-confetti span:nth-child(8) { right: 64px; top: 82%; animation-delay: .30s; }
@keyframes cbRise {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cbDot {
  0%   { opacity: 0; transform: translate(0,0) scale(.4); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: translate(8px,-14px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .celebration-banner { animation: none; }
  .cb-confetti { display: none; }
}

/* ── Empty states ──────────────────────────────────────────── */
.empty-grid {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 40px 24px; text-align: center;
}
.empty-grid .empty-icon { color: var(--accent); opacity: 0.8; padding-bottom: 4px; }
.empty-grid .empty-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.015em;
}
.empty-grid .empty-sub { color: var(--ink-soft); font-weight: 500; margin: 0; max-width: 280px; line-height: 1.5; font-size: 13px; }
.empty-grid .btn { width: auto; padding: 12px 20px; min-height: 46px; }
.empty-state {
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 14px;
  color: var(--ink); padding: 22px 18px; text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}

/* ── History ───────────────────────────────────────────────── */
.hist-filters { display: flex; gap: 8px; }
.chip {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 8px; font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; color: var(--ink-soft);
  box-shadow: 0 1px 1px rgba(20,15,5,0.03);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.chip:hover { background: var(--surface-elev); color: var(--ink); }
.chip.on {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
  box-shadow: 0 1px 4px rgba(20,15,5,0.18);
}
.chip-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px;
  font-size: 10px; padding: 0 5px; border-radius: 99px;
  background: rgba(0,0,0,0.07);
}
.chip.on .chip-count { background: rgba(255,255,255,0.18); }
.hist-group { display: flex; flex-direction: column; gap: 8px; }
.hist-month {
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; padding: 0 4px;
}
.hist-item-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px; min-height: 72px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20,15,5,0.04);
  cursor: pointer;
  transition: background .12s ease, transform .12s ease, box-shadow .18s ease;
}
.hist-item-row:hover {
  background: var(--surface-elev); transform: translateY(-1px);
  box-shadow: 0 6px 14px -6px rgba(20,15,5,0.10);
}
.hist-item-row .meta { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hist-item-row .meta .d { font-weight: 600; font-size: 15px; }
.hist-item-row .meta .s { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.pct-bar {
  background: var(--line); border: 0; border-radius: 99px;
  height: 5px; flex: 1; max-width: 80px; position: relative; overflow: hidden;
}
.pct-fill { background: var(--accent); border-radius: 99px; position: absolute; inset: 0 auto 0 0; }
.pct-text { white-space: nowrap; color: var(--ink-soft); font-family: "JetBrains Mono", monospace; }
.hist-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hist-right .chev { color: var(--ink-soft); display: inline-flex; }
.badge {
  background: var(--accent-soft); color: var(--accent-strong); border: 0;
  border-radius: 99px; font-family: "JetBrains Mono", monospace;
  font-size: 10px; padding: 5px 9px; letter-spacing: 0.04em;
}
.badge.err { background: var(--warn-soft); color: var(--warn); }
.restore-hint {
  font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.04em;
  opacity: 0.5; text-align: center; padding: 0 4px;
}

/* ── History detail ────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 8px 6px 4px; font-family: "JetBrains Mono", monospace;
  color: var(--ink-soft); font-size: 13px; align-self: flex-start;
  transition: color .12s ease;
}
.back-btn:hover { color: var(--ink); }
.detail-head { display: flex; flex-direction: column; gap: 4px; }
.crumb-line { font-family: "JetBrains Mono", monospace; color: var(--ink-soft); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.detail-date { font-family: "Manrope", sans-serif; font-weight: 700; letter-spacing: -0.02em; font-size: 26px; }
.detail-sub { color: var(--ink-soft); font-family: "Manrope", sans-serif; font-size: 13px; }
.sync-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px; border: 0;
  font-family: "Manrope", sans-serif; font-size: 13px;
}
.sync-banner .bi { display: inline-flex; flex-shrink: 0; }
.sync-banner.synced { background: var(--accent-soft); color: var(--accent-strong); }
.sync-banner.failed { background: var(--warn-soft); color: var(--warn); }
.sync-banner.syncing { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.row-group { display: flex; flex-direction: column; gap: 8px; }

/* ── Setup rows ────────────────────────────────────────────── */
.section-label {
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; padding: 0 4px;
}
.settings-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 1px rgba(20,15,5,0.03);
  padding: 14px; display: flex; justify-content: space-between; align-items: center;
  width: 100%; min-height: 64px; text-align: left; gap: 12px;
  transition: background .12s ease;
}
.settings-row.nav { cursor: pointer; }
.settings-row.nav:hover { background: var(--surface-elev); }
.settings-row .kv { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.settings-row .k {
  font-family: "JetBrains Mono", monospace; font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
}
.settings-row .v { font-family: "Manrope", sans-serif; font-weight: 500; font-size: 14px; display: flex; gap: 8px; }
.settings-row .v.link {
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--accent-strong);
}
.settings-row .chev { color: var(--ink-soft); display: inline-flex; flex-shrink: 0; }
.pill {
  border: 0; border-radius: 99px; font-family: "JetBrains Mono", monospace;
  font-size: 10px; padding: 5px 9px; flex-shrink: 0; white-space: nowrap;
}
.pill.ok { background: var(--accent-soft); color: var(--accent-strong); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.inline-input {
  width: 100%; padding: 4px 0; font-size: 14px; font-weight: 500;
  font-family: "Manrope", sans-serif;
  border: 0; outline: 0; background: transparent; color: var(--ink);
}
.inline-input:focus { box-shadow: inset 0 -2px 0 0 var(--accent); }
.inline-input.grow { flex: 1; }

/* ── Members editor ────────────────────────────────────────── */
.member-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; min-height: 60px; gap: 10px;
}
.member-row.archived { opacity: 0.55; }
.member-row .member-name {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member-row.archived .member-name { text-decoration: line-through; }
.member-actions { display: flex; gap: 6px; flex-shrink: 0; }
.member-action {
  border: 1px solid var(--line-strong); background: var(--surface-elev);
  border-radius: 99px; font-family: "JetBrains Mono", monospace;
  font-size: 11px; padding: 6px 10px; min-height: 32px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; transition: background .12s ease;
}
.member-action:hover { background: var(--bg-2); }
.member-action.primary-action { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.member-action.primary-action:hover { background: color-mix(in oklab, var(--ink) 90%, var(--bg)); }
.member-action:disabled { opacity: 0.4; cursor: not-allowed; }
.member-row.adding { padding: 8px 14px; }
.add-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.add-actions .add-btn { flex: 1 1 0; min-width: 0; }
.add-actions .import-btn { flex: 0 0 auto; padding: 14px 16px; }

.switch {
  width: 44px; height: 24px; position: relative; flex-shrink: 0; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px;
  transition: background .15s ease, border-color .15s ease;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 99px;
  background: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  transition: left .15s ease, background .15s ease;
}
.switch.on .switch-thumb { left: 22px; background: var(--surface-elev); }

/* ── Passphrase ────────────────────────────────────────────── */
.pp-block { display: flex; flex-direction: column; gap: 10px; background-color: var(--bg-2); border-radius: 14px; }
.pp-string {
  font-family: "JetBrains Mono", monospace; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px;
  font-size: 18px; font-weight: 500; padding: 18px 16px;
  box-shadow: 0 1px 2px rgba(20,15,5,0.04); text-align: center; word-break: break-all;
}
.pp-actions { display: flex; align-items: center; justify-content: space-between; }
.pp-copy {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 99px; font-family: "JetBrains Mono", monospace;
  font-size: 12px; padding: 8px 12px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  transition: background .12s ease;
}
.pp-copy:hover { background: var(--bg-2); }
.pp-meta { color: var(--ink-soft); font-family: "JetBrains Mono", monospace; font-size: 11px; }
.pp-warn {
  background: var(--accent-soft); border: 0; border-radius: 12px;
  color: var(--ink); font-family: "Manrope", sans-serif;
  padding: 12px; display: flex; gap: 10px; align-items: flex-start;
}
.pp-warn .ico { color: var(--accent-strong); flex-shrink: 0; display: inline-flex; margin-top: 2px; }

/* ── Sign out ──────────────────────────────────────────────── */
.signout-warn {
  background: var(--warn-soft); border: 0; border-radius: 14px;
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  font-family: "Manrope", sans-serif;
}
.signout-warn .bi { flex-shrink: 0; margin-top: 2px; color: var(--warn); }
.signout-warn-title { font-weight: 600; margin-bottom: 4px; }
.signout-warn-body { font-size: 13px; line-height: 1.45; opacity: 0.8; }
.checkbox-line {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; gap: 12px; padding: 14px;
  min-height: 60px; font-size: 13px; line-height: 1.4;
  text-align: left; width: 100%; cursor: pointer;
  font-family: "Manrope", sans-serif;
}
.checkbox-line .box {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: var(--bg); border-radius: 7px;
  display: inline-grid; place-items: center;
  transition: background .12s ease, border-color .12s ease;
}
.checkbox-line .box.on { background: var(--accent); border-color: var(--accent); }
.checkbox-line .box.on::after {
  content: ""; width: 11px; height: 6px;
  border-left: 2.5px solid var(--surface); border-bottom: 2.5px solid var(--surface);
  transform: rotate(-50deg) translate(1px, -2px);
}

/* ── Restore flow ──────────────────────────────────────────── */
.restore-err {
  background: var(--warn-soft); border: 0; border-radius: 14px;
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  font-family: "Manrope", sans-serif;
}
.restore-err .bi { flex-shrink: 0; margin-top: 1px; color: var(--warn); }
.restore-tips {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px;
  font-family: "Manrope", sans-serif;
}
.restore-tips .tips-label {
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
}
.restore-tips ul {
  margin: 0; padding-left: 18px;
  font-size: 12px; line-height: 1.5; color: var(--ink);
  display: flex; flex-direction: column; gap: 4px; opacity: 0.85;
}

/* ── Onboarding ────────────────────────────────────────────── */
.onb {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px 28px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.onb .progress { display: flex; gap: 6px; }
.onb .progress span {
  flex: 1; height: 3px; border-radius: 99px;
  background: var(--ink); opacity: 0.10;
}
.onb .progress span.on { opacity: 1; background: var(--accent); }
.onb h2 {
  font-size: 36px; font-weight: 600; line-height: 1.08;
  letter-spacing: -0.025em; color: var(--ink);
}
.onb p.lead {
  font-family: "Manrope", sans-serif; font-size: 16px; line-height: 1.55;
  color: var(--ink-soft); font-weight: 500; text-wrap: pretty; margin: 0;
}
.onb .field { display: flex; flex-direction: column; gap: 8px; }
.onb label.lbl {
  display: block; font-family: "JetBrains Mono", monospace;
  color: var(--ink-soft); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
}
.onb input.tf, .onb textarea.tf {
  width: 100%; padding: 14px 12px; font-size: 16px;
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 12px; font-family: "Manrope", sans-serif; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.onb input.tf:focus, .onb textarea.tf:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: 0;
}
.onb .tf-err { border-color: var(--warn) !important; }
.onb .field-err {
  font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--warn); margin-top: 4px;
}
.onb .footer-actions {
  margin-top: auto; padding-top: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.onb .alt-link {
  font-size: 13px; text-align: center; color: var(--ink-soft);
  font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  background: none; border: 0; padding: 4px;
}
.onb .alt-link:hover { color: var(--ink); }
.what-card {
  border: 1px solid var(--line); background: var(--surface); border-radius: 14px;
  padding: 16px; font-family: "Manrope", sans-serif;
  box-shadow: 0 1px 2px rgba(20,15,5,0.03);
}
.what-card .mono {
  font-family: "JetBrains Mono", monospace; font-size: 10px;
  letter-spacing: 0.14em; color: var(--ink-soft); text-transform: uppercase;
  margin-bottom: 10px;
}
.what-list { display: grid; gap: 8px; }
.what-step { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink); }
.what-step .n {
  font-family: "Newsreader", serif; font-style: italic; font-weight: 400;
  font-size: 22px; line-height: 1; color: var(--accent); width: 22px; flex-shrink: 0;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: absolute; left: 14px; right: 14px; bottom: 92px;
  padding: 12px 18px; display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--bg); border: 0; border-radius: 99px;
  font-family: "Manrope", sans-serif; font-weight: 500; font-size: 13px;
  box-shadow: 0 12px 24px -8px rgba(20,15,5,0.28);
  transform: translateY(8px); opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
  z-index: 80;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { background: var(--accent-strong); }

/* ── Bottom-sheet export ───────────────────────────────────── */
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(20,15,5,0.36); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.export-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 51;
  border-radius: 22px 22px 0 0; padding: 8px 16px 28px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface-elev); border-top: 1px solid var(--line);
  box-shadow: 0 -18px 32px -16px rgba(20,15,5,0.30);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,.7,.2,1);
  max-height: 85%; overflow-y: auto;
}
.export-sheet.open { transform: translateY(0); }
.sheet-grab {
  width: 38px; height: 4px; background: var(--line-strong);
  border-radius: 99px; margin: 4px auto 6px; flex-shrink: 0;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.sheet-title { font: 700 18px "Manrope", sans-serif; letter-spacing: -0.015em; }
.sheet-close {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 99px; color: var(--ink-soft); cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.sheet-close:hover { background: var(--bg-2); color: var(--ink); }
.sheet-meta { display: flex; gap: 8px; flex-wrap: wrap; font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-soft); padding: 0 2px 2px; }
.export-options { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.export-opt {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border-radius: 14px; background: var(--bg); border: 1px solid var(--line);
  text-align: left; width: 100%; cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.export-opt:hover { background: var(--surface); }
.export-opt:active { transform: scale(0.99); }
.export-opt.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.export-opt.primary:hover { background: color-mix(in oklab, var(--ink) 92%, var(--bg)); }
.export-opt.primary .opt-sub { color: var(--bg); opacity: 0.7; }
.opt-icon {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 99px; background: var(--surface); color: var(--ink); flex-shrink: 0;
}
.export-opt.primary .opt-icon { background: rgba(255,255,255,0.12); color: var(--bg); }
.opt-icon.whatsapp-icon { background: #DCF3D0; color: #1E8A4A; }
@media (prefers-color-scheme: dark) {
  .opt-icon.whatsapp-icon { background: #1f3a25; color: #94d6a9; }
}
.opt-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.opt-title { font: 600 14px "Manrope", sans-serif; letter-spacing: -0.005em; }
.opt-sub { font-size: 12px; color: var(--ink-soft); }
.sheet-preview { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.preview-label { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.1em; color: var(--ink-soft); text-transform: uppercase; padding: 0 2px; }
.preview-body {
  margin: 0; padding: 12px 14px;
  background: var(--bg); border: 1px dashed var(--line-strong); border-radius: 12px;
  font: 12px/1.55 "JetBrains Mono", monospace; color: var(--ink);
  white-space: pre-wrap; max-height: 180px; overflow-y: auto;
}

/* ── Focus mode ────────────────────────────────────────────── */
.focus-grid {
  position: absolute; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
  transform: scale(1.04); opacity: 0; pointer-events: none;
  transition: transform .26s cubic-bezier(.2,.7,.2,1), opacity .26s ease;
}
.focus-grid.open { transform: scale(1); opacity: 1; pointer-events: auto; }
.focus-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.focus-meta { display: flex; flex-direction: column; gap: 2px; }
.focus-crumb { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.1em; color: var(--ink-soft); text-transform: uppercase; }
.focus-date { font: 700 17px "Manrope", sans-serif; letter-spacing: -0.015em; }
.focus-done {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px;
  border-radius: 99px; background: var(--ink); color: var(--bg);
  font: 600 13px "Manrope", sans-serif; border: 0; cursor: pointer;
}
.focus-done:hover { transform: translateY(-1px); }
.focus-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 14px 28px; }
.focus-body .grid-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 0; overflow-x: auto; box-shadow: 0 1px 2px rgba(20,15,5,0.04);
}

/* ── Print preview ─────────────────────────────────────────── */
.print-preview {
  position: absolute; inset: 0; z-index: 65;
  background: rgba(20,15,5,0.55);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.print-preview.open { opacity: 1; pointer-events: auto; }
.pp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface-elev);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.pp-head-meta { display: flex; flex-direction: column; gap: 2px; }
.pp-crumb { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.12em; color: var(--ink-soft); text-transform: uppercase; }
.pp-date { font: 600 14px "Manrope", sans-serif; letter-spacing: -0.01em; }
.pp-head-actions { display: flex; align-items: center; gap: 6px; }
.pp-cancel {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 99px; color: var(--ink-soft); cursor: pointer;
}
.pp-cancel:hover { background: var(--bg-2); color: var(--ink); }
.pp-body {
  flex: 1; min-height: 0; overflow: auto; padding: 14px;
  display: flex; justify-content: center;
}
.pp-page {
  width: 100%; max-width: 360px; background: #FFFFFF; color: #1A1A1A;
  border-radius: 6px; padding: 22px 22px 18px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 18px 30px -14px rgba(20,15,5,0.30);
  font-family: "Manrope", sans-serif; font-size: 11px; line-height: 1.4;
  display: flex; flex-direction: column; gap: 14px;
}
.pp-page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1.5px solid #1A1A1A; padding-bottom: 10px;
}
.pp-dept-line { display: flex; flex-direction: column; gap: 2px; }
.pp-dept { margin: 0; font: 700 18px "Manrope", sans-serif; letter-spacing: -0.02em; color: #1A1A1A; }
.pp-mark { font-family: "JetBrains Mono", monospace; font-size: 9px; letter-spacing: 0.18em; color: #555; text-transform: uppercase; }
.pp-page-date { font-size: 11px; font-weight: 600; text-align: right; color: #1A1A1A; }
.pp-summary {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #E0E0E0;
}
.pp-summary-item { display: flex; flex-direction: column; gap: 2px; }
.pp-num { font: 400 22px "Newsreader", serif; font-feature-settings: "lnum"; letter-spacing: -0.01em; line-height: 1; color: #1A1A1A; }
.pp-of { font-size: 12px; color: #777; }
.pp-lbl { font-family: "JetBrains Mono", monospace; font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; color: #555; }
.pp-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.pp-table th, .pp-table td {
  text-align: center; padding: 4px 2px;
  border-bottom: 1px solid #E8E8E8; vertical-align: middle;
}
.pp-table th {
  font-family: "JetBrains Mono", monospace; font-size: 8px; letter-spacing: 0.06em;
  text-transform: uppercase; color: #555; padding-bottom: 6px;
  border-bottom: 1px solid #1A1A1A;
}
.pp-table th:first-child, .pp-table td:first-child { text-align: left; padding-left: 2px; }
.pp-name { font-weight: 600; white-space: nowrap; font-size: 10.5px; max-width: 95px; overflow: hidden; text-overflow: ellipsis; }
.pp-table tr.absent .pp-name { color: #777; font-weight: 500; }
.pp-tick { color: #1A1A1A; font-weight: 700; }
.pp-dash { color: #BBB; }
.pp-total { font-family: "JetBrains Mono", monospace; font-size: 9px; color: #555; white-space: nowrap; }
.pp-table tfoot td { border-top: 1px solid #1A1A1A; border-bottom: 0; padding-top: 6px; font-size: 9px; letter-spacing: 0.04em; }
.pp-foot-label { text-align: left !important; font-weight: 700; }
.pp-foot-cell { color: #1A1A1A; }
.pp-page-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: auto; padding-top: 14px; font-size: 9px; color: #777; letter-spacing: 0.04em; }
.pp-signature { display: flex; flex-direction: column; gap: 2px; align-items: center; min-width: 100px; }
.pp-sig-name { display: block; font-size: 13px; text-align: center; margin-bottom: 2px; }
.pp-sig-line { display: block; width: 110px; border-bottom: 1px solid #1A1A1A; margin-bottom: 2px; height: 16px; }
.pp-sig-label { font-family: "JetBrains Mono", monospace; font-size: 8px; letter-spacing: 0.12em; color: #555; text-transform: uppercase; }
.pp-th-init { font-family: "JetBrains Mono", monospace; font-size: 8px; letter-spacing: 0.06em; text-align: center; width: 28px; min-width: 28px; max-width: 28px; }
.pp-legend { display: flex; flex-wrap: wrap; gap: 3px 14px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #DDD; font-size: 9px; color: #555; letter-spacing: 0.03em; }
.pp-legend-item b { font-family: "JetBrains Mono", monospace; font-size: 8px; color: #1A1A1A; letter-spacing: 0.06em; margin-right: 2px; }
.pp-actions {
  display: flex; gap: 8px; padding: 12px 16px 20px;
  border-top: 1px solid var(--line); flex-shrink: 0;
}
.pp-actions .btn { flex: 1; min-height: 46px; padding: 12px 16px; }

/* ── Date picker ───────────────────────────────────────────── */
.date-backdrop {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.18);
  animation: dpFade .15s ease both;
}
.date-popup {
  position: absolute; top: 100px; right: 14px; left: 14px; z-index: 41;
  padding: 14px;
  background: var(--surface-elev); border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 50px -20px rgba(20,15,5,0.30), 0 6px 12px -6px rgba(20,15,5,0.10);
  animation: dpUp .2s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes dpFade { from { opacity: 0; } }
@keyframes dpUp { from { opacity: 0; transform: translateY(-6px); } }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-head button { padding: 6px 8px; }
.dp-month { font-family: "Manrope", sans-serif; font-weight: 700; letter-spacing: -0.01em; font-size: 14px; }
.dp-dow {
  display: grid; grid-template-columns: repeat(7,1fr);
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.06em;
  text-align: center; margin-bottom: 4px;
}
.dp-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.dp-cell {
  height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; border-radius: 8px; font-family: "Manrope", sans-serif; font-weight: 500;
  transition: background .12s ease;
}
.dp-cell.empty { visibility: hidden; }
.dp-cell.off { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.dp-cell:not(.empty):not(.off) { cursor: pointer; }
.dp-cell:not(.empty):not(.off):hover { background: var(--accent-soft); }
.dp-cell.today { background: var(--accent-soft); color: var(--accent-strong); }
.dp-cell.sel { background: var(--ink); color: var(--bg); }
.dp-cell.has-report::after,
.dp-cell.has-queued::after {
  content: ''; display: block;
  width: 4px; height: 4px; border-radius: 50%;
  margin: 2px auto 0;
}
.dp-cell.has-report::after { background: var(--accent); }
.dp-cell.has-queued::after { background: var(--warn); }
.dp-cell.sel.has-report::after { background: var(--bg); }
.dp-cell.sel.has-queued::after { background: var(--bg); }
.dp-foot { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dp-quick {
  flex: 1; padding: 8px 6px; font-size: 11px; text-align: center; letter-spacing: 0.04em;
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  font-family: "JetBrains Mono", monospace; cursor: pointer;
  transition: background .12s ease;
}
.dp-quick:hover { background: var(--bg-2); }

/* ── Confirm dialog ────────────────────────────────────────── */
.dialog-backdrop {
  position: absolute; inset: 0; background: rgba(20,15,5,0.36); z-index: 70;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.dialog-backdrop.open { opacity: 1; pointer-events: auto; }
.confirm-dialog {
  position: absolute; z-index: 71; left: 24px; right: 24px; top: 50%;
  transform: translateY(-50%) scale(0.96); opacity: 0; pointer-events: none;
  background: var(--surface-elev); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 30px 50px -20px rgba(20,15,5,0.32);
  transition: transform .2s cubic-bezier(.22,.7,.2,1), opacity .2s ease;
}
.confirm-dialog.open { transform: translateY(-50%) scale(1); opacity: 1; pointer-events: auto; }
.dlg-title { font: 700 18px "Manrope", sans-serif; letter-spacing: -0.015em; color: var(--ink); }
.dlg-body { margin: 0; font: 500 14px "Manrope", sans-serif; line-height: 1.5; color: var(--ink-soft); text-wrap: pretty; }
.dlg-actions { display: flex; gap: 8px; margin-top: 4px; }
.dlg-actions .btn { flex: 1; min-height: 46px; padding: 12px 16px; }

/* ── Bulk import ───────────────────────────────────────────── */
.bulk-paste { display: flex; flex-direction: column; gap: 8px; }
.bulk-textarea {
  width: 100%; min-height: 140px; padding: 12px 14px;
  font: 14px/1.5 "JetBrains Mono", monospace;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  resize: vertical; color: var(--ink); outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bulk-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.bulk-sheets { align-self: flex-start; padding: 10px 14px; min-height: 40px; width: auto; }
.bulk-preview {
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.bulk-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.bulk-count {
  font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.04em;
  padding: 4px 9px; border-radius: 99px; text-transform: uppercase;
}
.bulk-count.fresh { background: var(--accent-soft); color: var(--accent-strong); }
.bulk-count.exists { background: var(--surface-elev); color: var(--ink-soft); border: 1px solid var(--line); }
.bulk-count.dupes { background: var(--warn-soft); color: var(--warn); }
.bulk-group { display: flex; flex-direction: column; gap: 6px; }
.bulk-group-label { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.bulk-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.bulk-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; font-size: 13px; background: var(--bg); border: 1px solid var(--line);
}
.bulk-tick {
  width: 18px; height: 18px; display: inline-grid; place-items: center;
  border-radius: 99px; background: var(--accent); color: var(--surface-elev);
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.bulk-mark { width: 18px; color: var(--ink-soft); text-align: center; flex-shrink: 0; }
.bulk-actions { margin-top: 4px; }
.bulk-actions .btn-row { gap: 8px; }

/* ── Print media ───────────────────────────────────────────── */
@media print {
  body * { visibility: hidden !important; }
  .pp-page, .pp-page * { visibility: visible !important; }
  .pp-page {
    position: fixed !important; inset: 0 !important;
    max-width: none !important; width: auto !important;
    margin: 0 !important; box-shadow: none !important;
    border-radius: 0 !important; padding: 24mm 18mm 18mm !important;
    font-size: 12px !important; background: white !important; color: #000 !important;
  }
  .pp-num { font-size: 28px !important; }
  .pp-table { font-size: 12px !important; }
  .pp-name { font-size: 13px !important; max-width: none !important; }
  .pp-table th { font-size: 9px !important; }
  @page { size: A4; margin: 0; }
}

/* ── App-specific additions ────────────────────────────────── */

/* Screen fills #app */
.screen {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Tab bar label text */
.tab-bar button span:not(.icon) {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.08em;
}

/* Date switch in entry header */
.date-switch {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px 5px;
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  box-shadow: 0 1px 1px rgba(20,15,5,0.04);
  margin-top: 6px;
}
.date-switch button { padding: 2px 4px; display: inline-flex; align-items: center; }
.date-switch .date-btn {
  padding: 0 6px; display: inline-flex; align-items: center; gap: 6px;
}
.date-switch .date-btn svg { opacity: 0.7; }

/* App header h2 sizing */
.app-header h2 { font-size: 22px; font-weight: 700; line-height: 1.1; }

/* Body area (scrollable pane) */
.body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 24px 16px 16px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
/* Pane headings inside body get some breathing room */
/* .body .app-header { padding: 14px 4px 10px; } */

/* Setup section gaps */
.body .section-label { margin-top: 4px; }

/* Grid table overrides (we use <table> inside .grid-card) */
.grid-card table.grid {
  display: table; width: 100%; border-collapse: collapse;
  min-width: 0;
}
.grid-card table.grid thead th,
.grid-card table.grid tbody td,
.grid-card table.grid tbody th {
  border: 0; padding: 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid-card table.grid thead th { height: 40px; }
.grid-card table.grid tbody td,
.grid-card table.grid tbody th { height: 46px; }
.grid-card table.grid .act-head {
  text-align: center; font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.04em; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap; padding: 0 6px;
  min-width: 70px;
}
.grid-card table.grid .member-head {
  text-align: left; padding-left: 14px;
  font-family: "Manrope", sans-serif; font-weight: 500; font-size: 13px;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.grid-card table.grid td { text-align: center; border-left: 1px solid var(--line); }

/* Flat CSS grid (non-table variant used by flat renderGrid) */
.grid:not(table) {
  display: grid; align-items: stretch;
}
.grid:not(table) .hd {
  height: 40px; display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace; color: var(--ink-soft);
  font-size: 10px; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; padding: 0 8px;
}
.grid:not(table) .hd:not(.hd-name) { border-left: 1px solid var(--line); }
.grid:not(table) .hd-name { justify-content: flex-start; padding-left: 14px; position: sticky; left: 0; z-index: 3;}
.grid:not(table) .name {
  height: 46px; display: flex; align-items: center;
  font-family: "Manrope", sans-serif; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--line); padding-inline: 14px;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; z-index: 1; background-color: var(--surface); box-shadow: hsl(0deg 0% 0% / 9%) 2px 2px 2px;
}
.grid:not(table) .cell {
  height: 46px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
}

/* Stats shorthand aliases */
.stats .stat { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.stats .num { font-family: "Newsreader", serif; font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: -0.02em; }
.stats .lbl { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.08em; color: var(--ink-soft); }

/* Member editor inputs */
.member-name.inline-input { font-size: 14px; flex: 1; }

/* Setup row danger */
.settings-row.danger, .settings-row[style*="warn"] { color: var(--warn); }

/* Onboarding full-height */
.onb {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 28px 24px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.onb .progress { display: flex; gap: 6px; }
.onb .progress span { flex: 1; height: 3px; border-radius: 99px; background: var(--ink); opacity: 0.12; }
.onb .progress span.on { opacity: 1; background: var(--accent); }
.onb h2 { font-size: 32px; font-weight: 600; line-height: 1.08; letter-spacing: -0.025em; }
.onb p.lead { font-size: 15px; line-height: 1.55; color: var(--ink-soft); font-weight: 500; margin: 0; }
.onb .field { display: flex; flex-direction: column; gap: 8px; }
.onb label.lbl { font-family: "JetBrains Mono", monospace; color: var(--ink-soft); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.onb .tf {
  width: 100%; padding: 14px 12px; font-size: 15px;
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 12px; font-family: "Manrope", sans-serif; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.onb .tf:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: 0; }
.onb .footer-actions { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.onb .alt-link {
  font-size: 13px; text-align: center; color: var(--ink-soft); font-weight: 500;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  background: none; border: 0; padding: 4px;
}
.onb .back-btn { align-self: flex-start; }

/* focus-body grid-wrap spacing */
.focus-body .grid-wrap { margin: 0; }

/* Export sheet backdrop layering */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20,15,5,0.36); z-index: 50; }
.export-sheet { z-index: 51; }

/* Print preview layering */
.print-preview { z-index: 65; }

/* Date picker click-through */
.date-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.18); z-index: 40; }

/* Confirm overlay */
.dialog-backdrop { position: absolute; inset: 0; background: rgba(20,15,5,0.36); z-index: 70; }

/* Install banner */
.install-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-elev); border: 1px solid var(--line-strong);
  border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(20,15,5,0.06);
}
.install-icon { flex-shrink: 0; color: var(--accent); }
.install-meta { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.install-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.install-sub   { font-size: 11px; font-family: "JetBrains Mono", monospace; color: var(--ink-soft); }
.install-btn {
  flex-shrink: 0; font-size: 12px; font-weight: 600; font-family: "Manrope", sans-serif;
  padding: 6px 14px; border-radius: 99px;
  background: var(--ink); color: var(--bg); border: none; cursor: pointer;
}
.install-dismiss {
  flex-shrink: 0; color: var(--ink-soft); padding: 4px;
  display: flex; align-items: center; cursor: pointer;
}
.install-dismiss:hover { color: var(--ink); }
/* iOS install guide */
.ios-install-dialog { text-align: center; padding: 28px 24px 24px; }
.ios-install-icon { color: var(--accent); margin-bottom: 12px; }
.ios-steps { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 4px; }
.ios-step  { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.4; }
.ios-step-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-family: "JetBrains Mono", monospace; font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
}

/* Correction sync lock panel */
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.sync-lock-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--surface); border-radius: 16px;
  padding: 32px 40px; box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.sync-lock-msg {
  font-family: "JetBrains Mono", monospace; font-size: 13px;
  color: var(--ink-soft); margin: 0;
}

/* Celebration share row */
.celebration-banner .cb-share { cursor: pointer; }

/* Pct badge in focus overlay */
.pct-badge {
  font-family: "JetBrains Mono", monospace; font-size: 12px; font-weight: 500;
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 4px 10px; border-radius: 99px;
}

/* Entry sync button */
.btn.loading { opacity: 0.7; pointer-events: none; }
.btn.loading svg { animation: spin 0.9s linear infinite; }

/* Banner row for inline action */
.banner-action { cursor: pointer; }

/* History section heading inside body */
.hist-group + .hist-group { margin-top: 6px; }

