/* ============ Tokens ============ */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --border: #e4e0d5;
  --border-strong: #d2ccbd;
  --text: #1c2620;
  --muted: #66726a;
  --faint: #8d978f;
  --primary: #1f6f4a;
  --primary-strong: #175a3b;
  --primary-ink: #ffffff;
  --primary-soft: #e3f0e8;
  --sidebar: #15241b;
  --sidebar-2: #1d3226;
  --sidebar-text: #dbe6de;
  --sidebar-muted: #8ea395;
  --pos: #1f7a46;
  --neg: #b42318;
  --neg-soft: #fbe9e7;
  --warn: #9a5a06;
  --warn-soft: #fbefd8;
  --focus: #2f8f62;
  --shadow-sm: 0 1px 2px rgba(28, 38, 32, .06), 0 1px 3px rgba(28, 38, 32, .05);
  --shadow-lg: 0 18px 50px rgba(20, 30, 24, .22);
  --radius: 14px;
  --radius-sm: 9px;
  /* The printable sheet always looks like paper */
  --paper: #ffffff;
  --ink: #111111;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411;
    --surface: #151d18;
    --surface-2: #1b2620;
    --border: #26332b;
    --border-strong: #35453b;
    --text: #e5ece7;
    --muted: #9caaa2;
    --faint: #74837a;
    --primary: #4cc38a;
    --primary-strong: #6fd6a2;
    --primary-ink: #052113;
    --primary-soft: #173426;
    --sidebar: #0a0f0c;
    --sidebar-2: #15201a;
    --sidebar-text: #dbe6de;
    --sidebar-muted: #7f9487;
    --pos: #5fd394;
    --neg: #f2837a;
    --neg-soft: #3a1916;
    --warn: #f0b54a;
    --warn-soft: #3a2c12;
    --focus: #4cc38a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1411;
  --surface: #151d18;
  --surface-2: #1b2620;
  --border: #26332b;
  --border-strong: #35453b;
  --text: #e5ece7;
  --muted: #9caaa2;
  --faint: #74837a;
  --primary: #4cc38a;
  --primary-strong: #6fd6a2;
  --primary-ink: #052113;
  --primary-soft: #173426;
  --sidebar: #0a0f0c;
  --sidebar-2: #15201a;
  --sidebar-text: #dbe6de;
  --sidebar-muted: #7f9487;
  --pos: #5fd394;
  --neg: #f2837a;
  --neg-soft: #3a1916;
  --warn: #f0b54a;
  --warn-soft: #3a2c12;
  --focus: #4cc38a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, .money-text { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ============ Buttons & fields ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--neg); }
