/* Church Maintenance — app styles
   Palette follows the original WOGAT Ministries page: navy, gold, warm paper. */

:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f8f6f2;
  --ink: #1d2433;
  --muted: #5b6475;
  --faint: #8a91a0;
  --line: #e7e1d7;
  --line-strong: #d6cec0;
  --accent: #1f3a5f;
  --accent-hover: #2a4b78;
  --accent-soft: #e7eef7;
  --on-accent: #ffffff;
  --gold: #b8862b;
  --gold-btn: #8f6516;
  --gold-btn-hover: #7a5612;
  --on-gold: #ffffff;
  --gold-soft: #fbf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #a8480a;
  --warn-soft: #fef1e1;
  --ok: #1e7b4b;
  --ok-soft: #e4f4eb;
  --info: #2459a8;
  --info-soft: #e8effa;
  --shadow: 0 1px 2px rgba(29, 36, 51, 0.05), 0 4px 14px rgba(29, 36, 51, 0.05);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161f;
    --surface: #19202c;
    --surface-2: #1f2735;
    --ink: #eef1f6;
    --muted: #a3acbd;
    --faint: #7d8699;
    --line: #2a3342;
    --line-strong: #384356;
    --accent: #8fb3e6;
    --accent-hover: #a9c5ee;
    --accent-soft: #1f2d42;
    --on-accent: #0f1826;
    --gold: #e2b65c;
    --gold-btn: #e2b65c;
    --gold-btn-hover: #ecc77a;
    --on-gold: #1b1404;
    --gold-soft: #2f2716;
    --danger: #f97066;
    --danger-soft: #3a1d1d;
    --warn: #f5a65b;
    --warn-soft: #3a2a17;
    --ok: #4fc488;
    --ok-soft: #16322a;
    --info: #84adf0;
    --info-soft: #1b2a42;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.2);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.55rem, 3.2vw, 2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.icon { flex-shrink: 0; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 18px; text-decoration: none; color: inherit; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: #1f3a5f; display: grid; place-items: center; flex-shrink: 0; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 1.08rem; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }
.nav a {
  display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: 12px; line-height: 20px; text-align: center; background: var(--danger-soft); color: var(--danger); }
.nav .count.gold { background: var(--gold-soft); color: var(--gold-btn); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 10px; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; font-size: 12.5px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 28px; min-height: 60px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tb-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-brand { display: none; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 28px 56px; max-width: 1200px; width: 100%; margin: 0 auto; }
.tabbar { display: none; }
.app.locked .sidebar, .app.locked .tabbar, .app.locked .topbar { display: none; }
.app.locked { grid-template-columns: 1fr; }

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 8px 16px; min-height: 56px; padding-top: max(8px, env(safe-area-inset-top)); }
  .tb-brand { display: grid; width: 32px; height: 32px; border-radius: 9px; }
  .content { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0 7px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-decoration: none;
  }
  .tabbar a.active { color: var(--accent); }
  .tabbar .dot { position: absolute; top: 6px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
  .hide-sm { display: none !important; }
}
@media (min-width: 900px) { .show-sm { display: none !important; } }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 60ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin: 24px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.gold { background: var(--gold-btn); border-color: var(--gold-btn); color: var(--on-gold); }
.btn.gold:hover { background: var(--gold-btn-hover); border-color: var(--gold-btn-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; gap: 5px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.link { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.done-btn {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--faint); cursor: pointer;
}
.done-btn:hover { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--muted); }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 14px; }
.cards > .card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .card + .card { margin-top: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: inherit; box-shadow: var(--shadow);
  text-align: left; cursor: pointer; font: inherit;
}
.stat:hover { border-color: var(--line-strong); }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 1.65rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -0.02em; line-height: 1.2; }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.danger .v { color: var(--danger); }
.stat.warn .v { color: var(--warn); }
.stat.ok .v { color: var(--ok); }
.stat.gold .v { color: var(--gold-btn); }

