/* Components: cards, buttons, forms, tables, badges, chips, tabs, modal, drawer, toast. */

/* ---------- Card ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	padding: var(--space-5);
	margin-bottom: var(--space-4);
	min-width: 0;
}
.stack > .card, .stack-lg > .card, .grid > .card, .grid-2 > .card, .grid-3 > .card, .grid-4 > .card,
.layout-rail .card, .card .card { margin-bottom: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
	margin-bottom: var(--space-4);
}
.card-flush > .card-header { padding: var(--space-4) var(--space-5); margin: 0; border-bottom: 1px solid var(--border); }
.card-title, .card > h3 {
	font-size: var(--text-lg);
	font-weight: 600;
	color: var(--text-strong);
	letter-spacing: -0.01em;
	display: flex;
	align-items: center;
	gap: var(--space-2);
}
.card > h3 { margin-bottom: var(--space-3); }
.card-subtitle { margin-top: 2px; color: var(--text-muted); font-size: var(--text-base); }
.card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	margin-top: var(--space-4);
	padding-top: var(--space-4);
	border-top: 1px solid var(--border);
}
.card-flush > .card-footer { margin: 0; padding: var(--space-3) var(--space-5); background: var(--surface-2); }
.card-accent { border-color: var(--accent-border); background: linear-gradient(135deg, var(--accent-tint), transparent 55%), var(--surface); }
.section-label {
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-faint);
	margin-bottom: var(--space-2);
}

/* ---------- Stat card ---------- */

