/* Base layer of the console, on the design tokens (styles/tokens.css): squid-ink top bar with an orange rule, white sidebar with an
   orange active marker, grey canvas, white panels with hairline borders, yellow pill primary buttons and teal links (UI_SPECS §2). */
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-ui); font-size: var(--fs-md); line-height: var(--lh-body); background: var(--c-canvas); color: var(--c-ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { text-wrap: balance; line-height: var(--lh-tight); }
button, input, select, textarea { font: inherit; color: inherit; }
/* Form controls as the reference Field (atoms/Field.module.css .control): surface fill, ink-3 hairline, accent ring on focus. Every
   page gets them, so no control falls back to the browser's own grey in the dark theme. */
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]), select, textarea) {
  min-height: 36px; padding: 8px var(--sp-3); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-ink-3);
  border-radius: var(--r-sm); box-shadow: inset 0 1px 2px rgba(15, 17, 17, 0.12); transition: border-color 120ms ease, box-shadow 120ms ease;
}
:where(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea):focus { outline: none; border-color: var(--c-accent); box-shadow: var(--focus); }
:where(input, textarea)::placeholder { color: var(--c-ink-3); }
:where(textarea) { resize: vertical; min-height: 96px; }
:where(select) { cursor: pointer; }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--c-accent); width: 16px; height: 16px; }
input[type="file"] { color: var(--c-ink-2); }
input[type="file"]::file-selector-button { margin-right: var(--sp-2); padding: 6px 14px; border: 1px solid var(--c-border); border-radius: var(--r-pill); background: var(--c-btn-secondary); color: var(--c-ink); font: inherit; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--c-btn-secondary-hover); }
:where(fieldset) { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3) var(--sp-3); margin: 0 0 var(--sp-3); }
:where(legend) { padding: 0 var(--sp-1); font-size: var(--fs-sm); font-weight: 700; color: var(--c-ink); }
a { color: var(--c-link); }
a:hover { color: var(--c-link-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.layout { display: flex; min-height: 100vh; flex-direction: column; }
.body { flex: 1; display: flex; min-width: 0; }

/* Top bar: sticky squid ink with the accent rule; the brand mark and the signed-in account live here. */
/* Above scrolling page content, under every interactive overlay: popups (10) and the customer-chat layers (31-33, chat.css). */
.topbar { position: sticky; top: 0; z-index: 5; height: var(--topbar-h); background: var(--c-squid); color: var(--c-squid-ink); border-bottom: 3px solid var(--c-accent); display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--sp-4); }
.topbar .brand { display: inline-flex; align-items: center; gap: 6px; color: var(--c-squid-ink); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--c-accent); color: var(--c-squid); font-weight: 700; font-size: 15px; }
.topbar-menu { display: none; border: 1px solid transparent; background: none; color: inherit; width: 36px; height: 36px; border-radius: var(--r-sm); cursor: pointer; font-size: 18px; line-height: 1; }
.topbar-menu:hover { border-color: var(--c-squid-ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.topbar-theme { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--c-squid-2); border-radius: var(--r-pill); background: transparent; color: var(--c-squid-ink); cursor: pointer; font-size: 16px; line-height: 1; }
.topbar-theme:hover { border-color: var(--c-accent); color: var(--c-accent); }
.push-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.topbar-install { position: relative; display: inline-flex; }
.topbar-install-btn { border: 1px solid var(--c-accent); border-radius: var(--r-pill); background: transparent; color: var(--c-accent); padding: 4px 12px; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.topbar-install-btn:hover { background: var(--c-accent); color: var(--c-squid); }
.topbar-install-hint { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 240px; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-border); font-size: var(--fs-sm); line-height: 1.4; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.topbar-account { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; color: var(--c-squid-ink); }

.sidebar { width: var(--sidebar-w); background: var(--c-surface); color: var(--c-ink); border-right: 1px solid var(--c-border); padding: var(--sp-3) var(--sp-2); flex-shrink: 0; }
.sidebar ul { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 1px; }
.brand { display: block; padding: 0 var(--sp-2); }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: var(--c-ink); padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-md); font: inherit; transition: background-color 120ms ease; }
.nav-item > svg { flex: none; color: var(--c-ink-2); }
.nav-item.active > svg { color: var(--c-ink); }
.nav-item:hover { background: var(--c-surface-2); }
.nav-item.active { background: var(--c-surface-2); font-weight: 700; }
.nav-item.active::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c-accent); }
main { flex: 1; min-width: 0; padding: var(--sp-4); }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); box-shadow: var(--shadow-panel); display: flex; flex-direction: column; gap: 4px; }
.card h3 { margin: 4px 0 0; font-size: var(--fs-lg); }
.price { font-weight: 700; margin: 0; }
.units, .description { margin: 0; font-size: var(--fs-sm); color: var(--c-ink-2); }
.out { color: var(--c-critical); margin-left: 4px; }
.product-image, .image-placeholder { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); }
.image-placeholder { background: var(--c-surface-2); display: grid; place-items: center; font-size: 2.2rem; color: var(--c-ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.btn { border: 1px solid transparent; border-radius: var(--r-pill); padding: 7px 14px; cursor: pointer; font-size: var(--fs-md); font-family: var(--font-ui); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--c-btn-primary); border-color: var(--c-btn-primary-border); color: var(--c-btn-primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--c-btn-primary-hover); }
.btn-secondary { background: var(--c-btn-secondary); border-color: var(--c-border); color: var(--c-ink); }
.btn-secondary:hover:not(:disabled) { background: var(--c-btn-secondary-hover); }
.btn-danger { background: var(--c-critical); color: var(--c-surface); }
.popup-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 17, .5); display: grid; place-items: center; z-index: 10; }
.popup { width: min(92vw, 640px); height: 88vh; background: var(--c-surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; overflow: hidden; }
.popup-header { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--c-divider); }
.popup-header h2 { margin: 0; font-size: var(--fs-lg); }
.popup-close { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--c-ink-2); }
.popup-body { overflow-y: auto; padding: var(--sp-4); flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-3); }
.field > span { font-size: var(--fs-sm); font-weight: 700; }
.field.inline { flex-direction: row; align-items: center; }
.field-error, .form-error, .page-error { color: var(--c-critical); }
.page-notice { color: var(--c-good); }
.actions { display: flex; gap: var(--sp-2); }
.price-changes { background: var(--c-warn-bg); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); margin-top: var(--sp-3); }
.price-changes ul { list-style: none; padding: 0; margin: 0; }
.price-changes li { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: 4px 0; }
/* Below 900px the sidebar is an off-canvas drawer the hamburger opens (S6); navigating or the backdrop closes it. Above the chat
   layers (31-33) on purpose: while the drawer is open, navigation is the task. */
