:root {
  --bg: #f5f4f0; --surface: #ffffff; --ink: #14201e; --ink-2: #3d4a47; --muted: #77827e; --line: #eae7e0; --line-2: #f1efea;
  --brand: #0f3d3e; --brand-2: #175556; --brand-soft: #e5efee;
  --accent: #d0643f; --accent-soft: #fbe9e2;
  --ok: #1d8350; --ok-soft: #e2f3e9; --bad: #c03a36; --bad-soft: #fbe7e5; --warn: #a86b12; --warn-soft: #fcf0d9;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 30, .04), 0 4px 16px rgba(20, 32, 30, .05);
  --sidebar: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow-x: clip; }
body { font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.layout { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--brand); color: #fff; display: flex; flex-direction: column; padding: 22px 14px; gap: 4px; }
.logo { font-weight: 800; font-size: 19px; letter-spacing: -.01em; padding: 4px 12px 22px; }
.logo span { color: #f3b896; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #d6e4e2; text-decoration: none; font-weight: 500; }
.sidebar a:hover { background: #ffffff12; color: #fff; }
.sidebar a.active { background: #ffffff1f; color: #fff; }
.sidebar .badge-dot { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.sidebar .foot { margin-top: auto; padding: 12px; border-top: 1px solid #ffffff1f; font-size: 13px; color: #b9cfcc; display: grid; gap: 8px; }
.sidebar .foot button { background: none; border: 0; color: #fff; padding: 0; text-align: left; cursor: pointer; display: flex; gap: 8px; align-items: center; }

.content { margin-left: var(--sidebar); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px; padding: 16px 28px; }
.topbar h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .mlogo { display: none; }
main { padding: 4px 28px 40px; max-width: 1080px; }

.month { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 3px; box-shadow: var(--shadow); }
.month button { width: 34px; height: 34px; border-radius: 99px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.month button:hover { background: var(--line-2); }
.month label { position: relative; padding: 0 8px; font-weight: 600; font-size: 14px; text-transform: capitalize; min-width: 118px; text-align: center; cursor: pointer; }
.month input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.bottombar { display: none; }

/* ---------- blocks ---------- */
.section { margin: 26px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section h2 { font-size: 15px; margin: 0; color: var(--ink-2); font-weight: 650; }
.section .act { font-size: 14px; color: var(--brand); font-weight: 600; text-decoration: none; background: none; border: 0; cursor: pointer; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line-2); }
.pad { padding: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.intro { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; max-width: 70ch; }

.hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border-radius: 22px; padding: 22px; box-shadow: 0 10px 30px rgba(15, 61, 62, .22); }
.hero .l { font-size: 13px; color: #c8dcda; }
.hero .big { font-size: 34px; font-weight: 750; letter-spacing: -.02em; margin: 4px 0 16px; font-variant-numeric: tabular-nums; }
.hero .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hero .stat { background: #ffffff14; border-radius: 14px; padding: 10px 12px; }
.hero .stat .v { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 15px; }
.hero .stat .l { font-size: 12px; }

.alert { display: flex; align-items: center; gap: 12px; background: var(--warn-soft); color: var(--warn); border-radius: 14px; padding: 12px 14px; margin-top: 14px; font-weight: 600; font-size: 14px; text-decoration: none; }
.alert svg { flex: none; }
.alert .go { margin-left: auto; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.dcard { padding: 16px; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.dcard:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(20,32,30,.05), 0 10px 24px rgba(20,32,30,.08); }
.dcard .top { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.dcard .name { font-weight: 650; }
.dcard .meta { font-size: 12.5px; color: var(--muted); }
.dcard .net { margin: 14px 0 10px; }
.dcard .net .v { font-size: 24px; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.dcard .mini { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; }
.dcard .mini b { display: block; color: var(--ink); font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line-2); margin: 12px 0 8px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.neutral { background: var(--line-2); color: var(--ink-2); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.uber { background: #111; color: #fff; }
.chip.bolt { background: #dff7ea; color: #0b7a43; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* list */
.list { padding: 4px 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; border-radius: 12px; margin: 0 4px; }
.item:hover { background: var(--line-2); }
.item + .item { box-shadow: 0 -1px 0 var(--line-2); }
.item .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--line-2); color: var(--ink-2); flex: none; font-weight: 700; font-size: 13px; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.item .s { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.item .r { text-align: right; flex: none; }
.item .r .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.item .r .s { justify-content: flex-end; }
.sumrow { display: flex; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--line); font-weight: 650; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; stroke: #c3c9c6; margin-bottom: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--line-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; height: 50px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.fab { display: none; }

/* forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field input[type=date] { min-width: 0; max-width: 100%; display: block; text-align: left; }
.field input::-webkit-date-and-time-value { text-align: left; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .field input, .field select, .field textarea { width: 100%; height: 48px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; font-size: 16px; outline: none; transition: border-color .15s; -webkit-appearance: none; appearance: none; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2377827e' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field input:focus, .field select:focus { border-color: var(--brand); }
.field input.amount { font-size: 26px; font-weight: 700; height: 60px; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line-2); border-radius: 13px; padding: 4px; gap: 4px; }
.seg label { position: relative; text-align: center; padding: 10px 8px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-2); line-height: 1.2; }
.seg label small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; padding: 6px 0; }
.toggle input { position: relative; width: 46px; height: 28px; border-radius: 99px; background: #d5d9d7; -webkit-appearance: none; appearance: none; cursor: pointer; transition: background .15s; border: 0; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 99px; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--ok); }
.toggle input:checked::after { transform: translateX(18px); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .field input { font-size: 15px; padding: 0 10px; }
.field .mini { font-size: 12px; font-weight: 600; color: var(--muted); }
.pchips { display: flex; gap: 6px; flex-wrap: wrap; }
.pchip { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.pchip:hover, .pchip:active { border-color: var(--brand); color: var(--brand); }
.error { color: var(--bad); font-size: 13.5px; min-height: 1em; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 45%, var(--bg) 45.1%); }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth .logo { color: var(--brand); padding: 0 0 4px; font-size: 24px; }
.auth .logo span { color: var(--accent); }

/* sheet / modal */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(12, 22, 21, .45); animation: fade .15s ease; }
.sheet { background: var(--surface); border-radius: 22px; width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 22px; animation: pop .18s ease; overscroll-behavior: contain; }
.sheet h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }
.card.pad > h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.01em; }
.sheet .grab { display: none; }
.sheet .close { float: right; width: 34px; height: 34px; border-radius: 99px; border: 0; background: var(--line-2); display: grid; place-items: center; cursor: pointer; margin: -4px -4px 0 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

.kv { display: grid; gap: 2px; }
.kv .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-variant-numeric: tabular-nums; }
.kv .row.minor { color: var(--muted); font-size: 14px; padding: 4px 0 4px 10px; }
.kv .row.total { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
.kv .h { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 2px; }
.netbox { margin-top: 18px; padding: 16px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 650; }
.netbox .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.netbox.pay { background: var(--ok-soft); color: var(--ok); }
.netbox.collect { background: var(--bad-soft); color: var(--bad); }
.netbox.zero { background: var(--line-2); }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; z-index: 60; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .18s ease; max-width: calc(100vw - 32px); }

.skeleton { height: 90px; border-radius: var(--r); background: linear-gradient(90deg, #ecebe6 25%, #f4f3ef 50%, #ecebe6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.menu-list .item .ic { background: var(--brand-soft); color: var(--brand); }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding-bottom: calc(76px + var(--safe-b)); }
  .topbar { padding: 12px 16px; gap: 8px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .topbar h1 { font-size: 19px; }
  .month label { min-width: 0; font-size: 13.5px; padding: 0 4px; }
  .month button { width: 30px; height: 30px; }
  main { padding: 0 14px 96px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 16px; }
  .hero { padding: 18px; border-radius: 20px; }
  .hero .big { font-size: 30px; }
  .hero .stats { grid-template-columns: 1fr 1fr; }
  .grid-cards { grid-template-columns: 1fr; }
  .item { padding: 12px; margin: 0 2px; }
  .desk { display: none !important; }

  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
  .bottombar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
  .bottombar a.active { color: var(--brand); }
  .bottombar a .badge-dot { position: absolute; top: 2px; left: calc(50% + 6px); background: var(--accent); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; min-width: 16px; text-align: center; }
  .bottombar svg.i { width: 23px; height: 23px; }

  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(84px + var(--safe-b)); width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; border: 0; box-shadow: 0 8px 22px rgba(208, 100, 63, .4); z-index: 15; cursor: pointer; }
  .fab svg.i { width: 26px; height: 26px; }

  .sheet-wrap { place-items: end stretch; padding: 0; }
  .sheet { width: 100%; border-radius: 22px 22px 0 0; max-height: 92vh; padding: 10px 18px calc(20px + var(--safe-b)); animation: up .22s cubic-bezier(.2,.8,.2,1); }
  .sheet .grab { display: block; width: 40px; height: 5px; border-radius: 99px; background: #d9dcda; margin: 0 auto 14px; }
  .sheet .close { display: none; }
  .toast { bottom: calc(92px + var(--safe-b)); }
}
@media (min-width: 861px) { .mob { display: none !important; } }

@media print {
  .sidebar, .topbar, .bottombar, .fab, .noprint { display: none !important; }
  .content { margin: 0; }
  body.printing .layout { display: none; }
  .sheet-wrap { position: static; background: none; padding: 0; }
  .sheet { max-height: none; width: 100%; box-shadow: none; }
}