.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	padding: var(--space-4) var(--space-5);
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: 0;
}
.stat-card-head { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: var(--text-base); font-weight: 500; }
.stat-card-head .icon { color: var(--text-faint); }
.stat-card-body { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); min-height: 34px; }
.stat-value { font-size: var(--text-3xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.stat-meta { font-size: var(--text-sm); color: var(--text-muted); }

/* ---------- Buttons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: var(--button-h);
	padding: 0 12px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text-strong);
	font: inherit;
	font-size: var(--text-base);
	font-weight: 550;
	line-height: 1;
	white-space: nowrap;
	cursor: pointer;
	text-decoration: none;
	transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { background: var(--hover); border-color: var(--text-faint); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.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-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--text-strong); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--text-sm); }
.btn-lg { height: 38px; padding: 0 16px; font-size: var(--text-md); }
.btn-icon { width: var(--button-h); padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--accent-text); font-weight: 500; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn .spinner { display: none; }
.btn.htmx-request .spinner, .htmx-request > .btn[type="submit"] .spinner { display: inline-block; }

.spinner {
	width: 14px;
	height: 14px;
	border: 2px solid var(--border-strong);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges & chips ---------- */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	height: 20px;
	padding: 0 8px;
	border-radius: var(--radius-full);
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: 0.01em;
	white-space: nowrap;
	border: 1px solid var(--border);
	background: var(--surface-2);
	color: var(--text-muted);
	vertical-align: middle;
}
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-accent { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent-border); }
.badge-success { background: var(--success-tint); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-tint); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-border); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 22px;
	padding: 0 7px;
	border-radius: var(--radius-sm);
	font-family: var(--font-mono);
	font-size: var(--text-sm);
	background: var(--code-bg);
	color: var(--code-text);
	border: 1px solid var(--border);
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}
.chip-danger { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-border); }
.chip-success { background: var(--success-tint); color: var(--success); border-color: var(--success-border); }
.chip-accent { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent-border); }
.chip button {
	display: inline-flex;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	opacity: 0.7;
	padding: 0;
}
.chip button:hover { opacity: 1; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Avatar ---------- */

.avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	flex-shrink: 0;
	font-size: var(--text-xs);
	font-weight: 650;
	letter-spacing: 0.02em;
	background: var(--accent-tint);
	color: var(--accent-text);
	border: 1px solid var(--accent-border);
	text-transform: uppercase;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-lg { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-t1 { background: rgb(167 139 250 / 0.14); color: #A78BFA; border-color: rgb(167 139 250 / 0.35); }
.avatar-t2 { background: var(--success-tint); color: var(--success); border-color: var(--success-border); }
.avatar-t3 { background: var(--warning-tint); color: var(--warning); border-color: var(--warning-border); }
.avatar-t4 { background: rgb(244 114 182 / 0.14); color: #F472B6; border-color: rgb(244 114 182 / 0.35); }
[data-theme="light"] .avatar-t1 { color: #6D28D9; }
[data-theme="light"] .avatar-t4 { color: #BE185D; }
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.identity-text { min-width: 0; line-height: 1.3; }
.identity-name { color: var(--text-strong); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-sub { color: var(--text-muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logo-tile {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: var(--radius);
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text-strong);
	font-weight: 700;
	font-size: var(--text-base);
	text-transform: uppercase;
	flex-shrink: 0;
}
.logo-tile-lg { width: 44px; height: 44px; font-size: var(--text-lg); border-radius: 10px; }
.logo-tile-img img { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; }
.logo-tile-lg.logo-tile-img img { width: 28px; height: 28px; border-radius: 6px; }
[data-theme="dark"] .logo-tile-img img.logo-mono { filter: brightness(0) invert(1); }
.logo-tile-glyph { color: var(--text-muted); }
.logo-tile-brand { color: var(--accent-text); background: var(--accent-tint); border-color: transparent; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }
label, .label {
	display: block;
	font-size: var(--text-base);
	font-weight: 550;
	color: var(--text-strong);
	margin-bottom: 6px;
}
.label-optional { color: var(--text-faint); font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
input[type="search"], input[type="date"], input[type="datetime-local"], input:not([type]), select, textarea {
	width: 100%;
	height: var(--control-h);
	padding: 0 10px;
	background: var(--bg);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	color: var(--text-strong);
	font: inherit;
	font-size: var(--text-md);
	transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
[data-theme="light"] input[type="text"], [data-theme="light"] input[type="email"], [data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"], [data-theme="light"] input[type="url"], [data-theme="light"] input[type="search"],
[data-theme="light"] input[type="date"], [data-theme="light"] input[type="datetime-local"], [data-theme="light"] input:not([type]),
[data-theme="light"] select, [data-theme="light"] textarea { background: var(--surface); }
textarea { height: auto; min-height: 88px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
input.mono, textarea.mono, .mono-input { font-family: var(--font-mono); font-size: var(--text-base); }
select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 30px;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
	background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.form-hint, .hint { margin-top: 6px; color: var(--text-muted); font-size: var(--text-sm); line-height: 1.45; }
.form-error { margin-top: 6px; color: var(--danger); font-size: var(--text-sm); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-actions { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); }
.form-actions.start { justify-content: flex-start; }
.input-group { display: flex; align-items: stretch; gap: var(--space-2); }
.input-group > input, .input-group > code { flex: 1; min-width: 0; }

.check {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 0;
	font-weight: 450;
	color: var(--text);
	cursor: pointer;
}
.check input { margin-top: 2px; }
.check-desc { display: block; color: var(--text-muted); font-size: var(--text-sm); font-weight: 400; }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; }
.checkbox-list label {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	font-weight: 450;
	cursor: pointer;
}
.checkbox-list label:hover { border-color: var(--border-strong); background: var(--hover); }

/* Radio cards */
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.radio-card {
	position: relative;
	display: flex;
	gap: 10px;
	padding: var(--space-3);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--bg);
	cursor: pointer;
	margin: 0;
	font-weight: 450;
}
.radio-card:hover { border-color: var(--text-faint); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.radio-card-title { display: block; color: var(--text-strong); font-weight: 600; font-size: var(--text-base); }
.radio-card-desc { display: block; color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track {
	width: 32px;
	height: 18px;
	border-radius: 9px;
	background: var(--border-strong);
	position: relative;
	transition: background var(--dur);
	flex-shrink: 0;
}
.switch-track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
	transition: transform var(--dur) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus-ring); }

/* Search + toolbar */
.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.search-field { position: relative; flex: 1 1 280px; min-width: 0; max-width: 520px; }
.search-field > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-field input[type="search"], .search-field input[type="text"] { padding-left: 32px; padding-right: 64px; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-field .search-aside { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; pointer-events: none; }
.search-field .htmx-indicator { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }

.segmented, .filter-group {
	display: inline-flex;
	gap: 2px;
	padding: 2px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}
.segmented > a, .segmented > button, .segmented > label, .filter-group button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 28px;
	padding: 0 10px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-size: var(--text-base);
	font-weight: 550;
	white-space: nowrap;
	cursor: pointer;
	margin: 0;
	text-decoration: none;
}
.segmented > a:hover, .segmented > button:hover, .segmented > label:hover, .filter-group button:hover { color: var(--text-strong); text-decoration: none; }
.segmented > .active, .segmented > [aria-pressed="true"], .segmented > [aria-selected="true"], .segmented > label:has(input:checked),
.filter-group button.active, .filter-group button[aria-pressed="true"] {
	background: var(--hover);
	color: var(--text-strong);
	box-shadow: inset 0 0 0 1px var(--border-strong);
}
.segmented > label { position: relative; }
.segmented > label input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented .count { color: var(--text-faint); font-weight: 500; }

/* ---------- Tabs ---------- */

.tabs {
	display: flex;
	gap: var(--space-1);
	border-bottom: 1px solid var(--border);
	margin-bottom: var(--space-6);
	overflow-x: auto;
}
.tab {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 12px;
	color: var(--text-muted);
	font-weight: 550;
	font-size: var(--text-base);
	white-space: nowrap;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: inherit;
}
.tab:hover { color: var(--text-strong); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--text-strong); }
.tab[aria-selected="true"]::after {
	content: "";
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: -1px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: var(--accent);
}
.tab .count { color: var(--text-faint); font-weight: 500; }

/* ---------- Tables ---------- */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
thead th {
	position: sticky;
	top: 0;
	text-align: left;
	height: 36px;
	padding: 0 var(--space-4);
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--text-faint);
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
tbody td {
	height: var(--row-h);
	padding: 8px var(--space-4);
	border-bottom: 1px solid var(--border);
	color: var(--text);
	vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur-fast); }
tbody tr:hover td { background: var(--hover); }
tbody tr.selected td { background: var(--accent-tint); }
tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions, th.actions { text-align: right; width: 1%; white-space: nowrap; }
td.muted { color: var(--text-muted); }
td code, td .chip { font-size: var(--text-sm); }
.card > table, .card > .table-wrap { margin: calc(var(--space-2) * -1) calc(var(--space-5) * -1) calc(var(--space-5) * -1); width: calc(100% + var(--space-5) * 2); }
.card-flush > table, .card-flush > .table-wrap { margin: 0; width: 100%; }
.card > .card-header + table, .card > .card-header + .table-wrap { margin-top: 0; }
.table-dense tbody td { height: var(--row-h-dense); padding-top: 4px; padding-bottom: 4px; }
.cell-sub { display: block; color: var(--text-muted); font-size: var(--text-sm); margin-top: 1px; }

/* ---------- Pagination ---------- */

.pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-3) var(--space-5);
	border-top: 1px solid var(--border);
	font-size: var(--text-sm);
	color: var(--text-muted);
}
.pagination-pages { display: flex; align-items: center; gap: 4px; }

/* ---------- Empty state ---------- */

.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: var(--space-12) var(--space-4);
	text-align: center;
	color: var(--text-muted);
	font-size: var(--text-md);
}
.empty-state-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text-muted);
	margin-bottom: var(--space-1);
}
.empty-state-title { color: var(--text-strong); font-weight: 600; font-size: var(--text-lg); }
.empty-state-body { max-width: 46ch; }
.empty-state .btn { margin-top: var(--space-2); }

/* ---------- Callouts & flash ---------- */

.callout {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px var(--space-3);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	font-size: var(--text-base);
	margin-bottom: var(--space-4);
}
.callout > .icon { margin-top: 2px; }
.callout-info { border-color: var(--accent-border); background: var(--accent-tint); }
.callout-info > .icon { color: var(--accent-text); }
.callout-success { border-color: var(--success-border); background: var(--success-tint); }
.callout-success > .icon { color: var(--success); }
.callout-warning { border-color: var(--warning-border); background: var(--warning-tint); }
.callout-warning > .icon { color: var(--warning); }
.callout-danger { border-color: var(--danger-border); background: var(--danger-tint); }
.callout-danger > .icon { color: var(--danger); }
.callout-title { font-weight: 600; color: var(--text-strong); }

.flash { display: none; }

/* Toasts */
.toast-root {
	position: fixed;
	right: var(--space-6);
	bottom: var(--space-6);
	z-index: 90;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	max-width: min(420px, calc(100vw - 32px));
	pointer-events: none;
}
.toast {
	pointer-events: auto;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	background: var(--elevated);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	box-shadow: var(--shadow-pop);
	color: var(--text-strong);
	font-size: var(--text-base);
}
.toast-success > .icon { color: var(--success); }
.toast-error > .icon { color: var(--danger); }
.toast-msg { flex: 1; min-width: 0; line-height: 1.45; }
.toast button { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0; display: inline-flex; }

/* ---------- Code blocks & copy ---------- */

.code-field {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding: 4px 4px 4px 12px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	min-width: 0;
}
[data-theme="light"] .code-field { background: var(--surface-2); }
.code-field code {
	flex: 1;
	min-width: 0;
	background: none;
	border: 0;
	padding: 4px 0;
	color: var(--accent-text);
	font-size: var(--text-base);
	overflow-x: auto;
	white-space: nowrap;
}
pre.code-block {
	margin: 0;
	padding: var(--space-3) var(--space-4);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--code-text);
	font-size: var(--text-sm);
	line-height: 1.6;
	overflow-x: auto;
	white-space: pre;
}
[data-theme="light"] pre.code-block { background: var(--surface-2); }

/* ---------- Meters ---------- */

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > span { background: var(--warning); }
.meter.full > span { background: var(--danger); }
.meter-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meter-row:last-child { border-bottom: 0; }

/* ---------- Key/value list ---------- */

.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px var(--space-4); font-size: var(--text-base); }
.kv dt { color: var(--text-muted); }
.kv dd { color: var(--text-strong); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Modal & drawer (native dialog) ---------- */

dialog {
	color: var(--text);
	background: var(--elevated);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-modal);
	padding: 0;
	max-width: min(480px, calc(100vw - 32px));
	width: 100%;
	max-height: calc(100vh - 64px);
	margin: auto;
	overflow: visible;
}
dialog::backdrop { background: var(--backdrop); }
dialog > form, dialog > .modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 64px); }
.modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-5) var(--space-5) var(--space-3);
}
.modal-title, dialog h3 { font-size: var(--text-lg); font-weight: 600; color: var(--text-strong); }
.modal-desc { color: var(--text-muted); font-size: var(--text-base); margin-top: 2px; }
.modal-body { padding: var(--space-2) var(--space-5) var(--space-5); overflow-y: auto; }
.modal-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: var(--space-2);
	padding: var(--space-3) var(--space-5);
	border-top: 1px solid var(--border);
	background: var(--surface-2);
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
dialog.modal-wide { max-width: min(640px, calc(100vw - 32px)); }
dialog:not(.modal):not(.drawer) { padding: var(--space-5); }

