/* FiveK Stock - design system
   Light + dark themes via CSS variables. Mobile first adjustments at the bottom. */

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f3f4f9;
  --surface-3: #eceef6;
  --border: #e5e7f0;
  --border-strong: #d3d6e4;
  --text: #171a26;
  --text-2: #3d4256;
  --muted: #6a7088;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eceafe;
  --on-primary: #ffffff;
  --green: #0f9d63;
  --green-soft: #e3f7ed;
  --amber: #c27803;
  --amber-soft: #fdf1d6;
  --red: #d92d20;
  --red-soft: #fde8e6;
  --blue: #1570ef;
  --blue-soft: #e3effe;
  --violet: #7a3fe0;
  --violet-soft: #f0e8fd;
  --topbar-bg: rgba(245, 246, 250, 0.82);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 10px 30px -10px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1017;
  --surface: #151923;
  --surface-2: #1a1f2b;
  --surface-3: #212736;
  --border: #252b3a;
  --border-strong: #323a4f;
  --text: #e9ecf4;
  --text-2: #c3c8d8;
  --muted: #8a92a8;
  --primary: #8b8cff;
  --primary-600: #a2a3ff;
  --primary-soft: #232552;
  --on-primary: #0d1017;
  --green: #3ddc97;
  --green-soft: #12301f;
  --amber: #f5b942;
  --amber-soft: #382b0e;
  --red: #ff7a6e;
  --red-soft: #3b1816;
  --blue: #6cb0ff;
  --blue-soft: #14284a;
  --violet: #b99cff;
  --violet-soft: #2a1f4d;
  --topbar-bg: rgba(13, 16, 23, 0.82);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.strong { font-weight: 600; }
