:root {
  --bg: #F6F7F6; --surface: #FFFFFF; --surface-2: #EFF2F0; --line: #DDE3DF; --text: #17211D; --muted: #55635C;
  --primary: #0F766E; --primary-ink: #FFFFFF; --primary-soft: #DDF3EE; --primary-hover: #0B5F59;
  --good: #166534; --good-soft: #DCF5E3; --warn: #8A5300; --warn-soft: #FDF0D5; --bad: #B3261E; --bad-soft: #FCE4E1; --info: #1D4F91; --info-soft: #E1ECFA;
  --shadow: 0 1px 2px rgb(16 32 26 / .06), 0 4px 16px rgb(16 32 26 / .05);
  --radius: 12px; --sidebar: 244px; --bottom: 62px;
  --s1: #008C7E; --s2: #EB6834; --s3: #2A78D6; --s4: #EDA100; --s5: #6250D6;
  --o1: #6FC0B3; --o2: #3FA595; --o3: #0F766E; --o4: #0A5048; --o5: #07332E; --grid: #E6EBE8; --axis: #C3CCC7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1412; --surface: #161E1B; --surface-2: #1F2925; --line: #2C3833; --text: #E9EFEC; --muted: #9DACA5;
    --primary: #2DBFAE; --primary-ink: #06201C; --primary-soft: #143A34; --primary-hover: #4FD3C3;
    --good: #6FD99A; --good-soft: #15352A; --warn: #F2BE62; --warn-soft: #3A2C10; --bad: #FF9A91; --bad-soft: #43201D; --info: #9CC2F5; --info-soft: #1B2D48;
    --s1: #1FA896; --s2: #D95926; --s3: #3987E5; --s4: #C98500; --s5: #9085E9;
    --o1: #14574F; --o2: #1C7E72; --o3: #26A596; --o4: #2DBFAE; --o5: #7FE0D3; --grid: #26302C; --axis: #38453F;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1412; --surface: #161E1B; --surface-2: #1F2925; --line: #2C3833; --text: #E9EFEC; --muted: #9DACA5;
  --primary: #2DBFAE; --primary-ink: #06201C; --primary-soft: #143A34; --primary-hover: #4FD3C3;
  --good: #6FD99A; --good-soft: #15352A; --warn: #F2BE62; --warn-soft: #3A2C10; --bad: #FF9A91; --bad-soft: #43201D; --info: #9CC2F5; --info-soft: #1B2D48;
  --s1: #1FA896; --s2: #D95926; --s3: #3987E5; --s4: #C98500; --s5: #9085E9;
  --o1: #14574F; --o2: #1C7E72; --o3: #26A596; --o4: #2DBFAE; --o5: #7FE0D3; --grid: #26302C; --axis: #38453F;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Tahoma, sans-serif; }
h1, h2, h3, h4, p, dl, dd, ul { margin: 0; padding: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 620; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.push { margin-inline-start: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.error { color: var(--bad); }
.print-only { display: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
main:focus { outline: none; }

/* Layout */
.shell { min-height: 100dvh; }
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar); background: var(--surface); border-inline-end: 1px solid var(--line); overflow-y: auto; padding: 14px 10px 20px; }
.main-col { margin-inline-start: var(--sidebar); min-width: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 22px 28px 48px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; font-size: 1.05rem; color: var(--text); padding: 4px 8px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }
.nav-group { margin-top: 16px; }
.nav-group h2 { font-size: .72rem; font-weight: 640; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 0 10px 4px; }
.nav-group a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.nav-group a:hover { background: var(--surface-2); text-decoration: none; }
.nav-group a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-brand { display: none; }
.company { flex: 1; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 4px; min-width: 0; margin-inline-start: auto; }
.user { max-width: 160px; padding-inline: 6px; font-weight: 550; }
.bottom-bar { display: none; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 60; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .45); }
.drawer { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 41; width: min(300px, 86vw); background: var(--surface); padding: 12px 10px 24px; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }

/* Page furniture */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--text); flex: none; }
.back:hover { background: var(--surface-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card > h2 { margin-bottom: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 240px; max-width: 380px; }
.search .icon { position: absolute; inset-inline-start: 11px; top: 11px; color: var(--muted); }
.search input { padding-inline-start: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .88rem; cursor: pointer; min-height: 34px; }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.section-actions.start { justify-content: flex-start; margin-top: 12px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #2A0B08; }
.btn-danger:hover { background: var(--bad); filter: brightness(.92); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-icon { padding: 7px; min-width: 38px; }
.btn.block { width: 100%; margin-top: 6px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .85rem; font-weight: 560; }
.hint { color: var(--muted); font-size: .8rem; }
.field .error { font-size: .8rem; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input:disabled { background: var(--surface-2); color: var(--muted); }
.has-error input, .has-error select { border-color: var(--bad); }
input[type="date"] { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-grid:has(.span-all) { grid-template-columns: minmax(0, 1fr); }
.combo { position: relative; }
.combo-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgb(0 0 0 / .18); max-height: 260px; overflow-y: auto; padding: 4px; min-width: min(320px, 80vw); }
.combo-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.combo-list li.active { background: var(--primary-soft); }
.opt { display: flex; justify-content: space-between; gap: 12px; }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: .78rem; font-weight: 620; color: var(--muted); text-align: start; padding: 10px 12px; background: var(--surface-2); white-space: nowrap; }
.table th.num { text-align: end; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table td.primary { font-weight: 570; }
.table td.nowrap { white-space: nowrap; }
.table tfoot td { font-weight: 650; background: var(--surface-2); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; font-size: .88rem; }
.pager-btns { display: flex; gap: 4px; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* Notices and states */
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.notice ul { list-style: disc; padding-inline-start: 18px; }
.notice-error { background: var(--bad-soft); color: var(--bad); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.notice-ok { background: var(--good-soft); color: var(--good); }
.empty { text-align: center; padding: 44px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 4px 0 14px; }
.loading { display: grid; gap: 10px; padding: 8px 0; }
.loading .bar { height: 42px; border-radius: 10px; background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.toasts { position: fixed; inset: auto 16px 16px auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toasts:popover-open { display: grid; }
.toast { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 6px 22px rgb(0 0 0 / .25); }
.toast-error { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast-error { color: #2A0B08; }
.toast .icon { flex: none; margin-top: 2px; }

/* Dialogs */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); width: min(460px, calc(100% - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 16px 60px rgb(0 0 0 / .3); }
dialog.wide { width: min(680px, calc(100% - 24px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-body { padding: 16px 18px 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dialog-head h2 { font-size: 1.1rem; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.push-end { margin-inline-end: auto; }
.narrow { max-width: 460px; display: grid; gap: 12px; }

/* Reports */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { flex: 1 1 170px; max-width: 280px; }
.rows div { display: flex; justify-content: space-between; gap: 18px; padding: 5px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rows div:first-child { border-top: 0; }

/* Finance */

/* Settings */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.file-btn { position: relative; overflow: hidden; }
.logo-picker { display: grid; gap: 6px; }
.logo-picker .label { font-size: .85rem; font-weight: 600; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-section { font-size: .95rem; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.file-btn.disabled { opacity: .6; pointer-events: none; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

/* Sign in */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; max-width: none; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.auth-card img { border-radius: 12px; }
.auth-card h1 { margin-top: 10px; }
.auth-card form { display: grid; gap: 12px; margin-top: 18px; text-align: start; }

/* Tablet */
@media (max-width: 1180px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { font-size: .9rem; }
  .table th, .table td { padding-inline: 7px; }
}
@media (max-width: 1100px) {
}

/* Phones and small tablets: navigation moves to the bottom bar and drawer */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-col { margin-inline-start: 0; }
  main { padding: 16px 16px calc(var(--bottom) + 24px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 8px 0 12px; }
  .topbar-brand { display: block; }
  .company, .user { display: none; }
  .topbar-actions { margin-inline-start: auto; }
  .bottom-bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-bar a, .bottom-bar button { flex: 1; min-width: 0; height: var(--bottom); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; font-size: .72rem; color: var(--muted); background: none; border: 0; cursor: pointer; }
  .bottom-bar a:hover { text-decoration: none; }
  .bottom-bar a.active { color: var(--primary); font-weight: 600; }
  .sticky-actions { bottom: calc(var(--bottom) + env(safe-area-inset-bottom)); }
  .toasts { inset: auto 16px calc(var(--bottom) + 12px) 16px; max-width: none; }
}

/* Phones: tables become cards */
@media (max-width: 720px) {
  h1 { font-size: 1.3rem; }
  .form-grid, .form-grid.two { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .chip { flex: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .totals { min-width: 0; }

  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .table, .table tbody, .table tfoot, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .table td { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; border: 0; text-align: end; min-width: 0; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .84rem; font-weight: 500; text-align: start; flex: none; max-width: 45%; }
  .table td:empty, .table td[data-label=""]:empty { display: none; }
  .table td[data-label=""]::before { content: none; }
  .table td[data-label=""] { justify-content: flex-end; }
  .table td.primary { font-size: 1rem; text-align: start; padding-bottom: 6px; }
  .table td.primary::before { content: none; }
  .table tfoot tr { background: var(--surface-2); }

}

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

/* Shared pieces */
.plain li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); min-width: 0; }
.plain li:first-child { border-top: 0; }
.plain li > a:first-child { white-space: nowrap; }
.sticky-actions { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.stack-form { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--primary); }
.section-title { margin: 18px 0 8px; font-size: 1rem; }
.neg { color: var(--bad); }
.ok-text { color: var(--good); }
.notice-info { background: var(--info-soft); color: var(--info); }
.date-filter { width: auto; }
.table td.nowrap { white-space: nowrap; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); font-size: .75rem; }

/* Home and report cards */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat > span { font-size: .84rem; }
.stat strong { font-size: 1.4rem; font-weight: 650; line-height: 1.3; }
.stat small { font-size: .78rem; }
.home-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.c-4 { grid-column: span 4; } .c-8 { grid-column: span 8; } .c-12 { grid-column: span 12; }
.chart-card { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; min-height: 32px; }
.chart-head h2 a { color: inherit; }
.chart-head .btn-icon { min-height: 32px; min-width: 32px; padding: 5px; color: var(--muted); }
.plot { position: relative; }
.plot svg { display: block; }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--axis); stroke-width: 1; }
.tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; top: 6px; width: 126px; z-index: 5; padding: 8px 10px; font-size: .78rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .18); pointer-events: none; }
.chart-tip strong { display: block; }
.chart-tip div { display: flex; color: var(--muted); }
.chart-tip b { margin-inline-start: auto; color: var(--text); }
.chart-table { overflow-x: auto; max-height: 300px; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.chart-table th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; text-align: start; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.chart-table th.num { text-align: end; }
.chart-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.no-data { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 140px; flex: 1; }
.hbars { display: grid; gap: 10px; }
.hbars li { min-width: 0; }
.hbar-text { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.hbar-text b { font-weight: 620; white-space: nowrap; }
.hbar-track { height: 8px; margin-top: 3px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 4px; min-width: 2px; }
.hbars small { font-size: .75rem; }
.report-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.filter-dates { display: flex; flex-wrap: wrap; gap: 12px; flex: 1 1 280px; max-width: 420px; min-width: 0; }
.filter-dates .field { flex: 1 1 130px; max-width: none; }
.shift-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.shift-grid .card { margin: 0; }
.refund-lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto 84px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pur-lines { margin-top: 10px; }
.pur-lines li { display: grid; grid-template-columns: minmax(150px, 1fr) 90px 130px 130px 40px; gap: 10px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.pur-lines label { display: grid; gap: 2px; }
.pur-name { align-self: center; font-weight: 560; min-width: 0; }
.sum { font-size: .95rem; }

/* Till */
.shell.selling .sidebar, .shell.selling .company { display: none; }
.shell.selling .main-col { margin-inline-start: 0; }
.shell.selling .topbar-brand, .shell.selling .menu-btn { display: block; }
.shell.selling .menu-btn { display: inline-flex; }
.shell.selling main { max-width: none; padding: 0; }
.menu-btn { display: none; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 390px; height: calc(100dvh - 56px); overflow: hidden; }
.pos-catalog { display: flex; flex-direction: column; min-height: 0; padding: 12px 14px; gap: 10px; }
.pos-search { display: flex; gap: 8px; }
.pos-search .search { max-width: none; flex: 1; }
.pos-search .search input { min-height: 46px; font-size: 1.05rem; }
.pos-search .search .icon { top: 14px; }
.orders-btn { min-height: 46px; }
.pos-cats { flex-wrap: nowrap; overflow-x: auto; flex: none; scrollbar-width: none; }
.pos-cats .chip { flex: none; min-height: 40px; padding-inline: 16px; }
.pos-none { padding: 24px 4px; text-align: center; }
.tiles { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); grid-auto-rows: 92px; gap: 8px; align-content: start; padding-bottom: 8px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; padding: 10px 11px; text-align: start; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; font: inherit; cursor: pointer; box-shadow: var(--shadow); touch-action: manipulation; min-width: 0; }
.tile:hover { border-color: var(--primary); }
.tile:active { background: var(--primary-soft); transform: scale(.98); }
.tile-name { font-weight: 570; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.stock-low { color: var(--warn); font-weight: 600; }
.stock-out { color: var(--bad); font-weight: 600; }
.pos-cart { display: flex; flex-direction: column; min-height: 0; gap: 8px; padding: 12px 14px; background: var(--surface); border-inline-start: 1px solid var(--line); }
.cart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cart-close { display: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.seg button { border: 0; border-radius: 8px; background: none; color: var(--text); min-height: 38px; font: inherit; font-size: .9rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); font-weight: 620; box-shadow: var(--shadow); }
.cart-customer { display: flex; gap: 4px; align-items: center; }
.cart-customer .combo { flex: 1; min-width: 0; }
.cart-lines { flex: 1; overflow-y: auto; min-height: 60px; }
.cart-empty { padding: 28px 10px; text-align: center; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 66px; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.cart-line-main { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 0; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.cart-line-main span { max-width: 100%; }
.cart-line-main small { font-size: .76rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-total { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .92rem; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.1rem; cursor: pointer; touch-action: manipulation; }
.stepper span { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-size: .92rem; }
.cart-foot { display: grid; gap: 8px; padding-top: 4px; }
.cart-sums div { display: flex; justify-content: space-between; font-size: .9rem; }
.cart-sums .grand { font-size: 1.15rem; font-weight: 680; }
.cart-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.cart-actions .btn { padding-inline: 6px; }
.btn-big { min-height: 54px; font-size: 1.1rem; font-weight: 650; }
.cart-bar { display: none; }
.till-gate { display: grid; place-items: center; min-height: calc(100dvh - 56px); padding: 16px; }
.till-gate .card { width: min(380px, 100%); display: grid; gap: 10px; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.pay-total strong { font-size: 1.7rem; }
.pay-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.pay-mode { min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; }
.pay-mode[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.quick-cash { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quick-cash .chip { min-height: 42px; padding-inline: 14px; }
.change { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--good-soft); color: var(--good); }
.change strong { font-size: 1.4rem; }
.change.short { background: var(--bad-soft); color: var(--bad); }
.done { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0; }
.done .change { width: 100%; }
.done-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--good-soft); color: var(--good); }
.done-total { font-size: 1.5rem; }
.order-list button { display: flex; width: 100%; gap: 10px; align-items: center; min-height: 52px; padding: 8px 10px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.order-list button:hover { background: var(--surface-2); }

/* Add-ons */
.addons, .addon-editor { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0; min-width: 0; }
.addons legend, .addon-editor legend { font-size: .85rem; font-weight: 600; padding: 0 4px; }
.addon { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--line); cursor: pointer; }
.addon:last-child { border-bottom: 0; }
.addon input { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--primary); }
.addon b { margin-inline-start: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.addon-editor { margin-top: 14px; display: grid; gap: 8px; }
.addon-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 40px; gap: 8px; }

/* Lock screen and PIN pad */
.lock .auth-card { width: min(440px, 100%); }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.staff { display: grid; justify-items: center; gap: 8px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.staff:hover { border-color: var(--primary); }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 1.2rem; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--primary); border-color: var(--primary); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; direction: ltr; }
.pinpad button { min-height: 60px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 1.4rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.pinpad button:active { background: var(--primary-soft); }
.lock-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

/* Help */
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.help-grid .card { margin: 0; }
.help-grid ol { padding-inline-start: 20px; display: grid; gap: 6px; }

/* Receipt, on screen and on an 80mm printer */
.receipt-preview { display: flex; justify-content: center; }
.receipt-preview .receipt { background: #fff; color: #000; padding: 18px 14px; border-radius: 4px; box-shadow: 0 4px 22px rgb(0 0 0 / .14); width: min(330px, 100%); }
.receipt { font-size: 12.5px; line-height: 1.35; }
.receipt header { text-align: center; padding-bottom: 6px; border-bottom: 1px dashed #000; }
.receipt h2 { font-size: 16px; }
.receipt h3 { font-size: 14px; margin-top: 6px; }
.receipt .r-meta { padding: 6px 0; border-bottom: 1px dashed #000; }
.receipt .r-meta div, .receipt .r-row { display: flex; justify-content: space-between; gap: 10px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th { font-size: 11px; font-weight: 600; text-align: start; padding: 5px 0; border-bottom: 1px dashed #000; }
.receipt th.num { text-align: end; }
.receipt td { padding: 4px 0 3px; }
.receipt small { display: block; font-size: 11px; }
.r-name { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.r-line { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.r-line span:nth-child(2), .r-line b { text-align: end; }
.r-totals { padding-top: 6px; border-top: 1px dashed #000; }
/* Thermal printers print in black only, so the logo is turned to greyscale and kept small. */
.r-logo { display: block; margin: 0 auto 6px; max-width: 46mm; max-height: 22mm; object-fit: contain; filter: grayscale(1) contrast(1.2); }
.r-logo-small { max-width: 30mm; max-height: 12mm; }
.logo-preview { max-width: 200px; max-height: 90px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.lock-logo { display: block; margin: 0 auto; max-width: 160px; max-height: 64px; object-fit: contain; }
.r-strong { font-size: 15px; font-weight: 700; padding: 3px 0; }
.receipt footer { margin-top: 8px; padding-top: 6px; text-align: center; border-top: 1px dashed #000; }
.ticket { font-size: 15px; }
.ticket h2 { font-size: 24px; letter-spacing: .02em; }
.ticket h3 { font-size: 17px; }
.ticket li { padding: 5px 0; border-bottom: 1px dashed #000; }
#print-root { display: none; }

@media (max-width: 1180px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
  .c-4, .c-8 { grid-column: span 12; }
  .home-grid .c-4 { grid-column: span 6; }
}
@media (max-width: 900px) {
  .menu-btn { display: none; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-catalog { padding-bottom: 72px; }
  .pos-cart { position: fixed; inset: 56px 0 0 0; z-index: 25; transform: translateY(102%); transition: transform .18s ease; border: 0; }
  .pos-cart.open { transform: none; }
  .cart-close { display: inline-flex; margin-inline-start: auto; }
  .cart-bar { position: fixed; inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 24; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 620; cursor: pointer; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
  .cart-bar b { margin-inline-start: auto; }
}
@media (max-width: 720px) {
  .home-grid .c-4 { grid-column: span 12; }
  .shift-grid { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 12px; }
  .stat strong { font-size: 1.15rem; }
  .pur-lines li { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pur-name { grid-column: 1 / -1; }
  .pay-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); grid-auto-rows: 84px; }
  .filter-dates { max-width: none; }
  .orders-btn { padding-inline: 10px; }
}

/* Print */
/* The receipt sets its own width. Paper length is left to the printer, so a long bill never splits across pages. */
@page slip { margin: 2mm 3mm; }
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --line: #ccc; --text: #000; --muted: #444; --primary: #0F766E; --shadow: none; color-scheme: light; }
  body { font-size: 12px; background: #fff; }
  .sidebar, .drawer, .scrim, .topbar, .bottom-bar, .no-print, .toasts, .skip, .page-actions, .chart-head .btn, .cart-bar { display: none !important; }
  .print-only { display: block; margin-bottom: 12px; }
  .main-col { margin: 0; }
  main { padding: 0; max-width: none; }
  .card, .table-wrap, .stat { border: 0; box-shadow: none; }
  .table tr { break-inside: avoid; }
  a { color: inherit; }
  body.printing #app { display: none; }
  body.printing #print-root { display: block; page: slip; width: 72mm; color: #000; }
  /* Each slip gets its own page, so the printer cuts between the bill and the kitchen ticket. */
  body.printing #print-root .receipt + .receipt { break-before: page; }
}