dialog.drawer {
	margin: 0 0 0 auto;
	height: 100vh;
	max-height: 100vh;
	max-width: min(440px, 100vw);
	border-radius: 0;
	border-width: 0 0 0 1px;
}
dialog.drawer > .modal-inner { height: 100%; max-height: 100vh; }
dialog.drawer .modal-body { flex: 1; }

/* ---------- Integration cards ---------- */

.integration-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.integration-card {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding: var(--space-4);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	color: inherit;
	min-height: 120px;
	transition: border-color var(--dur-fast), transform var(--dur-fast), background var(--dur-fast);
}
.integration-card:hover { border-color: var(--border-strong); transform: translateY(-1px); text-decoration: none; background: var(--surface-2); }
.integration-card.connected { border-color: var(--accent-border); }
.integration-card-header { display: flex; align-items: center; gap: var(--space-3); }
.integration-card-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text-strong); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integration-card-desc { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.45; flex: 1; }
.integration-card-footer, .integration-card-badges { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.integration-section { margin-bottom: var(--space-6); }
.integration-section-title { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--space-3); }
mark { background: var(--accent-tint); color: var(--accent-text); border-radius: 2px; padding: 0 1px; }

/* ---------- Master-detail picker (policy editor) ---------- */

.picker { display: grid; grid-template-columns: 280px minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 460px; }
.picker-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.picker-search { padding: var(--space-3); border-bottom: 1px solid var(--border); }
.picker-items { flex: 1; overflow-y: auto; max-height: 560px; }
.picker-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px var(--space-3);
	border: 0;
	border-bottom: 1px solid var(--border);
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: var(--text-base);
	text-align: left;
	cursor: pointer;
}
.picker-item:hover { background: var(--hover); }
.picker-item[aria-selected="true"] { background: var(--accent-tint); box-shadow: inset 2px 0 0 var(--accent); }
.picker-item .name { flex: 1; min-width: 0; font-weight: 550; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .sub { display: block; font-weight: 400; color: var(--text-faint); font-size: var(--text-xs); }
.picker-detail { padding: var(--space-5); min-width: 0; }
.picker-panel[hidden] { display: none; }
/* Before policy-picker.js runs (or if it never loads) every integration
   panel stays visible in one stacked column, so all rules remain editable. */
.picker:not(.is-ready) { grid-template-columns: minmax(0, 1fr); }
.picker:not(.is-ready) .picker-list { display: none; }
.picker:not(.is-ready) .picker-panel + .picker-panel { border-top: 1px solid var(--border); margin-top: var(--space-5); padding-top: var(--space-5); }

.chip-input {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-height: var(--control-h);
	padding: 5px 6px;
	background: var(--bg);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	cursor: text;
}
[data-theme="light"] .chip-input { background: var(--surface); }
.chip-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.chip-input input[type="text"] {
	flex: 1;
	min-width: 160px;
	height: 24px;
	border: 0;
	padding: 0 4px;
	background: transparent;
	box-shadow: none;
	font-family: var(--font-mono);
	font-size: var(--text-sm);
}
.chip-input input[type="text"]:focus { box-shadow: none; }

/* Sticky save bar */
.save-bar {
	position: static;
	bottom: var(--space-4);
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	margin-top: var(--space-6);
	padding: var(--space-3) var(--space-4);
	background: var(--elevated);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	box-shadow: var(--shadow-pop);
}
.save-bar-status { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--text-base); }
.save-bar-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
form[data-dirty="true"] .save-bar-status::before { background: var(--warning); }
form[data-dirty="true"] .save-bar-status .clean { display: none; }
form:not([data-dirty="true"]) .save-bar-status .dirty { display: none; }

