
:root {
  --bg: #f6f1e8;
  --surface: #fffdf9;
  --surface-2: #f1ede5;
  --surface-3: #ebe5da;
  --field-bg: #ffffff;
  --surface-warm: #fffaf2;
  --surface-highlight: #fff9ef;
  --surface-soft: #f7f8f5;
  --surface-quiet: #faf8f3;
  --surface-disabled: #f4f3ef;
  --surface-row: #fbfcfb;
  --surface-archived: #f7f3ec;
  --hero-end: #fff8ef;
  --info-bg: #eee8f7;
  --info-text: #6d5688;
  --warning-border: #ecd7b7;
  --warm-border: #ead8ba;
  --accent-border: #efd3b4;
  --accent-soft-border: #efd7ba;
  --accent-text: #795b3c;
  --danger-border: #e8c4bf;
  --danger-hover: #f6dfdb;
  --test-bg: #fff6d8;
  --test-border: #eadca7;
  --test-text: #69591e;
  --plan-track: #e9efec;
  --plan-stat-bg: #f6f9f7;
  --plan-stat-border: #e5ece8;
  --plan-featured-bg: #eef7f3;
  --plan-featured-border: #cfe2d9;
  --switch-track: #cfd8d4;
  --text: #26332e;
  --muted: #707873;
  --line: #e2dbcf;
  --brand: #315f52;
  --brand-strong: #254b40;
  --brand-soft: #e8f1ed;
  --accent: #dc8d45;
  --accent-soft: #fff0df;
  --success: #2d7658;
  --success-bg: #e9f5ef;
  --warning: #9a642a;
  --warning-bg: #fff3df;
  --danger: #a4483f;
  --danger-bg: #faece9;
  --shadow: 0 12px 36px rgba(42,52,47,.07);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 92% -10%, rgba(220,141,69,.12), transparent 31rem), var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-header {
  position: sticky; top: 0; z-index: 30;
  min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 10px max(18px, calc((100vw - 1120px)/2));
  background: rgba(246,241,232,.92); backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(226,219,207,.82);
}
.brand-button { display: flex; gap: 11px; align-items: center; border: 0; padding: 0; background: transparent; color: var(--text); text-align: left; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand); color: white; font-size: 21px; box-shadow: var(--shadow); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 19px; line-height: 1.1; }
.brand-copy small { color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.save-state { color: var(--muted); font-size: 12px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 800; letter-spacing: 2px; }
.app-menu { position: absolute; right: max(18px, calc((100vw - 1120px)/2)); top: 61px; width: min(310px, calc(100vw - 32px)); padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 20px 50px rgba(30,42,36,.16); }
.app-menu button { width: 100%; border: 0; background: transparent; text-align: left; padding: 11px 12px; border-radius: 10px; color: var(--text); }
.app-menu button:hover { background: var(--surface-2); }

.shell { width: min(1120px, calc(100% - 36px)); margin: 28px auto 56px; }
.screen { animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.card { background: var(--surface); border: 1px solid rgba(226,219,207,.92); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 28px; min-height: 190px; padding: 32px 36px; background: linear-gradient(135deg, var(--surface), var(--hero-end)); }
.hero h1, .dashboard-top h1, .wizard-header h1 { margin: 4px 0 9px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; }
.hero p, .dashboard-top p, .wizard-header p { margin: 0; color: var(--muted); line-height: 1.55; max-width: 660px; }
.hero-pet { width: 116px; height: 116px; flex: 0 0 auto; border-radius: 36px; display: grid; place-items: center; background: var(--brand-soft); font-size: 58px; transform: rotate(4deg); }
.eyebrow { display: inline-block; color: var(--brand); text-transform: uppercase; letter-spacing: .11em; font-weight: 850; font-size: 10px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; margin-bottom: 20px; }
.section-heading.compact { margin-bottom: 16px; }
.section-heading h2 { margin: 3px 0 5px; font-size: 23px; letter-spacing: -.025em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 690px; }
.row-heading { margin-top: 28px; align-items: center; }
.row-heading.compact { margin-top: 0; }

.button { border: 0; border-radius: 12px; min-height: 44px; padding: 0 17px; font-weight: 800; color: var(--text); }
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-strong); }
.button.secondary { background: var(--surface); border: 1px solid var(--line); }
.button.secondary:hover { background: var(--surface-2); }
.button.danger-soft { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.button.danger-soft:hover { background: var(--danger-hover); }
.button.small { min-height: 38px; padding: 0 13px; font-size: 13px; }
.text-button { border: 0; padding: 6px 0; background: transparent; color: var(--brand); font-weight: 800; }
.back-button { display: block; margin-bottom: 12px; color: var(--muted); }

.empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; gap: 5px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 17px; }
.empty-state p { margin: 0 0 13px; max-width: 480px; font-size: 13px; line-height: 1.5; }
.empty-icon { font-size: 38px; }
.small-empty { min-height: 150px; box-shadow: none; border: 0; padding: 12px; }

