/* Royal Sanitary Store – UI styles. Tokens follow the design canvas style guide. */
:root {
  --bg: #F8FAFC; --surface: #FFFFFF; --surface2: #F1F5F9; --border: #E2E8F0;
  --text: #0F172A; --muted: #475569;
  --primary: #0369A1; --on-primary: #FFFFFF; --primary-soft: #E0F2FE; --primary-text: #075985;
  --success: #047857; --success-soft: #D1FAE5; --on-success: #FFFFFF;
  --warn: #B45309; --warn-soft: #FEF3C7;
  --danger: #B91C1C; --danger-soft: #FEE2E2;
  --side: #0F172A; --side-text: #CBD5E1; --side-active: #0369A1; --side-active-text: #FFFFFF; --side-card: #1E293B;
  --bar: #0369A1; --bar2: #7DD3FC;
  --radius: 14px;
  --font: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Rubik', var(--font);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0B1220; --surface: #111A2B; --surface2: #1A2438; --border: #263248;
  --text: #E2E8F0; --muted: #94A3B8;
  --primary: #38BDF8; --on-primary: #082F49; --primary-soft: #0C2A3F; --primary-text: #7DD3FC;
  --success: #34D399; --success-soft: #0B3B2E; --on-success: #052E21;
  --warn: #FBBF24; --warn-soft: #3A2A0A;
  --danger: #F87171; --danger-soft: #3B1414;
  --side: #070D18; --side-text: #94A3B8; --side-active: #0C2A3F; --side-active-text: #7DD3FC; --side-card: #111A2B;
  --bar: #38BDF8; --bar2: #1E4A6B;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0B1220; --surface: #111A2B; --surface2: #1A2438; --border: #263248;
    --text: #E2E8F0; --muted: #94A3B8;
    --primary: #38BDF8; --on-primary: #082F49; --primary-soft: #0C2A3F; --primary-text: #7DD3FC;
    --success: #34D399; --success-soft: #0B3B2E; --on-success: #052E21;
    --warn: #FBBF24; --warn-soft: #3A2A0A;
    --danger: #F87171; --danger-soft: #3B1414;
    --side: #070D18; --side-text: #94A3B8; --side-active: #0C2A3F; --side-active-text: #7DD3FC; --side-card: #111A2B;
    --bar: #38BDF8; --bar2: #1E4A6B;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
a { color: var(--primary-text); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.c-success { color: var(--success); }
.c-danger { color: var(--danger); }
.c-warn { color: var(--warn); }
.c-primary { color: var(--primary-text); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; background: var(--side-active); color: var(--side-active-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 17px; color: #F8FAFC; display: block; }
.brand-sub { font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-decoration: none; font-weight: 600; color: var(--side-text); }
.nav a:hover { background: var(--side-card); }
.nav a.active { background: var(--side-active); color: var(--side-active-text); }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--side-card); }
.side-user .who { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.side-user .who b { color: #F8FAFC; font-size: 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--side-active); color: var(--side-active-text); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; text-transform: uppercase; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: inherit; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface2); }
.sidebar .icon-btn:hover { background: var(--side); }
main.content { flex: 1; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head .title { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  main.content { padding: 16px 14px 104px; gap: 14px; }
  h1 { font-size: 22px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(68px + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom); gap: 2px; background: var(--surface); border-top: 1px solid var(--border); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 12px; font-weight: 700; color: var(--muted); border-radius: 12px; }
  .bottom-nav a.active { color: var(--primary-text); }
  .bottom-nav a.fab span.fab-btn { width: 52px; height: 52px; margin-top: -20px; border-radius: 16px; background: var(--primary); color: var(--on-primary); display: flex; align-items: center; justify-content: center; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.tight { padding: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.row > .grow { flex: 2 1 460px; min-width: 0; }
.row > .side { flex: 1 1 320px; min-width: 0; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.kpi .value { font-family: var(--font-head); font-size: clamp(20px, 1.9vw, 26px); white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 13px; color: var(--muted); }
.kpi .ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.ico.blue { background: var(--primary-soft); color: var(--primary-text); }
.ico.green { background: var(--success-soft); color: var(--success); }
.ico.amber { background: var(--warn-soft); color: var(--warn); }
.ico.red { background: var(--danger-soft); color: var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; background: var(--surface); color: var(--text); border-color: var(--border); white-space: nowrap; }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.success { background: var(--success); color: var(--on-success); border-color: var(--success); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary-text); }
.btn.big { min-height: 50px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; min-width: 0; }
.field .help { font-weight: 400; font-size: 13px; color: var(--muted); }
.field .err { font-weight: 700; font-size: 13px; color: var(--danger); }
.input, select.input, textarea.input { height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 400; width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; }
.input.bad { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 520px) { .form-grid .span2 { grid-column: auto; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.search { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); flex: 1 1 260px; align-self: stretch; max-height: 48px; }
.catalog .search { flex: 0 0 auto; }
.search input { border: 0; outline: none; background: transparent; color: var(--text); width: 100%; min-height: 44px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg button { min-width: 46px; height: 40px; border: 0; background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface2); }
.tabs button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.tabs button[aria-pressed="true"], .tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.low { background: var(--warn-soft); color: var(--warn); }
.badge.out, .badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--primary-soft); color: var(--primary-text); }
.badge.muted { background: var(--surface2); color: var(--muted); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; padding: 10px 10px; background: var(--surface2); white-space: nowrap; }
.table td { padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface2); }
.table .right { text-align: right; }
.card.flush { padding: 0; overflow: hidden; }
.card:not(.flush) > .table-wrap { margin: 0 -20px; border-radius: 0; }
.card:not(.flush) > .table-wrap:last-child { margin-bottom: -20px; border-radius: 0 0 var(--radius) var(--radius); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); min-height: 52px; }
.list-item:first-of-type { border-top: 0; }
.list-item .main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.total-box { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-text); gap: 10px; }
.total-box .amount { font-family: var(--font-head); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-lines { display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.sum-lines > div { display: flex; justify-content: space-between; gap: 12px; }
.note-box { padding: 10px 14px; border-radius: 10px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.note-box.warn { background: var(--warn-soft); color: var(--warn); }
.note-box.ok { background: var(--success-soft); color: var(--success); }
.note-box.info { background: var(--primary-soft); color: var(--primary-text); }

/* Chart */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 200px; border-bottom: 1px solid var(--border); }
.bars .bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.bars .bar { width: 100%; max-width: 54px; background: var(--bar2); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar.hi { background: var(--bar); }
.bar-labels { display: flex; gap: 12px; }
.bar-labels span { flex: 1 1 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.hbar { height: 12px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.hbar > div { height: 100%; background: var(--bar); border-radius: 6px; }

/* POS */
.pos { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.pos .catalog { flex: 1 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.pos .bill { flex: 1 1 420px; min-width: 0; position: sticky; top: 16px; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.prod-card { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; min-height: 116px; }
.prod-card:hover { border-color: var(--primary); }
.prod-card:disabled { opacity: 0.5; cursor: not-allowed; }
.prod-card .cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.prod-card .nm { font-weight: 700; line-height: 1.3; flex-grow: 1; }
.prod-card .ft { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.prod-card .ft b { white-space: nowrap; }
.line { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface2); }
.line .top { display: flex; align-items: flex-start; gap: 8px; }
.line .top .main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.line .disc { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line .disc .input { width: 80px; height: 40px; }
.line .disc .net { margin-left: auto; text-align: right; display: flex; flex-direction: column; }
.line .price-in { width: 100px; height: 36px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); flex-shrink: 0; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); }
.stepper input { width: 52px; height: 40px; border: 0; background: transparent; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper.on { border-color: var(--primary); background: var(--primary-soft); }
.bill-disc { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.bill-disc .input { width: 96px; }
.methods { display: flex; gap: 8px; }
.methods .chip { flex: 1; border-radius: 10px; min-height: 44px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16); max-height: 320px; overflow-y: auto; }
.results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 0; border-top: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.results button:first-child { border-top: 0; }
.results button:hover, .results button.active { background: var(--primary-soft); }
.rel { position: relative; }

@media (max-width: 900px) {
  .pos .bill { position: static; }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Dialog */
dialog.modal { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3); }
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.5); }
dialog.modal form, dialog.modal .body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
dialog.modal .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Toast */
.toasts { position: fixed; z-index: 100; top: 16px; right: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 420px; padding: 12px 16px; border-radius: 12px; font-weight: 700; background: var(--text); color: var(--bg); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25); }
.toast.error { background: var(--danger); color: #FFFFFF; }
.toast.ok { background: var(--success); color: var(--on-success); }

/* Login */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login .hero { flex: 1 1 420px; padding: 56px; background: #0F172A; color: #CBD5E1; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login .hero .big { font-family: var(--font-head); font-size: 38px; line-height: 1.15; font-weight: 600; color: #F8FAFC; max-width: 460px; }
.login .hero .pills { display: flex; flex-wrap: wrap; gap: 10px; }
.login .hero .pills span { padding: 8px 14px; border-radius: 999px; background: #1E293B; font-weight: 700; font-size: 14px; }
.login .form-side { flex: 1 1 420px; padding: 48px 20px; display: flex; align-items: center; justify-content: center; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 900px) { .login .hero { padding: 28px 20px; gap: 16px; } .login .hero .big { font-size: 26px; } .login .hero .pills { display: none; } }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.more-list a { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; border-top: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 700; }
.more-list a:first-child { border-top: 0; }
.table-wrap > table.table { min-width: 560px; }