/* Task list */
.task-list { list-style: none; }
.task {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	min-height: 52px;
	padding: 8px var(--space-4);
	border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--hover); }
.task-check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 1.5px solid var(--border-strong);
	background: transparent;
	color: var(--on-accent);
	cursor: pointer;
	flex-shrink: 0;
	padding: 0;
}
.task-check:hover { border-color: var(--accent); }
.task.done .task-check { background: var(--accent); border-color: var(--accent); }
.task-title { color: var(--text-strong); font-weight: 500; }
.task.done .task-title { color: var(--text-faint); text-decoration: line-through; }
.task-notes { color: var(--text-muted); font-size: var(--text-sm); }
.task-meta { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; flex-shrink: 0; }

/* Plan compare */
.plan-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.plan-card { position: relative; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.plan-card.recommended { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-tint); }
.plan-name { font-weight: 600; color: var(--text-strong); }
.plan-price { font-size: var(--text-2xl); font-weight: 650; color: var(--text-strong); letter-spacing: -0.02em; }
.plan-price small { font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.plan-features { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); color: var(--text-muted); flex: 1; }
.plan-features li { display: flex; gap: 6px; align-items: flex-start; }
.plan-features .icon { color: var(--success); margin-top: 2px; }

/* Steps (onboarding, google setup) */
.steps { list-style: none; display: flex; flex-direction: column; gap: var(--space-3); counter-reset: step; }
.steps > li { display: flex; gap: var(--space-3); align-items: flex-start; counter-increment: step; }
.steps > li::before {
	content: counter(step);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--accent-tint);
	border: 1px solid var(--accent-border);
	color: var(--accent-text);
	font-size: var(--text-sm);
	font-weight: 650;
	flex-shrink: 0;
}

