:root {
  --bg: #121110;
  --panel: #1b1a18;
  --panel-2: #23211e;
  --line: #2f2c28;
  --text: #f3efe8;
  --muted: #9c958a;
  --accent: #ff6a3d;      /* crispy-rice orange */
  --accent-ink: #1a0d07;
  --good: #49c58a;
  --bad: #ff5d5d;
  --warn: #f2b84b;
  --radius: 14px;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.brand { font-family: var(--display); font-weight: 700; font-size: 34px; letter-spacing: -0.03em; }
.brand span { color: var(--accent); }
.login-sub { color: var(--muted); margin: 6px 0 28px; }
.dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 28px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); transition: all .12s; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key { height: 68px; border-radius: 50%; aspect-ratio: 1; margin: 0 auto; width: 68px; border: 1px solid var(--line); background: var(--panel);
  font-family: var(--display); font-size: 26px; font-weight: 500; transition: background .1s, transform .05s; }
.key:active { background: var(--panel-2); transform: scale(.96); }
.key.ghost { background: none; border: none; font-size: 15px; color: var(--muted); font-family: var(--body); }
.login-msg { min-height: 22px; margin-top: 20px; color: var(--bad); font-size: 14px; }

/* ---------- shell ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 16px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; gap: 12px; }
.topbar .brand { font-size: 22px; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 9px 14px; border-radius: 10px; font-weight: 500; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.link { border: none; background: none; padding: 4px 6px; color: var(--muted); }
.btn.link:hover { color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.crumbs a { text-decoration: none; } .crumbs a:hover { color: var(--text); }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.kpi { background: var(--panel); padding: 16px 18px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-family: var(--display); font-size: 26px; font-weight: 600; margin-top: 6px; white-space: nowrap; }
.kpi.hero .kpi-value { font-size: 34px; }
.kpi-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpis > .kpi.hero, .kpis > .kpi:last-child { grid-column: span 2; } }

.brief { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; display: flex; gap: 14px; align-items: flex-start; }
.brief-tag { font-family: var(--mono); font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 168px; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); text-decoration: none; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: #4a443d; transform: translateY(-2px); }
.tile.live { border-color: rgba(255,106,61,.45); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tile h3 { font-size: 19px; }
.tile-badge { font-size: 11px; font-family: var(--mono); padding: 3px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.tile.live .tile-badge { background: rgba(255,106,61,.15); color: var(--accent); }
.tile-desc { color: var(--muted); font-size: 14px; line-height: 1.45; margin-top: 8px; }
.tile-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 16px; }
.tile-big { font-family: var(--display); font-size: 26px; font-weight: 600; }
.tile-files { color: var(--muted); font-size: 13px; }

/* ---------- panels / forms ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 30px; }
.headline-net { text-align: right; }
.headline-net .kpi-value { font-size: 34px; margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; border: none; background: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 14px; }
.grid-2 > .panel + .panel { margin-top: 0; }
.panel h2 { font-size: 17px; margin-bottom: 4px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .label { flex: 1; min-width: 0; }
.field { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.field:focus { outline: none; border-color: var(--accent); }
.money { position: relative; width: 130px; flex: none; }
.money::before { content: '$'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money .field { padding-left: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.pct { position: relative; width: 110px; flex: none; }
.pct::after { content: '%'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pct .field { padding-right: 26px; text-align: right; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; background: none; }
.chip.on { border-color: var(--good); color: var(--good); }
.chip.tp { border-color: #6b5bd6; color: #a99bff; }
.chip.direct { border-color: var(--good); color: var(--good); }
.chip.bad { border-color: var(--bad); color: var(--bad); }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- statement ---------- */
.stmt { width: 100%; border-collapse: collapse; }
.stmt td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.stmt td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.stmt td.pc { text-align: right; color: var(--muted); font-size: 13px; width: 64px; }
.stmt tr.sec td { text-align: left; padding-top: 16px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; border-bottom: none; }
.stmt tr.sub td:first-child { padding-left: 14px; color: var(--muted); }
/* General Settings: channel / tier rows, hours */
.channel-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.channel-row .cr-name { flex: 1 1 100%; font-weight: 600; }
.mini-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sub-head { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 4px; }
.hours-row { flex-wrap: wrap; align-items: center; }
.hours-row .day { flex: 0 0 40px; font-weight: 600; }
.hours-row .spans { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 200px; }
.hours-row .span { display: inline-flex; align-items: center; gap: 4px; }
.hours-row input[type=time] { width: auto; min-width: 0; }
.stmt tr.sub2 td { font-size: 12px; color: var(--muted); padding-top: 2px; padding-bottom: 2px; }
.stmt tr.sub2 td:first-child { padding-left: 26px; }
.stmt tr.est td, .month-table tr.est td { font-style: italic; }
.stmt tr.warn-row td { color: var(--warn); font-size: 13px; text-align: left; }
.stmt tr.tot td { font-weight: 600; }
.stmt tr.net td { font-family: var(--display); font-size: 20px; font-weight: 600; border-bottom: none; padding-top: 14px; }
.mini-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.mini-kpis .kpi { border: 1px solid var(--line); border-radius: 10px; }
.mini-kpis .kpi-value { font-size: 22px; }
.be { margin-top: 16px; padding: 14px; border-radius: 10px; background: var(--panel-2); }
.be-bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.be-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.month-table-wrap { overflow-x: auto; }
.month-table { border-collapse: collapse; width: 100%; min-width: 720px; }
.month-table th, .month-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.month-table th:first-child, .month-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
.month-table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.month-table th a { text-decoration: none; } .month-table th a:hover { color: var(--text); }
.month-table tr.sec td { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding-top: 16px; }
.month-table tr.tot td { font-weight: 600; }
.month-table td.total-col, .month-table th.total-col { background: var(--panel-2); }

