/* ACCSnet Admin - CF2016 redesign: sidebar layout, light/dark themes, indigo accent */

/* ---------- design tokens ---------- */
:root {
	--accent: #4f46e5;
	--accent-hover: #4338ca;
	--accent-soft: #eef2ff;
	--accent-ink: #3730a3;
	--on-accent: #ffffff;

	--bg: #f5f6fa;
	--surface: #ffffff;
	--surface-2: #f8f9fc;
	--surface-3: #eef0f5;
	--line: #e4e7ef;
	--line-strong: #cfd4e0;
	--text: #161a2b;
	--text-2: #4a5168;
	--muted: #6f7790;

	--side-bg: #11142a;
	--side-text: #b7bcd6;
	--side-text-strong: #ffffff;
	--side-hover: rgba(255,255,255,.06);
	--side-active: rgba(129,140,248,.18);
	--side-line: rgba(255,255,255,.08);

	--ok: #15803d;      --ok-bg: #e7f6ec;    --ok-line: #b9e3c7;
	--warn: #a15c00;    --warn-bg: #fff4dc;  --warn-line: #f2d7a0;
	--bad: #c8262f;     --bad-bg: #fdeaea;   --bad-line: #f3bcbf;
	--info: #2457c5;    --info-bg: #e8effd;  --info-line: #bed0f6;
	--highlight: #fff3bf;

	--radius: 10px;
	--radius-sm: 7px;
	--shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
	--shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
	--shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
	--font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
	--mono: "Cascadia Mono", Consolas, Menlo, monospace;
	--sidebar-w: 256px;
	--sidebar-w-collapsed: 68px;
	--topbar-h: 60px;
	color-scheme: light;
}

/* Dark theme: follows the computer unless the user picked light */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: rgba(129,140,248,.14); --accent-ink: #c7d2fe; --on-accent: #0f1226;
		--bg: #0d0f1c; --surface: #151829; --surface-2: #1a1e32; --surface-3: #22273e; --line: #272c45; --line-strong: #353b5a;
		--text: #e6e8f2; --text-2: #b8bdd3; --muted: #8b91ad;
		--side-bg: #0a0c18; --side-line: rgba(255,255,255,.06);
		--ok: #4ade80; --ok-bg: rgba(74,222,128,.12); --ok-line: rgba(74,222,128,.3);
		--warn: #fbbf24; --warn-bg: rgba(251,191,36,.12); --warn-line: rgba(251,191,36,.3);
		--bad: #f87171; --bad-bg: rgba(248,113,113,.12); --bad-line: rgba(248,113,113,.3);
		--info: #60a5fa; --info-bg: rgba(96,165,250,.12); --info-line: rgba(96,165,250,.3);
		--highlight: rgba(250,204,21,.28);
		--shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: rgba(129,140,248,.14); --accent-ink: #c7d2fe; --on-accent: #0f1226;
	--bg: #0d0f1c; --surface: #151829; --surface-2: #1a1e32; --surface-3: #22273e; --line: #272c45; --line-strong: #353b5a;
	--text: #e6e8f2; --text-2: #b8bdd3; --muted: #8b91ad;
	--side-bg: #0a0c18; --side-line: rgba(255,255,255,.06);
	--ok: #4ade80; --ok-bg: rgba(74,222,128,.12); --ok-line: rgba(74,222,128,.3);
	--warn: #fbbf24; --warn-bg: rgba(251,191,36,.12); --warn-line: rgba(251,191,36,.3);
	--bad: #f87171; --bad-bg: rgba(248,113,113,.12); --bad-line: rgba(248,113,113,.3);
	--info: #60a5fa; --info-bg: rgba(96,165,250,.12); --info-line: rgba(96,165,250,.3);
	--highlight: rgba(250,204,21,.28);
	--shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
	color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
