/* ECOM PORTAL – theme */
:root, [data-theme="dark"] {
  --bg: #0f172a; --panel: #1e293b; --panel-2: #172033; --line: #2c3a52; --line-2: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --faint: #64748b; --head: #f8fafc;
  --accent: #14b8a6; --accent-2: #2dd4bf; --accent-ink: #042f2e; --accent-soft: rgba(20,184,166,.14);
  --danger: #f87171; --warn: #fbbf24; --ok: #34d399; --info: #60a5fa;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.18);
  --radius: 12px; --input: #0f172a;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f1f5f9; --panel: #ffffff; --panel-2: #f8fafc; --line: #e2e8f0; --line-2: #cbd5e1;
  --text: #1e293b; --muted: #64748b; --faint: #94a3b8; --head: #0f172a;
  --accent: #0d9488; --accent-2: #14b8a6; --accent-ink: #ffffff; --accent-soft: rgba(13,148,136,.10);
  --danger: #dc2626; --warn: #b45309; --ok: #059669; --info: #2563eb;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.06);
  --input: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
[data-theme="light"] a { color: var(--accent); }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--head); margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code { background: var(--panel-2); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid var(--line); color: var(--head); text-decoration: none !important; }
.brand img, .brand svg { width: 34px; height: 34px; flex: none; }
.brand .brand-logo-custom { width: auto; max-width: 150px; height: 34px; object-fit: contain; }
.wordmark { font-weight: 800; letter-spacing: .06em; font-size: 1.02rem; white-space: nowrap; color: var(--head); }
.wordmark b { color: var(--accent-2); font-weight: 600; margin-left: .28em; }
[data-theme="light"] .wordmark b { color: var(--accent); }
.nav { padding: .6rem .5rem 1rem; flex: 1; }
.nav .sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); padding: .9rem .75rem .3rem; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .75rem; border-radius: 9px; color: var(--muted); font-weight: 500; text-decoration: none; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); }
[data-theme="light"] .nav a.active { color: var(--accent); }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--faint); }
.app.collapsed { grid-template-columns: 68px 1fr; }
.app.collapsed .wordmark, .app.collapsed .nav a span, .app.collapsed .nav .sec, .app.collapsed .sidebar-foot, .app.collapsed .brand-logo-custom { display: none; }
.app.collapsed .brand .icon-only { display: block !important; }
.app.collapsed .nav a { justify-content: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 650; color: var(--head); font-size: 1rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 9px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--panel); }
.icon-btn svg { width: 18px; height: 18px; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.content { padding: 1.25rem; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1; min-width: 180px; }
.menu-toggle { display: none; }
.backdrop { display: none; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card > h2:first-child, .card-head { margin-bottom: .75rem; }
.card-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; display: block; color: inherit; text-decoration: none !important; position: relative; overflow: hidden; }
a.kpi:hover { border-color: var(--accent); }
.kpi .k-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .k-val { color: var(--head); font-size: 1.35rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .k-sub { color: var(--faint); font-size: .78rem; }
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 45%; height: 30px; opacity: .5; }
.kpi .spark path { stroke: var(--accent); fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.delta { font-size: .75rem; font-weight: 600; margin-left: .25rem; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--faint); }
.delta.inv.up { color: var(--danger); } .delta.inv.down { color: var(--ok); }
.period-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.period { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.period h3 { margin: 0 0 .6rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.period .rows { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .75rem; }
.period .rows a, .period .rows div { display: block; color: inherit; text-decoration: none; }
.period .v { font-size: 1.15rem; font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; }
.period .l { font-size: .75rem; color: var(--faint); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: .5rem .85rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.2; min-height: 36px; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
[data-theme="dark"] .btn-primary { color: #042f2e; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: .3rem .6rem; min-height: 30px; font-size: .82rem; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line-2); color: var(--text); border-radius: 9px; padding: .5rem .65rem; font: inherit; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; color: var(--text); font-size: .88rem; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem 1rem; }
.form-grid .span2 { grid-column: span 2; } .form-grid .full { grid-column: 1 / -1; }
.field { min-width: 0; }
.hint { font-size: .76rem; color: var(--faint); margin-top: .2rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.inline-form { display: inline; }
.req::after { content: " *"; color: var(--danger); }

/* alerts */
.alert { padding: .65rem .9rem; border-radius: 10px; margin-bottom: .8rem; border: 1px solid; font-size: .9rem; }
.alert-success { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.alert-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert-info { background: color-mix(in srgb, var(--info) 10%, transparent); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* badges */
.badge { --bc: #64748b; display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap;
  color: color-mix(in srgb, var(--bc) 75%, var(--head)); background: color-mix(in srgb, var(--bc) 18%, transparent); border: 1px solid color-mix(in srgb, var(--bc) 35%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--bc); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 6px; font-size: .72rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag-demo { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -1.1rem; padding: 0 1.1rem; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
.t td { padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.t .num, .t th.num { text-align: right; white-space: nowrap; }
.t tfoot td { font-weight: 700; color: var(--head); border-top: 2px solid var(--line-2); }
.t a.cell-link { color: inherit; border-bottom: 1px dashed var(--faint); text-decoration: none; }
.t a.cell-link:hover { color: var(--accent-2); border-color: var(--accent-2); }
.t .sel { width: 30px; }
.t tr.muted-row td { opacity: .55; }
.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.empty { text-align: center; color: var(--faint); padding: 2rem 1rem !important; }

/* filters / chips */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: .25rem; }
.chip { padding: .32rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .82rem; text-decoration: none !important; white-space: nowrap; border: 0; background: none; cursor: pointer; font-family: inherit; }
.chip:hover { color: var(--text); background: var(--panel-2); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
[data-theme="dark"] .chip.on { color: #042f2e; }
.range-custom { display: none; align-items: center; gap: .35rem; }
.range-custom.show { display: inline-flex; }
.range-custom input { width: 145px; min-height: 34px; padding: .3rem .5rem; }
.filterbar select { width: auto; min-height: 36px; padding: .35rem .6rem; }
.status-tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .75rem; scrollbar-width: thin; }
.status-tabs a { flex: none; display: inline-flex; gap: .4rem; align-items: center; padding: .38rem .7rem; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 600; font-size: .82rem; text-decoration: none; }
.status-tabs a.on { border-color: var(--accent); color: var(--head); background: var(--accent-soft); }
.status-tabs .n { background: var(--panel-2); padding: 0 .4rem; border-radius: 6px; font-size: .75rem; }
.adv-filters { display: none; }
.adv-filters.show { display: block; }
.bulkbar { display: none; position: sticky; bottom: .75rem; z-index: 20; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: .6rem .8rem; box-shadow: var(--shadow); align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.bulkbar.show { display: flex; }
.bulkbar select { width: auto; min-height: 34px; }
.pager { display: flex; gap: .35rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: .8rem; color: var(--muted); font-size: .85rem; }
.loading { opacity: .5; pointer-events: none; transition: opacity .15s; }

/* charts */
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; min-height: 150px; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .axis { fill: var(--faint); font-size: 11px; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart a:hover .bar { opacity: 1; fill: var(--accent-2); }
.chart .hit { fill: transparent; }
.chart a:hover .hit { fill: var(--accent-soft); }
.chart .line { stroke: #60a5fa; stroke-width: 2.25; vector-effect: non-scaling-stroke; }
.chart .line-axis { fill: #60a5fa; opacity: .8; }
.legend { display: flex; gap: .9rem; align-items: center; font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.lg-bar, .lg-line { display: inline-block; width: 12px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: -.5rem; }
.lg-line { height: 3px; background: #60a5fa; margin-left: .5rem; }
.hbars { display: flex; flex-direction: column; gap: .35rem; }
.hb-row { --hb: var(--accent); display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; align-items: center; gap: .6rem; padding: .25rem .35rem; border-radius: 7px; color: inherit; text-decoration: none !important; font-size: .85rem; }
a.hb-row:hover { background: var(--panel-2); }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hb-track { height: 9px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--hb); border-radius: 99px; min-width: 2px; }
.hb-val { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--head); white-space: nowrap; }

/* order form */
.items-table td { padding: .4rem .35rem; vertical-align: middle; }
.items-table input, .items-table select { min-height: 36px; }
.items-table .qty { width: 80px; } .items-table .price { width: 110px; }
.totals { margin-left: auto; max-width: 340px; display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.15rem; font-weight: 800; color: var(--head); border-top: 1px solid var(--line); padding-top: .4rem; }
.phone-info { margin-top: .35rem; font-size: .82rem; }
.phone-info .warn-box { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); padding: .5rem .65rem; border-radius: 9px; }
.phone-info .bad-box { border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); padding: .5rem .65rem; border-radius: 9px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.2rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline li:last-child { border-color: transparent; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; } .dl dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .85rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.on { color: var(--head); border-color: var(--accent); }
.stock-low { color: var(--warn); font-weight: 700; } .stock-out { color: var(--danger); font-weight: 700; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid var(--line-2); }

/* auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background:
  radial-gradient(1200px 600px at 10% -10%, rgba(20,184,166,.16), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(59,130,246,.10), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 2rem 1.75rem 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: 1.4rem; }
.auth-logo img.mark { width: 64px; height: 64px; filter: drop-shadow(0 8px 18px rgba(20,184,166,.35)); }
.auth-logo .wordmark { font-size: 1.45rem; }
.auth-logo .tagline { color: var(--muted); font-size: .85rem; margin-top: -.35rem; }
.auth-card .field { margin-bottom: .85rem; }
.auth-foot { text-align: center; color: var(--faint); font-size: .78rem; margin-top: 1rem; }
.theme-float { position: fixed; top: 1rem; right: 1rem; }

/* print */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .bulkbar, .filterbar { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; }
  .print-only { display: block; }
  .invoice { page-break-after: always; border: 0 !important; box-shadow: none !important; }
  .invoice:last-child { page-break-after: auto; }
}
.invoice { background: #fff; color: #111827; border-radius: 12px; padding: 1.75rem; margin: 0 auto 1.25rem; max-width: 820px; box-shadow: var(--shadow); font-size: 13px; }
.invoice h1, .invoice h2, .invoice h3 { color: #111827; }
.invoice table { width: 100%; border-collapse: collapse; }
.invoice th, .invoice td { border-bottom: 1px solid #e5e7eb; padding: .45rem .4rem; text-align: left; }
.invoice .num { text-align: right; }
.invoice .inv-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.invoice .inv-logo { height: 44px; max-width: 220px; object-fit: contain; }
.invoice .muted { color: #6b7280; }
.invoice .box { border: 1px solid #e5e7eb; border-radius: 8px; padding: .7rem .8rem; }
.invoice .cod-box { border: 2px solid #111827; border-radius: 8px; padding: .5rem .8rem; font-size: 1.1rem; font-weight: 800; display: inline-block; }
.invoice .slip-cut { border-top: 2px dashed #9ca3af; margin: 1.25rem 0; }

/* responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .app.collapsed .wordmark, .app.collapsed .nav a span, .app.collapsed .nav .sec, .app.collapsed .sidebar-foot { display: initial; }
  .menu-toggle { display: inline-flex; }
  .collapse-toggle { display: none !important; }
  .content { padding: .85rem; }
  .topbar { padding: .5rem .85rem; }
  .user-chip .uname { display: none; }
  .period-cards { grid-template-columns: 1fr; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span2 { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-val { font-size: 1.1rem; }
  /* tables -> cards */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td, table.t.cards tfoot { display: block; width: 100%; }
  table.t.cards tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; padding: .45rem .7rem; background: var(--panel-2); position: relative; }
  table.t.cards td { border: 0; padding: .22rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.t.cards td::before { content: attr(data-label); color: var(--faint); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; padding-top: .1rem; }
  table.t.cards td.sel { position: absolute; right: .6rem; top: .55rem; width: auto; display: block; }
  table.t.cards td.sel::before, table.t.cards td.card-title::before { content: none; }
  table.t.cards td.card-title { display: block; text-align: left; padding-right: 2rem; font-size: .95rem; }
  table.t.cards td.num { justify-content: space-between; }
  table.t.cards tbody tr:hover td { background: transparent; }
  table.t.cards tfoot tr { background: var(--panel); }
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .card { padding: .85rem; }
  .hide-sm { display: none !important; }
  .range-custom input { width: 130px; }
  .filterbar > * { max-width: 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .totals { max-width: none; }
  .items-table .qty { width: 64px; } .items-table .price { width: 90px; }
  .invoice { padding: 1rem; }
}
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Country workspace switcher ---------- */
.ws-switch{position:relative}
.ws-switch>summary{list-style:none;display:flex;align-items:center;gap:.5rem;cursor:pointer;padding:.4rem .75rem;border-radius:10px;
  border:1px solid color-mix(in srgb,var(--accent) 45%,var(--line));background:color-mix(in srgb,var(--accent) 12%,var(--panel));font-weight:600;white-space:nowrap;user-select:none}
.ws-switch>summary::-webkit-details-marker{display:none}
.ws-switch>summary:hover{border-color:var(--accent)}
.ws-switch .ws-flag{font-size:1.15rem;line-height:1}
.ws-switch .ws-cur{font-size:.72rem;font-weight:700;padding:.1rem .4rem;border-radius:6px;background:var(--accent);color:var(--accent-ink)}
.ws-switch svg{width:16px;height:16px;opacity:.7}
.ws-menu{position:absolute;left:0;top:calc(100% + 6px);z-index:60;min-width:250px;background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,.35);padding:.35rem}
.ws-menu a{display:flex;align-items:center;gap:.6rem;padding:.55rem .65rem;border-radius:8px;color:var(--text);text-decoration:none}
.ws-menu a:hover{background:var(--panel-2)}
.ws-menu a.on{background:color-mix(in srgb,var(--accent) 16%,transparent)}
.ws-menu a small{margin-left:auto;color:var(--muted);font-weight:600}
.ws-menu a.ws-all{border-top:1px solid var(--line);border-radius:0 0 8px 8px;color:var(--muted)}
@media (max-width:640px){.ws-switch .ws-name{display:none}.topbar .title{font-size:.95rem}}
.danger-zone{border-color:color-mix(in srgb,var(--danger,#ef4444) 50%,var(--line))}
.danger-zone h2{color:var(--danger,#ef4444)}
tr.row-err td{background:color-mix(in srgb,#ef4444 12%,transparent)}
tr.row-ok td:first-child{box-shadow:inset 3px 0 0 #22c55e}
td .cell-err{outline:1px dashed #ef4444;outline-offset:2px}
.ov-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:1rem}
.btn-primary-soft{background:var(--accent-soft);border-color:var(--accent);color:var(--accent-2);font-weight:600}
.btn-primary-soft:hover{background:var(--accent);color:var(--accent-ink)}
.import-group{gap:0}.import-group .btn:first-child{border-top-right-radius:0;border-bottom-right-radius:0}.import-group .btn:last-child{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}
.import-preview td.import-result{min-width:220px;max-width:320px;white-space:normal}
.import-preview td{white-space:nowrap}
.import-preview td.import-result .neg{font-size:.82rem;line-height:1.35}
@media (max-width:760px){.import-preview td{white-space:normal}.import-preview td.import-result{min-width:0;max-width:none}}