.profiles-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.profile-card { position: relative; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 20px; box-shadow: var(--shadow); transition: transform .14s ease, border-color .14s ease; }
.profile-card:hover { transform: translateY(-2px); border-color: #cfc5b8; }
.profile-avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--brand-soft); color: var(--brand); font-size: 22px; font-weight: 900; margin-bottom: 15px; }
.profile-card h3 { margin: 0 0 6px; font-size: 19px; }
.profile-card p { margin: 0; color: var(--muted); font-size: 12px; }
.profile-mini-stats { display: flex; gap: 16px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.profile-mini-stats div { display: grid; gap: 2px; }
.profile-mini-stats span { color: var(--muted); font-size: 10px; }
.profile-mini-stats strong { font-size: 13px; }

.dashboard-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.dashboard-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.month-card { margin-bottom: 18px; }
.month-picker, .text-input { height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); padding: 0 12px; color: var(--text); outline: 0; }
.month-picker:focus, .text-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,95,82,.11); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat-card { min-height: 114px; padding: 17px; border-radius: 16px; background: var(--surface-2); display: grid; align-content: center; gap: 6px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: clamp(20px, 2.8vw, 29px); letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.stat-card small { color: var(--muted); font-size: 10px; }
.stat-card.accent { background: var(--brand); color: white; }
.stat-card.accent span, .stat-card.accent small { color: rgba(255,255,255,.74); }
.active-shift-notice { margin-bottom: 18px; padding: 15px 17px; border-radius: 16px; background: var(--accent-soft); border: 1px solid var(--accent-border); display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.active-shift-notice strong { display: block; }
.active-shift-notice p { margin: 3px 0 0; color: var(--accent-text); font-size: 12px; }
.active-shift-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.history-list { display: grid; gap: 9px; }
.history-item { display: grid; grid-template-columns: minmax(170px,1.05fr) minmax(120px,.72fr) minmax(120px,.65fr) minmax(150px,.8fr) auto; gap: 14px; align-items: center; padding: 14px 15px; border: 1px solid var(--line); border-radius: 14px; }
.history-main strong { display: block; }
.history-main span, .history-stat span { color: var(--muted); font-size: 11px; }
.history-stat { text-align: right; }
.history-stat strong { display: block; margin-top: 3px; font-size: 14px; font-variant-numeric: tabular-nums; }
.history-stat small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; justify-content: flex-end; }
.pill { padding: 6px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 800; }

.wizard-header { margin: 0 0 20px; }
.edit-shift-meta { margin-bottom: 18px; background: var(--surface-warm); }
.edit-meta-grid { grid-template-columns: 1.2fr .8fr .8fr .7fr; }
.stepper { width: min(720px,100%); margin: 0 auto 22px; display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; }
.step { display: grid; justify-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); padding: 0; }
.step span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-weight: 850; }
.step strong { font-size: 11px; }
.step.active { color: var(--brand); }
.step.active span { border-color: var(--brand); background: var(--brand); color: #fff; }
.step.done span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.step-line { height: 2px; background: var(--line); margin: 0 8px 18px; }
.step-line.done { background: var(--brand); }

.cash-table { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cash-row { min-height: 58px; display: grid; grid-template-columns: minmax(90px,.8fr) minmax(150px,1.1fr) minmax(150px,1.1fr) minmax(110px,.8fr); gap: 12px; align-items: center; padding: 0 16px; border-top: 1px solid var(--line); }
.cash-row:first-child { border-top: 0; }
.cash-head { min-height: 42px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 800; }
.denomination-label { font-weight: 850; font-variant-numeric: tabular-nums; }
.count-control { display: grid; grid-template-columns: 30px 1fr 30px; gap: 5px; align-items: center; }
.count-control button { height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 17px; }
.count-input { width: 100%; height: 38px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--field-bg); text-align: center; color: var(--text); font-weight: 850; outline: 0; font-variant-numeric: tabular-nums; }
.count-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,95,82,.11); }
.count-input.invalid { border-color: var(--danger); background: var(--danger-bg); }
.money-column { text-align: right; font-variant-numeric: tabular-nums; }
.total-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 16px; }
.total-box { padding: 15px 16px; border-radius: 14px; background: var(--surface-2); display: grid; gap: 5px; }
.total-box span { color: var(--muted); font-size: 11px; }
.total-box strong { font-size: 21px; font-variant-numeric: tabular-nums; }
.primary-total { background: var(--brand); color: #fff; }
.primary-total span { color: rgba(255,255,255,.72); }

.wizard-actions { margin-top: 18px; display: flex; gap: 10px; }
.wizard-actions.end { justify-content: flex-end; }
.split-actions { justify-content: space-between; }
.two-column { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(300px,.7fr); gap: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; font-weight: 800; }
.field em { font-style: normal; color: var(--muted); font-weight: 500; }
.money-input { height: 45px; display: grid; grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); overflow: hidden; }
.money-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,95,82,.11); }
.money-input input { width: 100%; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0 4px 0 12px; background: transparent; color: var(--text); font-weight: 800; }
.money-input span { padding-right: 12px; color: var(--muted); }
.summary-list { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.summary-list > div { min-height: 47px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 14px; border-top: 1px solid var(--line); }
.summary-list > div:first-child { border-top: 0; }
.summary-list span { color: var(--muted); font-size: 12px; }
.summary-list strong { font-variant-numeric: tabular-nums; }
.summary-list .summary-result { background: var(--brand-soft); }
.summary-list .summary-result span, .summary-list .summary-result strong { color: var(--brand); font-weight: 850; }
.status { display: grid; grid-template-columns: 35px 1fr; gap: 10px; margin-top: 13px; padding: 13px; border-radius: 14px; }
.status-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 900; }
.status strong { font-size: 12px; }
.status p { margin: 3px 0 0; font-size: 11px; line-height: 1.4; }
.status.neutral { background: var(--surface-2); }
.status.neutral .status-icon { background: var(--surface-3); }
.status.success { background: var(--success-bg); color: var(--success); }
.status.success .status-icon { background: rgba(45,118,88,.13); }
.status.warning { background: var(--warning-bg); color: var(--warning); }
.status.warning .status-icon { background: rgba(154,100,42,.13); }
.earnings-card { align-self: stretch; display: grid; align-content: center; background: linear-gradient(160deg, #315f52, #244c40); color: #fff; }
.earnings-card .eyebrow { color: #d9eee6; }
.earnings-amount { margin: 9px 0 3px; font-size: clamp(38px,5vw,56px); font-weight: 900; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.earnings-card > p { margin: 0 0 18px; color: rgba(255,255,255,.78); }
.mini-note { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 11px; line-height: 1.45; }
.earnings-card .mini-note { border: 0; background: rgba(255,255,255,.09); color: rgba(255,255,255,.72); }

.collection-row { grid-template-columns: minmax(90px,.8fr) minmax(170px,1.1fr) minmax(170px,1fr); }
.collection-summary { display: grid; grid-template-columns: 1.1fr .9fr; gap: 10px; margin-top: 16px; }
.envelope-total, .remain-total { padding: 17px; border-radius: 15px; display: grid; gap: 5px; }
.envelope-total { background: var(--accent-soft); border: 1px solid var(--accent-soft-border); }
.envelope-total span { color: #805d38; font-size: 11px; }
.envelope-total strong { color: #754a1e; font-size: 27px; }
.remain-total { background: var(--brand-soft); align-content: start; }
.remain-total > span { color: var(--brand); font-size: 11px; font-weight: 800; margin-bottom: 4px; }
.remain-summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 5px 0; }
.remain-summary-row small { color: var(--muted); font-size: 11px; }
.remain-summary-row small em { color: var(--brand); font-style: normal; font-weight: 700; }
.remain-summary-row strong { color: var(--text); font-size: 16px; }
.remain-summary-result { margin-top: 4px; padding-top: 9px; border-top: 1px solid rgba(49,95,82,.14); }
.remain-summary-result small, .remain-summary-result strong { color: var(--brand); font-weight: 800; }
.remain-summary-result strong { font-size: 22px; }
.inline-message { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: 11px; line-height: 1.45; }
.inline-message.neutral { background: var(--surface-2); color: var(--muted); }
.inline-message.warning { background: var(--warning-bg); color: var(--warning); }

.dialog { width: min(470px, calc(100vw - 30px)); border: 0; border-radius: 21px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 28px 85px rgba(24,34,29,.24); }
.dialog::backdrop { background: rgba(25,34,30,.4); backdrop-filter: blur(3px); }
.dialog form { padding: 26px; }
.dialog-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); font-size: 22px; }
.success-mark { background: var(--success-bg); color: var(--success); font-weight: 900; }
.dialog h2 { margin: 13px 0 4px; }
.dialog-copy { margin: 0 0 17px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.profile-pay-grid { margin-top: 13px; }
.dialog-actions { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-summary { display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 14px 0; }
.dialog-summary div { min-height: 44px; padding: 0 13px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-top: 1px solid var(--line); }
.dialog-summary div:first-child { border-top: 0; }
.dialog-summary span { color: var(--muted); font-size: 11px; }
.dialog-summary strong { font-variant-numeric: tabular-nums; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translate(-50%,18px); opacity: 0; pointer-events: none; padding: 10px 14px; border-radius: 12px; background: #26342e; color: #fff; font-size: 12px; box-shadow: var(--shadow); transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 900px) {
  .profiles-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr 1fr; }
  .history-main { grid-column: 1 / -1; }
  .history-stat { text-align: left; }
  .history-actions { justify-content: flex-start; }
  .edit-meta-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 650px) {
  .app-header { padding: 9px 11px; }
  .brand-mark { width: 40px; height: 40px; }
  .save-state { display: none; }
  .shell { width: min(100% - 18px,1120px); margin-top: 12px; }
  .card { padding: 16px; border-radius: 17px; }
  .hero { min-height: 0; padding: 22px 18px; }
  .hero-pet { display: none; }
  .hero h1, .dashboard-top h1, .wizard-header h1 { font-size: 29px; }
  .row-heading, .dashboard-top { align-items: stretch; flex-direction: column; }
  .dashboard-actions { width: 100%; }
  .dashboard-actions .button { flex: 1; }
  .profiles-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 96px; padding: 13px; }
  .step strong { display: none; }
  .step-line { margin-bottom: 0; }
  .cash-table { overflow-x: auto; }
  .cash-row { min-width: 580px; grid-template-columns: 84px 165px 165px 110px; padding: 0 10px; gap: 8px; }
  .collection-row { min-width: 470px; grid-template-columns: 84px 175px 170px; }
  .total-grid, .collection-summary { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .wizard-actions.split-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .wide-mobile { width: 100%; }
  .history-item { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .active-shift-notice { align-items: stretch; flex-direction: column; }
  .active-shift-actions { justify-content: stretch; }
  .active-shift-actions .button { flex: 1; }
  .opening-entry-grid, .edit-meta-grid { grid-template-columns: 1fr; }
}

/* v3: report + separate drawer/reserve carryover */
.opening-balance-info { margin-top: 14px; }
.opening-balance-info strong { color: var(--text); }
.opening-entry-copy { display: grid; gap: 3px; }
.opening-entry-copy span { color: inherit; }
.opening-entry-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 12px; }
.compact-field { gap: 5px; }
.compact-field > span { font-size: 10px; }
.remain-split { font-size: 11px; color: var(--muted); line-height: 1.35; }
.button:disabled { cursor: not-allowed; opacity: .5; }
@media (max-width: 650px) {
  .collection-row { min-width: 500px; grid-template-columns: 84px 190px 190px; }
}

/* v5: store dashboard, archive/delete and infographic history */
.store-dashboard-top {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px;
}
.store-dashboard-top h1 { margin: 4px 0 9px; font-size: clamp(30px,4vw,44px); letter-spacing: -.045em; }
.store-dashboard-top p { margin: 0; color: var(--muted); line-height: 1.55; }
.store-overview-card { margin-bottom: 18px; }
.store-stats-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 10px; }
.store-stats-grid .stat-card { min-height: 122px; }
.stat-card.featured { background: linear-gradient(145deg, var(--brand), #244c40); color: white; }
.stat-card.featured span, .stat-card.featured small { color: rgba(255,255,255,.72); }
.negative-number { color: var(--danger) !important; }
.warning-number:not(.negative-number) { color: var(--warning) !important; }

.dashboard-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 18px; margin-bottom: 18px; }
.dashboard-grid .wide-card { grid-row: span 2; }
.chart-card { min-width: 0; }
.chart-area { min-height: 290px; display: flex; align-items: stretch; }
.compact-chart { min-height: 230px; }
.bar-chart-scroll { width: 100%; overflow-x: auto; padding: 4px 2px 2px; }
.bar-chart { min-width: max(100%, calc(var(--bars) * 64px)); height: 255px; display: grid; grid-template-columns: repeat(var(--bars), minmax(48px,1fr)); gap: 8px; align-items: end; padding: 28px 4px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0 49px, rgba(112,120,115,.08) 50px); }
.compact-chart .bar-chart { height: 200px; min-width: max(100%, calc(var(--bars) * 56px)); }
.bar-column { height: 100%; display: grid; grid-template-rows: 22px 1fr 28px; align-items: end; min-width: 0; }
.bar-value { text-align: center; font-size: 9px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.bar-track { height: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; width: min(34px,70%); justify-self: center; border-radius: 9px 9px 3px 3px; overflow: hidden; background: var(--surface-2); }
.bar-part { width: 100%; min-height: 0; transition: height .2s ease; }
.cash-part { background: var(--brand); }
.noncash-part { background: var(--accent); }
.total-part { background: linear-gradient(to top, var(--brand), #4f8676); }
.bar-label { align-self: center; text-align: center; font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-legend { display: flex; justify-content: center; gap: 18px; padding-top: 13px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.cash-dot { background: var(--brand); }
.noncash-dot { background: var(--accent); }
.chart-empty { flex: 1; min-height: 210px; display: grid; place-items: center; align-content: center; text-align: center; gap: 5px; color: var(--muted); }
.chart-empty span { font-size: 31px; }
.chart-empty strong { color: var(--text); }
.chart-empty small { font-size: 11px; }
.small-chart-empty { min-height: 120px; }

.rank-chart { display: grid; gap: 14px; }
.rank-row { display: grid; gap: 6px; }
.rank-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.rank-copy span { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-copy strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rank-track span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.rank-row small { color: var(--muted); font-size: 10px; }

.cash-position { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cash-position > div { padding: 14px; border-radius: 14px; background: var(--surface-2); display: grid; gap: 4px; }
.cash-position span { color: var(--muted); font-size: 11px; }
.cash-position strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.composition-bar { height: 12px; display: flex; overflow: hidden; border-radius: 99px; margin-top: 14px; background: var(--surface-2); }
.composition-bar span { display: block; height: 100%; }
.composition-drawer { background: var(--brand); }
.composition-reserve { background: var(--accent); }
.muted-caption { display: block; margin-top: 9px; color: var(--muted); line-height: 1.4; }
.recent-shifts-card, .personal-chart-card { margin-bottom: 18px; }

.profile-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.profile-title-row h3 { min-width: 0; }
.archived-section { margin-top: 30px; }
.archived-profile-card { opacity: .78; background: var(--surface-archived); }
.profile-dashboard-actions { flex-wrap: wrap; justify-content: flex-end; }

.history-item-rich { grid-template-columns: minmax(180px,1fr) minmax(150px,.85fr) minmax(145px,.72fr) minmax(160px,.85fr) auto; }
.history-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.shift-status, .history-edit-mark { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 999px; font-size: 9px; font-weight: 850; }
.shift-status.success { background: var(--success-bg); color: var(--success); }
.shift-status.warning { background: var(--warning-bg); color: var(--warning); }
.shift-status.neutral { background: var(--surface-2); color: var(--muted); }
.history-edit-mark { background: var(--info-bg); color: var(--info-text); }
.history-actions { gap: 6px; flex-wrap: wrap; }

.employee-picker-list { display: grid; gap: 8px; margin: 14px 0 4px; max-height: min(460px,55vh); overflow-y: auto; }
.employee-picker-item { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; }
.employee-picker-item:hover { background: var(--brand-soft); border-color: color-mix(in srgb,var(--brand) 34%,var(--line)); }
.employee-picker-item > span:nth-child(2) { display: grid; gap: 3px; }
.employee-picker-item small { color: var(--muted); }
.employee-picker-item b { color: var(--brand); font-size: 18px; }
.mini-avatar { width: 40px; height: 40px; margin: 0; border-radius: 12px; font-size: 17px; }
.single-action { grid-template-columns: 1fr; }
.danger-mark { background: var(--danger-bg); color: var(--danger); font-weight: 900; }
.danger-button { background: var(--danger); color: white; }
.danger-button:hover { background: #8f3b34; }
.stacked-actions { grid-template-columns: 1fr; }

.toast { display: flex; align-items: center; gap: 12px; }
.toast-action { border: 0; padding: 4px 2px; background: transparent; color: #f6c58f; font-weight: 900; }
.toast-action:hover { text-decoration: underline; }

@media (max-width: 1050px) {
  .store-stats-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .history-item-rich { grid-template-columns: 1fr 1fr 1fr; }
  .history-item-rich .history-main { grid-column: 1 / -1; }
  .history-item-rich .history-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 800px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .wide-card { grid-row: auto; }
  .store-dashboard-top { align-items: stretch; flex-direction: column; }
  .store-dashboard-top .dashboard-actions { width: 100%; }
  .store-dashboard-top .dashboard-actions .button { flex: 1; }
}
@media (max-width: 650px) {
  .store-stats-grid { grid-template-columns: 1fr 1fr; }
  .store-stats-grid .stat-card { min-height: 104px; }
  .history-item-rich { grid-template-columns: 1fr; }
  .history-item-rich .history-main, .history-item-rich .history-actions { grid-column: auto; }
  .history-item-rich .history-stat { text-align: left; }
  .profile-dashboard-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .profile-dashboard-actions .button:last-child { grid-column: 1 / -1; }
  .bar-chart { min-width: max(100%, calc(var(--bars) * 58px)); }
}

/* v6: opening/current balance hierarchy, shift viewer and reliable undo */
.toast.show { pointer-events: auto; }
.toast-action { cursor: pointer; }
.balance-section-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 2px 8px; }
.balance-section-label small { color: var(--muted); font-size: 10px; }
.opening-balance-panel { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.opening-balance-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 11px; }
.opening-balance-head h3 { margin: 3px 0 3px; font-size: 16px; }
.opening-balance-head p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.opening-total-grid { margin: 0; }
.opening-total-grid .total-box { background: var(--surface); }
.opening-total-grid .primary-total { background: var(--brand-soft); }
.opening-edit-toggle { flex: 0 0 auto; }
.opening-editor { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.first-opening-panel { background: var(--surface-highlight); border-color: var(--warm-border); }
.first-opening-panel .opening-balance-head p { max-width: 680px; }
.opening-help { margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.history-item-rich { cursor: default; }
.history-main[data-view-shift], .history-stat[data-view-shift] { cursor: pointer; }
.history-main[data-view-shift]:hover strong { color: var(--brand); }
.shift-view-dialog { width: min(620px, calc(100vw - 30px)); }
.shift-view-status { margin: -6px 0 14px; }
.shift-view-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shift-view-group { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.shift-view-group.wide { grid-column: 1 / -1; }
.shift-view-group h3 { margin: 0; padding: 11px 13px; background: var(--surface-2); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.shift-view-row { min-height: 42px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-top: 1px solid var(--line); }
.shift-view-row:first-of-type { border-top: 0; }
.shift-view-row span { color: var(--muted); font-size: 11px; }
.shift-view-row strong { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.shift-view-edited { margin-top: 12px; padding: 10px 12px; border-radius: 11px; background: var(--info-bg); color: var(--info-text); font-size: 10px; }
.shift-view-actions { grid-template-columns: 1fr 1fr 1fr; }
.history-view-button { white-space: nowrap; }

@media (max-width: 650px) {
  .balance-section-label, .opening-balance-head { align-items: stretch; flex-direction: column; }
  .opening-edit-toggle { align-self: flex-start; }
  .shift-view-summary { grid-template-columns: 1fr; }
  .shift-view-group.wide { grid-column: auto; }
  .shift-view-actions { grid-template-columns: 1fr; }
}

/* v7 foundation: stabilization and detailed shift history */
.opening-total-grid .primary-total { background: var(--brand); color: #fff; }
.opening-total-grid .primary-total span { color: rgba(255,255,255,.74); }

.expenses-panel, .discrepancy-details {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}
.subsection-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 12px; }
.subsection-heading h3 { margin: 3px 0 3px; font-size: 16px; }
.subsection-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.compact-subsection { margin-bottom: 10px; }
.subsection-total { font-size: 19px; color: var(--brand); white-space: nowrap; font-variant-numeric: tabular-nums; }
.expense-list { display: grid; gap: 8px; margin-bottom: 10px; }
.expense-empty { padding: 11px 12px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: 11px; text-align: center; background: var(--surface); }
.expense-item { display: grid; grid-template-columns: minmax(130px,.55fr) minmax(180px,1fr) auto; gap: 8px; align-items: center; }
.expense-money { min-width: 0; }
.expense-add-row { display: grid; grid-template-columns: minmax(130px,.55fr) minmax(180px,1fr) auto; gap: 10px; align-items: end; }
.icon-text-button { min-height: 40px; border: 0; background: transparent; font-weight: 800; padding: 0 8px; }
.danger-text { color: var(--danger); }
.text-area { width: 100%; min-height: 92px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); padding: 11px 12px; color: var(--text); outline: 0; font: inherit; line-height: 1.45; }
.text-area:focus, select.text-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,95,82,.11); }
.shift-comment-field { margin-top: 18px; }
.discrepancy-details { background: var(--warning-bg); border-color: var(--warning-border); }
.discrepancy-details .eyebrow { color: var(--warning); }

.shift-view-note { padding: 13px; color: var(--text); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 650px) {
  .expense-item, .expense-add-row { grid-template-columns: 1fr; }
  .expense-item .icon-text-button { justify-self: start; padding-left: 0; }
  .subsection-heading { flex-direction: column; gap: 8px; }
}

/* v8: production hardening + cash ledger */
.dashboard-grid .wide-card { grid-row: span 3; }
.data-health-card { align-content: start; }
.data-health-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 42px; padding: 0 2px; border-top: 1px solid var(--line); font-size: 11px; }
.data-health-row:first-of-type { border-top: 0; }
.data-health-row span { color: var(--muted); }
.data-health-row strong { text-align: right; }
.full-width-button { width: 100%; margin-top: 10px; }
.cash-journal-preview-card { margin-bottom: 18px; }

.cash-movements-panel { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.cash-operations-list { display: grid; gap: 8px; }
.cash-operation-item { display: grid; grid-template-columns: minmax(160px,1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cash-operation-copy { min-width: 0; display: grid; gap: 2px; }
.cash-operation-copy strong { font-size: 12px; }
.cash-operation-copy small { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cash-operation-amount { font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cash-operation-amount.inflow { color: var(--success); }
.cash-operation-amount.outflow { color: var(--danger); }
.cash-operation-amount.transfer { color: var(--brand); }
.cash-operations-impact { margin-top: 10px; padding: 10px 12px; border-radius: 11px; background: var(--surface); color: var(--muted); font-size: 11px; line-height: 1.45; }
.cash-operations-impact strong { color: var(--text); }

.cash-operation-dialog { width: min(620px, calc(100vw - 30px)); }
.operation-table-wrap { margin: 14px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; max-height: 390px; overflow-y: auto; }
.operation-table-head, .operation-row { display: grid; grid-template-columns: 1fr minmax(130px,.8fr) minmax(100px,.7fr); gap: 10px; align-items: center; padding: 0 13px; }
.operation-table-head { min-height: 38px; position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 850; }
.operation-row { min-height: 50px; border-top: 1px solid var(--line); }
.operation-row .count-input { height: 34px; }
.operation-row-sum { text-align: right; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.operation-total-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 14px; padding: 12px 13px; border-radius: 12px; background: var(--brand-soft); }
.operation-total-row span { color: var(--brand); font-size: 11px; }
.operation-total-row strong { color: var(--brand); font-size: 20px; font-variant-numeric: tabular-nums; }

.journal-balance-card { margin-bottom: 18px; }
.ledger-list { display: grid; gap: 8px; }
.ledger-entry { display: grid; grid-template-columns: 82px minmax(180px,1fr) minmax(120px,.55fr) auto; gap: 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.ledger-time { display: grid; gap: 2px; color: var(--muted); font-size: 10px; }
.ledger-time strong { color: var(--text); font-size: 11px; }
.ledger-main { min-width: 0; display: grid; gap: 2px; }
.ledger-main strong { font-size: 12px; }
.ledger-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger-context { color: var(--muted); font-size: 10px; text-align: right; }
.ledger-amount { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger-amount.inflow { color: var(--success); }
.ledger-amount.outflow { color: var(--danger); }
.ledger-amount.transfer { color: var(--brand); }
.ledger-amount.neutral { color: var(--text); }
.ledger-entry.synthetic { background: var(--surface-quiet); }
.ledger-entry.standalone { border-color: #cdded6; }
.ledger-delete { justify-self: end; }

.backup-fresh { color: var(--success); }
.backup-warning { color: var(--warning); }
.backup-danger { color: var(--danger); }

@media (max-width: 800px) {
  .dashboard-grid .wide-card { grid-row: auto; }
  .ledger-entry { grid-template-columns: 72px 1fr auto; }
  .ledger-context { grid-column: 2; text-align: left; }
  .ledger-delete { grid-column: 3; grid-row: 1 / span 2; }
}
@media (max-width: 650px) {
  .cash-operation-item { grid-template-columns: 1fr auto; }
  .cash-operation-item .icon-text-button { grid-column: 1 / -1; justify-self: start; padding-left: 0; }
  .operation-table-head, .operation-row { grid-template-columns: 85px 1fr 90px; padding: 0 9px; }
  .ledger-entry { grid-template-columns: 1fr auto; }
  .ledger-time { grid-column: 1; display: flex; gap: 8px; align-items: baseline; }
  .ledger-main { grid-column: 1 / -1; grid-row: 2; }
  .ledger-context { grid-column: 1; grid-row: 3; }
  .ledger-amount { grid-column: 2; grid-row: 1; }
  .ledger-delete { grid-column: 2; grid-row: 3; }
}

/* v9: simplified external cash movements */
.external-movement-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.status .external-movement-actions .button { min-height: 34px; padding: 7px 11px; font-size: 10px; }
.operation-breakdown { display: grid; gap: 10px; }
.cash-movements-panel .cash-operations-impact { line-height: 1.5; }
@media (min-width: 651px) { .report-grid { grid-template-columns: 1fr 1fr; } }

/* v10: shift-scoped cash chain and gap recovery */
.chain-gap-panel { background: var(--warning-bg); border-color: var(--warning-border); }
.chain-gap-panel .eyebrow { color: var(--warning); }
.chain-gap-actions { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.chain-gap-actions .text-button { margin-left: 2px; }
.opening-unknown-panel { background: var(--surface-disabled); border-style: dashed; }
.opening-editor-footer { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.opening-editor-footer .opening-help { margin-top: 0; }
.cash-movements-panel { background: var(--surface-2); }
.cash-operation-dialog .dialog-copy { max-width: 540px; }
@media (max-width: 650px) {
  .chain-gap-actions { display: grid; grid-template-columns: 1fr; }
  .chain-gap-actions .button, .chain-gap-actions .text-button { width: 100%; text-align: center; }
  .opening-editor-footer { align-items: stretch; flex-direction: column; }
}



/* v11: store plan, missing-day accounting and virtual business date */
.test-mode-banner { position: static; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 9px 16px; background: var(--test-bg); border-bottom: 1px solid var(--test-border); color: var(--test-text); }
.test-mode-banner > div { display: flex; align-items: center; gap: 10px; }
.test-mode-banner .text-button { color: inherit; }
.store-plan-card { margin-top: 18px; }
.plan-empty { padding: 18px; border: 1px dashed var(--line, #dfe7e3); border-radius: 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.plan-empty p { flex: 1 1 420px; margin: 0; color: var(--muted, #68736e); }
.plan-progress-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 4px 0 10px; }
.plan-progress-head strong { font-size: 23px; }
.plan-progress-head span { font-weight: 800; color: var(--brand, #315f52); }
.plan-progress { height: 12px; overflow: hidden; background: var(--plan-track); border-radius: 999px; }
.plan-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand, #315f52); transition: width .2s ease; }
.plan-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.plan-stats-grid > div { padding: 14px; border-radius: 14px; background: var(--plan-stat-bg); border: 1px solid var(--plan-stat-border); display: grid; gap: 4px; }
.plan-stats-grid span, .plan-stats-grid small { color: var(--muted, #68736e); }
.plan-stats-grid strong { font-size: 20px; }
.featured-plan-stat { background: var(--plan-featured-bg) !important; border-color: var(--plan-featured-border) !important; }
.missing-days-card { margin-top: 18px; }
.missing-day-list, .revenue-only-section { display: grid; gap: 8px; }
.missing-day-row, .revenue-only-row { display: grid; grid-template-columns: minmax(180px,1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--plan-stat-border); border-radius: 14px; background: var(--surface-row); }
.missing-day-row > div:first-child, .revenue-only-row > div:first-child { display: grid; gap: 3px; }
.missing-day-row small, .revenue-only-row small { color: var(--muted, #68736e); }
.missing-day-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.revenue-only-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--plan-stat-border); }
.revenue-only-row { grid-template-columns: minmax(180px,1fr) auto auto; }
.revenue-only-row > div:nth-child(2) { display: grid; gap: 3px; text-align: right; }
.settings-section { padding: 16px 0; border-top: 1px solid var(--plan-stat-border); }
.settings-section:first-of-type { border-top: 0; }
.toggle-setting-row { display: flex; gap: 18px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toggle-setting-row > div { display: grid; gap: 4px; }
.toggle-setting-row p { margin: 0; color: var(--muted, #68736e); font-size: 13px; }
.switch-control { position: relative; flex: 0 0 auto; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control span { display: block; width: 48px; height: 28px; border-radius: 999px; background: var(--switch-track); position: relative; cursor: pointer; transition: .18s ease; }
.switch-control span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: .18s ease; }
.switch-control input:checked + span { background: var(--brand, #315f52); }
.switch-control input:checked + span::after { transform: translateX(20px); }
.switch-control input:disabled + span { opacity: .5; cursor: not-allowed; }
.test-date-actions { display: flex; gap: 8px; margin-top: 8px; }

@media (max-width: 720px) {
  .test-mode-banner { position: static; align-items: flex-start; justify-content: space-between; }
  .test-mode-banner > div { align-items: flex-start; flex-direction: column; gap: 2px; }
  .plan-stats-grid { grid-template-columns: 1fr; }
  .missing-day-row, .revenue-only-row { grid-template-columns: 1fr; }
  .revenue-only-row > div:nth-child(2) { text-align: left; }
  .missing-day-actions { justify-content: flex-start; }
}

/* v12: point initialization + standardized gap recovery */
.setup-grid { display: grid; grid-template-columns: minmax(0,.8fr) minmax(480px,1.2fr); gap: 18px; align-items: start; }
.initial-setup-card { min-width: 0; }
.setup-money-field { margin-top: 18px; }
.large-money-input input { min-height: 52px; font-size: 24px; font-weight: 850; }
.compact-cash-table { margin-top: 8px; }
.initial-reserve-row { grid-template-columns: 110px minmax(180px,1fr) 120px; }
.setup-reserve-total { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border-radius: 13px; background: var(--brand-soft); }
.setup-reserve-total span { color: var(--brand); font-size: 11px; font-weight: 750; }
.setup-reserve-total strong { color: var(--brand); font-size: 21px; font-variant-numeric: tabular-nums; }
.setup-total-card { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr 1.15fr auto; gap: 10px; align-items: stretch; }
.setup-total-card > div { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.setup-total-card span { color: var(--muted); font-size: 10px; }
.setup-total-card strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.setup-total-card .setup-grand-total { background: var(--brand); border-color: var(--brand); }
.setup-total-card .setup-grand-total span { color: rgba(255,255,255,.72); }
.setup-total-card .setup-grand-total strong { color: #fff; }
.setup-total-card .button { align-self: stretch; min-width: 230px; }

.recovery-card { margin-bottom: 16px; }
.gap-day-card { border: 1px solid var(--line); border-radius: 15px; padding: 14px; background: var(--surface-2); margin-top: 10px; }
.gap-day-card:first-child { margin-top: 0; }
.gap-day-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.gap-day-head > div { display: grid; gap: 3px; }
.gap-day-head strong { font-size: 13px; }
.gap-day-head small { color: var(--muted); font-size: 10px; }
.gap-status-select { width: auto; min-width: 190px; }
.gap-day-fields { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.recovery-drawer-field { max-width: 520px; }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.recovery-reserve-summary { margin-bottom: 12px; }
.recovery-reserve-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.recovery-reserve-summary span, .recovery-reserve-summary small { color: var(--muted); font-size: 10px; }
.recovery-reserve-summary strong { margin-left: auto; font-size: 19px; font-variant-numeric: tabular-nums; }
.recovery-reserve-summary small { max-width: 290px; text-align: right; }
.recovery-reserve-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#gapReserveEditor { margin-top: 14px; }
#gapReserveConfirmButton { margin-top: 10px; }
#gapRecoveryError { margin: 0 0 14px; }

@media (max-width: 850px) {
  .setup-grid { grid-template-columns: 1fr; }
  .setup-total-card { grid-template-columns: 1fr 1fr; }
  .setup-total-card .button { grid-column: 1 / -1; }
}
@media (max-width: 650px) {
  .initial-reserve-row { min-width: 520px; grid-template-columns: 90px 190px 110px; }
  .setup-total-card { grid-template-columns: 1fr; }
  .gap-day-head { align-items: stretch; flex-direction: column; }
  .gap-status-select { width: 100%; }
  .recovery-reserve-summary > div { align-items: flex-start; flex-direction: column; }
  .recovery-reserve-summary strong { margin-left: 0; }
  .recovery-reserve-summary small { text-align: left; max-width: none; }
  .recovery-reserve-actions { display: grid; grid-template-columns: 1fr; }
  .recovery-reserve-actions .button, .recovery-reserve-actions .text-button { width: 100%; text-align: center; }
}

/* ===== v2 product redesign ===== */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px; --radius-xl: 28px;
  --surface-raised: var(--surface); --surface-hover: var(--surface-2);
  --focus-ring: color-mix(in srgb, var(--brand) 22%, transparent);
  --motion-fast: 140ms; --motion-base: 220ms;
}
:root[data-accent="forest"] { --brand:#315f52; --brand-strong:#244a3f; --brand-soft:#e5f0eb; --accent:#d48b4b; }
:root[data-accent="amber"] { --brand:#9a5d22; --brand-strong:#794616; --brand-soft:#f8ead9; --accent:#c98035; }
:root[data-accent="berry"] { --brand:#91465b; --brand-strong:#733246; --brand-soft:#f6e6eb; --accent:#bd6d7f; }
:root[data-accent="ocean"] { --brand:#356779; --brand-strong:#274f5e; --brand-soft:#e3eef2; --accent:#4f90a5; }
:root[data-accent="violet"] { --brand:#66558f; --brand-strong:#4f4174; --brand-soft:#eee9f8; --accent:#8b76bd; }
:root[data-theme="dark"] {
  --bg:#111613; --surface:#19201c; --surface-2:#202923; --surface-3:#28332c; --text:#f2f4f2; --muted:#a9b4ad; --line:#334039;
  --field-bg:#202923; --surface-warm:#211f1a; --surface-highlight:#242319; --surface-soft:#1d2520; --surface-quiet:#1c231f; --surface-disabled:#202722; --surface-row:#1c231f; --surface-archived:#1e2521; --hero-end:#202923;
  --info-bg:#30283a; --info-text:#d0bee2; --warning-border:#5b4930; --warm-border:#55482f; --accent-border:#5b4430; --accent-soft-border:#5b4631; --accent-text:#d7b48d; --danger-border:#694039; --danger-hover:#482925;
  --test-bg:#302b19; --test-border:#514828; --test-text:#d8c77a; --plan-track:#2a352e; --plan-stat-bg:#202923; --plan-stat-border:#334039; --plan-featured-bg:#203029; --plan-featured-border:#365348; --switch-track:#35423b;
  --brand-soft:color-mix(in srgb, var(--brand) 24%, #18201c); --accent-soft:#35281d; --success-bg:#183128; --warning-bg:#392d1e; --danger-bg:#38221f;
  --shadow:0 16px 44px rgba(0,0,0,.24);
}
html { scroll-behavior:smooth; }
body { background:
  radial-gradient(circle at 78% -5%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 28rem),
  radial-gradient(circle at 8% 80%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 32rem), var(--bg); }
.card, .button, .text-input, .month-picker, .money-input, .profile-card, dialog { transition:background-color var(--motion-base) ease,border-color var(--motion-base) ease,color var(--motion-base) ease,transform var(--motion-fast) ease,box-shadow var(--motion-base) ease; }
.card { border-radius:var(--radius-lg); padding:var(--space-5); box-shadow:var(--shadow); }
.button { border-radius:var(--radius-md); min-height:44px; padding:0 16px; white-space:nowrap; }
.button:active { transform:translateY(1px) scale(.99); }
.button.primary { box-shadow:0 8px 22px color-mix(in srgb, var(--brand) 22%, transparent); }
.text-input, .month-picker, .money-input { border-radius:var(--radius-md); }
.text-input, .month-picker, .money-input input, .count-input, .text-area { background:var(--field-bg); color:var(--text); }
.text-input:focus, .month-picker:focus, .money-input:focus-within { box-shadow:0 0 0 4px var(--focus-ring); }
.money-input input { font-variant-numeric:tabular-nums; letter-spacing:.01em; }
.section-heading h2, .page-heading h1, .overview-heading h1, .onboarding-card h2 { text-wrap:balance; }
.section-heading p, .section-copy, .page-heading p { max-width:680px; }

/* Persistent navigation */
.primary-nav { display:flex; gap:6px; }
.nav-item { border:0; background:transparent; color:var(--muted); min-height:42px; border-radius:12px; padding:0 12px; display:flex; align-items:center; gap:8px; font:inherit; cursor:pointer; }
.nav-item span { font-size:17px; width:20px; text-align:center; }
.nav-item strong { font-size:13px; }
.nav-item:hover { background:var(--surface-2); color:var(--text); }
.nav-item.active { background:var(--brand-soft); color:var(--brand); }
.compat-dashboard-actions { display:none; }

.overview-heading, .page-heading { display:flex; justify-content:space-between; align-items:flex-end; gap:24px; margin:4px 0 20px; }
.overview-heading h1, .page-heading h1 { margin:4px 0 7px; font-size:clamp(30px,4vw,46px); letter-spacing:-.045em; }
.overview-heading p, .page-heading p { margin:0; color:var(--muted); }
.today-action-card { position:relative; overflow:hidden; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:24px; align-items:center; margin-bottom:var(--space-5); padding:28px 30px; background:linear-gradient(135deg,color-mix(in srgb,var(--brand-soft) 76%,var(--surface)),var(--surface)); }
.today-action-card::after { content:'🐾'; position:absolute; right:170px; top:50%; transform:translateY(-50%) rotate(-12deg); font-size:92px; opacity:.055; pointer-events:none; }
.today-action-copy h2 { margin:10px 0 6px; font-size:28px; letter-spacing:-.035em; }
.today-action-copy p { margin:0; color:var(--muted); }
.today-action-side { display:grid; gap:12px; justify-items:end; min-width:180px; }
.today-action-side>strong { font-size:23px; letter-spacing:-.025em; font-variant-numeric:tabular-nums; }
.status-badge { display:inline-flex; width:max-content; padding:6px 9px; border-radius:999px; background:var(--brand); color:#fff; font-size:11px; font-weight:850; }
.action-button { min-width:160px; }
.overview-support-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:24px; }
.analytics-grid { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(280px,.75fr); gap:16px; }
.analytics-grid .wide-card { grid-column:auto; }
#analyticsScreen .store-overview-card { margin-bottom:16px; }
#shiftsScreen > .card + .card { margin-top:16px; }


/* Screen composition and motion */
.page-heading-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.screen:not(.hidden) { animation:screen-enter var(--motion-base) ease both; }
@keyframes screen-enter { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }
@media (max-width:760px) {
  .page-heading-actions { display:grid; grid-template-columns:1fr; width:100%; }
  .page-heading-actions .button, .page-heading-actions .month-picker { width:100%; }
}

/* Onboarding */
.onboarding-screen { min-height:calc(100vh - 64px); }
.onboarding-shell { width:min(940px,100%); margin:0 auto; }
.onboarding-intro { text-align:center; margin:18px auto 26px; max-width:650px; }
.onboarding-intro h1 { margin:10px 0 8px; font-size:clamp(34px,5vw,52px); letter-spacing:-.05em; }
.onboarding-intro p { margin:0; color:var(--muted); }
.onboarding-logo { width:62px; height:62px; display:grid; place-items:center; margin:0 auto 14px; border-radius:20px; background:var(--brand); color:white; font-size:29px; box-shadow:var(--shadow); }
.onboarding-progress { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin-bottom:16px; }
.onboarding-progress span { position:relative; min-height:48px; border-radius:14px; border:1px solid var(--line); color:var(--muted); background:var(--surface); display:flex; align-items:center; justify-content:center; gap:7px; font-weight:850; }
.onboarding-progress span i { font-style:normal; font-size:11px; font-weight:700; }
.onboarding-progress span.active { border-color:var(--brand); background:var(--brand-soft); color:var(--brand); }
.onboarding-progress span.done { color:var(--brand); border-color:color-mix(in srgb,var(--brand) 30%,var(--line)); }
.onboarding-card { min-height:340px; }
.onboarding-card>h2 { margin:7px 0 6px; font-size:29px; letter-spacing:-.035em; }
.section-copy { margin:0 0 24px; color:var(--muted); line-height:1.55; }
.onboarding-form-grid { grid-template-columns:2fr 1fr 1fr 1fr; }
.onboarding-add-profile { display:grid; grid-template-columns:minmax(170px,1fr) 110px 140px auto; gap:10px; align-items:center; margin-bottom:16px; }
.compact-select { min-width:0; }
.onboarding-profile-list { display:flex; flex-wrap:wrap; gap:10px; }
.onboarding-profile-chip { display:flex; align-items:center; gap:9px; padding:10px 12px; border-radius:14px; background:var(--profile-bg,var(--surface-2)); border:1px solid var(--line); }
.onboarding-profile-chip span { font-size:20px; }
.onboarding-profile-chip button { border:0; background:transparent; color:var(--muted); font-size:18px; }
.onboarding-opening-grid { grid-template-columns:.72fr 1.28fr; }
.onboarding-total-panel { margin-top:16px; display:grid; grid-template-columns:1fr auto; gap:8px 14px; padding:16px; border-radius:16px; background:var(--surface-2); }
.onboarding-total-panel span { color:var(--muted); font-size:12px; }
.onboarding-actions { display:grid; grid-template-columns:auto 1fr auto auto; gap:10px; margin-top:16px; }

/* Profiles */
.profile-card { text-align:left; overflow:hidden; }
.profile-color-sage { --profile-bg:#e8f1ed; }
.profile-color-sand { --profile-bg:#f4eadb; }
.profile-color-sky { --profile-bg:#e3eef6; }
.profile-color-rose { --profile-bg:#f6e5e9; }
.profile-color-lilac { --profile-bg:#eee7f6; }
.profile-color-mint { --profile-bg:#e2f3ea; }
:root[data-theme="dark"] .profile-color-sage { --profile-bg:#21342c; }
:root[data-theme="dark"] .profile-color-sand { --profile-bg:#382e22; }
:root[data-theme="dark"] .profile-color-sky { --profile-bg:#22333c; }
:root[data-theme="dark"] .profile-color-rose { --profile-bg:#39252b; }
:root[data-theme="dark"] .profile-color-lilac { --profile-bg:#30283c; }
:root[data-theme="dark"] .profile-color-mint { --profile-bg:#21372d; }
.profile-card .profile-avatar { background:var(--profile-bg); color:var(--text); }
.profile-card::before { content:''; position:absolute; inset:0 auto 0 0; width:5px; background:var(--profile-bg); }
.profile-custom-grid { grid-template-columns:1fr 1fr; margin-top:12px; }

/* Theme hardening */
:root[data-theme="dark"] body, :root[data-theme="dark"] .app-header { background-color:var(--bg); }
:root[data-theme="dark"] .app-header { background:color-mix(in srgb,var(--bg) 91%,transparent); border-color:var(--line); }
:root[data-theme="dark"] .card, :root[data-theme="dark"] .profile-card, :root[data-theme="dark"] .app-menu, :root[data-theme="dark"] dialog { background:var(--surface); border-color:var(--line); color:var(--text); }
:root[data-theme="dark"] .text-input, :root[data-theme="dark"] .month-picker, :root[data-theme="dark"] .money-input, :root[data-theme="dark"] .money-input input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background:var(--surface-2); color:var(--text); border-color:var(--line); }
:root[data-theme="dark"] .button.secondary, :root[data-theme="dark"] .icon-button { background:var(--surface-2); color:var(--text); border-color:var(--line); }
:root[data-theme="dark"] .cash-row, :root[data-theme="dark"] .history-item, :root[data-theme="dark"] .dialog-summary, :root[data-theme="dark"] .shift-view-group { border-color:var(--line); }
:root[data-theme="dark"] .stat-card { background:var(--surface-2); }
:root[data-theme="dark"] .hero { background:linear-gradient(135deg,var(--surface),var(--surface-2)); }
:root[data-theme="dark"] input[type="month"], :root[data-theme="dark"] input[type="date"] { color-scheme:dark; }

:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background-color:var(--field-bg); color:var(--text); border-color:var(--line);
}
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color:color-mix(in srgb,var(--muted) 78%,transparent); }
:root[data-theme="dark"] .edit-shift-meta { background:var(--surface-warm); }
:root[data-theme="dark"] .first-opening-panel { background:var(--surface-highlight); border-color:var(--warm-border); }
:root[data-theme="dark"] .archived-profile-card { background:var(--surface-archived); }
:root[data-theme="dark"] .history-edit-mark, :root[data-theme="dark"] .shift-view-edited { background:var(--info-bg); color:var(--info-text); }
:root[data-theme="dark"] .cash-movements-panel, :root[data-theme="dark"] .ledger-entry.synthetic, :root[data-theme="dark"] .opening-unknown-panel, :root[data-theme="dark"] .missing-day-row, :root[data-theme="dark"] .revenue-only-row { border-color:var(--line); }
:root[data-theme="dark"] .count-control button { background:var(--surface-2); border-color:var(--line); color:var(--text); }
:root[data-theme="dark"] .active-shift-notice { border-color:var(--accent-border); }
:root[data-theme="dark"] .active-shift-notice p { color:var(--accent-text); }
:root[data-theme="dark"] .discrepancy-details, :root[data-theme="dark"] .chain-gap-panel { border-color:var(--warning-border); }
:root[data-theme="dark"] .test-mode-banner { background:var(--test-bg); border-color:var(--test-border); color:var(--test-text); }

.month-setup-previous { margin:12px 0 18px; padding:12px 14px; border-radius:14px; background:var(--surface-2); color:var(--muted); }
.data-health-card .section-heading h2 { text-transform:none; }

/* Desktop app shell */
@media (min-width: 1040px) {
  .app-header { position:fixed; inset:0 auto 0 0; width:244px; min-height:100vh; padding:24px 16px; flex-direction:column; align-items:stretch; justify-content:flex-start; gap:22px; border-right:1px solid var(--line); border-bottom:0; backdrop-filter:blur(18px); }
  .brand-button { padding:0 6px; }
  .brand-mark { width:46px; height:46px; }
  .primary-nav { flex-direction:column; gap:5px; }
  .nav-item { justify-content:flex-start; width:100%; min-height:46px; padding:0 12px; }
  .nav-item span { width:24px; }
  .header-actions { margin-top:auto; flex-wrap:wrap; padding:14px 6px 0; border-top:1px solid var(--line); }
  .save-state { width:100%; }
  .app-menu { position:fixed; left:16px; right:auto; bottom:76px; top:auto; width:212px; }
  .shell { width:auto; max-width:1320px; margin:0 32px 64px 276px; padding-top:30px; }
  .test-mode-banner { margin-left:244px; }
  .focus-mode .primary-nav { opacity:.36; pointer-events:none; }
}

@media (max-width: 1039px) {
  .primary-nav { display:none; }
  .overview-heading { align-items:flex-start; }
  .analytics-grid, .overview-support-grid { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
  .today-action-card { grid-template-columns:1fr; padding:20px; }
  .today-action-side { justify-items:stretch; min-width:0; }
  .today-action-side>strong { font-size:20px; }
  .action-button { width:100%; }
  .onboarding-progress span i { display:none; }
  .onboarding-form-grid, .onboarding-opening-grid, .profile-custom-grid { grid-template-columns:1fr; }
  .onboarding-add-profile { grid-template-columns:1fr 1fr; }
  .onboarding-add-profile #onboardingProfileName { grid-column:1/-1; }
  .onboarding-add-profile button { grid-column:1/-1; }
  .onboarding-card { min-height:0; }
  .overview-heading, .page-heading { flex-direction:column; align-items:stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; transition-duration:.01ms !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; }
}
:root[data-theme="dark"] .plan-stats-grid > div { background:var(--plan-stat-bg); border-color:var(--plan-stat-border); }
:root[data-theme="dark"] .featured-plan-stat { background:var(--plan-featured-bg) !important; border-color:var(--plan-featured-border) !important; }
:root[data-theme="dark"] .plan-progress { background:var(--plan-track); }
:root[data-theme="dark"] .composition-bar, :root[data-theme="dark"] .rank-track, :root[data-theme="dark"] .bar-track { background:var(--surface-3); }
#storeSettingsDialog { width:min(720px,calc(100vw - 30px)); max-height:min(880px,90vh); overflow:auto; }
@media (max-width:1039px) {
  body { padding-bottom:76px; }
  .primary-nav { display:grid; position:fixed; z-index:60; left:10px; right:10px; bottom:10px; grid-template-columns:repeat(5,1fr); gap:4px; padding:6px; border:1px solid var(--line); border-radius:18px; background:color-mix(in srgb,var(--surface) 94%,transparent); box-shadow:0 12px 34px rgba(23,33,28,.18); backdrop-filter:blur(18px); }
  .nav-item { min-width:0; min-height:52px; padding:5px 2px; flex-direction:column; justify-content:center; gap:1px; }
  .nav-item span { font-size:16px; line-height:1; }
  .nav-item strong { font-size:9px; max-width:100%; overflow:hidden; text-overflow:ellipsis; }
  .focus-mode .primary-nav { display:none; }
  .focus-mode { padding-bottom:0; }
}

/* ===== v17 spacing normalization ===== */
:root {
  --page-section-gap: 24px;
  --card-section-gap: 20px;
  --card-padding: 24px;
  --compact-card-padding: 20px;
  --control-gap: 12px;
}

/* Alignment modifiers must never create layout spacing on their own. */
.row-heading { margin-top: 0; }

/* One source of truth for vertical rhythm between top-level screen blocks. */
#storeDashboardScreen,
#analyticsScreen,
#shiftsScreen,
#profilesScreen,
#dashboardScreen,
#initialSetupScreen,
#gapRecoveryScreen,
#shiftScreen {
  display: grid;
  align-content: start;
  gap: var(--page-section-gap);
}

#storeDashboardScreen > *,
#analyticsScreen > *,
#shiftsScreen > *,
#profilesScreen > *,
#dashboardScreen > *,
#initialSetupScreen > *,
#gapRecoveryScreen > *,
#shiftScreen > * {
  min-width: 0;
}

/* Remove legacy margins now replaced by parent screen gaps. */
#storeDashboardScreen > :where(.overview-heading,.today-action-card,.active-shift-notice,.store-plan-card,.overview-support-grid),
#analyticsScreen > :where(.page-heading,.store-overview-card,.analytics-grid),
#shiftsScreen > :where(.page-heading,.missing-days-card,.recent-shifts-card),
#profilesScreen > :where(.hero,.section-heading,.profiles-grid,.archived-section,.empty-state),
#dashboardScreen > :where(.dashboard-top,.active-shift-notice,.month-card,.personal-chart-card,.card),
#initialSetupScreen > :where(.wizard-header,.setup-grid,.setup-total-card),
#gapRecoveryScreen > :where(.wizard-header,.recovery-card,.form-error,.wizard-actions),
#shiftScreen > :where(.wizard-header,.edit-shift-meta,.stepper,.wizard-step) {
  margin-block: 0;
}

/* Legacy sibling spacing is no longer needed once screens own the rhythm. */
#analyticsScreen .store-overview-card,
#shiftsScreen > .card + .card,
.recent-shifts-card,
.personal-chart-card,
.month-card,
.store-overview-card,
.missing-days-card,
.recovery-card,
.archived-section,
.today-action-card,
.overview-support-grid {
  margin-block: 0;
}

/* Card interior rhythm. */
.card { padding: var(--card-padding); }
.card > .section-heading:first-child,
.card > .section-heading.row-heading:first-child {
  margin-top: 0;
  margin-bottom: var(--card-section-gap);
}
.card > .section-heading.compact:first-child {
  margin-bottom: var(--space-4);
}
.section-heading {
  gap: var(--space-4);
  margin-bottom: var(--card-section-gap);
}
.section-heading.compact { margin-bottom: var(--space-4); }
.subsection-heading {
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.compact-subsection { margin-bottom: var(--space-3); }

/* Common content groups inside cards. */
.form-grid { gap: var(--space-4); }
.field { gap: var(--space-2); }
.stats-grid,
.store-stats-grid,
.total-grid,
.plan-stats-grid,
.cash-position,
.collection-summary,
.shift-view-summary { gap: var(--space-3); }
.profiles-grid,
.analytics-grid,
.overview-support-grid,
.setup-grid { gap: var(--space-4); }
.history-list,
.missing-day-list,
.revenue-only-section,
.cash-operations-list,
.expense-list { gap: var(--space-3); }

/* Embedded panels should feel like sub-sections, not separate floating cards. */
.expenses-panel,
.cash-movements-panel,
.discrepancy-details,
.opening-balance-panel {
  margin-top: var(--card-section-gap);
  padding: var(--space-4);
}
.shift-comment-field { margin-top: var(--card-section-gap); }
.cash-operations-impact { margin-top: var(--space-3); }

/* Dense row/card components use the same inner padding family. */
.profile-card { padding: var(--compact-card-padding); }
.stat-card { padding: var(--space-4); }
.history-item,
.missing-day-row,
.revenue-only-row,
.gap-day-card,
.ledger-entry,
.cash-operation-item { padding: var(--space-3) var(--space-4); }
.plan-stats-grid > div,
.cash-position > div { padding: var(--space-4); }

/* Setup / recovery composition. */
.setup-reserve-total,
.recovery-reserve-summary > div { padding: var(--space-3) var(--space-4); }
.setup-total-card { gap: var(--space-3); }
.setup-total-card > div { padding: var(--space-3) var(--space-4); }
.gap-day-card + .gap-day-card { margin-top: var(--space-3); }

/* Onboarding gets the same component rhythm instead of ad-hoc margins. */
.onboarding-intro { margin: var(--space-4) auto var(--space-5); }
.onboarding-progress { margin-bottom: var(--space-4); }
.onboarding-card { padding: var(--card-padding); }
.section-copy { margin: 0 0 var(--space-5); }
.onboarding-add-profile { gap: var(--space-3); margin-bottom: var(--space-4); }
.onboarding-profile-list { gap: var(--space-3); }
.onboarding-total-panel { margin-top: var(--space-4); padding: var(--space-4); }
.onboarding-actions { gap: var(--space-3); margin-top: var(--space-4); }

/* Dialogs follow the same spacing scale. */
.dialog form { padding: var(--card-padding); }
.dialog-copy { margin-bottom: var(--space-4); }
.dialog-actions { margin-top: var(--space-5); gap: var(--space-3); }
.dialog-summary { margin: var(--space-4) 0; }

@media (max-width: 760px) {
  :root {
    --page-section-gap: 16px;
    --card-section-gap: 16px;
    --card-padding: 18px;
    --compact-card-padding: 16px;
  }

  .shell { width: min(100% - 24px, 1120px); margin-bottom: 32px; }
  .card { padding: var(--card-padding); border-radius: 18px; }
  .profile-card { padding: var(--compact-card-padding); }
  .overview-heading, .page-heading, .dashboard-top, .wizard-header { gap: var(--space-3); }
  .overview-heading, .page-heading { margin: 0; }
  .today-action-card { padding: var(--card-padding); gap: var(--space-4); }
  .section-heading { gap: var(--space-3); margin-bottom: var(--space-4); }
  .section-heading.compact { margin-bottom: var(--space-3); }
  .form-grid,
  .stats-grid,
  .store-stats-grid,
  .total-grid,
  .plan-stats-grid,
  .cash-position,
  .collection-summary,
  .profiles-grid,
  .analytics-grid,
  .overview-support-grid,
  .setup-grid { gap: var(--space-3); }
  .expenses-panel,
  .cash-movements-panel,
  .discrepancy-details,
  .opening-balance-panel { padding: var(--space-3); }
  .dialog form { padding: 20px; }
  .onboarding-card { padding: 20px; }
}

@media (max-width: 480px) {
  :root { --card-padding: 16px; --compact-card-padding: 14px; }
  .shell { width: min(100% - 18px, 1120px); }
  .card { border-radius: 16px; }
  .history-item,
  .missing-day-row,
  .revenue-only-row,
  .gap-day-card,
  .cash-operation-item { padding: 12px; }
}


/* ===== v18 component spacing audit ===== */
:root {
  --nested-row-gap: 12px;
  --settings-section-gap: 14px;
  --settings-section-padding: 20px;
}

/* Dynamic row collections must own the spacing between their items. */
#revenueOnlyList,
#closedDaysList {
  display: grid;
  gap: var(--nested-row-gap);
}

/* The section owns heading-to-list spacing; the heading must not add a second margin. */
.revenue-only-section {
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
}
.revenue-only-section > .subsection-heading {
  margin-bottom: 0;
}

/* Settings use one internal rhythm instead of a mix of legacy margins. */
.settings-section {
  display: grid;
  gap: var(--settings-section-gap);
  padding: var(--settings-section-padding) 0;
  border-top: 1px solid var(--plan-stat-border);
}
.dialog-copy + .settings-section {
  padding-top: 0;
  border-top: 0;
}
.settings-section > .eyebrow,
.settings-section > .form-grid,
.settings-section > .field,
.settings-section > .mini-note,
.settings-section > .test-date-actions,
.settings-section > .toggle-setting-row {
  margin-block: 0;
}
.settings-section > .mini-note {
  margin-top: 0;
}
.toggle-setting-row {
  gap: var(--space-4);
  margin-bottom: 0;
}
.test-date-actions {
  gap: var(--space-2);
  margin-top: 0;
}
.test-settings-section > .field {
  margin-top: 0;
}

/* Rows have a little more internal breathing room and a consistent content rhythm. */
.missing-day-row,
.revenue-only-row {
  gap: var(--space-4);
  padding: var(--space-4);
}
.missing-day-row > div:first-child,
.revenue-only-row > div:first-child,
.revenue-only-row > div:nth-child(2) {
  gap: var(--space-1);
}

/* Small explanatory panels should not visually stick to the control above them. */
.settings-section .mini-note {
  padding: var(--space-3) var(--space-4);
}

@media (max-width: 760px) {
  :root {
    --nested-row-gap: 10px;
    --settings-section-gap: 12px;
    --settings-section-padding: 18px;
  }
  .missing-day-row,
  .revenue-only-row {
    gap: var(--space-3);
    padding: var(--space-3);
  }
  .revenue-only-section {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
  }
}


/* Remaining dynamic collections use the same container-owned spacing. */
#gapRecoveryDays {
  display: grid;
  gap: var(--nested-row-gap);
}
.gap-day-card,
.gap-day-card + .gap-day-card {
  margin-top: 0;
}
.employee-picker-list {
  gap: var(--nested-row-gap);
}

/* The last settings section already provides its own content spacing; avoid a doubled bottom gap before actions. */
.test-settings-section {
  padding-bottom: 0;
}
#storeSettingsForm > .dialog-actions {
  margin-top: var(--space-5);
}

/* ===== v19 live appearance + day entry redesign ===== */
:root {
  --day-entry-section-bg: color-mix(in srgb, var(--surface-2) 84%, var(--surface));
  --day-entry-section-border: color-mix(in srgb, var(--line) 88%, transparent);
  --onboarding-step-bg: color-mix(in srgb, var(--surface) 94%, var(--bg));
  --onboarding-step-active-bg: color-mix(in srgb, var(--brand-soft) 78%, var(--surface));
  --onboarding-step-done-bg: color-mix(in srgb, var(--brand-soft) 42%, var(--surface));
}

/* The setup rail is a real themed component, not a set of white pills. */
.onboarding-progress span {
  background: var(--onboarding-step-bg);
  border-color: var(--line);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--surface) 70%, transparent);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.onboarding-progress span.active {
  background: var(--onboarding-step-active-bg);
  border-color: color-mix(in srgb, var(--brand) 68%, var(--line));
  color: var(--brand);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 10%, transparent);
}
.onboarding-progress span.done {
  background: var(--onboarding-step-done-bg);
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
  color: color-mix(in srgb, var(--brand) 82%, var(--text));
}
:root[data-theme="dark"] .onboarding-progress span {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
:root[data-theme="dark"] .onboarding-progress span.active {
  color: color-mix(in srgb, var(--brand) 72%, white);
}
:root[data-theme="dark"] .onboarding-progress span.done {
  color: color-mix(in srgb, var(--brand) 66%, white);
}

/* Day without a full close: rebuilt as a grouped data-entry flow. */
.day-entry-dialog {
  width: min(700px, calc(100vw - 30px));
}
.day-entry-form {
  display: grid;
  gap: var(--space-4);
}
.day-entry-header {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: var(--space-4);
  align-items: start;
}
.day-entry-header > div:last-child {
  min-width: 0;
}
.day-entry-header h2 {
  margin: 2px 0 5px;
  font-size: 28px;
  letter-spacing: -.035em;
}
.day-entry-header p {
  margin: 0;
  max-width: 580px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.day-entry-section {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--day-entry-section-border);
  border-radius: 16px;
  background: var(--day-entry-section-bg);
}
.day-entry-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.day-entry-section-head > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.day-entry-section-head strong {
  font-size: 14px;
  line-height: 1.3;
}
.day-entry-section-head small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.day-entry-date-section {
  grid-template-columns: minmax(0,1fr) minmax(210px,.55fr);
  align-items: end;
}
.day-entry-date-section .day-entry-section-head {
  align-self: center;
}
.day-entry-date-field {
  margin: 0;
}
.day-entry-revenue-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: var(--space-3);
}
.day-entry-total {
  min-width: 132px;
  display: grid;
  gap: 2px;
  justify-items: end;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.day-entry-total span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .045em;
}
.day-entry-total strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.day-entry-extra-section {
  background: color-mix(in srgb, var(--day-entry-section-bg) 86%, var(--brand-soft));
}
.day-entry-extra-section > .field,
.day-entry-revenue-grid > .field {
  margin: 0;
}
.day-entry-note-field textarea {
  min-height: 70px;
  resize: vertical;
  line-height: 1.45;
}
.day-entry-dialog .field-help {
  margin-top: 6px;
}
.day-entry-dialog .form-error {
  margin: 0;
}
.day-entry-actions {
  margin-top: 0;
}

@media (max-width: 650px) {
  .day-entry-dialog {
    width: min(100% - 18px, 700px);
  }
  .day-entry-form {
    gap: var(--space-3);
  }
  .day-entry-header {
    gap: var(--space-3);
  }
  .day-entry-header h2 {
    font-size: 24px;
  }
  .day-entry-section {
    padding: var(--space-3);
    gap: var(--space-3);
    border-radius: 14px;
  }
  .day-entry-date-section {
    grid-template-columns: 1fr;
  }
  .day-entry-revenue-grid {
    grid-template-columns: 1fr;
  }
  .day-entry-section-head {
    align-items: flex-start;
  }
  .day-entry-total {
    min-width: 112px;
    padding: 9px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .onboarding-progress span { transition: none; }
}

/* v19 mobile polish for the rebuilt day entry dialog. */
.day-entry-dialog {
  max-height: calc(100dvh - 28px);
  overflow: auto;
  overscroll-behavior: contain;
}
@media (max-width: 650px) {
  .day-entry-revenue-section .day-entry-section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .day-entry-total {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    justify-items: initial;
  }
  .day-entry-total strong {
    font-size: 19px;
    white-space: nowrap;
  }
  .day-entry-actions {
    position: sticky;
    bottom: -1px;
    z-index: 2;
    padding-top: var(--space-2);
    background: linear-gradient(to bottom, transparent, var(--surface) 24%);
  }
}


/* ===== v21 component consistency + visual QA ===== */
:root {
  --control-height: 48px;
  --control-height-large: 56px;
  --control-padding-inline: 14px;
  --layout-grid-gap: 16px;
  --layout-grid-gap-mobile: 12px;
  --compact-gap: 12px;
}

/* Base form controls: one geometry and one vertical baseline everywhere. */
.text-input,
.month-picker,
.money-input,
.count-input,
.text-area {
  border-radius: var(--radius-md);
}

.text-input,
.month-picker {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 0 var(--control-padding-inline);
  line-height: 1.2;
  font-weight: 650;
}

input.text-input,
input.month-picker {
  display: block;
}

.text-input::placeholder,
.money-input input::placeholder,
.text-area::placeholder {
  font-weight: 500;
}

/* Native select arrows are not visually consistent across browsers. */
select.text-input,
select.gap-status-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none'%3E%3Cpath d='M5 7l4 4 4-4' stroke='%23707873' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px 18px;
}
:root[data-theme="dark"] select.text-input,
:root[data-theme="dark"] select.gap-status-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18' fill='none'%3E%3Cpath d='M5 7l4 4 4-4' stroke='%23A9B4AD' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Money fields used to have a 45px wrapper around a 52px input, which clipped the text. */
.money-input {
  height: var(--control-height);
  min-height: var(--control-height);
  align-items: stretch;
}
.money-input input {
  height: 100%;
  min-height: 0;
  padding: 0 6px 0 var(--control-padding-inline);
  line-height: 1.15;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.money-input > span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--control-padding-inline) 0 8px;
  line-height: 1;
}
.large-money-input {
  height: var(--control-height-large);
  min-height: var(--control-height-large);
}
.large-money-input input {
  height: 100%;
  min-height: 0;
  font-size: 24px;
  line-height: 1.1;
  padding-top: 0;
  padding-bottom: 0;
}

.count-input {
  height: 40px;
  min-height: 40px;
  padding: 0 8px;
  line-height: 1.2;
}

.text-area,
textarea.text-input {
  height: auto;
  min-height: 84px;
  padding: 12px var(--control-padding-inline);
  line-height: 1.45;
}

/* Icon-only buttons are centered geometrically, never by text glyph metrics. */
.icon-button {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  letter-spacing: 0;
}
.icon-button .icon-dots {
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
}

/* Equal row/column rhythm inside comparable grids. */
.form-grid,
.profiles-grid,
.stats-grid,
.store-stats-grid,
.total-grid,
.plan-stats-grid,
.cash-position,
.collection-summary,
.profile-custom-grid,
.overview-support-grid,
.analytics-grid,
.setup-grid,
.onboarding-form-grid,
.day-entry-revenue-grid,
.edit-meta-grid,
.opening-entry-grid {
  gap: var(--layout-grid-gap);
}

/* Repeated cards/rows use one compact rhythm as well. */
.history-list,
#revenueOnlyList,
#closedDaysList,
#gapRecoveryDays,
.employee-picker-list,
.cash-operations-list,
.expense-list,
.onboarding-profile-list {
  gap: var(--compact-gap);
}

/* Keep field labels consistently separated from their control. */
.field {
  gap: 8px;
}
.field > span {
  line-height: 1.3;
}

/* Onboarding monetary fields should not inherit old ad-hoc top margins. */
.onboarding-card .setup-money-field {
  margin-top: 20px;
}
.onboarding-card .large-money-input {
  width: 100%;
}

/* Key/value summary in onboarding uses symmetric spacing. */
.onboarding-total-panel {
  gap: 12px;
  padding: 16px;
}

/* Small-screen grids keep the same horizontal/vertical spacing within the grid. */
@media (max-width: 760px) {
  .form-grid,
  .profiles-grid,
  .stats-grid,
  .store-stats-grid,
  .total-grid,
  .plan-stats-grid,
  .cash-position,
  .collection-summary,
  .profile-custom-grid,
  .overview-support-grid,
  .analytics-grid,
  .setup-grid,
  .onboarding-form-grid,
  .day-entry-revenue-grid,
  .edit-meta-grid,
  .opening-entry-grid {
    gap: var(--layout-grid-gap-mobile);
  }

  .text-input,
  .month-picker,
  .money-input {
    min-height: var(--control-height);
  }

  .large-money-input {
    height: 54px;
    min-height: 54px;
  }
  .large-money-input input {
    font-size: 22px;
  }
}

/* v21.1: dark-theme select keeps the custom chevron geometry. */
:root[data-theme="dark"] select.text-input,
:root[data-theme="dark"] select.gap-status-select {
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) 50%;
  background-size: 18px 18px;
}

/* v21.2: final consistency cleanup found by the mobile/settings audit. */
@media (min-width: 761px) {
  .settings-section { gap: var(--space-4); }
}
@media (max-width: 650px) {
  .day-entry-actions {
    position: static;
    bottom: auto;
    padding-top: 0;
    background: none;
  }
}
