/* Kestrel Admin Panel - builds on the main app's design system (/shared/css/app.css) */

:root { --sidebar-w: 256px; --side-bg: #0b1220; --side-text: #cbd5e1; --side-muted: #94a3b8; --side-hover: #16213a; --side-active: #172554; }
:root[data-theme="dark"] { --side-bg: #070d18; --side-hover: #111a2e; --side-active: #172554; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-bg: #070d18; --side-hover: #111a2e; --side-active: #172554; } }

/* shell */
.adm .sidebar { background: var(--side-bg); border-right: 0; color: var(--side-text); }
.adm .brand { color: #fff; padding-bottom: 6px; }
.adm .brand small { display: block; font: 600 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--brand-400); margin-top: 3px; }
.adm .nav { gap: 2px; overflow-y: auto; }
.adm .nav .grp { font: 600 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); padding: 18px 12px 8px; }
.adm .nav a { color: var(--side-text); height: 38px; font-size: 13.5px; }
.adm .nav a:hover { background: var(--side-hover); color: #fff; }
.adm .nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-400); }
.adm .nav a.active svg { color: var(--brand-400); }
.adm .side-foot { border-top: 1px solid #1e293b; padding-top: 12px; margin-top: auto; }
.adm .side-foot button { color: var(--side-text); }
.adm .side-foot button:hover { background: var(--side-hover); color: #fff; }
.adm-me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; color: #fff; }
.adm-me .avatar { background: var(--brand-500); color: #fff; }
.adm-me small { display: block; color: var(--side-muted); font-size: 11.5px; }
.shell.collapsed .adm-me div, .shell.collapsed .nav .grp { display: none; }

.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.crumbs b { color: var(--text); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 13px; height: 13px; opacity: .6; }
.env-pill { font: 600 11px/1 var(--mono); padding: 6px 10px; border-radius: var(--r-full); background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); display: inline-flex; gap: 6px; align-items: center; }
.env-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.env-pill.off i { background: var(--danger); }

.page-head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(26px, 3vw, 34px); letter-spacing: -.03em; }

/* KPI grid */
.akpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.akpi { padding: 16px 18px; display: grid; gap: 6px; color: inherit; text-decoration: none !important; }
.akpi .k { font-size: 12px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 8px; }
.akpi .k svg { color: var(--primary); }
.akpi .v { font: 500 30px/1.05 var(--serif); letter-spacing: -.03em; color: var(--text); }
.akpi .s { font-size: 12px; color: var(--muted); }
a.akpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.panel { padding: 20px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-h h2 { font-size: 15px; font-weight: 700; }
.panel-h p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mb { margin-bottom: 16px; }

/* charts */
.chart { position: relative; }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.cols .c { flex: 1; min-width: 3px; display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; cursor: default; position: relative; }
.cols .c i { display: block; border-radius: 4px 4px 0 0; background: var(--primary); min-height: 0; }
.cols .c i.b { background: var(--danger); } .cols .c i.g { background: var(--success); }
.cols .c:hover i { filter: brightness(1.12); }
.cols .c:hover::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 4px; pointer-events: none; }
.axis { display: flex; justify-content: space-between; font: 500 11px/1 var(--mono); color: var(--faint); padding-top: 6px; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--text); color: var(--bg); font-size: 12px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: var(--shadow-md); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; } .legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); } .legend i.b { background: var(--danger); } .legend i.g { background: var(--success); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.hbar .t { height: 10px; border-radius: 6px; background: var(--bg-soft); overflow: hidden; }
.hbar .t i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .8s var(--ease); }
.hbar b { font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.hbar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ratio { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--bg-soft); }
.ratio i { display: block; background: var(--success); } .ratio i.b { background: var(--danger); }

/* lists */
.alist { display: grid; }
.alist > * { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: inherit; text-decoration: none !important; }
.alist > *:last-child { border-bottom: 0; }
.alist .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-soft); color: var(--text-2); }
.alist .ico.error { background: var(--danger-soft); color: var(--danger); } .alist .ico.warning { background: var(--warning-soft); color: var(--warning); } .alist .ico.info { background: var(--info-soft); color: var(--info); } .alist .ico.ok { background: var(--success-soft); color: var(--success); }
.alist b { font-weight: 650; display: block; } .alist small { color: var(--muted); display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* data table */
.dt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dt th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dt th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.dt th button:hover, .dt th button.on { color: var(--text); }
.dt th button svg { width: 12px; height: 12px; }
.dt td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr.link { cursor: pointer; } .dt tbody tr.link:hover td { background: var(--surface-2); }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; }
.dt .t1 { font-weight: 650; } .dt .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dt .clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-card { overflow: hidden; }
.dt-scroll { overflow-x: auto; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager .btn { height: 32px; min-width: 32px; padding: 0 10px; }
.pager .btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.fbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.fbar .input { height: 38px; width: auto; min-width: 140px; }
.fbar .input-icon { flex: 1; min-width: 220px; max-width: 380px; }
.fbar input[type=date] { min-width: 0; }
.fbar .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }

