/* Admin panel: dark moss sidebar, light working canvas. Uses tokens from styles.css. */
.admin { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
@media (min-width: 1000px) { .admin { grid-template-columns: 248px minmax(0, 1fr); } }
.side {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: 268px; max-width: 86vw;
  background: var(--moss); color: var(--on-moss); display: flex; flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 14px calc(16px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  transform: translateX(-102%); transition: transform .2s ease; overflow-y: auto;
}
.side.open { transform: none; box-shadow: var(--shadow); }
@media (min-width: 1000px) { .side { position: sticky; top: 0; height: 100vh; width: auto; transform: none; } }
.side .logo { color: var(--on-moss); font-size: 20px; padding: 4px 10px 18px; }
.side .logo > svg { color: var(--brass-mark); }
.side .brand-name { font-size: 17px; }
.side .brand-tag .bt-letters { font-size: 8px; letter-spacing: 0; }
.side .logo small { display: block; font-size: 12.5px; font-weight: 500; color: var(--on-moss-2); letter-spacing: 0; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 8px; color: var(--on-moss-2); text-decoration: none; font-weight: 550; font-size: 15px; }
.side nav a:hover { background: var(--moss-2); color: var(--on-moss); }
.side nav a[aria-current="page"] { background: var(--moss-2); color: var(--on-moss); box-shadow: inset 3px 0 0 var(--brass-mark); }
.side .count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--brass-mark); color: #1d1408; font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--moss-2); display: grid; gap: 10px; font-size: 14px; }
.side-foot .who strong { display: block; color: var(--on-moss); }
.side-foot .who span { color: var(--on-moss-2); font-size: 13px; }
.side-foot .links { display: flex; flex-wrap: wrap; gap: 6px; }
.side-foot a, .side-foot button { display: inline-flex; align-items: center; gap: 6px; color: var(--on-moss-2); background: none; border: 1px solid var(--moss-2); border-radius: 999px; padding: 6px 12px; text-decoration: none; font-size: 13.5px; cursor: pointer; }
.side-foot a:hover, .side-foot button:hover { color: var(--on-moss); border-color: var(--on-moss-2); }
.side-foot svg { width: 15px; height: 15px; }
.side-scrim { position: fixed; inset: 0; z-index: 45; background: rgb(10 14 12 / 45%); }
@media (min-width: 1000px) { .side-scrim { display: none; } }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; display: flex; align-items: center; gap: 10px; padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); background: var(--moss); color: var(--on-moss); }
.topbar .icon-btn { color: var(--on-moss); }
.topbar .icon-btn:hover { background: var(--moss-2); }
.topbar strong { font-size: 17px; }
@media (min-width: 1000px) { .topbar { display: none; } }

.admin-main { min-width: 0; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 760px) { .admin-main { padding-left: 32px; padding-right: 32px; } }
.admin-main > div { max-width: 1280px; }
.a-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.a-head h1 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.03em; }
.a-head p { color: var(--ink-3); margin-top: 6px; font-size: 15px; }
.a-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.box { background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; padding: 20px; min-width: 0; }
.box > h2, .box-head h2 { font-size: 17px; letter-spacing: -0.01em; }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.box + .box { margin-top: 16px; }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .cols.c2 { grid-template-columns: 1fr 1fr; } .cols.c21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .cols.c12 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); } }
.cols > .box + .box { margin-top: 0; }

/* KPI tiles */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(var(--kpi-n, 5), minmax(0, 1fr)); } }
.kpi { background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; padding: 16px; display: grid; gap: 4px; text-decoration: none; min-width: 0; }
a.kpi:hover { border-color: var(--line); }
.kpi .k-label { font-size: 13.5px; color: var(--ink-3); }
.kpi .k-value { font-size: clamp(20px, 1.9vw, 26px); font-weight: 650; letter-spacing: -0.02em; white-space: nowrap; }
.kpi .k-delta { font-size: 13px; color: var(--ink-3); }
.kpi .k-delta .up { color: var(--good); font-weight: 650; }
.kpi .k-delta .down { color: var(--bad); font-weight: 650; }
.kpi.attn { border-color: color-mix(in srgb, var(--info) 45%, transparent); background: var(--info-soft); }
.kpi.attn .k-value { color: var(--info); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--line-2); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }

