:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1d212a; --line: #2a2f3a; --text: #e8e6e1; --muted: #9aa0ab;
  --gold: #c9a15a; --gold-2: #e0bd78; --red: #e05a5a; --green: #4fbf7f; --blue: #5a9be0; --orange: #e0a25a;
  --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.35);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--gold-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #0b0d11; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.brand img { width: 170px; height: auto; }
.brand span { color: var(--muted); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
.nav-group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; margin: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); opacity: .82; }
.nav a:hover { background: var(--panel); opacity: 1; }
.nav a.active { background: linear-gradient(90deg, rgba(201,161,90,.22), rgba(201,161,90,.04)); color: var(--gold-2); opacity: 1; }
.nav .ico { width: 18px; text-align: center; }
.nav .badge { margin-left: auto; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 26px; border-bottom: 1px solid var(--line); background: rgba(15,17,21,.9); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px); }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
.top .spacer { flex: 1; }
.top .who { color: var(--muted); font-size: 13px; }
.menu-btn { display: none; }
.content { padding: 22px 26px 60px; max-width: 1400px; }

/* Cards */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .muted { font-weight: 400; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi.warn .value { color: var(--orange); } .kpi.bad .value { color: var(--red); } .kpi.good .value { color: var(--green); } .kpi.gold .value { color: var(--gold-2); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mb { margin-bottom: 16px; }
.mt { margin-top: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--panel-2); }
tr.click { cursor: pointer; }
td.wrap { white-space: normal; min-width: 220px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }

/* Controls */
.btn { background: var(--panel-2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); }
.btn.danger { background: rgba(224,90,90,.12); border-color: rgba(224,90,90,.5); color: #ff9b9b; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: #0d0f13; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { width: 100%; min-height: 80px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2b303b; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #cfd3da; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--gold); }
.switch input:checked + span::before { transform: translateX(18px); background: #1a1408; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #2a2f3a; color: #cfd3da; }
.b-red { background: rgba(224,90,90,.15); color: #ff8f8f; } .b-green { background: rgba(79,191,127,.15); color: #7fe0a8; }
.b-orange { background: rgba(224,162,90,.15); color: #ffc27f; } .b-blue { background: rgba(90,155,224,.15); color: #8fc0ff; }
.b-gold { background: rgba(201,161,90,.18); color: var(--gold-2); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: transparent; border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: rgba(201,161,90,.16); border-color: var(--gold); color: var(--gold-2); }

/* Settings list */
.setting { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .name { font-weight: 500; }
.setting .desc { color: var(--muted); font-size: 12px; margin-top: 3px; }
.setting .ctl { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.setting .ctl input[type=number] { width: 110px; text-align: right; }
.setting .ctl input[type=text] { width: 100%; }
.setting.changed { background: linear-gradient(90deg, rgba(201,161,90,.08), transparent); }
.savebar { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--gold); padding: 10px 14px; border-radius: 12px; margin-top: 16px; box-shadow: var(--shadow); }

/* Bars (simple charts) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar span { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.hbar { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.hbar .track { background: #0d0f13; border-radius: 99px; height: 8px; overflow: hidden; }
.hbar .fill { background: var(--gold); height: 100%; border-radius: 99px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; }
.kv div:nth-child(odd) { color: var(--muted); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at top, #1d1a14 0%, var(--bg) 60%); }
.login .card { width: 100%; max-width: 380px; padding: 28px; box-shadow: var(--shadow); }
.login img { width: 220px; display: block; margin: 0 auto 10px; }
.login h2 { text-align: center; margin: 0 0 20px; font-weight: 500; color: var(--muted); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; }
.login form { display: grid; gap: 14px; }
.login .err { color: #ff8f8f; font-size: 13px; min-height: 18px; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow); }
.modal-card.wide { max-width: 980px; }
.modal-card h2 { margin: 0 0 16px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 12px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { border-left-color: var(--red); }
.code { font-family: ui-monospace, Consolas, monospace; background: #0d0f13; border: 1px solid var(--line); border-radius: 8px; padding: 10px; word-break: break-all; user-select: all; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .cols-2, .cols-3, .form-grid { grid-template-columns: 1fr; }
  .setting { grid-template-columns: 1fr; }
  .setting .ctl { justify-content: flex-start; }
  .content { padding: 16px; }
  .top { padding: 12px 16px; }
}
