/* The selected appearance applies to every screen; receipts return to white for print. */
:root[data-theme="light"] {
  --ink: #272426;
  --muted: #706b6c;
  --line: #e8e3e1;
  --surface: #fff;
  --red-dark: #951d17;
  --red-light: #fff0ed;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #f4f1f2;
  --muted: #b6b3bb;
  --line: #393d46;
  --surface: #23262d;
  --red-dark: #ff7975;
  --red-light: #392326;
  --shadow: 0 12px 32px rgba(0,0,0,.13), 0 1px 2px rgba(0,0,0,.15);
  color: var(--ink);
  background: #15171c;
  color-scheme: dark;
}

/* Header settings menu */
.site-header .settings-dropdown { position: relative; flex: none; }
.site-header .settings-dropdown summary {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
  background: rgba(255,255,255,.07); color: #f4f0f1; list-style: none;
}
.site-header .settings-dropdown summary::-webkit-details-marker { display: none; }
.site-header .settings-dropdown summary:hover,
.site-header .settings-dropdown[open] summary { background: rgba(207,23,27,.17); border-color: rgba(207,23,27,.42); }
.site-header .settings-panel {
  position: absolute; z-index: 90; top: calc(100% + 13px); right: 0; width: 220px;
  padding: 15px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); color: var(--ink); box-shadow: 0 18px 45px rgba(0,0,0,.23);
  white-space: normal;
}
.settings-panel > strong { display: block; font-size: 14px; }
.settings-caption { display: block; margin: 17px 0 8px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.theme-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb,var(--surface) 85%,var(--ink)); }
.site-header .settings-panel .theme-choices button {
  min-height: 34px; padding: 5px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 750;
}
.site-header .settings-panel .theme-choices button:hover { color: var(--ink); background: color-mix(in srgb,var(--surface) 87%,var(--ink)); }
.site-header .settings-panel .theme-choices button[aria-pressed="true"] { color: var(--red-dark); background: var(--surface); box-shadow: 0 1px 5px rgba(0,0,0,.12); }
.settings-panel form { margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line); }
.site-header .settings-panel .settings-sign-out {
  width: 100%; min-height: 36px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left;
  font-size: 12px; font-weight: 750;
}
.site-header .settings-panel .settings-sign-out:hover { border-color: var(--red); color: var(--red-dark); background: var(--red-light); text-decoration: none; }
.site-header .settings-panel .settings-users-link { display: block; margin-top: 13px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 12px; font-weight: 750; }
.site-header .settings-panel .settings-users-link:hover { border-color: var(--red); color: var(--red-dark); background: var(--red-light); text-decoration: none; }