.week-list { display: grid; gap: 10px; }
.week-card { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; }
.week-card:hover { border-color: #4a443d; }
.week-card .chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) { .week-card { grid-template-columns: 1fr 1fr; } .week-card .chips { grid-column: span 2; justify-content: flex-start; } }

/* ---------- dropzone / files ---------- */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 16px; text-align: center; color: var(--muted); transition: all .15s; cursor: pointer; }
.drop.compact { padding: 14px; }
.drop.over { border-color: var(--accent); background: rgba(255,106,61,.06); color: var(--text); }
.drop strong { color: var(--text); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.file { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.file-thumb { aspect-ratio: 4 / 3; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font-family: var(--mono); color: var(--muted); font-size: 18px; }
.file-meta { padding: 8px 10px; font-size: 12px; min-width: 0; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--text); }
.file-actions { display: flex; justify-content: space-between; padding: 0 6px 6px; }
.roadmap { list-style: none; padding: 0; margin: 0; }
.roadmap li { padding: 8px 0 8px 22px; position: relative; color: var(--muted); border-bottom: 1px solid var(--line); }
.roadmap li:last-child { border-bottom: none; }
.roadmap li::before { content: ''; position: absolute; left: 4px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px;
  border-radius: 10px; font-weight: 500; opacity: 0; transition: all .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }
.saving { font-size: 12px; color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---------- Price Watch ---------- */
.alert-list { display: grid; gap: 10px; }
.alert-card { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.alert-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-card a { text-decoration: none; } .alert-card a:hover { text-decoration: underline; }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 12px)); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; pointer-events: none; opacity: 0; white-space: nowrap; }
.chart-tip.show { opacity: 1; }
.mini { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }

/* ---------- Food Cost ---------- */
.back-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; font-size: 20px; line-height: 1; flex: none; }
.crumbs { flex-wrap: wrap; }
.cost-kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
@media (max-width: 960px) { .cost-kpis { grid-template-columns: 1fr 1fr; } .cost-kpis > .kpi:last-child { grid-column: auto; } .cost-kpis > .kpi:nth-child(odd):last-child { grid-column: span 2; } }
.cost-callout { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 14px; }
.cost-callout a { text-decoration: none; color: var(--warn); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.mini-tile { display: grid; gap: 6px; padding: 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
.mini-tile:hover { border-color: var(--accent); }
.mini-tile.dim { opacity: .6; }
@media (max-width: 420px) { .tile-grid { grid-template-columns: 1fr 1fr; } }
.cost-table td:first-child { white-space: normal; min-width: 150px; }
.cost-table .chip { margin-left: 6px; }
.month-table tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.math ol { padding-left: 20px; margin: 10px 0; display: grid; gap: 6px; font-size: 14px; }
.math summary, .sub-batch summary { cursor: pointer; }
.sub-batch { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sub-batch .month-table-wrap { margin-top: 8px; }
.link-form .field { min-width: 0; }
.cost-lines { display: grid; }
.cost-line { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cost-line .cl-name { min-width: 0; overflow-wrap: anywhere; }
.cost-line .cl-cost { text-align: right; font-variant-numeric: tabular-nums; }
.cost-line .cl-math { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cost-line .cl-share { color: var(--muted); font-size: 13px; text-align: right; }
.cost-line.pack { opacity: .7; }
.cost-line.total { border-bottom: none; font-weight: 600; }

/* Invoice review: each line item is one card (line, alerts, ingredient question), bold divider between. */
.line-card { padding: 10px 0 12px; border-bottom: 3px solid var(--line); }
.line-card:first-child { padding-top: 0; }
.line-card:last-of-type { border-bottom: none; }
.line-card .row { border-bottom: none; }
/* Upload progress, one row per file. */
.upload-status:empty { display: none; }
.upload-status { margin-top: 10px; display: grid; gap: 6px; }
.upload-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.upload-row strong { overflow-wrap: anywhere; }
.upload-out { display: flex; flex-wrap: wrap; gap: 6px 12px; flex-basis: 100%; }
.upload-out .chip { white-space: normal; }
/* "Invoices complete" on a P&L week. */
.complete-box { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.complete-box input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

/* ---------- public pages (/text-alerts, /privacy, /terms) + the text alerts consent box ---------- */
.legal { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; line-height: 1.55; }
.legal .topbar { border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.legal h1 { font-size: 28px; margin-bottom: 6px; }
.legal h2 { font-size: 18px; margin: 26px 0 6px; }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: 20px; }
.legal a { color: var(--accent); }
.legal .muted { color: var(--muted); }
.legal nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.legal footer { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.consent-box { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.5; margin: 12px 0; cursor: pointer; }
.consent-box input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.consent-box a { color: var(--accent); }