details.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 550; font-size: var(--text-base); }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .icon { transition: transform var(--dur); }
details.disclosure[open] > summary .icon { transform: rotate(90deg); }

@media (max-width: 1024px) {
	.picker { grid-template-columns: minmax(0, 1fr); }
	.picker-list { border-right: 0; border-bottom: 1px solid var(--border); }
	.picker-items { max-height: 240px; }
}
@media (max-width: 640px) {
	.form-row, .radio-cards { grid-template-columns: minmax(0, 1fr); }
	.kv { grid-template-columns: minmax(0, 1fr); }
	.task { flex-wrap: wrap; }
	.task-meta { margin-left: 30px; }
}

/* ---------- Savings ---------- */

.savings-headline { font-size: var(--text-3xl); font-weight: 650; letter-spacing: -0.02em; color: var(--text-strong); margin: 2px 0; }
.savings-headline .text-muted { font-size: var(--text-md); font-weight: 500; }
.metric-tile { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); min-width: 0; }
[data-theme="light"] .metric-tile { background: var(--surface-2); }
.metric-value { font-size: var(--text-xl); font-weight: 650; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.metric-label { font-size: var(--text-sm); font-weight: 550; color: var(--text-muted); margin-top: 2px; }
.metric-detail { font-size: var(--text-xs); color: var(--text-faint); margin-top: 2px; }
.savings-footer { justify-content: flex-start; gap: var(--space-8); }
.savings-card .grid-3 { gap: var(--space-3); }
@media (max-width: 1400px) { .savings-card .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Misc helpers for pages ---------- */
select.auto-width, input.auto-width { width: auto; }
.capitalize { text-transform: capitalize; }
.truncate-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chips { padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border); gap: var(--space-2); }
.audit-filters { padding: var(--space-3) var(--space-4); }
.identity .logo-tile { width: 22px; height: 22px; font-size: 10px; border-radius: 6px; }
.identity .logo-tile-img img { width: 14px; height: 14px; border-radius: 3px; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-3) var(--space-4); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
pre.code-block.wrap { white-space: pre-wrap; max-height: 280px; overflow-y: auto; }
.google-workspace-card { margin-bottom: var(--space-6); }
.integration-no-results { margin-bottom: var(--space-4); }
.kv-tight { grid-template-columns: 80px minmax(0, 1fr); gap: 8px var(--space-3); }
fieldset { border: 0; min-width: 0; }
fieldset:disabled { opacity: 0.5; }
.meter-inline { display: inline-block; width: 120px; }
.grants-cell { max-width: 420px; }
.expr-preview { display: block; max-width: 420px; }

/* ---------- Policy editor ---------- */
.glob-field [data-picker-allow-group].is-off { opacity: 0.55; }
.picker-item.is-enabled .name { color: var(--text-strong); }
.tool-preview { list-style: none; border: 1px solid var(--border); border-radius: var(--radius); max-height: 320px; overflow-y: auto; }
.tool-preview li { display: grid; grid-template-columns: 16px minmax(180px, max-content) minmax(0, 1fr); align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.tool-preview li:last-child { border-bottom: 0; }
.tool-preview .tool-desc { color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); justify-self: center; }
.tool-preview li[data-state="allowed"] .tool-mark { background: var(--success); }
.tool-preview li[data-state="denied"] .tool-mark { background: var(--danger); }
.tool-preview li[data-state="denied"] code { text-decoration: line-through; color: var(--danger); }
.tool-preview li[data-state="off"] code { color: var(--text-faint); }
.cel-group { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); margin-top: var(--space-3); background: var(--surface-2); }
.cel-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-2); }
.cel-row-value-container { position: relative; flex: 1; min-width: 160px; }
.suggest-anchor { position: relative; display: block; }
.cel-suggest-panel { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: var(--elevated); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 260px; overflow-y: auto; }
.cel-suggest-panel:empty { display: none; }
.cel-suggest-list { list-style: none; padding: 4px; }
.cel-suggest-option { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: var(--text-sm); }
.cel-suggest-option:hover, .cel-suggest-option[aria-selected="true"], .cel-suggest-option.active { background: var(--hover); }
.cel-suggest-label { font-family: var(--font-mono); color: var(--text-strong); }
.cel-suggest-desc { flex-basis: 100%; color: var(--text-faint); font-size: var(--text-xs); }
.cel-suggest-empty { padding: 8px 10px; color: var(--text-faint); font-size: var(--text-sm); }
.person-list { list-style: none; }
.person-list li { padding: 8px var(--space-5); border-bottom: 1px solid var(--border); }
.person-list li:last-child { border-bottom: 0; }
.pad { padding: var(--space-3) var(--space-5) var(--space-5); }
label > .icon { margin-right: 4px; vertical-align: -2px; }
.tool-preview li { grid-template-columns: 16px minmax(0, 42%) minmax(0, 1fr); }
.tool-preview code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.indent-1 { padding-left: calc(var(--space-4) + 20px) !important; }
.indent-2 { padding-left: calc(var(--space-4) + 40px) !important; }
.indent-3 { padding-left: calc(var(--space-4) + 60px) !important; }
.indent-4 { padding-left: calc(var(--space-4) + 80px) !important; }
.indent-5 { padding-left: calc(var(--space-4) + 100px) !important; }
.indent-6 { padding-left: calc(var(--space-4) + 120px) !important; }
.indent-7 { padding-left: calc(var(--space-4) + 140px) !important; }
.indent-8 { padding-left: calc(var(--space-4) + 160px) !important; }
.link-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.link-list a { display: flex; align-items: center; gap: var(--space-2); padding: 7px 8px; border-radius: 6px; color: var(--text); }
.link-list a:hover { background: var(--hover); text-decoration: none; color: var(--text-strong); }