.btn.danger:hover { background: var(--neg-soft); }
.btn.sm { height: 32px; padding: 0 11px; font-size: .84rem; }
.btn.block { width: 100%; height: 44px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.text-link { color: var(--primary); font-weight: 600; font-size: .88rem; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field .hint { font-size: .78rem; font-weight: 400; color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.money input { padding-left: 24px; font-variant-numeric: tabular-nums; }
.form-error { margin: 0 24px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--neg-soft); color: var(--neg); font-size: .9rem; font-weight: 500; }

/* ============ Loading ============ */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Brand ============ */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-on-dark { color: #fff; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M10 9h9a4 4 0 0 1 0 8h-7m0 0h8a4 4 0 0 1 0 8H10V9' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
:root[data-theme="dark"] .logo { background-color: #1f6f4a; }

/* ============ Auth ============ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.auth-aside {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 40px 48px; color: var(--sidebar-text);
  background:
    radial-gradient(1100px 500px at -10% 110%, rgba(76, 195, 138, .22), transparent 60%),
    radial-gradient(700px 400px at 110% -10%, rgba(240, 181, 74, .14), transparent 60%),
    var(--sidebar);
}
.auth-pitch h2 { font-size: 2rem; line-height: 1.2; color: #fff; max-width: 15ch; margin-bottom: 14px; letter-spacing: -.02em; }
.auth-pitch p { max-width: 40ch; color: var(--sidebar-muted); font-size: 1rem; }
.auth-foot { color: var(--sidebar-muted); font-size: .85rem; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .form-error { margin: 0; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 22px; color: var(--muted); font-size: .92rem; }
.auth-actions { display: flex; gap: 10px; margin-top: 8px; }
.auth-actions .btn { flex: 1; }
.notice { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); margin-bottom: 20px; font-size: .92rem; }
.notice svg { color: var(--primary); margin-top: 2px; }

/* ============ Shell ============ */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px; background: var(--sidebar); color: var(--sidebar-text);
}
.sidebar .brand { padding: 0 8px; }
/* Department switcher: the page's dropdown, styled for the dark sidebar */
.dept-switch { margin-top: -12px; }
.dept-switch .field { gap: 6px; }
.dept-switch .field > span { padding: 0 8px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); }
.dept-switch .picker-trigger {
  padding: 7px 10px; border-radius: 12px; border-color: rgba(255, 255, 255, .07);
  background: var(--sidebar-2); color: #fff;
}
.dept-switch .picker-trigger:hover { background: #24402f; border-color: rgba(255, 255, 255, .12); }
.dept-switch .picker-trigger[aria-expanded="true"], .dept-switch .picker-trigger:focus-visible {
  border-color: rgba(76, 195, 138, .55); box-shadow: 0 0 0 3px rgba(76, 195, 138, .15);
}
.dept-switch .picker-trigger .chev { color: var(--sidebar-muted); }
.dept-switch .picker-trigger[aria-expanded="true"] .chev { color: #fff; }
.dept-switch .picker-current .opt-label { font-weight: 650; }
.dept-switch .picker-menu { background: #1f3427; border-color: rgba(255, 255, 255, .09); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); }
.dept-switch .picker-option { color: var(--sidebar-text); }
.dept-switch .picker-option.active { background: rgba(255, 255, 255, .07); color: #fff; }
.dept-switch .picker-option .check { color: #4cc38a; }
.dept-switch .picker-option[aria-selected="true"] .store-badge { background: #4cc38a; color: #072a17; }
.dept-switch .store-switch-label { display: block; padding: 0 8px; margin-bottom: 6px; }
.dept-single { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--sidebar-2); color: #fff; font-weight: 650; }

/* Store switcher (custom listbox) */
.store-switch { position: relative; display: flex; flex-direction: column; gap: 6px; }
.store-switch-label { padding: 0 8px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); }
.store-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 12px;
  background: var(--sidebar-2); color: #fff; font: inherit; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.store-trigger:hover { background: #24402f; border-color: rgba(255, 255, 255, .12); }
.store-trigger[aria-expanded="true"] { border-color: rgba(76, 195, 138, .55); box-shadow: 0 0 0 3px rgba(76, 195, 138, .15); }
.store-trigger:disabled { cursor: default; }
.store-trigger:disabled:hover { background: var(--sidebar-2); border-color: rgba(255, 255, 255, .07); }
.store-trigger:disabled .store-chevron { display: none; }
.store-trigger-name { flex: 1; min-width: 0; font-weight: 650; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-chevron { color: var(--sidebar-muted); transition: transform .2s ease; }
.store-trigger[aria-expanded="true"] .store-chevron { transform: rotate(180deg); color: #fff; }
.store-badge {
  display: inline-grid; place-items: center; min-width: 32px; height: 24px; padding: 0 7px; border-radius: 7px; flex: none;
  background: rgba(76, 195, 138, .16); color: #8fe3b8; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.store-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  max-height: min(360px, 60vh); overflow-y: auto;
  background: #1f3427; border: 1px solid rgba(255, 255, 255, .09); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .25);
  transform-origin: top center; animation: menu-in .14s ease-out;
}
.store-menu:focus { outline: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.store-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; color: var(--sidebar-text); font-size: .93rem; cursor: pointer;
}
.store-option .opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-option .opt-check { color: #4cc38a; visibility: hidden; }
.store-option.active { background: rgba(255, 255, 255, .07); color: #fff; }
.store-option[aria-selected="true"] { color: #fff; font-weight: 650; }
.store-option[aria-selected="true"] .opt-check { visibility: visible; }
.store-option[aria-selected="true"] .store-badge { background: #4cc38a; color: #072a17; }
.store-sep { height: 1px; margin: 4px 8px; background: rgba(255, 255, 255, .1); list-style: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: .94rem;
}
.nav a svg { color: var(--sidebar-muted); }
.nav a:hover { background: var(--sidebar-2); }
.nav a.active { background: var(--sidebar-2); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #4cc38a; }
.nav a.active svg { color: #4cc38a; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 16px; }
.who {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.who:hover { background: var(--sidebar-2); }
.who-edit { margin-left: auto; color: var(--sidebar-muted); opacity: 0; transition: opacity .15s; width: 16px; height: 16px; }
.who:hover .who-edit, .who:focus-visible .who-edit { opacity: 1; }
.who-text .add-name { color: #8fe3b8; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: #2b4a37; color: #fff; font-weight: 700; font-size: .9rem; text-transform: uppercase;
}
.who-text { min-width: 0; display: flex; flex-direction: column; }
.who-text strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 600; }
.who-text span { font-size: .78rem; color: var(--sidebar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.side-actions button, .side-actions .file-btn {
  padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--sidebar-muted);
  font: inherit; font-size: .8rem; text-align: left; cursor: pointer;
}
.side-actions button:hover, .side-actions .file-btn:hover { background: var(--sidebar-2); color: #fff; }
.file-btn input { display: none; }
.scrim { display: none; }

.main { min-width: 0; }
.mobilebar { display: none; }
.pages { max-width: 1180px; margin: 0 auto; padding: 32px 32px 80px; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-intro { color: var(--muted); max-width: 70ch; margin: -10px 0 22px; }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; min-width: 0; }
.kpis + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .85rem; padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.kpi .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .hint { font-size: .8rem; color: var(--faint); }
.kpi.feature { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.kpi.feature .label, .kpi.feature .hint { color: inherit; opacity: .85; }

/* Week strip */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2);
  font: inherit; color: inherit; text-align: left; cursor: pointer; min-width: 0;
}
.day:hover { border-color: var(--border-strong); }
.day .dname { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.day .ddate { font-size: .78rem; color: var(--faint); }
.day .damt { margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.day.empty .damt { color: var(--primary); font-weight: 600; font-size: .85rem; }
.day.future { opacity: .5; cursor: default; }
.day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.day.done { background: var(--surface); }
/* Month view: a calendar with weekday headings */
.week-strip.month { gap: 6px; }
.strip-head { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 4px 2px; }
.week-strip.month .day { padding: 8px 10px; min-height: 62px; justify-content: space-between; }
.week-strip.month .dnum { font-size: .82rem; font-weight: 700; color: var(--muted); }
.week-strip.month .damt { margin-top: 2px; font-size: .86rem; }
.week-strip.month .day.empty .damt { font-size: .78rem; }
.day.outside { visibility: hidden; }
.week-strip .damt.short { display: none; }

/* Mini lists */
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.mini-row:first-child { border-top: 0; padding-top: 2px; }
.mini-row .main-col { min-width: 0; }
.mini-row strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .sub { color: var(--muted); font-size: .82rem; }
.mini-row .amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-state { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ============ Tables ============ */
/* Not clipped, so toolbar dropdowns can open past the bottom of the card */
.table-card { padding: 0; }
.table-card > :last-child { border-radius: 0 0 var(--radius) var(--radius); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1 1 240px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 17px; height: 17px; }
.search input { padding-left: 35px; }
.toolbar .month { flex: 0 1 180px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.empty-row { cursor: default; }
table.data tbody tr.empty-row:hover { background: none; }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .vendor { font-weight: 600; }
table.data .sub { color: var(--muted); font-size: .82rem; }
table.data .row-edit { text-align: right; width: 48px; color: var(--faint); }
.date-group td { background: var(--bg); font-size: .78rem; font-weight: 700; color: var(--muted); padding: 7px 16px; text-transform: uppercase; letter-spacing: .05em; cursor: default; }
table.data tbody tr.date-group:hover { background: none; }
.table-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; padding: 13px 16px; color: var(--muted); font-size: .9rem; }
.table-foot strong { color: var(--text); font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill.green { background: var(--primary-soft); color: var(--primary); }
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--neg-soft); color: var(--neg); }

/* ============ Drawer ============ */
.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(480px, 100vw);
  padding: 0; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.drawer[open] { animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer::backdrop { background: rgba(10, 18, 13, .45); }
.drawer form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 14px; }
.drawer-head h2 { font-size: 1.3rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface); }
.drawer-foot .spacer { flex: 1; }
.drawer .form-error { margin-bottom: 4px; }
.vendor-other { margin-top: -8px; }

/* Dropdowns in the add/edit panel (custom listbox) */
.picker { position: relative; }
.picker-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px;
  padding: 6px 10px 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.picker-trigger:hover { border-color: var(--faint); }
.picker-trigger:focus-visible, .picker-trigger[aria-expanded="true"] { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.picker-trigger.invalid { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.picker-current { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.picker-current .opt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-current .placeholder { color: var(--faint); padding-left: 4px; }
.picker-trigger .chev { color: var(--faint); transition: transform .2s ease; }
.picker-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); color: var(--text); }
.picker-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none; max-height: min(460px, 58vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 36px rgba(20, 30, 24, .16), 0 2px 6px rgba(20, 30, 24, .08);
  transform-origin: top center; animation: menu-in .14s ease-out;
}
.picker-menu:focus { outline: none; }
.picker-option { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.picker-option.active { background: var(--surface-2); }
.picker-option .opt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-option .check { color: var(--primary); visibility: hidden; }
.picker-option[aria-selected="true"] { font-weight: 600; }
.picker-option[aria-selected="true"] .check { visibility: visible; }
.opt-hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.opt-icon {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase;
}
.opt-icon.num { font-variant-numeric: tabular-nums; text-transform: none; }
.picker-option[aria-selected="true"] .opt-icon, .picker-current .opt-icon { background: var(--primary-soft); color: var(--primary); }
.picker-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* Small centered dialog (username) */
.modal {
  width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.modal[open] { animation: fade .16s ease-out; }
.modal::backdrop { background: rgba(10, 18, 13, .45); }
.modal form { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.modal h2 { font-size: 1.2rem; }
.modal .form-error { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* One day's sales breakdown */
.day-box { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; }
.day-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.day-head h2 { font-size: 1.2rem; }
.day-body { display: flex; flex-direction: column; gap: 12px; max-height: min(60vh, 520px); overflow-y: auto; }
.db-store { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.db-store header { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); }
.db-store header strong { flex: 1; }
.db-store .store-badge, .db-row .store-badge { background: var(--primary-soft); color: var(--primary); }
.db-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.db-list > .db-row:first-child { border-top: 0; }
.db-store .db-row, .db-store .db-missing { padding-left: 46px; }
.db-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-top: 1px solid var(--border); background: none; color: inherit; font: inherit; text-align: left; }
.day-body > .db-row:first-child { border-top: 0; }
button.db-row { cursor: pointer; }
button.db-row:hover { background: var(--surface-2); }
button.db-row svg { width: 16px; height: 16px; color: var(--faint); }
.db-name { flex: 1; display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.db-note { font-size: .82rem; font-weight: 400; color: var(--muted); }
.db-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.db-missing { margin: 0; padding: 8px 12px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.day-body > .db-missing { border-top: 0; padding: 0; }
.db-empty { margin: 0; color: var(--muted); }
.day-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.day-foot strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; margin-left: 6px; }

/* Excel import preview */
.import-modal { width: min(1000px, calc(100vw - 32px)); }
.import-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.import-head p { margin: 3px 0 0; font-size: .9rem; }
.import-controls { display: flex; flex-wrap: wrap; gap: 12px; }
.import-controls > div:not(:empty) { flex: 1 1 240px; max-width: 340px; }
.import-controls:not(:has(> div:not(:empty))) { display: none; }
.import-summary { display: flex; flex-direction: column; gap: 3px; font-size: .92rem; }
.import-summary .red-text { color: var(--neg); }
.import-table { max-height: min(52vh, 480px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.import-table table.data th { position: sticky; top: 0; z-index: 1; padding: 8px 12px; }
.import-table table.data td { padding: 8px 12px; }
@media (min-width: 641px) { .import-table table.data td { white-space: nowrap; } }
.import-table table.data tbody tr { cursor: default; }
.import-table table.data tr.skip td:not(:last-child) { opacity: .6; }

/* Dropdowns used as toolbar filters (label kept for screen readers only) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.toolbar-picker { flex: 0 1 210px; min-width: 170px; }
.toolbar-picker .field { gap: 0; }
.toolbar-picker .picker-trigger { min-height: 40px; }

/* Audit log */
.audit-table tbody tr { cursor: default; }
.audit-table tbody tr:hover { background: none; }
table.data.audit-table td { vertical-align: top; }
.audit-table .when { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-table .actor { font-weight: 600; white-space: nowrap; }
.audit-table .what .pill { margin-right: 6px; }
.audit-table .what .sub { margin-top: 3px; }
.pill.gray { background: var(--surface-2); color: var(--muted); }

/* Entry type buttons: Vendor / Store transfer / In-store transfer */
.type-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.type-seg label { position: relative; }
.type-seg input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.type-seg span {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 4px 6px;
  border-radius: 9px; color: var(--muted); font-size: .85rem; font-weight: 600; text-align: center; line-height: 1.15;
  transition: background .15s, color .15s;
}
.type-seg span svg { width: 16px; height: 16px; }
.type-seg label:hover span { color: var(--text); }
.type-seg input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.type-seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (max-width: 420px) { .type-seg span svg { display: none; } }

/* ============ Users ============ */
.users { display: flex; flex-direction: column; gap: 14px; }
.user-card { display: flex; flex-direction: column; gap: 16px; }
.user-card.pending { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn-soft), var(--shadow-sm); }
.user-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-top .avatar { background: var(--primary-soft); color: var(--primary); }
.user-id { flex: 1; min-width: 0; }
.user-id strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.user-id span { font-size: .82rem; color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none;
}
.chip span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip input:checked + span::before { background: currentColor; }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip input:disabled + span { cursor: not-allowed; opacity: .7; }
/* Settings */
.settings-card { display: flex; flex-direction: column; gap: 16px; max-width: 980px; }
.settings-card + .settings-card { margin-top: 18px; }
.settings-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.settings-head h2 { font-size: 1.1rem; }
.settings-head p { margin: 4px 0 0; max-width: 70ch; font-size: .92rem; }
.vendor-add { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.vendor-add .field { max-width: 420px; }
.vendor-add .form-error { margin: 0; }
.vendor-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vendor-tools .search { flex: 0 1 320px; }
.vendor-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.vendor-row { display: grid; grid-template-columns: minmax(170px, 1fr) auto auto; align-items: center; gap: 10px 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.vendor-name { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.vendor-name strong { overflow-wrap: anywhere; }
.vendor-row .chips { gap: 6px; }
.vendor-row .chip span { padding: 4px 10px; font-size: .8rem; }
@media (max-width: 900px) {
  .vendor-row { grid-template-columns: 1fr auto; }
  .vendor-row .chips { grid-column: 1 / -1; grid-row: 2; }
}
.maint-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#maint-status.on { color: var(--warn); font-weight: 600; }
/* On/off switch */
.switch { position: relative; flex: 0 0 auto; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span[aria-hidden] { width: 46px; height: 26px; border-radius: 999px; background: var(--border-strong); transition: background .15s; position: relative; }
.switch span[aria-hidden]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + span[aria-hidden] { background: var(--warn); }
.switch input:checked + span[aria-hidden]::after { transform: translateX(20px); }
.switch input:focus-visible + span[aria-hidden] { outline: 2px solid var(--focus); outline-offset: 2px; }
.maint-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 18px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); font-size: .92rem; }
.maint-banner strong { color: var(--warn); }
.notice.warn { background: var(--warn-soft); }
.notice.warn svg { color: var(--warn); }

.access-group { display: flex; flex-direction: column; gap: 8px; }
.access-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); padding-top: 14px; }
.switch { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: .88rem; cursor: pointer; margin-right: auto; }
.switch input { appearance: none; width: 38px; height: 22px; min-height: 0; padding: 0; border-radius: 999px; background: var(--border-strong); border: 0; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:disabled { opacity: .55; cursor: not-allowed; }
.reset-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .85rem; }
.reset-box input { flex: 1 1 260px; min-height: 34px; font-size: .82rem; }

/* ============ Weekly record page ============ */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-pick { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.week-pick input { width: auto; }
.week-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.week-summary .pill { font-size: .8rem; padding: 4px 11px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.sheet-scroll { overflow-x: auto; padding-bottom: 8px; }

/* The printable Receiving Record (matches the paper form) */
.sheet {
  width: 8.5in; margin: 0 auto 24px; padding: .3in .35in;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .18);
  font: 11px/1.2 Arial, Helvetica, sans-serif;
}
.sheet-frame { border: 2.5px solid var(--ink); }
.sheet-title { text-align: center; font: 20px/1 Georgia, "Times New Roman", serif; letter-spacing: .02em; padding: 12px 0 8px; }
.sheet-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 48px; padding: 8px 8px 14px; border-bottom: 4px double var(--ink); }
.sf { display: flex; align-items: flex-end; gap: 6px; font: 13px Georgia, "Times New Roman", serif; }
.sf-label { white-space: nowrap; }
.sf-line {
  flex: 1; min-width: 0; width: auto; height: 20px; min-height: 0;
  padding: 0 4px; border: 0; border-bottom: 1.5px solid var(--ink); border-radius: 0;
  background: transparent; color: var(--ink); font: 600 13px Arial, Helvetica, sans-serif;
}
.sf-line:focus { outline: 0; box-shadow: none; border-color: var(--primary); background: var(--primary-soft); }
.sheet-legend { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; padding: 5px 8px; font: 10.5px/1.35 Georgia, "Times New Roman", serif; border-bottom: 4px double var(--ink); }
.sheet-table, .sheet-sales { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* Vendor, invoice #, invoice date, cost, retail, credit date, credit #, credit amount */
.sheet-table col:nth-child(1) { width: 26%; }
.sheet-table col:nth-child(2) { width: 11%; }
.sheet-table col:nth-child(3), .sheet-table col:nth-child(6) { width: 9%; }
.sheet-table col:nth-child(4), .sheet-table col:nth-child(5), .sheet-table col:nth-child(8) { width: 11.5%; }
.sheet-table col:nth-child(7) { width: 10.5%; }
.sheet-table th, .sheet-sales th { font: 12px/1.15 Georgia, "Times New Roman", serif; color: var(--ink); border: 1px solid var(--ink); padding: 3px 2px; text-align: center; vertical-align: middle; }
.sheet-table th { height: .42in; }
.sheet-table td, .sheet-sales td { border: 1px solid var(--ink); height: .27in; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.sheet-table tr > :first-child, .sheet-sales tr > :first-child { border-left: 0; }
.sheet-table tr > :last-child, .sheet-sales tr > :last-child { border-right: 0; }
.sheet-table thead th { border-top: 0; }
.sheet-table .vend { border-right: 3px double var(--ink); }
.sheet-table .cstart { border-left: 3px double var(--ink); }
.sheet .n { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.n { padding: 0 4px; }
.sheet .tight { font-size: 9.5px; letter-spacing: -.02em; }
.sheet-table tfoot td { height: .3in; border-top-width: 2px; }
.sheet-table tfoot .lbl { font: 15px Georgia, "Times New Roman", serif; text-align: right; padding-right: 6px; }
.sheet-table tfoot .n { font-weight: 700; }
.sheet-sales { border-top: 4px double var(--ink); }
.sheet-sales .sales-title { font-size: 19px; height: .36in; border-top: 0; }
.sheet-sales th { height: .32in; font-size: 12.5px; }
.sheet-sales .ts { font-size: 17px; text-align: left; padding-left: 4px; }
.sheet-sales td { height: .3in; }
.sheet-sales .ts-val { font-weight: 700; }
.sheet-comments { display: flex; gap: 6px; align-items: flex-start; border-top: 1px solid var(--ink); padding: 5px 6px; min-height: .6in; font: 13px Georgia, "Times New Roman", serif; }
.sheet-comments textarea { flex: 1; height: .5in; min-height: 0; padding: 0; border: 0; border-radius: 0; resize: none; background: transparent; color: var(--ink); font: 12px/1.3 Arial, Helvetica, sans-serif; }
.sheet-comments textarea:focus { outline: 0; box-shadow: none; background: var(--primary-soft); }
.sheet-comment-list { flex: 1; font: 12px/1.3 Arial, Helvetica, sans-serif; }
.sheet-comment-list p { margin: 0 0 2px; white-space: pre-wrap; }
.sheet-margin { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; min-width: 1.3in; padding-left: 8px; border-left: 1px solid var(--ink); }
.sheet-margin .sm-label { font: 13px Georgia, "Times New Roman", serif; }
.sheet-margin strong { font: 700 15px Arial, Helvetica, sans-serif; }
.sheet-margin span:not(.sm-label) { font: 11px Arial, Helvetica, sans-serif; }
.sheet-page { text-align: right; padding-top: 4px; font-size: 10px; }

/* ============ Vendor report ============ */
.report-controls { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.report-fields { display: grid; grid-template-columns: 170px 170px minmax(200px, 300px); gap: 12px; align-items: end; }
.report-vendor-slot .field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.check-line { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; }
.check-line input { width: 17px; height: 17px; min-height: 0; accent-color: var(--primary); }
/* The report always looks like paper, so the screen matches the printout */
.report {
  --rp-ink: #15181b; --rp-muted: #6a7075; --rp-line: #e3e4e1; --rp-soft: #f5f5f2;
  --rp-accent: #1f6f4a; --rp-tint: #eaf4ee;
  max-width: 8.5in; margin: 0 auto; padding: .5in .55in;
  background: #fff; color: var(--rp-ink); box-shadow: 0 2px 14px rgba(0, 0, 0, .14); border-radius: 4px;
  font: 10.5px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.report h2, .report h3, .report h4, .report p { margin: 0; }
.rp-label { font-size: 8.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--rp-muted); }
.rp-brand { display: flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 700; color: var(--rp-muted); }
.rp-logo { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; background: var(--rp-accent); color: #fff; font-size: 11px; }
.rp-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 16px; }
.rp-kicker { font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--rp-accent); }
.rp-title h2 { margin: 3px 0 2px; font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; }
.rp-sub { color: var(--rp-muted); }
.rp-period { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; white-space: nowrap; }
.rp-period strong { font-size: 13px; }
.rp-period span:last-child { color: var(--rp-muted); }
.rp-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 22px; }
.rp-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--rp-soft); }
.rp-kpi strong { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.rp-hint { font-size: 9px; color: var(--rp-muted); }
.rp-kpi.accent { background: var(--rp-accent); color: #fff; }
.rp-kpi.accent .rp-label, .rp-kpi.accent .rp-hint { color: rgba(255, 255, 255, .78); }
.rp-h { margin-bottom: 6px !important; font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--rp-muted); }
.rp-table { width: 100%; border-collapse: collapse; }
.rp-table th { padding: 6px 8px; border-bottom: 1px solid var(--rp-ink); text-align: left; font-size: 8.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--rp-muted); white-space: nowrap; }
.rp-table td { padding: 6px 8px; border-bottom: 1px solid var(--rp-line); vertical-align: top; }
.rp-table .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-table .strong, .rp-name { font-weight: 600; }
.rp-table tfoot td { border-bottom: 0; border-top: 1.5px solid var(--rp-ink); font-weight: 700; }
.rp-share { display: inline-flex; align-items: center; gap: 6px; }
.rp-bar { width: 56px; height: 6px; overflow: visible; }
.rp-bar rect { stroke: none; }
.rp-bar .bg { fill: var(--rp-line); }
.rp-bar .fg { fill: var(--rp-accent); }
.rp-vendor { margin-top: 26px; }
.rp-summary + .rp-vendor { margin-top: 30px; }
.rp-vhead { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--rp-ink); }
.rp-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; background: var(--rp-tint); color: var(--rp-accent); font-size: 12px; font-weight: 700; }
.rp-vhead h3 { flex: 1; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.rp-vstats { display: flex; gap: 18px; margin: 0; }
.rp-vstats div { text-align: right; }
.rp-vstats dt { font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--rp-muted); }
.rp-vstats dd { margin: 0; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-vstats .net dd { color: var(--rp-accent); font-weight: 700; }
.rp-vendor h4 { display: flex; align-items: center; gap: 6px; margin: 14px 0 2px; font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.rp-vendor h4 span { padding: 0 6px; border-radius: 999px; background: var(--rp-soft); color: var(--rp-muted); font-size: 8.5px; letter-spacing: 0; }
.rp-none { padding: 6px 8px; color: var(--rp-muted); font-style: italic; }
.rp-net { width: 240px; margin: 12px 0 0 auto; font-variant-numeric: tabular-nums; }
.rp-net div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 8px; }
.rp-net div:not(.total) { color: var(--rp-muted); }
.rp-net .total { margin-top: 3px; padding-top: 6px; border-top: 1.5px solid var(--rp-ink); font-size: 12px; }
.rp-running { display: none; justify-content: space-between; gap: 12px; margin-bottom: 12px !important; padding-bottom: 6px; border-bottom: 1px solid var(--rp-line); font-size: 8.5px; color: var(--rp-muted); }
.rp-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--rp-line); font-size: 8.5px; color: var(--rp-muted); }
.rp-empty { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; padding: 36px; border: 1px dashed var(--rp-line); border-radius: 8px; text-align: center; color: var(--rp-muted); }
.rp-empty strong { color: var(--rp-ink); font-size: 13px; }

/* Ledger look: compact, black and white, gridded tables (fits the most on a page) */
.report { --rp-accent: #15181b; --rp-tint: #ececea; font-size: 9.5px; }
.report .rp-head { padding-bottom: 10px; border-bottom: 3px solid var(--rp-ink); }
.report .rp-title { margin-top: 10px; }
.report .rp-title h2 { font-size: 19px; }
.report .rp-kicker { color: var(--rp-muted); }
.report .rp-kpis { gap: 0; margin: 14px 0 18px; border: 1.5px solid var(--rp-ink); border-radius: 0; }
.report .rp-kpi { padding: 7px 10px; border-radius: 0; background: none; }
.report .rp-kpi + .rp-kpi { border-left: 1px solid var(--rp-ink); }
.report .rp-kpi strong { font-size: 14px; }
.report .rp-kpi.accent { background: var(--rp-ink); }
.report .rp-table th { padding: 4px 6px; border: 1px solid var(--rp-ink); background: var(--rp-tint); color: var(--rp-ink); }
.report .rp-table td { padding: 3px 6px; border: 1px solid #c9cac6; }
.report .rp-table tbody tr:nth-child(even) td { background: #f7f7f5; }
.report .rp-table tfoot td { border: 1px solid var(--rp-ink); border-top-width: 2px; }
.report .rp-vendor { margin-top: 20px; }
.report .rp-vhead { padding: 6px 10px; border: 0; background: var(--rp-ink); color: #fff; }
.report .rp-avatar { width: 20px; height: 20px; border-radius: 4px; background: #fff; color: var(--rp-ink); font-size: 10px; }
.report .rp-vhead h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.report .rp-vstats dt { color: rgba(255, 255, 255, .7); }
.report .rp-vstats .net dd { color: #fff; }
.report .rp-vendor h4 { margin-top: 10px; }
.report .rp-net { border: 1.5px solid var(--rp-ink); }
.report .rp-net .total { background: var(--rp-tint); }
.report .rp-bar .fg { fill: var(--rp-ink); }
@media screen and (max-width: 760px) {
  .report-fields { grid-template-columns: 1fr 1fr; }
  .report-vendor-slot { grid-column: 1 / -1; }
  .report { padding: 18px 14px; }
  .rp-title { flex-direction: column; align-items: flex-start; }
  .rp-period { align-items: flex-start; text-align: left; }
  .rp-kpis { grid-template-columns: 1fr 1fr; }
  .rp-vhead { flex-wrap: wrap; }
  .rp-vstats { width: 100%; justify-content: flex-start; }
  .rp-table { display: block; overflow-x: auto; }
}

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 16px);
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 11px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--neg); color: #fff; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; width: 280px; max-width: 85vw;
    transform: translateX(-100%); transition: transform .22s ease-out;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; z-index: 39; background: rgba(10, 18, 13, .45); }
  .sidebar.open + .scrim { display: block; }
  .mobilebar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobilebar-title { font-weight: 700; }
  .mobilebar-store { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
  .pages { padding: 22px 16px 64px; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { padding: 26px 22px; gap: 18px; }
  .auth-pitch h2 { font-size: 1.4rem; max-width: none; }
  .auth-pitch p, .auth-foot { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.45rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.feature { grid-column: 1 / -1; }
  .week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* A month keeps its 7 columns on phones, with smaller cells */
  .week-strip.month { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .week-strip.month .day { padding: 5px 4px; min-height: 48px; border-radius: 8px; }
  .week-strip.month .damt { font-size: .68rem; }
  .week-strip.month .damt.full { display: none; }
  .week-strip.month .damt.short { display: block; }
  .week-strip.month .day.empty .damt { font-size: .6rem; }
  .strip-head { padding: 0 2px; font-size: .62rem; }
  .field-row { grid-template-columns: 1fr; }
  .seg { width: 100%; overflow-x: auto; }
  .seg button { flex: 1; }
  /* Tables become stacked rows */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tbody tr { padding: 10px 16px; border-bottom: 1px solid var(--border); }
  table.data td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.data td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; }
  table.data td.row-edit { display: none; }
  table.data .date-group td, table.data .empty-row td { display: block; text-align: left; }
  table.data .date-group td::before, table.data .empty-row td::before { content: none; }
  .drawer-foot { flex-wrap: wrap; }
  .drawer-foot .btn.primary, #drawer-again { flex: 1; }
}

/* ============ Print: only the weekly Receiving Record ============ */
@media print {
  @page { size: letter portrait; margin: .3in; }
  html, body { background: #fff !important; }
  .sidebar, .scrim, .mobilebar, .toast, .no-print, .auth, .boot, .drawer { display: none !important; }
  .shell { display: block; }
  .pages { padding: 0; max-width: none; }
  .page { display: none !important; }
  /* Prints the weekly sheet, or the vendor report when printed from its page */
  body:not(.printing-report) #page-weekly, body.printing-report #page-report { display: block !important; animation: none; }
  .report { box-shadow: none; border: 0; padding: 0; max-width: none; border-radius: 0; page: report; }
  .rp-vendor.page-break { break-before: page; }
  .rp-running { display: flex; }
  .rp-table tr, .rp-net, .rp-kpis, .rp-vhead, .rp-head { break-inside: avoid; }
  .rp-vhead, .rp-vendor h4 { break-after: avoid; }
  /* The report's pages get a footer with page numbers (browsers that support page margin boxes) */
  @page report {
    margin: .45in .5in .55in;
    @bottom-left { content: "Bill Book · Vendor Report"; font: 8px Inter, Arial, sans-serif; color: #6a7075; }
    @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 8px Inter, Arial, sans-serif; color: #6a7075; }
  }
  .sheet-scroll { overflow: visible; padding: 0; }
  .sheet { width: auto; margin: 0; padding: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet ::placeholder { color: transparent; }
  .sf-line, .sheet-comments textarea { background: transparent !important; }
}