mark { background: var(--highlight); color: inherit; padding: 0 2px; border-radius: 3px; }
svg { flex-shrink: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app frame ---------- */
body.app { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- sidebar ---------- */
.sidebar {
	position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex-shrink: 0;
	display: flex; flex-direction: column; background: var(--side-bg); color: var(--side-text);
	border-right: 1px solid var(--side-line); z-index: 50; transition: width .18s ease;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px; height: var(--topbar-h); color: var(--side-text-strong); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
	display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
	background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 800; font-size: 15px;
	box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.brand strong { font-weight: 700; }
.sidenav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.nav-home { margin-bottom: 6px; }
.nav-item {
	display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border-radius: 8px;
	color: var(--side-text); font: inherit; font-size: 13.5px; text-align: left; background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.nav-item:hover { background: var(--side-hover); color: var(--side-text-strong); text-decoration: none; }
.nav-item.active { background: var(--side-active); color: var(--side-text-strong); font-weight: 600; }
.nav-icon { width: 19px; height: 19px; opacity: .85; }
.nav-text { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chev { width: 14px; height: 14px; opacity: .55; transition: transform .15s ease; }
.nav-group.open > .nav-group-btn .chev { transform: rotate(90deg); }
.nav-group.open > .nav-group-btn { color: var(--side-text-strong); }
.nav-sub { display: none; margin: 2px 0 6px 20px !important; padding-left: 10px !important; border-left: 1px solid var(--side-line); }
.nav-group.open > .nav-sub { display: block; }
.nav-sub .nav-item { padding: 6px 10px; font-size: 13px; }
.nav-sub .nav-sub { margin-left: 8px !important; }
.nav-heading { padding: 10px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.4); }
.sidebar-collapse {
	display: flex; align-items: center; gap: 11px; margin: 0 10px 12px; padding: 8px 10px; border-radius: 8px;
	background: none; border: 1px solid var(--side-line); color: var(--side-text); font: inherit; font-size: 13px; cursor: pointer;
}
.sidebar-collapse:hover { background: var(--side-hover); color: #fff; }
.sidebar-collapse svg { width: 18px; height: 18px; transition: transform .18s ease; }

/* collapsed (desktop) */
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .sidebar .nav-text,
.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .chev,
.sidebar-collapsed .sidebar .nav-sub,
.sidebar-collapsed .sidebar .nav-heading { display: none !important; }
.sidebar-collapsed .sidebar .brand { padding: 14px 18px; }
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 9px 0; }
.sidebar-collapsed .sidebar-collapse { justify-content: center; }
.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.scrim { display: none; }

/* ---------- top bar ---------- */
.topbar {
	position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
	display: flex; align-items: center; gap: 14px; padding: 0 24px;
	background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(160%) blur(10px);
	border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.icon-btn {
	display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
	background: none; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .icon-sun { display: block; }
	:root:not([data-theme="light"]) .icon-moon { display: none; }
}

.quick-search { position: relative; display: flex; align-items: center; width: min(360px, 40vw); }
.quick-search svg { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.quick-search input[type=search] { width: 100%; padding: 8px 12px 8px 36px; border-radius: 9px; background: var(--surface-2); border-color: var(--line); }
.quick-search input[type=search]:focus { background: var(--surface); }

.modem-stats { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; font-size: 12px; }
.modem-stats li { display: flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--text-2); }
.modem-stats strong { color: var(--text); font-variant-numeric: tabular-nums; }

.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 999px; color: var(--text); border: 1px solid transparent; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--surface-3); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px; }
.username { font-weight: 550; }
.usermenu-panel {
	position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 230px; padding: 6px;
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.usermenu-head { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.usermenu-head strong { color: var(--text); }
.menu-row { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px; color: var(--text); font: inherit; background: none; border: 0; cursor: pointer; }
.menu-row:hover { background: var(--surface-3); text-decoration: none; }
.menu-row.danger { color: var(--bad); }
.usermenu-panel form { margin: 0; }

/* ---------- page ---------- */
.page { width: 100%; max-width: 1480px; margin: 0 auto; padding: 26px 28px 10px; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 18px; }
.page-head h1 { font-size: 23px; font-weight: 700; margin: 0; }
.page-head p { margin: 0; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0 28px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 14px; }
.toolbar .spacer { flex: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.flash::before { content: ""; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.flash-ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.flash-bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad); }
.flash-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.flash.errors { display: block; }
.flash.errors::before { display: none; }

/* ---------- forms ---------- */
label { font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=email], select, textarea {
	font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm); padding: 8px 11px; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 180px minmax(0, 380px); gap: 14px 18px; align-items: center; }
.form-grid > label { text-align: right; }
.form-grid .actions { grid-column: 2; display: flex; gap: 8px; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 2px 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
	font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
	border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm);
	transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data thead th {
	position: sticky; top: 0; z-index: 1; background: var(--surface-2); white-space: nowrap;
	font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
table.data thead th a { color: inherit; }
table.data thead th a.sorted { color: var(--accent); }
table.data tbody tr { transition: background .08s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.is-disabled td:first-child, tr.is-disabled td:nth-child(2) { color: var(--bad); }
tr.is-open td { color: var(--info); }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- badges / chips ---------- */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px; letter-spacing: .01em; vertical-align: 1px; white-space: nowrap; border: 1px solid transparent; }
.badge-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge-muted { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line); }
a.chip:hover { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; text-decoration: none; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.meter { display: inline-block; width: 46px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.meter.high > span { background: var(--bad); }

/* ---------- detail lists ---------- */
dl.details { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin: 0; }
dl.details dt { color: var(--muted); font-weight: 500; }
dl.details dd { margin: 0; }
.secret { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 7px; border-radius: 5px; }

/* ---------- home ---------- */
.section-card { transition: border-color .12s, transform .12s; }
.section-card:hover { border-color: var(--line-strong); }
.section-card h2 { font-size: 15px; }
.section-card ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 18px; }
.section-card li { padding: 3px 0; break-inside: avoid; }

/* ---------- login / error pages ---------- */
.login-body {
	min-height: 100vh; display: grid; place-items: center; padding: 20px;
	background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.45), transparent 60%),
	            radial-gradient(900px 500px at 110% 110%, rgba(139,92,246,.35), transparent 60%), #0f1226;
}
.login-card { width: 100%; max-width: 390px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px; }
.login-card .brand { color: var(--text); padding: 0; height: auto; margin-bottom: 22px; }
.login-card h1 { font-size: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; margin-top: 4px; }
.error-detail { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: 6px; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; font-weight: 500; }
.toast.show { opacity: 1; transform: none; }

/* ---------- print sheet / bare pages ---------- */
body.bare .page { max-width: 820px; }
.print-warning { background: #c8262f; color: #fff; text-align: center; font-weight: 700; padding: 8px; border-radius: 6px; margin: 0 0 18px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet { max-width: 760px; margin: 0 auto; }
.sheet h1 { font-size: 26px; text-align: center; margin: 10px 0 18px; }
.sheet .card { box-shadow: none; }

@media print {
	:root { color-scheme: light; }
	body { background: #fff; color: #000; }
	.sidebar, .topbar, .foot, .no-print, .scrim { display: none !important; }
	.page { padding: 0; max-width: none; }
	.card, .table-wrap { box-shadow: none; background: #fff; border-color: #ccc; }
}

/* ---------- tablets & phones: sidebar becomes a slide-out drawer ---------- */
@media (max-width: 960px) {
	.sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); width: var(--sidebar-w) !important; }
	.sidebar-open .sidebar { transform: none; }
	.sidebar-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8,10,20,.45); z-index: 45; }
	.sidebar-collapse { display: none; }
	.sidebar-collapsed .sidebar .nav-text, .sidebar-collapsed .sidebar .brand-text, .sidebar-collapsed .sidebar .chev { display: initial !important; }
	.sidebar-collapsed .sidebar .nav-item { justify-content: flex-start; padding: 8px 10px; }
	.sidebar-collapsed .sidebar .nav-group.open > .nav-sub { display: block !important; }
	.menu-btn { display: grid; }
	.topbar { padding: 0 14px; gap: 10px; }
	.modem-stats { display: none; }
}
@media (max-width: 640px) {
	.page { padding: 18px 14px 8px; }
	.quick-search { width: auto; flex: 1; }
	.username { display: none; }
	.usermenu summary { padding: 3px; }
	.form-grid { grid-template-columns: 1fr; }
	.form-grid > label { text-align: left; }
	.form-grid .actions { grid-column: 1; }
	dl.details { grid-template-columns: 1fr; gap: 2px; }
	dl.details dd { margin-bottom: 10px; }
	.section-card ul { columns: 1; }
	.page-head h1 { font-size: 20px; }
}

/* keep toolbar inputs inside their card and row actions on one or two lines */
.toolbar .field { max-width: 100%; }
.toolbar input[type=search], .toolbar input[type=text] { max-width: 100%; }
.row-actions { min-width: 250px; }

/* ---------- two-step sign-in ---------- */
.mfa-card { max-width: 440px; }
.mfa-card h1 { margin-bottom: 6px; }
.mfa-steps { padding-left: 20px; margin: 14px 0; color: var(--text-2); }
.mfa-steps li { margin-bottom: 10px; }
.qr-box { width: 190px; height: 190px; margin: 12px 0 8px; padding: 6px; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.manual-key summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.manual-key .key { display: inline-block; margin: 8px 0 4px; font-size: 14px; letter-spacing: .06em; word-break: break-all; }
.code-input { width: 100%; font-family: var(--mono) !important; font-size: 22px !important; letter-spacing: .3em; text-align: center; margin-bottom: 12px; }
.mfa-card form .btn { width: 100%; }
.mfa-help { font-size: 12.5px; margin-top: 16px; }
.recovery-codes { list-style: none; padding: 14px; margin: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; font-family: var(--mono); font-size: 15px; text-align: center; }
@media print { .login-body { background: #fff; } .login-card { box-shadow: none; border: 0; } }

/* ---------- charts and stat tiles ---------- */
.chart-wrap { margin: 0; }
.chart { width: 100%; height: 260px; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart .s1, .chart-legend .s1 { stroke: var(--accent); fill: var(--accent); background: var(--accent); }
.chart .s2, .chart-legend .s2 { stroke: #f59e0b; fill: #f59e0b; background: #f59e0b; }
.chart .s3, .chart-legend .s3 { stroke: #10b981; fill: #10b981; background: #10b981; }
.chart .s4, .chart-legend .s4 { stroke: #ef4444; fill: #ef4444; background: #ef4444; }
.chart .line.s1, .chart .line.s2, .chart .line.s3, .chart .line.s4 { fill: none; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.chart-legend i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.barlist { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 240px) 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 60px; text-align: right; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.warn .stat-value { color: var(--warn); }
.stat.bad .stat-value { color: var(--bad); }
.long-session { color: var(--bad); font-weight: 600; }

/* ---------- MRTG graph grid ---------- */
.graph-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.graph-card { display: block; padding: 12px 14px; margin: 0; color: var(--text); transition: border-color .12s; }
.graph-card:hover { border-color: var(--accent); text-decoration: none; }
.graph-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.graph-card img { display: block; width: 100%; height: auto; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.graph-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- Manage section ---- */
.small { font-size: 12px; }
.strong { font-weight: 600; }
details.inline-edit { display: inline-block; position: relative; }
details.inline-edit > summary { list-style: none; cursor: pointer; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] > summary { background: var(--accent-soft); color: var(--accent-ink); }
details.inline-edit > form { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: flex; gap: 6px; align-items: center;
	background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); white-space: nowrap; }
.perm-tree { padding: 8px 0; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 5px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.perm-row:last-child { border-bottom: 0; }
.perm-row:hover { background: var(--surface-3); }
.perm-row .mono { margin-left: auto; }

/* ---- Marketing tree ---- */
details.mk-node { margin: 6px 0; }
details.mk-node > summary { cursor: pointer; padding: 4px 0; }
.mk-body { margin-left: 18px; padding-left: 12px; border-left: 2px solid var(--line); }
.mk-ad { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.mk-ad form.inline { margin-left: auto; }

/* =====================================================================
   Layout v3: page header with actions, list cards, row menus, tabs,
   detail pages, dashboard tiles, Jump-to palette, pinned pages
   ===================================================================== */

/* Page header: section label, title, actions on the right */
.page-head.v3 { align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-head.v3 .head-text { flex: 1 1 300px; min-width: 0; }
.page-head .crumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.page-head .crumb a { color: var(--muted); }
.page-head.v3 h1 { font-size: 26px; letter-spacing: -0.01em; }
.page-head.v3 p { margin-top: 3px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.page-actions a:not(.btn) { font-weight: 500; font-size: 14px; }

/* A list inside one card: toolbar, table, footer */
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 16px; }
.list-card > .list-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-card .table-wrap { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.list-card table.data { font-size: 14px; }
.list-card table.data th, .list-card table.data td { padding: 11px 16px; }
.list-card table.data thead th { background: var(--surface-2); }
.list-foot { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }

.search-box { position: relative; flex: 1 1 320px; display: block; margin: 0; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--muted); pointer-events: none; }
.search-box input { width: 100%; height: 42px; padding: 0 12px 0 40px; font-size: 14px; border-radius: 9px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg a { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; text-decoration: none; }
.seg a:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.seg a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.filter-select { height: 36px; border-radius: 8px; font-size: 13px; max-width: 220px; }

.user-cell a.user-link { font-weight: 600; color: var(--text); }
.user-cell a.user-link:hover { color: var(--accent); }
.user-cell .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-muted { background: var(--surface-3); color: var(--text-2); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }

/* Row "⋯" menu (a <details> element, so it works without JavaScript) */
td.menu-cell { width: 56px; text-align: right; }
.rowmenu { position: relative; display: inline-block; }
.rowmenu > summary { list-style: none; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-2); cursor: pointer; }
.rowmenu > summary::-webkit-details-marker { display: none; }
.rowmenu > summary:hover, .rowmenu[open] > summary { background: var(--surface-3); }
.rowmenu > summary svg { width: 18px; height: 18px; }
.rowmenu-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; text-align: left; }
.rowmenu-panel.up { top: auto; bottom: calc(100% + 4px); }
.rowmenu-panel a, .rowmenu-panel button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; white-space: nowrap; }
.rowmenu-panel a:hover, .rowmenu-panel button:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.rowmenu-panel form { margin: 0; }
.rowmenu-panel .sep { height: 1px; background: var(--line); margin: 4px 0; }
.rowmenu-panel .warn { color: var(--warn); }
.rowmenu-panel .is-off { color: var(--muted); cursor: not-allowed; }
.rowmenu-panel .is-off:hover { background: none; color: var(--muted); }

/* Paging */
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; text-decoration: none; box-sizing: border-box; }
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager .cur { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.pager .edge { border: 1px solid var(--line-strong); }
.pager .gap { min-width: 0; padding: 0 2px; }

/* Detail page: summary card + tabbed panel */
.detail-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.summary-card { flex: 1 1 280px; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 16px; box-sizing: border-box; }
.summary-card .who { display: flex; gap: 14px; align-items: center; }
.summary-card .initials { width: 52px; height: 52px; flex: none; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.summary-card h1 { margin: 0; font-size: 22px; font-weight: 700; word-break: break-all; }
.summary-card .who .sub { color: var(--text-2); font-size: 14px; }
.summary-card dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px 12px; font-size: 14px; }
.summary-card dt { color: var(--muted); }
.summary-card dd { margin: 0; overflow-wrap: anywhere; }
.summary-actions { display: flex; flex-direction: column; gap: 8px; }
.summary-actions .btn { justify-content: center; width: 100%; box-sizing: border-box; }
.summary-actions .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.summary-actions .two form { margin: 0; }

.tab-card { flex: 999 1 480px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs [role=tab] { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--text-2); padding: 14px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected=true] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { padding: 22px; }
.tab-panel[hidden] { display: none; }
.tab-panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tab-panel .divider { height: 1px; background: var(--line); margin: 22px 0; }
.field-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; font-size: 14px; }
.field-grid dt { color: var(--muted); font-size: 13px; }
.field-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.tab-panel table.data { font-size: 13px; }

.danger-zone { border: 1px solid var(--bad-line); border-radius: 12px; background: var(--surface); padding: 18px 22px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-bottom: 16px; }
.danger-zone .dz-text { flex: 1 1 320px; }
.danger-zone h2 { margin: 0; font-size: 15px; color: var(--bad); }
.danger-zone p { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }
.danger-zone .dz-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-zone form { margin: 0; }
.btn-warn-outline { border-color: var(--warn-line); color: var(--warn); background: var(--surface); }
.btn-warn-outline:hover { background: var(--warn-bg); }

/* Dashboard */
.dash-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.dash-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.dash-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.dash-head .search-box { flex: 0 1 420px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--text); display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile .t-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile .t-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile .t-value small { font-size: 16px; color: var(--muted); font-weight: 500; }
.tile .t-note { font-size: 13px; color: var(--text-2); }
.tile.attention { border-color: var(--warn-line); }
.tile.attention .t-label { color: var(--warn); font-weight: 600; }
.tile .bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.tile .bar span { display: block; height: 100%; background: var(--ok); }
.tile .bar.high span { background: var(--bad); }
.dash-cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.dash-cols > section { flex: 1 1 300px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-sizing: border-box; box-shadow: var(--shadow-sm); }
.dash-cols > section.wide { flex: 1.4 1 420px; }
.dash-cols h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.dash-cols .sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.shortcut-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.shortcut-grid a { border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; color: var(--text); font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shortcut-grid a:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.activity { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity .when { width: 74px; flex: none; color: var(--muted); white-space: nowrap; }
.activity .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Sidebar: Jump-to button and pinned pages */
.jump-btn { display: flex; align-items: center; gap: 10px; width: calc(100% - 20px); margin: 0 10px 8px; padding: 9px 10px; border: 0; border-radius: 8px; background: rgba(255,255,255,.08); color: var(--side-text); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.jump-btn:hover { background: rgba(255,255,255,.12); color: var(--side-text-strong); }
.jump-btn svg { width: 16px; height: 16px; flex: none; }
.jump-btn .nav-text { flex: 1; }
.jump-btn kbd { font: inherit; font-size: 11px; border: 1px solid rgba(255,255,255,.18); border-radius: 5px; padding: 1px 6px; }
.sidebar-collapsed .sidebar .jump-btn { justify-content: center; }
.sidebar-collapsed .sidebar .jump-btn kbd { display: none; }
.nav-pins[hidden] { display: none; }
.nav-pins .pin-heading { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(183,188,214,.6); padding: 10px 12px 4px; }
.sidebar-collapsed .sidebar .nav-pins .pin-heading { display: none; }

/* Jump-to palette */
.palette-scrim { position: fixed; inset: 0; z-index: 200; background: rgba(10,12,24,.45); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.palette-scrim[hidden] { display: none; }
.palette { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette input { width: 100%; box-sizing: border-box; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; height: 54px; padding: 0 18px; font-size: 16px; background: var(--surface); }
.palette input:focus { outline: none; box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); font-size: 14px; }
.palette li a .where { color: var(--muted); font-size: 12px; white-space: nowrap; }
.palette li a.sel, .palette li a:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.palette .none { padding: 18px; color: var(--muted); font-size: 14px; }
.palette .hint { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
	.summary-card { max-width: none; }
	.page-head.v3 h1, .dash-head h1 { font-size: 22px; }
	.shortcut-grid { grid-template-columns: minmax(0, 1fr); }
	/* User list becomes cards on phones */
	.list-card table.data.cards thead { display: none; }
	.list-card table.data.cards, .list-card table.data.cards tbody, .list-card table.data.cards tr, .list-card table.data.cards td { display: block; width: auto; }
	.list-card table.data.cards tr { position: relative; padding: 12px 56px 12px 16px; border-bottom: 1px solid var(--line); }
	.list-card table.data.cards td { padding: 2px 0; border: 0; }
	.list-card table.data.cards td.menu-cell { position: absolute; top: 10px; right: 10px; padding: 0; }
	.list-card table.data.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