/* ---------- Skill editor ---------- */
.skill-edit { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-6); align-items: start; }
.skill-edit-main, .skill-edit-side { min-width: 0; }
.skill-edit-side { position: sticky; top: var(--space-6); }
.skill-instructions { min-height: 28rem; font-size: var(--text-base); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.skill-instructions.resource-body { min-height: 12rem; }
.skill-arg-row { display: grid; grid-template-columns: 8rem 9rem minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.skill-arg-required { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 450; color: var(--text-muted); white-space: nowrap; }
.skill-resource-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 1200px) { .skill-edit { grid-template-columns: minmax(0, 1fr); } .skill-edit-side { position: static; } }
@media (max-width: 640px) { .skill-arg-row { grid-template-columns: 1fr 1fr; } .skill-arg-required { grid-column: 1 / -1; } }
.list-rows { list-style: none; }
.list-rows li { border-bottom: 1px solid var(--border); }
.list-rows li:last-child { border-bottom: 0; }
.list-rows a { display: flex; align-items: center; gap: var(--space-3); padding: 12px var(--space-5); color: var(--text); }
.list-rows a:hover { background: var(--hover); text-decoration: none; }
.list-rows a > .icon { color: var(--text-faint); }
.quick-add { display: flex; align-items: center; gap: var(--space-2); padding: 6px 6px 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.quick-add > .icon { color: var(--text-faint); }
.quick-add input[type="text"] { border: 0; background: transparent; box-shadow: none; padding: 0 4px; }
.quick-add input[type="text"]:focus { box-shadow: none; }
.task form { display: inline-flex; }
.todo-progress { gap: var(--space-3); }
.savings-fieldset { border: 0; }
.savings-fieldset legend { margin-bottom: var(--space-2); }
.label-row label { margin-bottom: 0; }
.label-row { margin-bottom: 6px; }

/* ---------- Plugins ---------- */
.plugin-page { display: grid; gap: var(--space-6); }
.plugin-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); padding: 0; background: none; border: 0; box-shadow: none; }
.plugin-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-card); }
.plugin-stat-label { color: var(--text-muted); font-size: var(--text-base); font-weight: 500; }
.plugin-stat-value { color: var(--text-strong); font-size: var(--text-xl); font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.plugin-section { display: grid; gap: var(--space-3); }
.plugin-section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.plugin-section-title { color: var(--text-strong); font-size: var(--text-lg); font-weight: 600; }
.plugin-section-copy { color: var(--text-muted); font-size: var(--text-base); max-width: 72ch; }
.plugin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.plugin-card { display: grid; gap: var(--space-3); align-content: start; margin-bottom: 0; }
.plugin-card-head { display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; }
.plugin-card h4, .plugin-subhead { margin: 0 0 4px; color: var(--text-strong); font-size: var(--text-md); font-weight: 600; }
.plugin-card p { color: var(--text-muted); margin: 0; font-size: var(--text-base); }
.plugin-meta { color: var(--text-faint); font-size: var(--text-sm); }
.plugin-form { display: grid; gap: var(--space-4); max-width: var(--form-max); }
.plugin-form-row { display: grid; gap: 6px; }
.plugin-help { color: var(--text-muted); font-size: var(--text-sm); }
.plugin-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.plugin-advanced { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.plugin-advanced summary { cursor: pointer; color: var(--text-muted); font-weight: 600; }
.plugin-advanced[open] summary { margin-bottom: var(--space-3); }
.plugin-source-list { display: grid; gap: var(--space-2); }
.plugin-source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.plugin-source-row:first-child { border-top: 0; }
.plugin-url { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
@media (max-width: 720px) { .plugin-stats { grid-template-columns: minmax(0, 1fr); } .plugin-source-row { grid-template-columns: minmax(0, 1fr); } }
.snippet { position: relative; }
.snippet .snippet-copy { position: absolute; top: 8px; right: 8px; }
.client-tabs { flex-wrap: wrap; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2); }
.service-option { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-weight: 500; cursor: pointer; }
[data-theme="light"] .service-option { background: var(--surface); }
.service-option:hover { border-color: var(--border-strong); }
.service-option .logo-tile { width: 26px; height: 26px; border-radius: 6px; }
.service-option .logo-tile-img img { width: 16px; height: 16px; }
.service-option:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.consent-scope-list { list-style: none; }
.consent-scope { padding: 10px 0; border-top: 1px solid var(--border); display: grid; gap: 2px; }
.consent-scope:first-child { border-top: 0; }
.prose p, .prose ul { margin-bottom: var(--space-3); color: var(--text-muted); }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }

/* ---------- Auth shell (sign in, pickers) ---------- */
.auth-body { min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-tint), transparent 60%), var(--bg); }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-6); padding: var(--space-8) var(--space-4); }
.auth-brand { margin: 0; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: var(--space-6); }
.auth-title { font-size: var(--text-xl); font-weight: 650; color: var(--text-strong); }
.auth-sub { color: var(--text-muted); margin: 4px 0 var(--space-5); }
.auth-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.auth-links { display: flex; flex-direction: column; gap: 6px; margin-top: var(--space-4); font-size: var(--text-sm); color: var(--text-muted); }
.auth-footer { width: 100%; max-width: 280px; }
.acct-list, .org-list { display: flex; flex-direction: column; gap: var(--space-2); }
.acct-btn, .org-btn { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
[data-theme="light"] .acct-btn, [data-theme="light"] .org-btn { background: var(--surface-2); }
.acct-btn:hover, .org-btn:hover, .acct-btn[aria-current="true"], .org-btn[aria-current="true"] { border-color: var(--accent); }
.acct-btn > div { flex: 1; min-width: 0; }
.acct-btn .name, .org-btn .name { font-weight: 600; color: var(--text-strong); }
.acct-btn .meta, .org-btn .meta { font-size: var(--text-sm); color: var(--text-muted); }
.acct-btn .arrow, .org-btn .arrow, .acct-btn > span { color: var(--text-faint); }
.auth-card .empty { padding: var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted); font-size: var(--text-base); }
.auth-card .status { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); min-height: 1.2em; }
.auth-card .status.error { color: var(--danger); }
#org-list-mount { margin-top: var(--space-4); }
.clerk-mount { display: flex; justify-content: center; min-height: 120px; align-items: center; }