@media (max-width: 899px) {
  .topbar-menu { display: grid; place-items: center; }
  .sidebar { position: fixed; z-index: 40; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 160ms ease; overflow-y: auto; }
  .sidebar.sidebar-open { transform: none; box-shadow: var(--shadow-pop); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(15, 17, 17, .5); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
@media (max-width: 480px) { main { padding: var(--sp-2); } .topbar-theme { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--c-squid-2); border-radius: var(--r-pill); background: transparent; color: var(--c-squid-ink); cursor: pointer; font-size: 16px; line-height: 1; }
.topbar-theme:hover { border-color: var(--c-accent); color: var(--c-accent); }
.topbar-account { display: none; } }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.order-head h3 { margin: 0; }
.order-items { margin: 0; padding-left: 18px; font-size: var(--fs-sm); }
.hold { background: var(--c-critical-bg); border-radius: var(--r-md); padding: var(--sp-2); display: flex; flex-direction: column; gap: 6px; }
.item-row { display: flex; gap: 6px; margin-bottom: var(--sp-2); }
.item-row select, .item-row input { padding: 6px; border: 1px solid var(--c-border); border-radius: var(--r-sm); font: inherit; }
.item-row input[inputmode="numeric"] { width: 72px; }
.items-editor { border: 1px solid var(--c-border); border-radius: var(--r-sm); margin-bottom: var(--sp-3); }
a.btn { text-decoration: none; display: inline-block; }
.actions input { padding: 6px; border: 1px solid var(--c-border); border-radius: var(--r-sm); font: inherit; min-width: 0; flex: 1; }
.actions { flex-wrap: wrap; }
.metric-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.metric-card { background: var(--c-surface); border: 1px solid var(--c-border); border-top: 4px solid var(--c-accent); border-radius: var(--r-md); padding: var(--sp-3); box-shadow: var(--shadow-panel); }
.metric-card h3 { margin: 0; font-size: var(--fs-sm); color: var(--c-ink-2); }
.metric-value { margin: 4px 0 0; font-size: var(--fs-2xl); font-weight: 700; }
.line-chart { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); margin: var(--sp-3) 0; }
.line-chart svg { width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-sm); }
.legend i, .legend-list i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.donuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-3); }
.donut { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); margin: 0; }
.donut svg { width: 140px; height: 140px; display: block; margin: 0 auto; }
.legend-list { list-style: none; padding: 0; margin: 4px 0 0; font-size: var(--fs-sm); }
.hint { color: var(--c-ink-2); font-size: var(--fs-sm); max-width: 60ch; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.tag-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.tag-list li { display: flex; align-items: center; gap: var(--sp-2); }
.settings-form { max-width: 520px; }
.chat-options { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chat-log { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-2); margin: var(--sp-2) 0; }
.bubble { max-width: 80%; border-radius: var(--r-md); padding: 6px 10px; }
.bubble p { margin: 2px 0 0; white-space: pre-wrap; }
.bubble small { color: var(--c-ink-2); }
.bubble .chat-photo { display: block; max-width: 240px; max-height: 240px; margin: 4px 0; border-radius: var(--r-md); object-fit: cover; }
.bubble-in { align-self: flex-end; background: var(--c-info-bg); }
.bubble-out { align-self: flex-start; background: var(--c-good-bg); }
.bubble-notice { align-self: center; background: var(--c-warn-bg); font-size: var(--fs-sm); }
.chat-form { display: flex; gap: var(--sp-2); }
.chat-form input { flex: 1; padding: 8px; border: 1px solid var(--c-border); border-radius: var(--r-sm); font: inherit; min-width: 0; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.auth-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-5); width: min(100%, 440px); box-shadow: var(--shadow-pop); }
.auth-card h1 { margin-top: 0; }
.qr { width: 200px; height: 200px; display: block; margin: var(--sp-2) auto; background: var(--c-surface); }
.manual-key { font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
.recovery-codes { columns: 2; padding-left: 24px; }
.recovery-codes code { font-size: 1rem; }
.invite-link { width: 100%; padding: 8px; font: inherit; }
.sidebar .signout { margin-top: var(--sp-5); }
.signout { margin-top: var(--sp-5); padding: 0 var(--sp-2); }

/* Sidebar groups (UI_SPECS §4): an uppercase caption over each visual group of pages. */
.nav-group { margin-top: var(--sp-3); }
.nav-group:first-child { margin-top: 0; }
.nav-group-title { margin: 0; padding: 4px 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-ink-3); }
.nav-group ul { margin-top: 0; }
.notes-search { display: block; margin: var(--sp-2) 0 0; max-width: 360px; }
.notes-search input { width: 100%; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-sm); font: inherit; background: var(--c-surface); color: var(--c-ink); }
/* A list of checkboxes in a fieldset (approval kinds, agent features). */
.check-list { display: grid; gap: 2px; }
.check-row { display: flex; align-items: center; gap: var(--sp-2); padding: 5px 6px; border-radius: var(--r-sm); cursor: pointer; }
.check-row:hover { background: var(--c-surface-2); }
/* Nothing to show yet: the reference EmptyState panel; inside a picker list it stays a muted line. */
p.empty { display: grid; justify-items: center; margin: var(--sp-2) 0; padding: var(--sp-5) var(--sp-4); text-align: center; color: var(--c-ink-2); border: 1px dashed var(--c-border); border-radius: var(--r-md); background: var(--c-surface); grid-column: 1 / -1; }
li.empty { font-size: var(--fs-xs); color: var(--c-ink-2); padding: 6px; }
/* Chart text follows the theme: SVG text defaults to black, unreadable on the dark palette. */
.line-chart svg text { fill: var(--c-ink-2); }
.donut svg text { fill: var(--c-ink); }
/* Page layout as the reference (templates/PageLayout): a regular-weight page title, bold section titles, one rhythm of space. */
.page { max-width: 1360px; min-width: 0; }
.page-header { align-items: flex-end; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.page-header h1 { margin: 0; font-size: var(--fs-2xl); font-weight: 400; letter-spacing: -0.01em; }
.page h2 { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-xl); font-weight: 700; }
.page > .hint, .page > header + p.hint { color: var(--c-ink-2); max-width: 72ch; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.stat-card { background: var(--c-surface); border: 1px solid var(--c-border); border-top: 4px solid var(--c-accent); border-radius: var(--r-md); padding: var(--sp-3); box-shadow: var(--shadow-panel); }
.stat-head { display: flex; justify-content: space-between; gap: var(--sp-2); align-items: baseline; }
.stat-head h3 { margin: 0; font-size: var(--fs-md); }
.stat-change { font-size: var(--fs-sm); font-weight: 700; }
.stat-change.up { color: var(--c-good); }
.stat-change.down { color: var(--c-critical); }
.stat-total { margin: 4px 0 0; }
.stat-unit, .stat-foot { color: var(--c-ink-2); font-size: var(--fs-sm); }
.stat-line { width: 100%; height: auto; display: block; margin-top: var(--sp-2); }
.stat-foot { margin: var(--sp-1) 0 0; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); align-items: start; }
.pending-list { list-style: none; margin: 0; padding: 0; }
.pending-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--c-divider); }
.pending-row:first-child { border-top: 0; }
.pending-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pending-text span { color: var(--c-ink-2); font-size: var(--fs-sm); }
.table-wrap { overflow-x: auto; margin-top: var(--sp-3); }
.traffic-table { width: 100%; border-collapse: collapse; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.traffic-table th, .traffic-table td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--c-divider); vertical-align: top; }
.traffic-table th { font-size: var(--fs-sm); color: var(--c-ink-2); }
.traffic-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-sm); float: left; margin-right: var(--sp-2); }
.traffic-sub { display: flex; flex-wrap: wrap; gap: var(--sp-2); color: var(--c-ink-2); font-size: var(--fs-sm); }
.traffic-error { color: var(--c-critical); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--c-link); cursor: pointer; text-align: left; }