/* detail pages */
.dhead { display: flex; gap: 18px; align-items: center; padding: 22px; flex-wrap: wrap; }
.dhead .avatar { width: 64px; height: 64px; font-size: 22px; border-radius: 18px; }
.dhead h1 { font: 500 26px/1.1 var(--serif); letter-spacing: -.02em; }
.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips span { font-size: 12px; padding: 4px 10px; border-radius: var(--r-full); background: var(--bg-soft); border: 1px solid var(--border); }
.tl { display: grid; gap: 0; }
.tl > div { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; padding: 10px 0; font-size: 13px; position: relative; }
.tl > div::before { content: ""; position: absolute; left: 6px; top: 22px; bottom: -10px; width: 2px; background: var(--border); }
.tl > div:last-child::before { display: none; }
.tl i { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--primary); background: var(--surface); margin-top: 2px; }
.tl i.error { border-color: var(--danger); } .tl i.ok { border-color: var(--success); }
.tl small { color: var(--muted); display: block; }

/* switch rows (features, platform toggles) */
.srow { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.srow:last-child { border-bottom: 0; }
.srow .grow b { display: block; font-weight: 650; } .srow .grow small { color: var(--muted); font-size: 12.5px; }

/* permission matrix */
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 16px; height: 16px; accent-color: var(--primary); }

/* list editor (config dropdown values) */
.leditor { display: grid; gap: 10px; }
.leditor .chips span { display: inline-flex; gap: 6px; align-items: center; }
.leditor .chips button { all: unset; cursor: pointer; color: var(--muted); display: inline-grid; } .leditor .chips button:hover { color: var(--danger); }
.leditor .chips svg { width: 12px; height: 12px; }

.frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--r-md); background: #fff; }
.logo-sw { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; flex: none; }
.mono { font-family: var(--mono); font-size: 12px; }
.pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-soft); border-radius: 8px; padding: 8px 10px; max-height: 200px; overflow: auto; }

/* auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.auth-art { background: var(--side-bg); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; width: 560px; height: 560px; right: -160px; bottom: -200px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--brand-500) 55%, transparent), transparent 65%); }
.auth-art h2 { font: 400 clamp(32px, 4vw, 52px)/1.02 var(--serif); letter-spacing: -.04em; max-width: 520px; position: relative; z-index: 1; }
.auth-art h2 em { color: var(--brand-400); }
.auth-art ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: #cbd5e1; position: relative; z-index: 1; font-size: 14px; }
.auth-art li { display: flex; gap: 10px; align-items: center; } .auth-art li svg { color: var(--brand-400); }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form form { width: min(380px, 100%); display: grid; gap: 16px; }
.auth-form h1 { font: 500 30px/1.1 var(--serif); letter-spacing: -.03em; }
.auth-form .err-box { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; display: none; }
.auth-form .err-box.on { display: block; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

@media (max-width: 760px) {
  .adm .shell { grid-template-columns: 1fr; }
  .adm .sidebar { position: fixed; z-index: 60; left: 0; width: 270px; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .adm .shell.open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .adm .topbar { padding: 0 16px; } .adm .page { padding: 8px 16px 40px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
  .hbar { grid-template-columns: 90px 1fr auto; }
}
.menu-btn { display: none; } @media (max-width: 760px) { .menu-btn { display: inline-flex; } }
.adm .switch, .dt .switch, .srow .switch, .panel-h .switch { display: inline-block; vertical-align: middle; }
.adm .nav { flex: 1; min-height: 0; }
.adm .nav .grp { padding: 12px 12px 6px; }
.adm .nav a { height: 34px; }
.adm .brand { padding-bottom: 2px; }
@media (max-width: 1024px) and (min-width: 761px) { .adm .nav .grp, .adm-me div { display: none; } }
.dt .num, .dt td:last-child { white-space: nowrap; }
.dt .cell-main { min-width: 0; max-width: 340px; }
.dt .cell-main .t1, .dt .cell-main .t2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* billing (pages/billing.js) */
.bill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.bill-plan { padding: 18px; }
.bill-plan.off { opacity: .65; }
.bill-plan h3 { margin: 0; font-size: 17px; }
.bill-price { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 4px; }
.bill-price b { font-size: 26px; }
.bill-price s { color: var(--muted); }
.bill-edit { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .bill-edit { grid-template-columns: minmax(0, 1fr); } }
.bill-prev { position: sticky; top: 0; }
.bill-card { position: relative; padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.bill-card.hl { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.bill-card h4 { margin: 0 0 4px; font-size: 18px; }
.bill-card ul { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; font-size: 13px; }
.bill-card li.no { color: var(--faint); text-decoration: line-through; }
.bill-card .btn { width: 100%; }
.bill-badge { position: absolute; top: -10px; right: 14px; padding: 3px 10px; border-radius: 99px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; }
.bill-ft td, .bill-ft th { padding: 8px 10px; }
.err { color: var(--danger); font-weight: 600; font-size: 13px; }
.err:empty { display: none; }
