:root {
  --red-900: #7a1c1c;
  --red-700: #a52a2a;
  --red-500: #c94a4a;
  --red-100: #fbeaea;
  --red-50:  #fdf5f5;
  --ink: #2a1f1f;
  --muted: #8a7272;
  --line: #efdcdc;
  --bg: #fffafa;
}

* { box-sizing: border-box; }
body { margin: 0; font: 13px/1.4 "Inter", system-ui, sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }
h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--red-900); }
h3.set-title { font-size: 13px; margin: 18px 0 6px; color: var(--red-700); }
.muted { color: var(--muted); }

.site-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--red-50); border-bottom: 1px solid var(--line); }
.brand-logo { height: 40px; width: auto; display: block; }
body { position: relative; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.site-header, .site-footer { flex-shrink: 0; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: url("../assets/logo.png") center / min(60vw, 480px) no-repeat; opacity: 0.05; pointer-events: none; }
.brand-tag { font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 10px; color: var(--ink); text-decoration: none; border-radius: 4px; }
.tab.active, .tab:hover { background: var(--red-100); color: var(--red-900); }

.wrap { padding: 16px 20px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
#view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.group-title { font-weight: 600; margin: 10px 0 4px; color: var(--ink); }
.set-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--red-700); margin: 18px 0 6px; }
.set-actions button { background: none; border: none; cursor: pointer; color: var(--red-700); font-size: 12px; margin-left: 6px; }

table.xl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.xl th, table.xl td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.xl th { font-weight: 600; color: var(--red-700); background: var(--red-50); position: sticky; top: 0; z-index: 1; }
table.xl td.num, table.xl th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; padding-right: 0; }
table.xl td:has(.status-wrap) { width: 1%; white-space: nowrap; }
.period-wrap { position: relative; }
.pp-toggle { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; }
.pp-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); padding: 10px; }
.pp-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.pp-tabs button, .pp-head button, .pp-foot button, .pp-grid button { font: inherit; background: transparent; border: none; cursor: pointer; color: var(--ink); border-radius: 4px; }
.pp-tabs button { flex: 1; padding: 4px; font-size: 12px; }
.pp-tabs button.on, .pp-grid button.on { background: var(--red-700); color: #fff; }
.pp-tabs button:hover, .pp-head button:hover, .pp-foot button:hover, .pp-grid button:hover { background: var(--red-50); }
.pp-tabs button.on:hover, .pp-grid button.on:hover { background: var(--red-700); }
.pp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.pp-head button { padding: 2px 8px; font-size: 16px; }
.pp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.pp-grid.daily { grid-template-columns: repeat(7, 1fr); }
.pp-grid button { padding: 6px 0; font-size: 12px; }
.pp-grid span { display: block; }
.pp-foot { margin-top: 8px; text-align: center; }
.pp-foot button { font-size: 12px; color: var(--red-700); padding: 2px 10px; }
body[data-page="inventory.html"] #view { margin-right: -20px; }
table.xl th:last-child { padding-right: 0; }
.status-wrap { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
table.xl th:last-child { text-align: right; }
td.actions button { margin-left: 4px; font-size: 11px; background: none; border: none; color: var(--red-700); cursor: pointer; }
.dropdown { position: relative; display: inline-block; }
.kebab-btn { font-size: 18px !important; font-weight: bold; color: var(--muted) !important; padding: 0 4px; margin-right: -4px; background: transparent; border: none; cursor: pointer; }
.kebab-btn:hover { color: var(--ink) !important; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 10; min-width: 110px; flex-direction: column; text-align: left; overflow: hidden; }
.dropdown:hover .dropdown-menu, .dropdown:focus-within .dropdown-menu { display: flex; }
.dropdown-menu button { margin: 0 !important; padding: 8px 12px; width: 100%; text-align: left; background: transparent; color: var(--ink); border: none; border-bottom: 1px solid var(--line) !important; border-radius: 0; font-size: 12px; cursor: pointer; transition: background 0.15s; }
.dropdown-menu button:last-child { border-bottom: none !important; }
.dropdown-menu button:hover { background: var(--red-50); }

.btn { font: inherit; padding: 6px 12px; border-radius: 4px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--red-700); color: #fff; }
.btn-ghost { background: transparent; color: var(--red-700); border-color: var(--line); }
.btn-danger { background: var(--red-900); color: #fff; }
.seg { display: flex; gap: 4px; }
.seg .btn.active { background: var(--red-100); }

.site-footer { display: flex; justify-content: space-between; padding: 12px 20px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); }

.toast-wrap { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 50; }
.toast { padding: 8px 14px; background: var(--ink); color: #fff; border-radius: 4px; transition: opacity .3s; }
.toast-success { background: var(--red-700); }
.toast-error { background: var(--red-900); }
.toast.out { opacity: 0; }

.modal-overlay { position: fixed; inset: 0; background: rgba(42,31,31,.25); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; z-index: 40; }
.modal-overlay.show { opacity: 1; }
.modal { background: #fff; width: min(420px, 92vw); border-radius: 6px; padding: 16px; }
.modal-title { font-weight: 600; color: var(--red-900); margin-bottom: 10px; }
.modal-body { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { min-width: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { padding: 6px 2px 10px; border-bottom: 1px solid var(--line); }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi b { display: block; font-size: 18px; margin-top: 4px; color: var(--red-700); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart { padding: 6px 2px; overflow: hidden; }
.chart h4 { margin: 0 0 10px; font-size: 13px; color: var(--red-700); display: flex; justify-content: space-between; align-items: center; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; font-size: 11px; font-weight: 600; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; }
.bar-stack { width: 70%; display: flex; flex-direction: column; justify-content: flex-end; }
.seg-paid { background: var(--red-700); }
.seg-unpaid { background: #e8b4b4; }
.legend { font-size: 10px; font-weight: normal; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-left: 6px; }
.legend i.seg-paid, .legend i.seg-unpaid { height: 8px; }
@media (max-width: 720px) { .dash-grid { grid-template-columns: 1fr; } .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.field input, .field select, .field textarea { font: inherit; padding: 6px; border: 1px solid var(--line); border-radius: 4px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.checklist { max-height: 60vh; overflow: auto; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 12px; cursor: pointer; }
.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.modal.order-modal { width: min(640px, 94vw); max-height: 88vh; overflow: auto; }

/* Thin, theme-matched scrollbars */
* { scrollbar-width: thin; scrollbar-color: #e0b0b0 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e0b0b0; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-700); }
.sec { margin-bottom: 6px; }
.sec:last-child { margin-bottom: 0; }
.sec-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.sec-name { font-weight: 600; color: var(--red-900); }
.sec-limit { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.sec-limit input { width: 60px; font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.pill { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.pill.on { background: var(--red-700); color: #fff; border-color: var(--red-700); }
.order-note { min-height: 0; color: var(--red-700); font-size: 12px; }
.order-note:empty { display: none; }
.qtys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.qty-row { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.qty-row input { width: 40px; font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; }