/* ZERØ ONE v1 — shared dark-only design system. */
:root {
  color-scheme: dark;
  --bg-app: #081119;
  --bg-header: #0b151e;
  --bg-sidebar: #0b151e;
  --surface-primary: #101b24;
  --surface-secondary: #15232e;
  --surface-elevated: #1b2c38;
  --border-default: #263743;
  --border-strong: #425866;
  --text-primary: #f3f6f8;
  --text-secondary: #a7b4bf;
  --text-muted: #92a4b2;
  --accent-primary: #10d8c4;
  --accent-secondary: #269df5;
  --status-success: #43d6a0;
  --status-warning: #f5b942;
  --status-danger: #ff7878;
  --status-neutral: #a7b4bf;
  --chart-first: var(--accent-primary);
  --chart-second: var(--accent-secondary);
  --chart-third: #b49aef;
  --surface-selected: color-mix(in srgb, var(--accent-primary) 9%, var(--bg-sidebar));
  --surface-warning: color-mix(in srgb, var(--status-warning) 7%, var(--surface-primary));
  --surface-danger: color-mix(in srgb, var(--status-danger) 8%, var(--surface-primary));
  --radius-sm: 6px;
  --radius: 9px;
  --shadow: 0 2px 8px #0002;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --control-height: 40px;
  --header-height: 64px;
  --sidebar-width: 72px;
  --motion: 160ms ease;
}
:root[data-sidebar="expanded"] { --sidebar-width: 232px; }
* { box-sizing: border-box; }
[hidden] { display: none; }
html { scroll-padding-top: calc(var(--header-height) + 16px); scrollbar-color: var(--border-strong) var(--bg-app); }
body { margin: 0; background: var(--bg-app); color: var(--text-primary); font: 15px/1.5 system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, .button { display: inline-flex; justify-content: center; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding: 8px 16px; border: 1px solid var(--accent-primary); border-radius: var(--radius-sm); background: var(--accent-primary); color: var(--bg-app); font-weight: 650; cursor: pointer; text-decoration: none; transition: background var(--motion), border-color var(--motion); }
button:hover, .button:hover { background: color-mix(in srgb, var(--accent-primary) 85%, var(--text-primary)); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
.secondary, .icon-button, .text-button { background: var(--surface-secondary); color: var(--text-primary); border-color: var(--border-default); }
.secondary:hover, .icon-button:hover, .text-button:hover { background: var(--surface-elevated); border-color: var(--border-strong); }
.danger { background: var(--status-danger); border-color: var(--status-danger); color: var(--bg-app); }
.danger:hover { background: color-mix(in srgb, var(--status-danger) 85%, var(--text-primary)); }
:disabled, [aria-disabled="true"] { cursor: not-allowed; color: var(--text-muted); background: var(--surface-secondary); border-color: var(--border-default); opacity: .75; }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
.icon { width: 24px; height: 24px; flex: 0 0 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { width: 44px; height: 44px; padding: 9px; }
/* Shell: logo coordinates are relative to the entire viewport. */
.topbar { position: fixed; inset: 0 0 auto; height: var(--header-height); z-index: 30; background: var(--bg-header); border-bottom: 1px solid var(--border-default); display: flex; align-items: center; padding: 0 var(--space-5); }
.brand { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 280px; height: 52px; overflow: hidden; }
.brand img { position: absolute; top: 50%; left: 0; transform: translateY(-50%); width: 100%; height: auto; display: block; }
.account-menu { padding: 0; margin-left: auto; position: relative; }
.account-menu summary { list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: 44px; color: var(--text-primary); cursor: pointer; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary .icon { width: 16px; height: 16px; flex-basis: 16px; }
.account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { position: absolute; right: 0; top: calc(100% + 8px); width: max-content; min-width: 150px; max-width: 240px; padding: var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-elevated); box-shadow: var(--shadow); }
.account-actions>span { display: block; overflow-wrap: anywhere; margin-bottom: var(--space-2); color: var(--text-secondary); }
.account-actions button { width: 100%; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 40; display: flex; flex-direction: column; background: var(--bg-sidebar); border-right: 1px solid var(--border-default); }
.sidebar-head { height: var(--header-height); flex: 0 0 var(--header-height); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border-default); }
.sidebar-brand { width: 58px; display: block; }
.sidebar-brand img { width: 100%; height: auto; display: block; }
.sidebar nav { padding: var(--space-3) 6px; display: flex; flex-direction: column; gap: 6px; }
.nav-link { position: relative; display: flex; width: 100%; min-height: 48px; align-items: center; gap: var(--space-3); padding: 10px 17px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: 14px; font-weight: 600; white-space: nowrap; justify-content: flex-start; }
.nav-link:hover { background: var(--surface-secondary); color: var(--text-primary); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--surface-selected); color: var(--accent-primary); }
.nav-link[aria-current="page"]::before { position: absolute; content: ""; left: -7px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--accent-primary); }
.nav-label { display: none; overflow: hidden; text-overflow: ellipsis; }
:root[data-sidebar="expanded"] .nav-label { display: inline; }
.nav-tooltip { pointer-events: none; position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); padding: 6px 10px; background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; visibility: hidden; opacity: 0; }
:root:not([data-sidebar="expanded"]) .nav-link:is(:hover,:focus-visible) .nav-tooltip { visibility: visible; opacity: 1; }
.sidebar-bottom { margin-top: auto; padding: 8px 6px 12px; border-top: 1px solid var(--border-default); }
.sidebar-user { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 8px 18px; color: var(--text-secondary); font-size: 13px; }
:root[data-sidebar="expanded"] .sidebar-toggle .icon { transform: rotate(180deg); }
.mobile-menu, .drawer-close { display: none; }
.workspace { padding-top: var(--header-height); min-width: 0; }
.has-sidebar .workspace { margin-left: var(--sidebar-width); }
main { margin: 0; padding: var(--space-5) clamp(20px,2.6vw,48px); min-width: 0; min-height: calc(100vh - 130px); }
footer { padding: 20px; text-align: center; color: var(--text-muted); font-size: 12px; }
.skip { position: fixed; left: -10000px; z-index: 80; padding: 12px; background: var(--surface-elevated); }
.skip:focus { left: 12px; top: 8px; }
/* Shared type, surfaces and layout. */
h1, h2, h3 { color: var(--text-primary); }
h1 { font-size: 32px; line-height: 1.2; letter-spacing: -.7px; margin: 0 0 12px; }
h2 { font-size: 18px; line-height: 1.4; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0; }
p { margin: 6px 0 12px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 6px; }
.muted, small { color: var(--text-muted); }
small { font-size: 12px; }
.strong { font-weight: 650; color: var(--text-primary); }
.heading, .section-title { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); }
.heading { margin-bottom: 16px; }
.heading h1 { margin-bottom: 6px; }
.heading p:last-child { margin-bottom: 0; }
.section-title { margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.panel { border: 1px solid var(--border-default); border-radius: var(--radius); background: var(--surface-primary); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.content-fit { width: fit-content; max-width: 100%; }
.cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--space-3); margin-bottom: 14px; }
.cards>.metric { margin: 0; padding: 12px 16px; }
.metric { display: flex; flex-direction: column; min-width: 0; }
.metric>span { color: var(--text-secondary); font-size: 13px; }
.metric strong { color: var(--text-primary); font-size: 32px; line-height: 1.25; font-weight: 650; overflow-wrap: anywhere; margin: 3px 0; font-variant-numeric: tabular-nums; }
.metric strong.location { font-size: 20px; }
.dashboard-cards, .finance-cards { grid-template-columns: repeat(4,minmax(0,1fr)); }
.dashboard-cards .metric strong, .finance-cards .metric strong { font-size: 26px; }
.metric-comparison { margin-top: 4px; font-size: 12px; }
.dashboard-comparison-period, [data-period-label] { font-size: 12px; color: var(--text-muted); margin: 4px 0; }
.dashboard-comparison-period { margin-bottom: 8px; }
.dashboard-pending { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin: 8px 0 14px; }
.dashboard-pending strong { font-size: 18px; }
.actions, .form-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.form-actions { margin-top: 20px; }
.activity-nav { margin-bottom: 16px; }
.activity-nav [aria-current="page"] { background: var(--surface-selected); border-color: var(--accent-primary); color: var(--accent-primary); }
.product-group+.product-group { margin-top: 20px; }
.product-group .section-title { margin-bottom: 10px; }
.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }
.inline-action { margin-left: 14px; }
/* Tables retain all columns, scroll within their own boundary on narrow screens. */
.table-panel { padding: 0; overflow: hidden; }
.table-panel .section-title { padding: 14px 18px; margin: 0; }
.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th { background: var(--surface-secondary); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
th, td { padding: 11px 16px; border-bottom: 1px solid var(--border-default); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-elevated) 45%, transparent); }
td small { display: block; margin-top: 3px; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.quantity { font-size: 20px; font-weight: 650; }
.tag { display: inline-block; background: var(--surface-secondary); color: var(--text-secondary); border: 1px solid var(--border-default); padding: 2px 7px; border-radius: var(--radius-sm); font-size: 12px; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-muted); }
.empty h3 { color: var(--text-primary); }
/* Forms and feedback. Native date/select controls inherit dark color-scheme. */
label { display: block; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; font-size: 14px; }
input, select, textarea { width: 100%; min-width: 0; min-height: var(--control-height); padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-primary); background: var(--surface-secondary); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; margin: 0 6px 0 0; accent-color: var(--accent-primary); vertical-align: middle; }
input[type="file"] { max-width: 100%; }
input::file-selector-button { background: var(--surface-elevated); color: var(--text-primary); border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: 6px 10px; margin-right: 10px; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--status-danger); }
input:autofill { box-shadow: 0 0 0 100px var(--surface-secondary) inset; -webkit-text-fill-color: var(--text-primary); }
.field { margin-bottom: 16px; min-width: 0; }
.field small { display: block; margin-top: 5px; }
.form-single, .sale-line { max-width: 760px; }
.form-layout { display: grid; grid-template-columns: minmax(0,2fr) minmax(250px,1fr); max-width: 1160px; gap: 20px; align-items: start; }
.sale-header { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,2fr); gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; width: fit-content; max-width: 100%; padding: 10px 12px; margin-bottom: 10px; }
.filters>div:not([hidden]) { display: flex; gap: 8px; align-items: center; min-width: 0; max-width: 100%; }
.filters label { margin: 0; white-space: nowrap; font-size: 13px; }
.filters input, .filters select { width: auto; max-width: 100%; }
.filters .grow input { width: clamp(200px,22vw,360px); }
.finance-period { margin-bottom: 6px; }
.notice { background: color-mix(in srgb, var(--status-success) 7%, var(--surface-primary)); border: 1px solid color-mix(in srgb, var(--status-success) 50%, var(--border-default)); color: var(--text-primary); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.help { background: var(--surface-secondary); font-size: 14px; }
.errorlist { color: var(--status-danger); background: var(--surface-danger); border: 1px solid color-mix(in srgb, var(--status-danger) 55%, var(--border-default)); border-radius: var(--radius-sm); padding: 10px 12px 10px 28px; font-size: 13px; }
.sale-warning { background: var(--surface-warning); border-color: var(--status-warning); }
.operation, .attention-brief { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-default); }
.operation:last-child, .attention-brief:last-child { border: 0; }
.operation p, .attention-brief p { margin: 3px 0; }
.attention-brief p { color: var(--text-secondary); font-size: 13px; }
.attention-brief>a { flex-shrink: 0; align-self: center; }
details { padding: 8px 0; }
summary { cursor: pointer; color: var(--accent-primary); }
dl { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
dt { color: var(--text-secondary); }
dt, dd, code { overflow-wrap: anywhere; }
dd { margin: 0; }
.login { max-width: 420px; margin: 50px auto; }
.login button { width: 100%; }
/* Charts consume these same tokens in finance.js; datasets and grouping are untouched. */
.finance-chart svg { display: block; width: 100%; height: auto; margin-top: 12px; }
.chart-legend { gap: 20px; }
.chart-legend label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.legend-sales { color: var(--chart-first); }
.legend-collections, .legend-profit { color: var(--chart-second); }
.legend-payments { color: var(--chart-third); }
.chart-note { font-size: 12px; }
.chart-tooltip { position: fixed; z-index: 60; max-width: calc(100vw - 16px); padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-elevated); color: var(--text-primary); font-size: 12px; pointer-events: none; }
/* Responsive shell and shared components. */
@media (max-width: 1100px) {
  .form-layout { grid-template-columns: 1fr; }
  .dashboard-cards .metric strong, .finance-cards .metric strong { font-size: 23px; }
}
@media (max-width: 800px) {
  :root { --header-height: 60px; }
  .topbar { padding: 0 12px; }
  .brand { width: clamp(156px,calc(100vw - 180px),280px); height: 48px; }
  .account-name { max-width: 52px; font-size: 12px; }
  .account-menu summary { gap: 4px; }
  .account-menu summary .icon { width: 12px; flex-basis: 12px; }
  .mobile-menu { display: inline-flex; }
  .drawer-close { display: inline-flex; position: absolute; right: 10px; }
  .sidebar { width: 232px; transform: translateX(-100%); visibility: hidden; transition: transform var(--motion), visibility var(--motion); }
  .sidebar .nav-label { display: inline; }
  .sidebar .nav-tooltip, .sidebar-toggle { display: none; }
  .sidebar-head { justify-content: flex-start; padding-left: 18px; }
  :root[data-drawer="open"] .sidebar { transform: translateX(0); visibility: visible; }
  :root[data-drawer="open"] body { overflow: hidden; }
  .drawer-backdrop { position: fixed; inset: 0; background: #0009; z-index: 35; }
  .has-sidebar .workspace { margin-left: 0; }
  main { padding: 20px 16px; }
  h1 { font-size: 27px; }
  .heading { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .panel { padding: 14px; }
  .table-panel { padding: 0; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .cards>.metric { padding: 12px; }
  .metric strong { font-size: 28px; }
  .dashboard-cards .metric strong, .finance-cards .metric strong { font-size: 22px; }
  .sale-header { grid-template-columns: 1fr; gap: 0; }
  .filters { width: 100%; }
  .filters>div:not([hidden]) { flex-wrap: wrap; flex: 1 1 180px; }
  .filters input, .filters select, .filters .grow input { width: 100%; }
  .finance-period>div:not([hidden]) { flex: 1 1 160px; }
  th, td { padding: 10px 12px; }
  .section-title { flex-wrap: wrap; }
  .operation, .attention-brief { flex-wrap: wrap; }
  .chart-legend { gap: 10px; }
  .dashboard-pending { font-size: 14px; }
}
@media (max-height: 600px) { .sidebar { overflow-y: auto; } .sidebar nav { gap: 2px; padding-top: 6px; padding-bottom: 6px; } .nav-link { min-height: 40px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none; scroll-behavior: auto; } }