.hidden { display: none !important; }
.ic { flex: none; }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 0 14px 14px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; height: 68px; padding: 0 8px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6d5dfc 0%, #4f46e5 55%, #3b32c9 100%);
  box-shadow: 0 6px 14px -4px rgba(79, 70, 229, .55);
}
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.nav-label { margin: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; margin-top: 10px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 68px;
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topsearch {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.topsearch:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.topsearch input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.topsearch input::-webkit-search-cancel-button { display: none; }
.topsearch kbd { font: 600 11px var(--font); color: var(--muted); border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; background: var(--surface-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.when-dark { display: none; }
[data-theme="dark"] .when-dark { display: inline-flex; }
[data-theme="dark"] .when-light { display: none; }
.scrim { display: none; }

.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: 28px 28px 64px; }
.content-narrow { max-width: 920px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h1 { font-size: 25px; font-weight: 700; letter-spacing: -0.025em; }
.page-title .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h2 { font-size: 15.5px; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.card-body { padding: 16px 20px 20px; }
.grid { display: grid; gap: 18px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-bottom: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
.stack-gap > * + * { margin-top: 18px; }

.kpi { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.kpi > div:last-child { min-width: 0; overflow-wrap: anywhere; }
.kpi-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.kpi-icon.c-blue { background: var(--blue-soft); color: var(--blue); }
.kpi-icon.c-violet { background: var(--violet-soft); color: var(--violet); }
.kpi-icon.c-green { background: var(--green-soft); color: var(--green); }
.kpi-icon.c-amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.c-primary { background: var(--primary-soft); color: var(--primary); }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -0.025em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-foot { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-link:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b42318; border-color: #b42318; }
.btn-danger-ghost { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent;
  color: var(--text-2); border-radius: 11px; cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
form.inline { display: inline; margin: 0; }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .opt { font-weight: 400; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a92a8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.warn { color: var(--red); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 20px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-3); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 3px solid var(--primary-soft); }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }

/* ------------------------------------------------------------ line items */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line-head, .line { display: grid; gap: 12px; align-items: start; }
.cols-4 { grid-template-columns: minmax(0, 3fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1.2fr) 40px; }
.cols-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) 40px; }
.line-head { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 2px; }
.line { padding: 0; }
.line .l-label { display: none; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.line .l-cell { min-width: 0; }
.line .l-unit { position: relative; }
.line .l-unit .unit { position: absolute; right: 12px; top: 11px; font-size: 12.5px; color: var(--muted); pointer-events: none; }
.line .l-unit .input { padding-right: 46px; }
.line .l-amount { height: 42px; display: flex; align-items: center; justify-content: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 4px; }
.line .l-remove { height: 42px; }
.lines-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }
.total-box { display: flex; align-items: baseline; gap: 12px; }
.total-box .t-label { color: var(--muted); font-weight: 500; }
.total-box .t-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 11px 16px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .item-name { font-weight: 600; color: var(--text); }
.table .sub { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table a.row-link { color: var(--text); font-weight: 600; }
.table a.row-link:hover { color: var(--primary); }
.table .actions { text-align: right; white-space: nowrap; }
.in-qty { color: var(--green); font-weight: 600; }
.out-qty { color: var(--red); font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); }
.pager-info { color: var(--muted); font-size: 13px; }
.pager-links { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------ badges, meters */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.green > span { background: var(--green); }
.meter.amber > span { background: var(--amber); }
.meter.red > span { background: var(--red); }

/* ------------------------------------------------------------ alerts, empty, dialog */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 18px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.alert > div { flex: 1; }
.alert-success { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-info, .alert-warning { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.alert-x { background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; display: grid; }
.alert-x:hover { opacity: 1; }
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty h3 { font-size: 16px; }
.empty p { color: var(--muted); margin: 6px auto 16px; max-width: 380px; }
.dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-md), 0 0 0 1px var(--border); width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); }
.dialog > form, .dialog > .dialog-body { padding: 24px; }
.dialog h3 { font-size: 17px; margin-bottom: 6px; }
.dialog-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog-wide { width: min(620px, calc(100vw - 32px)); }

/* ------------------------------------------------------------ detail pages */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px 24px; }
.meta .m-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meta .m-value { margin-top: 3px; font-weight: 600; font-size: 15px; word-break: break-word; }
.big-number { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); flex-wrap: wrap; }
.tabs a, .tabs button { padding: 7px 14px; border-radius: 9px; font: 600 13.5px var(--font); color: var(--muted); border: 0; background: none; cursor: pointer; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active, .tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font: 600 13px var(--font); color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip.active b { color: inherit; opacity: .85; }
.link-list { display: flex; flex-direction: column; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); color: inherit; }
.link-row:last-child { border-bottom: 0; }
.link-row:hover { text-decoration: none; }
.link-row .grow { flex: 1; min-width: 0; }
.link-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .s { color: var(--muted); font-size: 12.5px; }
.dot-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.big-search { position: relative; }
.big-search .ic { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.big-search .input { height: 54px; padding-left: 48px; font-size: 16px; border-radius: 14px; }

/* trace cards */
.lot { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.lot + .lot { margin-top: 14px; }
.lot-head { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 18px; background: var(--surface-2); }
.lot-head .l-title { font-weight: 600; font-size: 15px; }
.lot-nums { display: flex; gap: 22px; flex-wrap: wrap; }
.lot .table { table-layout: fixed; min-width: 640px; }
.lot .table th:nth-child(1) { width: 130px; }
.lot .table th:nth-child(2) { width: 24%; }
.lot .table th:nth-child(4) { width: 18%; }
.lot .table th:nth-child(5) { width: 120px; }
.lot-nums div { display: flex; flex-direction: column; }
.lot-nums small { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.lot-nums b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ charts */
.chart text { fill: var(--muted); font: 500 11px var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar-a { fill: var(--primary); }
.chart .bar-b { fill: var(--green); }
.chart rect { transition: opacity .15s; }
.chart g.col:hover rect { opacity: .8; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.login-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 10% -10%, #7b6dff 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #2e2a9e 0%, transparent 60%), #3f37c9;
}
.login-art::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(135deg, transparent 20%, #000 100%); -webkit-mask-image: linear-gradient(135deg, transparent 20%, #000 100%); pointer-events: none; }
.login-art > * { position: relative; z-index: 1; }
.login-art .brand { color: #fff; padding: 0; }
.login-art .brand-mark { background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.login-art h2 { font-size: 36px; line-height: 1.15; letter-spacing: -0.03em; max-width: 440px; }
.login-art p { opacity: .85; margin-top: 14px; max-width: 420px; font-size: 16px; line-height: 1.6; }
.login-steps { display: flex; gap: 10px; flex-wrap: wrap; }
.login-steps span { padding: 7px 14px; border-radius: 999px; background: rgba(255,255,255,.14); font-weight: 600; font-size: 13px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.login-panel { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.login-card .sub { color: var(--muted); margin: 6px 0 26px; }
.login-card .field + .field { margin-top: 16px; }
.login-card .btn { margin-top: 24px; height: 46px; font-size: 15px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-wrap button { position: absolute; right: 4px; top: 3px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.pw-wrap button:hover { background: var(--surface-2); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1360px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-2-1, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-md); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 12, 20, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 56px; }
}
@media (max-width: 760px) {
  .grid-kpi { gap: 12px; }
  .kpi { flex-direction: column; gap: 10px; padding: 14px; }
  .kpi-icon { width: 38px; height: 38px; border-radius: 11px; }
  .hide-sm { display: none !important; }
  .topsearch kbd { display: none; }
  .page-title h1 { font-size: 22px; }
  .kpi-value { font-size: 22px; }
  .filters { padding: 14px 16px; }
  .filters .field { flex: 1 1 140px; }
  .card-head { padding: 16px 16px 0; }
  .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
  .form-grid .span-2 { grid-column: 1 / -1; }

  /* line items become compact cards */
  .line-head { display: none; }
  .line { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); gap: 10px; }
  .cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)) 40px; }
  .cols-2 { grid-template-columns: minmax(0, 1fr) 40px; }
  .cols-4 .l-item { grid-column: 1 / -1; }
  .cols-2 .l-item { grid-column: 1 / -1; }
  .line .l-label { display: block; }
  .line .l-amount { justify-content: flex-start; }

  /* tables that opt in turn into stacked cards */
  .table.stack thead { display: none; }
  .lot .table { min-width: 0; table-layout: auto; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; text-align: right !important; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; }
  .table.stack td.cell-title { display: block; text-align: left !important; padding-bottom: 6px; font-size: 15.5px; }
  .table.stack td.cell-title::before, .table.stack td.no-label::before { display: none; }
  .table.stack td.actions { justify-content: flex-end; padding-top: 8px; }
  .table.stack tfoot { display: block; }
  .table.stack tfoot tr { display: flex; justify-content: space-between; }
  .table.stack tfoot td { width: auto; display: block; }
  .login-wrap { grid-template-columns: minmax(0, 1fr); }
  .login-art { display: none; }
}
@media (max-width: 420px) {
  .btn { padding: 0 13px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}

/* ------------------------------------------------------------ print */
.print-only { display: none; }
@media print {
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f4f4f6; --text: #000; --text-2: #222; --muted: #555; --border: #ccc; color-scheme: light; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .scrim, .page-actions, .no-print, .pager, .filters, .alert-x, .btn, .icon-btn { display: none !important; }
  .app { display: block; }
  .content { max-width: none; padding: 0; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .print-only { display: block; }
  .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { overflow: visible; }
  a { color: inherit; }
}
