:root {
  --bg: #f4f6fb; --card: #ffffff; --ink: #1b2333; --muted: #667085; --line: #e4e7ee;
  --brand: #1d4ed8; --brand-2: #1e3a8a; --brand-soft: #e8efff;
  --ok: #067647; --ok-soft: #e6f6ee; --warn: #b54708; --warn-soft: #fff4e5; --bad: #c01048; --bad-soft: #fdecf2;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout */
.topbar { position: sticky; top: 0; z-index: 20; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 10px; padding-top: calc(10px + env(safe-area-inset-top)); }
.topbar .logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; color: var(--brand-2); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.topbar .t1 { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .t2 { font-size: .75rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .userchip { font-size: .78rem; background: rgba(255,255,255,.16); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { display: none; }
main { flex: 1; min-width: 0; padding: 16px; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; width: 100%; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--brand); }
.bottomnav a.primary span.ic { background: var(--brand); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 12px rgba(29,78,216,.35); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }

@media (min-width: 900px) {
  .bottomnav { display: none; }
  .sidebar { display: block; width: 230px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: 12px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
  .sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; margin-bottom: 2px; }
  .sidebar a svg { width: 20px; height: 20px; color: var(--muted); }
  .sidebar a.active { background: var(--brand-soft); color: var(--brand); } .sidebar a.active svg { color: var(--brand); }
  .sidebar .sep { height: 1px; background: var(--line); margin: 10px 4px; }
  main { padding: 24px; }
}

/* ---------- components */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .sm-g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .k { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.stat .v { font-size: 1.45rem; font-weight: 800; margin-top: 2px; }
.stat .s { font-size: .8rem; color: var(--muted); }
.stat.blue { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; } .stat.blue .k, .stat.blue .s { color: rgba(255,255,255,.85); }
.stat.red .v { color: var(--bad); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row .grow { flex: 1; min-width: 0; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pagehead h2 { margin: 0; }

.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f5c2d3; }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.iconbtn { border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.iconbtn:hover { background: var(--bg); }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .82rem; font-weight: 600; color: #344054; margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29,78,216,.25); border-color: var(--brand); }
.seg { display: flex; background: var(--bg); padding: 4px; border-radius: 12px; gap: 4px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); color: inherit; }
.li:last-child { border-bottom: 0; }
.li .av { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.li .main { flex: 1; min-width: 0; }
.li .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .main .muted { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.blue { background: var(--brand-soft); color: var(--brand); } .pill.gray { background: #f2f4f7; color: #475467; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tfoot td { font-weight: 800; border-top: 2px solid var(--ink); }
table.t .r { text-align: right; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 38px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b span { font-size: .68rem; color: var(--muted); white-space: nowrap; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: .88rem; margin-bottom: 12px; }
.alert.info { background: var(--brand-soft); color: var(--brand-2); } .alert.warn { background: var(--warn-soft); color: var(--warn); } .alert.bad { background: var(--bad-soft); color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 100; font-size: .9rem; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); }

.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.5); z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }

.dropdown { position: relative; }
.dropdown .menu { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12); z-index: 40; max-height: 300px; overflow: auto; margin-top: 4px; }
.dropdown .menu .li { padding: 10px 12px; cursor: pointer; } .dropdown .menu .li:hover { background: var(--bg); }

.morelist a { display: flex; align-items: center; gap: 12px; padding: 14px 6px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.morelist a svg { width: 22px; height: 22px; color: var(--brand); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand-2), var(--brand) 60%, #60a5fa); }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; margin: 0 auto 10px; }

/* receipt / print */
.slip { background: #fff; max-width: 720px; margin: 0 auto; padding: 22px; border: 1px solid var(--line); border-radius: 8px; color: #000; }
.slip .sh { text-align: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
.slip .sh h1 { font-size: 1.45rem; margin: 0; letter-spacing: .02em; }
.slip .sh .addr { font-size: .85rem; }
.slip .sh .ttl { display: inline-block; margin-top: 8px; border: 1px solid #000; padding: 2px 14px; font-weight: 700; font-size: .85rem; letter-spacing: .05em; }
.slip table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.slip td, .slip th { border: 1px solid #999; padding: 6px 8px; text-align: left; }
.slip .kv td { border: 0; padding: 3px 4px; }
.slip .big { font-size: 1.15rem; font-weight: 800; }
.slip .sign { display: flex; justify-content: space-between; margin-top: 36px; font-size: .85rem; }
.slip .sign div { border-top: 1px solid #000; padding-top: 4px; min-width: 140px; text-align: center; }
.noprint {}
@media print {
  body { background: #fff; }
  .topbar, .sidebar, .bottomnav, .noprint, .toast { display: none !important; }
  main { padding: 0; }
  .slip { border: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  @page { margin: 12mm; }
}

/* fixes */
.btn svg { width: 18px; height: 18px; flex: none; }
@media (max-width: 639px) { #cl-out { position: static; } [style*="position:sticky"] { position: static !important; } }
.li .main .muted { display: block; }
@media (max-width: 600px) {
  .topbar .userchip { max-width: 92px; overflow: hidden; text-overflow: ellipsis; font-size: .7rem; }
  table.t { font-size: .82rem; }
  table.t td, table.t th { padding: 8px 4px; }
}
.langbtn { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; font: inherit; font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; flex: none; }
.langbtn:hover { background: rgba(255,255,255,.14); }

.calcbar { display: none; }
@media (max-width: 899px) {
  .calcbar { display: flex; justify-content: space-between; gap: 10px; position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
    background: var(--brand-2); color: #fff; padding: 10px max(16px, env(safe-area-inset-left)); font-size: .9rem; box-shadow: 0 -2px 10px rgba(0,0,0,.15); }
  .calcbar b { font-size: 1.05rem; }
}

.brandline { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--brand-2); font-size: .95rem; }
.login .logo.sm, .brandline .logo.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; margin: 0; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; }