/* Light uses a light header and hero to match the rest of the workspace. */
:root[data-theme="light"] .site-header {
  background: radial-gradient(circle at 10% -80%,rgba(207,23,27,.075),transparent 43%),#e2dede;
  border-bottom-color: #ddd7d6; box-shadow: 0 8px 24px rgba(43,33,36,.07);
}
:root[data-theme="light"] .site-header .brand-copy,
:root[data-theme="light"] .site-header .account-copy strong { color: #302b2d; }
:root[data-theme="light"] .site-header .account-copy small { color: #736b6e; }
:root[data-theme="light"] .site-header .account,
:root[data-theme="light"] .site-header nav { border-color: #e0d9d8; background: rgba(255,255,255,.6); }
:root[data-theme="light"] .site-header nav > a,
:root[data-theme="light"] .site-header .reports-dropdown summary { color: #585154; }
:root[data-theme="light"] .site-header nav > a:hover,
:root[data-theme="light"] .site-header .reports-dropdown summary:hover,
:root[data-theme="light"] .site-header .reports-dropdown[open] summary { color: #302b2d; background: #ede6e5; }
:root[data-theme="light"] .site-header nav > a.active,
:root[data-theme="light"] .site-header .reports-dropdown summary.active { color: #fff; }
:root[data-theme="light"] .site-header .settings-dropdown summary { color: #383235; border-color: #d5cccb; background: #fff; }
:root[data-theme="light"] .site-header .settings-dropdown summary:hover,
:root[data-theme="light"] .site-header .settings-dropdown[open] summary { background: #fff1ef; }
:root[data-theme="light"] .site-header .reports-menu { border-color: var(--line); background: var(--surface); }
:root[data-theme="light"] .home-hero {
  color: #2c292c; border-color: #ded7d8;
  background: radial-gradient(circle at 81% 12%,rgba(205,26,32,.09),transparent 38%),
              radial-gradient(circle at 5% 98%,rgba(177,28,32,.06),transparent 42%),
              linear-gradient(125deg,#f6f3f3,#e8e5e6 75%,#f1eeee);
}
:root[data-theme="light"] .home-hero::before { background: repeating-linear-gradient(125deg,transparent 0 74px,rgba(90,67,73,.025) 75px,transparent 76px 151px); }
:root[data-theme="light"] .home-hero::after { border-color: rgba(97,71,77,.13); }
:root[data-theme="light"] .home-company { color: #50474b; }
:root[data-theme="light"] .auth-brand {
  color: #342e31; background: radial-gradient(circle at 82% 10%,rgba(212,26,32,.14),transparent 39%),linear-gradient(145deg,#eae5e5,#d7d2d3 75%);
}
:root[data-theme="light"] .auth-company { color: #4a4145; }

/* Dark surfaces, text, tables, forms, dialogs, and market cards. */
:root[data-theme="dark"] body:not(.auth-body),
:root[data-theme="dark"] .home-body { background: #15171c !important; color: var(--ink); }
:root[data-theme="dark"] .site-header { border-bottom-color: #343841; }
:root[data-theme="dark"] .site-header .reports-menu { border-color: var(--line); background: var(--surface); }
:root[data-theme="dark"] .site-header .reports-menu a { color: var(--ink); }
:root[data-theme="dark"] .site-header .reports-menu a:hover,
:root[data-theme="dark"] .site-header .reports-menu a.active { color: var(--red-dark); background: var(--red-light); }
:root[data-theme="dark"] .page-head { border-bottom-color: var(--line); }
:root[data-theme="dark"] .page-head h1,
:root[data-theme="dark"] .card strong,
:root[data-theme="dark"] .details dd { color: var(--ink); }
:root[data-theme="dark"] .page-head .today { border-color: var(--line); background: var(--surface); color: var(--muted); }
:root[data-theme="dark"] .card span,
:root[data-theme="dark"] .card small,
:root[data-theme="dark"] .details dt,
:root[data-theme="dark"] .entry-form label,
:root[data-theme="dark"] .report-filter label,
:root[data-theme="dark"] .receipt-vendor-form label { color: var(--muted); }
:root[data-theme="dark"] .button:not(.primary),
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  border-color: var(--line); background: #2a2e36; color: var(--ink);
}
:root[data-theme="dark"] .button:not(.primary):hover { border-color: #777d8a; background: #343943; }
:root[data-theme="dark"] .button.primary:hover { border-color: #a9151c; background: #a9151c; }
:root[data-theme="dark"] .site-header .settings-panel .theme-choices button[aria-pressed="true"] { color: #ffaaa6; }
:root[data-theme="dark"] input[readonly] { background: #252931; color: var(--muted); }
:root[data-theme="dark"] input::placeholder { color: #8f939d; }
:root[data-theme="dark"] .table-wrap { border-color: var(--line); }
:root[data-theme="dark"] th,
:root[data-theme="dark"] .pgm-table th { border-color: var(--line); background: #292d35; color: #b6b3bb; }
:root[data-theme="dark"] td,
:root[data-theme="dark"] .pgm-table td { border-color: var(--line); color: #e7e4e7; }
:root[data-theme="dark"] tbody tr:hover { background: #2c3038; }
:root[data-theme="dark"] .pill.inventory { background: #20382d; color: #a6dfb9; }
:root[data-theme="dark"] .pill.partial { background: #463321; color: #f4d49b; }
:root[data-theme="dark"] .pill.sold { background: #34353b; color: #c5c1c4; }
:root[data-theme="dark"] .lot-table tr.selected,
:root[data-theme="dark"] .cycle-option:hover,
:root[data-theme="dark"] .cycle-option:has(input:checked) { background: #39272b; }
:root[data-theme="dark"] .reports-dropdown summary:hover { color: #fff; }
:root[data-theme="dark"] .home-hero { border-color: #3a3d45; }
:root[data-theme="dark"] .pgm-section-head h2,
:root[data-theme="dark"] .pgm-panel-head h3 { color: var(--ink); }
:root[data-theme="dark"] .pgm-section-head p,
:root[data-theme="dark"] .pgm-panel-head p,
:root[data-theme="dark"] .pgm-footnote,
:root[data-theme="dark"] .pgm-table td small { color: var(--muted); }
:root[data-theme="dark"] .pgm-panel { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow); }
:root[data-theme="dark"] .pgm-refresh { border-color: var(--line); background: #2a2e36; color: #ff8884; }
:root[data-theme="dark"] .pgm-refresh:hover { background: #353036; }
:root[data-theme="dark"] .pgm-panel-icon { border-color: #674044; background: #39272b; color: #ff7773; }
:root[data-theme="dark"] .pgm-footnote a { color: #ff8884; }
:root[data-theme="dark"] .receipt-sheet,
:root[data-theme="dark"] .receipt-save-dialog,
:root[data-theme="dark"] .cycle-edit-dialog { border-color: var(--line); background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .receipt-price-form button,
:root[data-theme="dark"] .receipt-quantity-add,
:root[data-theme="dark"] .receipt-average-toggle { border-color: var(--line); background: #2a2e36; color: var(--ink); }
:root[data-theme="dark"] .receipt-price-form button:hover,
:root[data-theme="dark"] .receipt-quantity-add:hover { background: #39272b; }
:root[data-theme="dark"] .cycle-option { border-color: var(--line); color: var(--ink); }
:root[data-theme="dark"] .cycle-options legend { color: var(--ink); }
:root[data-theme="dark"] .receipt-add-toast { border-color: #467254; background: #20382d; color: #b7eac4; }
:root[data-theme="dark"] .receipt-add-toast.is-error { border-color: #79433c; background: #39272b; color: #ffaaa2; }
:root[data-theme="dark"] .auth-body { background: radial-gradient(circle at 5% 8%,rgba(207,23,27,.1),transparent 35%),linear-gradient(145deg,#17191e,#111317); }
:root[data-theme="dark"] .auth-main { border-color: var(--line); background: var(--surface); box-shadow: 0 35px 100px rgba(0,0,0,.35); }
:root[data-theme="dark"] .auth-card h1 { color: var(--ink); }
:root[data-theme="dark"] .auth-card .entry-form label { color: var(--muted); }

@media print {
  :root[data-theme="dark"], :root[data-theme="dark"] body { color-scheme: light; background: #fff !important; color: #272426 !important; }
  :root[data-theme="dark"] .receipt-sheet { background: #fff !important; color: #272426 !important; }
  :root[data-theme="dark"] .receipt-sheet th { background: #faf8f7 !important; color: #7d7476 !important; }
  :root[data-theme="dark"] .receipt-sheet td { color: #423b3d !important; border-color: #f0eceb !important; }
}