/* ---------- Rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); min-width: 0; }
.rows > .row:first-child { border-top: 0; }
.click { cursor: pointer; }
.row.click:hover, .row .click:hover .row-title { color: var(--accent); }
.row.click:hover { background: var(--surface-2); color: inherit; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.row-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; }
.row-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.row-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.row-date { width: 56px; flex-shrink: 0; text-align: center; line-height: 1.1; }
.row-date .d { font-size: 1.25rem; font-weight: 700; }
.row-date .m { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.more-row { padding: 10px 18px; border-top: 1px solid var(--line); font-size: 13.5px; }
@media (max-width: 640px) {
  .row.wrap-sm { flex-wrap: wrap; }
  .row.wrap-sm > .row-side { width: 100%; justify-content: flex-start; padding-left: 0; }
  .row.wrap-sm.has-lead > .row-side { padding-left: 68px; }
  .row { padding: 12px 14px; }
}

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; line-height: 1.5; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip.gold { background: var(--gold-soft); color: var(--gold-btn); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.dashed { border-style: dashed; border-color: var(--line-strong); background: transparent; }
.chip .x { border: 0; background: none; padding: 0 0 0 2px; margin: 0; cursor: pointer; color: inherit; display: inline-grid; place-items: center; opacity: 0.7; }
.chip .x:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 220px; }
.search { position: relative; min-width: 0; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 36px !important; }
.seg {
  display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600;
  font-size: 13.5px; color: var(--muted); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.seg .n { font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--line); color: var(--muted); }
.seg .n.danger { background: var(--danger-soft); color: var(--danger); }
.toolbar select, .toolbar input[type="search"], .toolbar input[type="text"], .input {
  min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); max-width: 100%;
}
.toolbar input[type="search"] { width: 100%; }
.toggle-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 13.5px; font-weight: 600; }
.toggle-chip input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; }
.field .label { font-size: 13px; font-weight: 650; color: var(--ink); }
.field .help { font-size: 12.5px; color: var(--muted); }
.req { color: var(--danger); }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, .line input, .line select {
  width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
.field textarea { resize: vertical; min-height: 80px; }
.field input[type="file"] { font-size: 14px; padding: 8px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus, .line input:focus, .line select:focus, .toolbar select:focus, .toolbar input:focus, .input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
fieldset.field { border: 0; padding: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 6px; }
.check-grid.scroll { max-height: 230px; overflow-y: auto; padding: 2px; }
.check-grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.check {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; cursor: pointer; font-size: 14px; background: var(--surface); min-width: 0;
}
.check span { min-width: 0; overflow-wrap: anywhere; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.check.plain { border: 0; padding: 4px 0; background: none; }
.check.plain:has(input:checked) { background: none; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; padding-top: 14px; border-top: 1px solid var(--line); margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.form-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -18px;
  background: var(--surface); padding: 12px 0 0; margin-bottom: -2px; border-top: 1px solid var(--line);
}
.form-actions .left { margin-right: auto; }
.quick-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-picks button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.quick-picks button:hover, .quick-picks button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* Receipt line items */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: 1.4fr 1.4fr 76px 108px 40px; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.line .full { grid-column: 1 / 4; }
.line .full.all { grid-column: 1 / -1; }
.line .stock-add { grid-column: 4 / -1; }
.line label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 650; color: var(--muted); min-width: 0; }
.line .del { align-self: center; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
@media (max-width: 640px) {
  .line { grid-template-columns: 1fr 1fr; }
  .line .full, .line .full.all, .line .wide, .line .stock-add { grid-column: 1 / -1; }
  .line .del { grid-column: 2; justify-self: end; }
}

/* ---------- Dialog / modal ---------- */
dialog.modal {
  width: min(640px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal.wide { width: min(880px, calc(100vw - 24px)); }
dialog.modal.narrow { width: min(460px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(12, 17, 26, 0.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-head h2 { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
/* flex-basis must be auto: Safari collapses a 0% basis to nothing in an auto-height dialog. */
.modal-body { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
@media (max-width: 640px) {
  dialog.modal, dialog.modal.wide, dialog.modal.narrow {
    width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .modal-body { padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
  .form-actions { bottom: calc(-18px - env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
@media (max-width: 899px) { .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 11px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: toast-in 0.2s ease-out; max-width: 100%; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty states & notices ---------- */
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty h3 { color: var(--ink); margin-bottom: 4px; font-size: 1rem; }
.empty p { max-width: 46ch; margin: 0 auto; }
.empty .btn { margin-top: 14px; }
.empty.sm { padding: 18px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 14px; font-size: 14px; }
.notice > .icon { margin-top: 2px; }
.notice .grow { flex: 1; min-width: 0; }
.notice .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.notice.info { background: var(--info-soft); border-color: transparent; }
.notice.info > .icon { color: var(--info); }
.notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.warn > .icon { color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: transparent; }
.notice.danger > .icon { color: var(--danger); }
.notice.gold { background: var(--gold-soft); border-color: transparent; }
.notice.gold > .icon { color: var(--gold-btn); }

/* ---------- Inventory ---------- */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.stepper button:hover { background: var(--surface-2); }
.stepper .qty { width: auto; min-width: 42px; padding: 0 6px; display: grid; place-items: center; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-size: 15px; }
.qty { font-variant-numeric: tabular-nums; font-weight: 700; }
.unit { font-size: 12.5px; color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; width: 100%; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.bar.low > span { background: var(--danger); }
.bar.mid > span { background: var(--warn); }
.src-line { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.src-line b { color: var(--ink); font-weight: 650; }
.src-line.missing { color: var(--warn); }
.reorder { border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line)); background: var(--gold-soft); border-radius: 14px; padding: 16px; }
.reorder-head { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 750; color: var(--gold-btn); margin-bottom: 8px; }
.reorder .vendor { font-size: 1.15rem; font-weight: 700; }
.reorder .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reorder .url { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; margin-top: 4px; }
.big-qty { font-size: 2.4rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -0.02em; }
.inv-stock { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.shop-total { display: flex; justify-content: space-between; gap: 12px; padding: 14px 18px; font-weight: 700; border-top: 1px solid var(--line); }

/* ---------- Key/value, timeline, photos ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 7px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; padding-left: 20px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li.status::before { background: var(--accent); }
.timeline .when { font-size: 12.5px; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.photo {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: zoom-in; padding: 0;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.missing::after { content: "Unavailable"; }
.photo-tile { position: relative; min-width: 0; }
.photo-tile > .photo { width: 100%; }
.photo-x {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  border: 0; background: rgba(15, 20, 30, 0.72); color: #fff; cursor: pointer;
}
.photo-x:hover { background: var(--danger); }
/* File buttons: the real <input type=file> covers the button invisibly, so taps reach it directly (needed on iPhone). */
.file-tap { position: relative; overflow: hidden; }
.file-tap input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-tap:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo.add { cursor: pointer; border: 1.5px dashed var(--line-strong); background: var(--surface); color: var(--accent); text-align: center; padding: 6px; }
.photo.add:hover, .photo.add:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.picker .photos { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.photo.missing img { display: none; }
.viewer { display: grid; place-items: center; }
.viewer img { max-height: 72dvh; border-radius: 10px; }
.viewer iframe { width: 100%; height: 72dvh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 750; font-size: 13px; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.block-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.block-title:first-child { margin-top: 0; }
.block-title .btn, .block-title .link, .block-title label { text-transform: none; letter-spacing: 0; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; min-width: 0; }
.mini-list li:first-child { border-top: 0; }
.checklist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

/* ---------- Schedule ---------- */
.day { margin-bottom: 18px; }
.day-head { display: flex; align-items: baseline; gap: 8px; font-weight: 700; margin: 0 2px 8px; font-size: 15px; }
.day-head .muted { font-weight: 500; font-size: 13.5px; }
.day-head.overdue { color: var(--danger); }
.slots { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.slots.open { color: var(--warn); }
.slots.full { color: var(--ok); }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.bars .col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bars .b { width: 100%; max-width: 30px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .col.now .b { background: var(--gold-btn); }
.bars .lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 170px) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 999px; }
.hbar .amt { font-variant-numeric: tabular-nums; font-weight: 650; }
.budget { margin-top: 8px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table input[type="number"] { width: 90px; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Top bar widgets ---------- */
.sync { display: inline-flex; gap: 7px; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; background: var(--surface); cursor: pointer; min-height: 32px; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.sync.synced .dot { background: var(--ok); }
.sync.saving .dot { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.sync.offline .dot { background: var(--warn); }
.sync.error .dot, .sync.locked .dot { background: var(--danger); }
.sync.local .dot { background: var(--info); }
@keyframes pulse { 50% { opacity: 0.3; } }
.me-btn { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 3px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; max-width: 190px; }
.me-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-btn .avatar { width: 28px; height: 28px; font-size: 11px; }
@media (max-width: 899px) { .me-btn { padding: 3px; } .sync { padding: 5px 9px; } }

/* ---------- Home ---------- */
.home { max-width: 820px; margin: 0 auto; }
.home .stats { grid-template-columns: repeat(4, 1fr); }
.home-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.home-actions .btn { min-height: 52px; font-size: 15px; white-space: normal; text-align: center; }
@media (max-width: 640px) {
  .home .stats { grid-template-columns: repeat(2, 1fr); }
  .home-actions { grid-template-columns: 1fr; }
  .home-actions .btn { justify-content: flex-start; padding-left: 16px; }
}

/* ---------- Mobile "More" grid ---------- */
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.more-grid a { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; font-weight: 650; box-shadow: var(--shadow); }
.more-grid a .icon { color: var(--accent); }
.more-grid a small { font-weight: 500; color: var(--muted); font-size: 12.5px; }

/* ---------- Join & lock screens ---------- */
.hero { text-align: center; padding: 28px 20px 8px; }
.hero .brand-mark { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 14px; }
.hero .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.hero p { color: var(--muted); max-width: 52ch; margin: 8px auto 0; }
.narrow-page { max-width: 680px; margin: 0 auto; }
.lock-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.lock-card { width: 100%; max-width: 440px; }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.hstack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.loading { padding: 80px 20px; text-align: center; color: var(--muted); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.copybox { display: flex; gap: 8px; align-items: center; }
.copybox input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .tabbar, .topbar, .no-print, .toolbar, .page-actions, .toasts, .notice, .done-btn, .row-side .btn, .stepper button { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  body { background: #fff; color: #000; font-size: 12px; }
  .row { padding: 6px 10px; }
  a { color: #000; text-decoration: none; }
  .print-url { display: inline !important; }
}
.print-url { display: none; font-size: 11px; color: #444; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