/* Charts */
.chart { display: grid; gap: 10px; }
.chart-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.chart-head h3 { font-size: 17px; letter-spacing: -0.01em; }
.chart-head p { margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.chart-body { position: relative; }
.chart-svg { width: 100%; overflow: hidden; }
.chart-svg svg { display: block; overflow: visible; }
.chart-svg .tick { font-size: 11.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; font-family: var(--font); }
.chart-svg .lbl { font-size: 13px; fill: var(--ink-2); font-family: var(--font); }
.chart-svg .val { font-size: 12.5px; fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; font-family: var(--font); }
.chart-svg .hit { cursor: default; outline: none; }
.chart-svg .hit.on, .chart-svg .hit:focus-visible { fill: var(--ink); fill-opacity: .04; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 13px; display: grid; gap: 4px; }
.chart-tip strong { font-size: 13.5px; }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.chart-tip i { width: 9px; height: 9px; border-radius: 2px; }
.chart-tip b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--raised); }
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface); }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table .thumb { width: 64px; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--stage); }
.table .thumb img { width: 100%; height: 100%; object-fit: cover; }
.table .sub { display: block; font-size: 13px; color: var(--ink-3); font-weight: 400; }
.table input.input, .table select.select { min-height: 36px; padding: 6px 8px; font-size: 14px; }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.brass { background: var(--brass-soft); color: var(--brass); }
.low { color: var(--bad); font-weight: 650; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .input, .filters .select { min-height: 40px; width: auto; font-size: 15px; }
.filters .input { min-width: min(260px, 100%); flex: 1; }
.list-clean { list-style: none; padding: 0; margin: 0; display: grid; }
.list-clean li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14.5px; }
.list-clean li:last-child { border-bottom: 0; }

/* Product editor */
.design-rows { display: grid; gap: 12px; }
.design-row { display: grid; gap: 12px; grid-template-columns: 120px minmax(0, 1fr); padding: 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); }
.design-row .pv { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--stage); position: relative; }
.design-row .pv img { width: 100%; height: 100%; object-fit: cover; }
.design-row .grid-f { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.design-row .grid-f > .field:first-child { grid-column: 1 / -1; }
@media (max-width: 520px) { .design-row { grid-template-columns: 1fr; } .design-row .pv { max-width: 200px; } }
.design-row .bar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.design-row .bar .left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.color-in { display: flex; align-items: center; gap: 8px; }
.color-in input[type="color"] { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); cursor: pointer; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.savebar { position: sticky; bottom: 0; z-index: 10; margin-top: 18px; padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; align-items: center; }
.savebar .muted { margin-right: auto; }
.pick-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow: auto; padding: 2px; }
.role-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .role-cards { grid-template-columns: repeat(3, 1fr); } }
.role-cards ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); display: grid; gap: 4px; }
.slip-img { max-height: 420px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; }
.qr-preview { width: 160px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; }
.chip input { accent-color: var(--walnut); margin: 0; }
.chip:has(input:checked) { border-color: var(--ink); color: var(--ink); background: var(--surface); }

