/* Zarholm ACP: dark, no external resources (strict CSP). */
:root {
  color-scheme: dark;
  --bg: #0e1117;
  --panel: #161a23;
  --panel-2: #1c212c;
  --line: #262c3a;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --gold: #d4a84b;
  --gold-dim: #8a6f33;
  --ok: #4cc38a;
  --warn: #f0b429;
  --bad: #ef5f67;
  --info: #5aa9ff;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.right { margin-left: auto; }
.hidden { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / 3; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .06em; color: var(--gold); }
.brand svg { width: 26px; height: 26px; }
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.menu-btn { display: none; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 10px 30px; }
.nav-group { margin-top: 14px; }
.nav-group h3 { padding: 0 10px 6px; font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: #2a2417; color: var(--gold); }
.nav a.active svg { color: var(--gold); }
.content { overflow-y: auto; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.tile .hint { color: var(--muted); font-size: 12px; }
.tile.gold .value { color: var(--gold); }

.meter { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }

.alert { padding: 11px 14px; border-radius: 8px; border: 1px solid; margin-bottom: 14px; }
.alert.bad { background: #2a1519; border-color: #5a2830; color: #ffb3b8; }
.alert.warn { background: #2a2310; border-color: #5a4a1c; color: #ffe08a; }
.alert.ok { background: #11261d; border-color: #214c38; color: #9be0bf; }
.alert.info { background: #12202e; border-color: #234262; color: #a9d2ff; }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #1f4a37; background: #11261d; }
.badge.warn { color: var(--warn); border-color: #5a4a1c; background: #2a2310; }
.badge.bad { color: var(--bad); border-color: #5a2830; background: #2a1519; }
.badge.info { color: var(--info); border-color: #234262; background: #12202e; }
.badge.gold { color: var(--gold); border-color: var(--gold-dim); background: #2a2417; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* buttons & inputs */
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 7px 14px; border-radius: 8px; transition: background .15s, border-color .15s; }
button:hover:not(:disabled) { border-color: var(--gold-dim); background: #232938; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #e2b95c; }
button.danger { background: #3a1a20; border-color: #6b2c36; color: #ffb3b8; }
button.danger:hover:not(:disabled) { background: #4a2028; border-color: var(--bad); }
button.ghost { background: transparent; }
button.small { padding: 3px 9px; font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--text); background: #0f131b; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #5a4a22; border-color: var(--gold-dim); }
textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--gold); }
label.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
label.field > span { font-size: 12px; color: var(--muted); }
label.field small { color: var(--muted); font-size: 11.5px; }
label.check { display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar input[type=text] { min-width: 220px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: #131720; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #1a1f2a; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* log view */
.logbox { background: #0a0d13; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; height: 62vh; overflow: auto; font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.logbox .l { display: block; }
.logbox .err { color: #ff8b92; } .logbox .wrn { color: #ffd372; } .logbox .dim { color: var(--muted); }

/* charts */
.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
canvas.map { width: 100%; height: 260px; background: #0a0d13; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 11, .72); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--info); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.4); white-space: pre-wrap; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1000px 500px at 50% -10%, #2a2417 0%, transparent 60%), var(--bg); }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login .brand { justify-content: center; font-size: 20px; margin-bottom: 4px; }
.login p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.login form { display: grid; gap: 14px; }
.login .err { color: var(--bad); min-height: 20px; font-size: 13px; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; }
.perm-group { margin-top: 14px; }
.perm-group h3 { margin-bottom: 6px; }

@media (max-width: 1100px) { .grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-block; }
  .content { padding: 16px 14px 60px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; } }

/* item picker */
.ip { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: 16px; min-height: 420px; }
.ip-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ip-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ip-chip { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 3px 11px; font-size: 12px; cursor: pointer; text-transform: capitalize; }
.ip-chip.on { color: var(--gold); border-color: var(--gold); }
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; max-height: 380px; overflow: auto; padding: 2px; }
.ip-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: inherit; text-align: center; }
.ip-item:hover, .ip-item.sel { border-color: var(--gold); }
.ip-icon { width: 44px; height: 44px; border: 2px solid; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.ip-name { font-size: 12px; font-weight: 600; line-height: 1.2; }
.ip-sub { font-size: 10px; color: var(--muted); text-transform: capitalize; }
.ip-detail { display: flex; flex-direction: column; gap: 10px; }
.ip-card { border: 1px solid; border-radius: 8px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 4px; }
.ip-title { font-weight: 700; font-size: 16px; }
.ip-stats { color: var(--ok, #4cc38a); font-size: 12px; }
.ip-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ip-field.row { flex-direction: row; align-items: center; gap: 6px; }
@media (max-width: 800px) { .ip { grid-template-columns: 1fr; } }

/* stats page */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 60px; gap: 8px; align-items: center; font-size: 12px; }
.bar-row .track { background: var(--panel-2, #1b2030); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--gold); }
.bar-row .n { text-align: right; color: var(--muted); }
