/* Billing RT/RW Net — dashboard styles */
:root {
  --bg: #F3F4F1; --panel: #FFFFFF; --panel2: #EEF0EB; --line: #D9DED6; --line2: #C7CEC4;
  --text: #14181A; --muted: #525B56; --accent: #0B6B5C; --accentText: #FFFFFF; --accentSoft: #DCEFE9;
  --warn: #8A5000; --warnSoft: #FBEAD0; --bad: #A12F27; --badSoft: #F8DDD9; --ok: #1C6636; --okSoft: #DBEFE1;
  --info: #1F4E8C; --infoSoft: #DDE7F6; --shadow: 0 10px 30px rgba(20, 24, 26, .12);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1113; --panel: #161A1D; --panel2: #1D2226; --line: #2B3237; --line2: #3A434A;
    --text: #E7EBE9; --muted: #9BA6A1; --accent: #45B9A2; --accentText: #04211B; --accentSoft: #163933;
    --warn: #E7AA52; --warnSoft: #382913; --bad: #F08B81; --badSoft: #3B1E1B; --ok: #6CCB8D; --okSoft: #173222;
    --info: #8DB4EC; --infoSoft: #1A2840; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1113; --panel: #161A1D; --panel2: #1D2226; --line: #2B3237; --line2: #3A434A;
  --text: #E7EBE9; --muted: #9BA6A1; --accent: #45B9A2; --accentText: #04211B; --accentSoft: #163933;
  --warn: #E7AA52; --warnSoft: #382913; --bad: #F08B81; --badSoft: #3B1E1B; --ok: #6CCB8D; --okSoft: #173222;
  --info: #8DB4EC; --infoSoft: #1A2840; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
body { min-height: 100vh; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0; } h3 { font-size: 14px; margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .center { text-align: center; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--accentText); display: grid; place-items: center; flex: none; }
.bname { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }

/* layout */
.shell { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px; max-width: 1480px; margin: 0 auto; align-items: flex-start; }
.side { flex: 1 1 210px; max-width: 240px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; position: sticky; top: 76px; }
.side a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--panel2); }
.side a[aria-current="page"] { background: var(--accentSoft); color: var(--accent); font-weight: 700; }
.side a svg { flex: none; opacity: .85; }
.side .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.side .badge { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--warnSoft); color: var(--warn); }
main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 860px) {
  .btn.menu-btn { display: inline-flex; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; max-width: 280px; width: 80vw; z-index: 50; border-radius: 0 14px 14px 0; transform: translateX(-105%); transition: transform .18s; overflow-y: auto; padding-top: 16px; }
  body.nav-open .side { transform: none; box-shadow: var(--shadow); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .shell { padding: 14px; }
  .bname { max-width: 40vw; }
}

/* cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card > h2 { margin-bottom: 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi .card { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: var(--mono); font-size: 24px; font-weight: 500; }
.split { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: var(--accentText); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--panel2); }
.btn.soft { background: var(--panel2); color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--badSoft); color: var(--bad); border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 0; width: 40px; }
.btn[disabled] { opacity: .55; cursor: progress; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* pills / chips */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--okSoft); color: var(--ok); } .pill.warn { background: var(--warnSoft); color: var(--warn); }
.pill.bad { background: var(--badSoft); color: var(--bad); } .pill.info { background: var(--infoSoft); color: var(--info); }
.pill.accent { background: var(--accentSoft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.on { background: var(--ok); } .dot.off { background: var(--line2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accentText); border-color: var(--accent); }
.chip .n { opacity: .75; font-weight: 500; margin-left: 4px; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; min-width: 0; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 11px; width: 100%; min-height: 40px; }
input[readonly] { background: var(--panel2); color: var(--muted); }
textarea { resize: vertical; min-height: 90px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 40px; cursor: pointer; }
.fgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.fgrid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.search { flex: 1 1 220px; min-width: 0; }

/* collapsible sections */
details.sec { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--panel); min-height: 56px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary .t { display: flex; flex-direction: column; gap: 2px; }
details.sec > summary .t b { font-size: 15px; }
details.sec > summary .chev { transition: transform .15s; flex: none; color: var(--muted); }
details.sec[open] > summary { border-bottom: 1px solid var(--line); }
details.sec[open] > summary .chev { transform: rotate(180deg); }
details.sec > .body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer details.sec { border-radius: 12px; }
.seclist { display: flex; flex-direction: column; gap: 12px; }
.expand-tools { display: flex; gap: 6px; }

/* tables */
.tablebox { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 11px 14px; white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
td .sub { font-size: 12px; color: var(--muted); }
td.mono { white-space: nowrap; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.mobile-list { display: none; }

/* drawer / modal */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 16, .45); z-index: 60; display: flex; justify-content: flex-end; }
.drawer { width: min(640px, 100vw); height: 100%; background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .16s ease-out; }
.drawer > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer > .content { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.drawer > footer { padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto; }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }

/* misc */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; }
.toast.err { background: var(--bad); color: #fff; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--panel2); font-size: 13px; }
.note.warn { background: var(--warnSoft); color: var(--warn); } .note.info { background: var(--infoSoft); color: var(--info); } .note.ok { background: var(--okSoft); color: var(--ok); } .note.bad { background: var(--badSoft); color: var(--bad); }
.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.bars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: end; height: 150px; padding-top: 10px; }
.bars .b { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 44px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .v { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.steps { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--text); background: var(--panel); }
.step .ck { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line2); flex: none; }
.step.done .ck { background: var(--ok); border-color: var(--ok); color: #fff; }
.mcard { display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.bubble { background: var(--okSoft); border-radius: 12px 12px 12px 4px; padding: 10px 12px; white-space: pre-wrap; font-size: 13px; max-width: 340px; word-break: break-word; }
.phone { background: var(--panel2); border-radius: 14px; padding: 14px; min-height: 160px; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.var { font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 7px; border: 1px dashed var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; }
.progress { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; width: 90px; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.progress.full > i { background: var(--bad); }
.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.rcard { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--panel); }
.rcard:has(input:checked) { border-color: var(--accent); background: var(--accentSoft); }
.rcard input { margin-top: 2px; }
.code { font-family: var(--mono); font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; white-space: pre-wrap; word-break: break-all; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  #tenant-switch { display: none; }
  .top { padding: 10px 14px; }
  td, th { padding: 10px; }
  .kpi .value { font-size: 20px; }
}

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