/* Live chat inbox */
.inbox { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .inbox { grid-template-columns: 320px minmax(0, 1fr); align-items: start; } }
@media (max-width: 899px) { .inbox.has-chat .inbox-list { display: none; } .inbox:not(.has-chat) .inbox-chat { display: none; } }
@media (min-width: 900px) { .ic-back { display: none; } }
.inbox-list { max-height: 72vh; overflow-y: auto; }
.inbox-item { display: grid; gap: 4px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line-2); background: none; text-align: left; cursor: pointer; color: var(--ink); }
.inbox-item:hover { background: var(--surface); }
.inbox-item.on { background: var(--surface); box-shadow: inset 3px 0 0 var(--walnut); }
.ii-top { display: flex; align-items: center; gap: 8px; }
.ii-top .muted { margin-left: auto; }
.ii-last { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ii-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--walnut); }
.inbox-chat { display: flex; flex-direction: column; min-height: 60vh; padding: 0; overflow: hidden; }
.ic-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.ic-head > div:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.ic-head .actions { display: flex; gap: 6px; }
.ic-log { flex: 1; min-height: 320px; max-height: 58vh; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.inbox-chat .chat-form { border-top: 1px solid var(--line-2); }
.inbox-chat > .tiny { padding: 0 16px 10px; }
.seg a[aria-current="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
.seg a { border-radius: 999px; text-decoration: none; }

/* Customer-only codes */
.who-field { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.day-nav { align-items: center; }
.day-nav .input { width: auto; min-height: 34px; padding: 4px 10px; font-size: 14.5px; }
.table tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }

/* ---------- Payment accounts ---------- */
.pm-list { display: grid; gap: 10px; }
.pm-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); }
.pm-card.off { opacity: .62; }
.pm-qr { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line-2); }
.pm-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: var(--raised); color: var(--ink-2); }
.pm-icon svg { width: 22px; height: 22px; }
.pm-main { min-width: 0; }
.pm-main .sub { display: block; overflow-wrap: anywhere; }
.pm-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; margin-top: -4px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; margin-right: 6px; cursor: pointer; }
.switch input { width: 34px; height: 20px; appearance: none; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.form-grid.three { grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid.three { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Backups ---------- */
.help-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .help-cards { grid-template-columns: repeat(3, 1fr); } .help-cards .box + .box { margin-top: 0; } }
.help-cards h3 { font-size: 16px; margin-bottom: 6px; }
.help-cards p { color: var(--ink-2); line-height: 1.5; }
.progress { display: grid; gap: 6px; }
.progress .bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--good); transition: width .2s; }
.dialog p .spin, .restore-preview .spin { display: inline-block; vertical-align: -3px; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.restore-preview ul li + li { margin-top: 4px; }
.table td .link-btn { display: block; margin-top: 2px; }
#bk-settings + .box { margin-top: 0; }

.table .nowrap { white-space: nowrap; }
.table select[data-role] { min-width: 132px; }
.chart-svg .hit.link { cursor: pointer; }
.chart-svg .hit.link:hover { fill: var(--ink); fill-opacity: .04; }

/* ---------- Expense categories ---------- */
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; flex: none; }
.cat-name { display: inline-flex; align-items: center; text-decoration: none; color: inherit; font-weight: 600; }
.cat-name:hover { text-decoration: underline; }
.cat-title { display: flex; align-items: center; }
.cat-title .cat-dot { width: 16px; height: 16px; border-radius: 5px; margin-right: 12px; }
.share { display: block; height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.share span { display: block; height: 100%; border-radius: 999px; }
.swatches { border: 0; padding: 0; margin: 0; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span:not(.sr-only) { display: block; width: 32px; height: 32px; border-radius: 9px; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--raised); background-clip: padding-box; }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.table tr.click { cursor: pointer; }
.chart-tip .tip-total { border-top: 1px solid color-mix(in srgb, var(--bg) 30%, transparent); padding-top: 4px; margin-top: 2px; font-weight: 650; }
.side-foot .lang-switch { align-self: start; }
.side-foot .lang-switch button { border: 0; padding: 5px 11px; border-radius: 999px; font-size: 13px; }
.design-row .grid-f > .field:nth-child(2) { grid-column: 1 / -1; }

/* ---------- Debts, suppliers and purchases ---------- */
.th-sort { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; font: inherit; font-weight: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
.th-sort span { color: var(--ink-3); font-size: 12px; }
.th-sort.on span { color: var(--ink); }
.th-sort:hover, .th-sort:focus-visible { text-decoration: underline; }
th.r .th-sort { justify-content: flex-end; }
.credit-bar { display: block; height: 4px; margin-top: 5px; margin-left: auto; width: 90px; border-radius: 2px; background: var(--line); overflow: hidden; }
.credit-bar span { display: block; height: 100%; background: var(--brass-mark); border-radius: 2px; }
.mini-dl { display: grid; gap: 8px; margin: 0; }
.mini-dl > div { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; align-items: baseline; }
.mini-dl dt { color: var(--ink-3); font-size: 13.5px; }
.mini-dl dd { margin: 0; overflow-wrap: anywhere; }
.totals-dl .grand { border-top: 1px solid var(--line); padding-top: 8px; }
.danger-text { color: var(--bad) !important; font-weight: 600; }
.purchase-lines td { vertical-align: top; }
.purchase-lines .input-group { min-width: 150px; }
.purchase-lines .select { min-width: 220px; }
.debts-table td { vertical-align: top; }
.slip-ship { display: block; max-width: min(360px, 100%); max-height: 460px; width: auto; height: auto; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }
.input-group.pct .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group.pct .addon { border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.suggest-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); }
.suggest-bar p { margin: 0; color: var(--ink-2); flex: 1 1 240px; }
.cost-out { display: flex; align-items: center; min-height: 44px; font-weight: 650; }
.design-row .cost-line { grid-column: 1 / -1; margin: -2px 0 0; color: var(--ink-2); }
.design-row .cost-line.muted { color: var(--ink-3); }
.below-cost { color: var(--bad); }
.cost-warn { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--bad); }
.design-row .grid-f { align-items: end; }
.costs-table td:first-child { min-width: 180px; }
.costs-table td:nth-child(2) { min-width: 130px; }
.costs-table td.r { white-space: nowrap; }
.debts-table td.r, .debts-table th.r { white-space: nowrap; }
.debts-table td:nth-child(2) { min-width: 160px; }
.debts-table td:nth-child(3) { min-width: 140px; }
.debts-table td:first-child, .debts-table td:nth-child(4) { white-space: nowrap; }
.table td.r.num { white-space: nowrap; }
@media (max-width: 520px) { .design-row .grid-f { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.table td.r.num .sub { white-space: normal; }
.purchase-lines td.r.num .sub { white-space: nowrap; }
