:root { --bg:#1d1a17; --panel:#29241f; --panel2:#332c26; --line:#463d35; --text:#f3ece4; --muted:#b3a597; --accent:#e0a458; --ok:#5cb85c; --danger:#e05d5d; --info:#4fa3e0; --warn:#e6b94f; --r:12px; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Tahoma, Arial, sans-serif; font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 8px 14px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #241a10; border-color: var(--accent); font-weight: 700; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.sm { padding: 4px 10px; font-size: 13px; }
button.ghost { background: transparent; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.num { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.col { display: flex; flex-direction: column; gap: 10px; }
h2 { margin: 0 0 12px; } h3 { margin: 0 0 10px; color: var(--accent); font-size: 16px; }
label.f { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login .card { width: min(380px, 92vw); }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-left: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.side .brand { color: var(--accent); font-weight: 800; font-size: 18px; padding: 4px 8px 12px; }
.side button { text-align: right; background: transparent; border: 0; padding: 10px 12px; border-radius: 10px; }
.side button.on { background: var(--panel2); color: var(--accent); font-weight: 700; }
.side .sp { flex: 1; }
.main { padding: 18px 22px; overflow: auto; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.top h2 { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .l { color: var(--muted); font-size: 13px; } .kpi .v { font-size: 24px; font-weight: 800; color: var(--accent); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.branches { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: right; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px 6px; border-bottom: 1px solid #3a322b; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.off td { opacity: .5; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { background: #2f4d2f; border-color: var(--ok); } .badge.danger { background: #5a2a2a; border-color: var(--danger); } .badge.warn { background: #5a4520; border-color: var(--warn); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; max-width: 46px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .b span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.barsw { padding-bottom: 20px; }
.hbar { height: 8px; background: var(--accent); border-radius: 4px; }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.on { border-color: var(--accent); color: var(--accent); }
.code { font-size: 30px; font-weight: 800; letter-spacing: 4px; color: var(--accent); direction: ltr; text-align: center; background: var(--bg); border-radius: 10px; padding: 10px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 94vw); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(900px, 96vw); }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal .mb { padding: 14px; } .modal .mf { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-right: 4px solid var(--info); border-radius: 10px; padding: 10px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.toast.ok { border-right-color: var(--ok); } .toast.err { border-right-color: var(--danger); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; overflow-x: auto; border-left: 0; border-bottom: 1px solid var(--line); padding: 6px; position: sticky; top: 0; z-index: 5; }
  .side .brand, .side .sp { display: none; }
  .side button { white-space: nowrap; }
  .main { padding: 12px; }
  .card { overflow-x: auto; }
  table.t { min-width: 520px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 20px; }
  .branches, .grid2 { grid-template-columns: minmax(0, 1fr); }
  .branches table.t { min-width: 0; }
}
.thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; vertical-align: middle; }
.thumb.emo { display: inline-block; font-size: 22px; text-align: center; line-height: 32px; }
/* customer name under the brand, banners (blocked / subscription) */
.side .brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 2px; }
.notice { border: 1px solid var(--line); border-right: 4px solid var(--info); background: var(--panel2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; line-height: 1.6; }
.notice.warn { border-right-color: var(--warn); background: #3d3220; } .notice.danger { border-right-color: var(--danger); background: #3d2323; }
/* vendor portal */
.vbrand { color: var(--info) !important; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; } .kv > span:nth-child(odd) { color: var(--muted); }