/* The save bar sits inline until the form has unsaved changes, then sticks
   to the bottom of the viewport so Save is always reachable. */
form[data-dirty="true"] .save-bar, .save-bar.always-sticky { position: sticky; }
.plugin-page > .page-header { margin-bottom: 0; }
.plugin-page .card > .plugin-section-copy { margin: 6px 0 var(--space-4); }
.snippet pre.code-block { padding-right: 96px; }

/* ---------- Charts (components.Chart, drawn by static/js/charts.js) ---------- */

.dashboard-charts { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-card { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.chart-card-wide { grid-column: span 2; }
.chart-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.chart-card-title { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-lg); font-weight: 600; color: var(--text-strong); }
a.chart-card-title:hover { color: var(--accent-text); text-decoration: none; }
a.chart-card-title .icon { color: var(--text-faint); transition: color var(--dur-fast), transform var(--dur-fast) var(--ease-out); }
a.chart-card-title:hover .icon { color: var(--accent-text); transform: translate(1px, -1px); }
.chart-card-stat { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex-shrink: 0; }
.chart-card-stat .stat-value { font-size: var(--text-2xl); }
.chart-note { padding: var(--space-4) 0; }

.chart { position: relative; width: 100%; min-width: 0; }
.chart-sm { height: 150px; }
.chart-md { height: 200px; }
.chart-lg { height: 220px; }
.chart canvas { display: block; }
.chart-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.chart-center-value { font-size: var(--text-2xl); font-weight: 650; color: var(--text-strong); font-variant-numeric: tabular-nums; line-height: 1.1; }
.chart-center-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.chart-table { margin-top: var(--space-2); font-size: var(--text-sm); }
.chart-table > summary { cursor: pointer; color: var(--text-muted); width: max-content; border-radius: var(--radius-sm); }
.chart-table > summary:hover { color: var(--text); }
.chart-table .table-wrap { max-height: 280px; overflow-y: auto; margin-top: var(--space-2); }
.chart-table tbody th { font-weight: normal; text-align: left; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px var(--space-2); margin-top: auto; }
.chart-legend li { display: flex; min-width: 0; }
.chart-legend li > a, .chart-legend li > span:first-child { display: inline-flex; }
.chart-legend a, .chart-legend li { align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-muted); }
.chart-legend a { padding: 3px 6px; margin: 0 -6px; border-radius: var(--radius-sm); transition: background var(--dur-fast), color var(--dur-fast); }
.chart-legend a:hover { background: var(--hover); color: var(--text-strong); text-decoration: none; }
.chart-legend-value { color: var(--text-strong); font-weight: 550; font-variant-numeric: tabular-nums; }
.chart-swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; background: var(--accent); }
.chart-swatch-success { background: var(--success); }
.chart-swatch-warning { background: var(--warning); }
.chart-swatch-danger { background: var(--danger); }
.chart-swatch-text-faint { background: var(--text-faint); }
.chart-swatch-text-muted { background: var(--text-muted); }

@media (max-width: 1100px) {
	.dashboard-charts { grid-template-columns: minmax(0, 1fr); }
	.chart-card-wide { grid-column: auto; }
}
