/* UnifiedFax admin console — design system.
 *
 * Structure, in order: font, tokens (light, then dark), base, shell
 * (app bar, page header), layout, panels, buttons, forms, tables, badges,
 * menus, dialogs, toasts, tabs, trees, misc utilities.
 *
 * Visual model: a dark app bar frames the product; every page opens with a
 * full-width title band on the raised surface; content sits in bordered
 * panels whose header strip names the section. Borders are deliberately
 * heavier than consumer-app defaults so structure reads at a glance.
 */

@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-display: swap;
	font-weight: 100 900;
	src: url('../vendor/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
	color-scheme: light;

	/* Surfaces */
	--canvas: #f2f5f8;
	--surface: #ffffff;
	--surface-2: #f6f8fa; /* panel header strip, table head */
	--surface-hover: #eef3f7;
	--surface-selected: #e7f5f2;

	/* Ink */
	--ink: #1d2a36;
	--ink-2: #3c4a5a; /* labels */
	--ink-muted: #5e6b7a;
	--ink-faint: #8794a3;

	/* Lines */
	--line: #d3dae3; /* panel and table borders */
	--line-strong: #8a96a5; /* form-control borders */
	--line-soft: #e6eaef; /* row separators */

	/* Brand / action */
	--primary: #00715f;
	--primary-hover: #005a4c;
	--primary-active: #004a3e;
	--primary-ink: #ffffff;
	--primary-soft: #e7f5f2;
	--primary-soft-ink: #005a4c;
	--focus: #018a75;

	/* App bar: light in the light theme, with a brand stripe on top */
	--bar: #ffffff;
	--bar-2: #edf2f8;
	--bar-ink: #092e4c;
	--bar-muted: #4b5a6b;
	--bar-accent: #092e4c;
	--bar-mark-ink: #ffffff;
	--bar-border: #d3dae3;
	--bar-stripe: #092e4c;
	--avatar-bg: #e7f5f2;
	--avatar-ink: #005a4c;

	/* Status */
	--success: #1d7a46;
	--success-soft: #e3f4ea;
	--warning: #9a5a00;
	--warning-soft: #fff1d6;
	--danger: #c42b2f;
	--danger-hover: #a52226;
	--danger-soft: #fde8e8;
	--info: #1f6aa8;
	--info-soft: #e2f0fb;
	--neutral-soft: #e9edf2;
	--chart-in: #018a75;
	--chart-out: #1f4f7a;

	--shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
	--shadow-md: 0 4px 12px rgb(16 24 40 / 0.1), 0 1px 3px rgb(16 24 40 / 0.06);
	--shadow-lg: 0 18px 48px rgb(16 24 40 / 0.22), 0 2px 6px rgb(16 24 40 / 0.08);

	--radius: 4px;
	--radius-lg: 6px;

	--font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
	--mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', 'Liberation Mono', monospace;

	--bar-h: 0px; /* no top bar since the sidebar layout; kept for page CSS that offsets by it */
	--control-h: 36px;
	--control-h-sm: 30px;
}

:root[data-theme='dark'] {
	color-scheme: dark;

	--canvas: #08131f;
	--surface: #0f1e2d;
	--surface-2: #142638;
	--surface-hover: #1a2f45;
	--surface-selected: #123a3a;

	--ink: #e6ebf1;
	--ink-2: #c3ccd7;
	--ink-muted: #95a2b1;
	--ink-faint: #6c7a8a;

	--line: #253a4f;
	--line-strong: #4f6780;
	--line-soft: #1b2e42;

	--primary: #2ed3b7;
	--primary-hover: #5ce0c9;
	--primary-active: #85e8d6;
	--primary-ink: #071f33;
	--primary-soft: #123a3a;
	--primary-soft-ink: #8eead9;
	--focus: #5ce0c9;

	--bar: #061019;
	--bar-2: #12243a;
	--bar-ink: #e6ebf1;
	--bar-muted: #93a1b1;
	--bar-accent: #2ed3b7;
	--bar-mark-ink: #071f33;
	--bar-border: #000000;
	--bar-stripe: #2ed3b7;
	--avatar-bg: #1d4a5c;
	--avatar-ink: #ffffff;

	--success: #4cc184;
	--success-soft: #15322a;
	--warning: #f0b252;
	--warning-soft: #3a2c12;
	--danger: #f06a6d;
	--danger-hover: #f38588;
	--danger-soft: #3e1d21;
	--info: #6ab4f0;
	--info-soft: #16304a;
	--neutral-soft: #24303d;
	--chart-in: #2ed3b7;
	--chart-out: #5b8bbd;

	--shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
	--shadow-md: 0 4px 14px rgb(0 0 0 / 0.45);
	--shadow-lg: 0 18px 48px rgb(0 0 0 / 0.6);
}

/* ---------- Base ---------- */

[hidden] {
	display: none !important;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	background: var(--canvas);
	color: var(--ink);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

body {
	min-height: 100vh;
}

h1,
h2,
h3,
h4,
p {
	margin: 0;
}

a {
	color: var(--primary);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}

code,
.mono {
	font-family: var(--mono);
	font-size: 0.92em;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.icon {
	flex-shrink: 0;
	vertical-align: middle;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0ms !important;
		animation-duration: 0ms !important;
	}
}

/* ---------- App layout: sidebar + page ---------- */

.app {
	--sidebar-w: 236px;
	display: grid;
	grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
	min-height: 100vh;
}
.app.collapsed {
	--sidebar-w: 64px;
}
.app-main {
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.sidebar {
	position: sticky;
	top: 0;
	height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bar);
	border-right: 1px solid var(--bar-border);
	border-top: 3px solid var(--bar-stripe);
	color: var(--bar-ink);
	z-index: 40;
}
.sidebar-top {
	padding: 12px 12px 6px;
}
.sidebar-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 4px;
	border-radius: var(--radius);
	color: var(--bar-ink);
	text-decoration: none !important;
	white-space: nowrap;
}
.sidebar-brand:hover {
	background: var(--bar-2);
}
.sidebar-brand .mark {
	display: none;
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	place-items: center;
}
.sidebar-brand img {
	display: block;
}
.sidebar-brand .mark img {
	width: 26px;
	height: auto;
}
.sidebar-brand .sidebar-text img {
	width: 148px;
	height: auto;
	margin: 3px 2px;
}
/* Each theme shows the logo drawn for its sidebar background. */
:root[data-theme='dark'] .sidebar-brand .on-light,
:root:not([data-theme='dark']) .sidebar-brand .on-dark {
	display: none;
}
.sidebar-nav {
	flex: 1;
	overflow-y: auto;
	padding: 4px 10px 12px;
}
.sidebar-section + .sidebar-section {
	margin-top: 10px;
}
.sidebar-heading {
	padding: 4px 10px 4px;
	color: var(--bar-muted);
	font-size: 11px;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
}
.sidebar-item {
	position: relative;
	display: flex;
	align-items: center;
	gap: 11px;
	height: 33px;
	padding: 0 10px;
	border-radius: var(--radius);
	color: var(--bar-ink);
	font-weight: 500;
	text-decoration: none !important;
	white-space: nowrap;
}
.sidebar-item .icon {
	color: var(--bar-muted);
}
.sidebar-item:hover {
	background: var(--bar-2);
}
.sidebar-item.active {
	background: var(--primary-soft);
	color: var(--primary-soft-ink);
	font-weight: 600;
}
.sidebar-item.active .icon {
	color: var(--primary-soft-ink);
}
.sidebar-item.active::before {
	content: '';
	position: absolute;
	left: 0;
	top: 6px;
	bottom: 6px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: var(--primary);
}
.sidebar-footer {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--bar-border);
}
.sidebar-account {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 6px 10px;
	border: 0;
	border-radius: var(--radius);
	background: none;
	color: var(--bar-ink);
	font: inherit;
	font-weight: 550;
	text-align: left;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
}
.sidebar-account:hover,
.sidebar-account[aria-expanded='true'] {
	background: var(--bar-2);
}
.sidebar-account .sidebar-text:not(.chev) {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}
.sidebar-account .chev {
	color: var(--bar-muted);
}
.sidebar-collapse {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 32px;
	border: 1px solid var(--bar-border);
	border-radius: var(--radius);
	background: var(--bar-2);
	color: var(--bar-muted);
	font: inherit;
	font-size: 13px;
	font-weight: 550;
	cursor: pointer;
	white-space: nowrap;
}
.sidebar-collapse:hover {
	color: var(--bar-ink);
}

/* Collapsed: icons only. */
.app.collapsed .sidebar-text {
	display: none;
}
.app.collapsed .sidebar-brand .mark {
	display: grid;
}
.app.collapsed .sidebar-heading {
	height: 1px;
	margin: 6px 8px 8px;
	padding: 0;
	background: var(--bar-border);
}
.app.collapsed .sidebar-section + .sidebar-section {
	margin-top: 4px;
}
.app.collapsed .sidebar-item,
.app.collapsed .sidebar-account,
.app.collapsed .sidebar-brand {
	justify-content: center;
	padding: 0;
}
.app.collapsed .sidebar-account {
	height: 36px;
}

.avatar {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--avatar-bg);
	color: var(--avatar-ink);
	font-size: 11px;
	font-weight: 700;
}

/* Narrow screens: the sidebar slides in over the page. */
.mobile-bar,
.sidebar-scrim {
	display: none;
}
@media (max-width: 900px) {
	.app,
	.app.collapsed {
		grid-template-columns: minmax(0, 1fr);
	}
	.app .sidebar-text {
		display: inline;
	}
	.app .sidebar-brand .mark {
		display: none;
	}
	.sidebar {
		position: fixed;
		inset: 0 auto 0 0;
		width: 260px;
		transform: translateX(-100%);
		transition: transform 160ms ease-out;
		box-shadow: var(--shadow-lg);
	}
	.app.mobile-open .sidebar {
		transform: none;
	}
	.app.mobile-open .sidebar-scrim {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 30;
		background: rgb(10 18 28 / 0.45);
	}
	.mobile-bar {
		display: flex;
		align-items: center;
		gap: 8px;
		height: 52px;
		padding: 0 12px;
		background: var(--bar);
		border-bottom: 1px solid var(--bar-border);
		border-top: 3px solid var(--bar-stripe);
	}
	.sidebar-collapse {
		display: none;
	}
}

/* ---------- Page header band ---------- */

.page-header {
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	box-shadow: var(--shadow-sm);
}
.page-header-inner {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
	padding: 18px 24px 20px;
}
.breadcrumb {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 6px;
	color: var(--ink-muted);
	font-size: 13px;
	font-weight: 500;
}
.breadcrumb a {
	color: var(--ink-muted);
}
.breadcrumb a:hover {
	color: var(--primary);
}
.page-title {
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.02em;
	color: var(--ink);
}
.page-subtitle {
	margin-top: 4px;
	max-width: 72ch;
	color: var(--ink-muted);
}
.page-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

/* ---------- Layout ---------- */

.page-body {
	padding: 20px 24px 32px;
	display: flex;
	flex-direction: column;
	gap: 20px;
}
/* Every page uses the full width; .narrow is kept as a no-op for pages that
   still pass it. */
.page-body.fullbleed {
	max-width: none;
	padding: 0;
	gap: 0;
}

.grid {
	display: grid;
	gap: 20px;
}
.grid-2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}
.split {
	display: grid;
	grid-template-columns: 320px minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}
.row {
	display: flex;
	align-items: center;
	gap: 8px;
}
.row.wrap {
	flex-wrap: wrap;
}
.spacer {
	flex: 1;
}
.stack {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.muted {
	color: var(--ink-muted);
}
.small {
	font-size: 13px;
}
.nowrap {
	white-space: nowrap;
}
.num {
	font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
	.split,
	.grid-2 {
		grid-template-columns: minmax(0, 1fr);
	}
	.page-header-inner {
		flex-direction: column;
		align-items: stretch;
		padding: 16px;
	}
	.page-body {
		padding: 16px;
	}
}

/* ---------- Panels ---------- */

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	min-width: 0;
}
.panel-header {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 48px;
	padding: 10px 16px;
	background: var(--surface-2);
	border-bottom: 1px solid var(--line);
	border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.panel-title {
	font-size: 15px;
	font-weight: 650;
	color: var(--ink);
}
.panel-desc {
	color: var(--ink-muted);
	font-size: 13px;
}
.panel-header .panel-actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
}
.panel-body {
	padding: 16px;
}
.panel-body.flush {
	padding: 0;
}
.panel-footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--line);
	background: var(--surface-2);
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.panel > .table-wrap:last-child table tr:last-child td {
	border-bottom: 0;
}

/* KPI strip */
.kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
}
.kpi {
	padding: 14px 18px 16px;
	border-left: 1px solid var(--line);
	border-top: 4px solid transparent;
}
.kpi:first-child {
	border-left: 0;
}
.kpi-label {
	color: var(--ink-muted);
	font-size: 13px;
	font-weight: 550;
}
.kpi-value {
	margin-top: 4px;
	font-size: 28px;
	font-weight: 700;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}
.kpi.tone-info {
	border-top-color: var(--info);
}
.kpi.tone-warning {
	border-top-color: var(--warning);
}
.kpi.tone-success {
	border-top-color: var(--success);
}
.kpi.tone-danger {
	border-top-color: var(--danger);
}
.kpi.tone-neutral {
	border-top-color: var(--line-strong);
}

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

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: var(--control-h);
	padding: 0 14px;
	border: 1px solid transparent;
	border-radius: var(--radius);
	font: inherit;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
	vertical-align: middle;
	transition:
		background-color 120ms,
		border-color 120ms,
		color 120ms;
	text-decoration: none !important;
}
.btn:disabled,
.btn[aria-disabled='true'] {
	opacity: 0.5;
	cursor: not-allowed;
}
.btn-primary {
	background: var(--primary);
	color: var(--primary-ink);
	box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.18);
}
.btn-primary:hover:not(:disabled) {
	background: var(--primary-hover);
}
.btn-primary:active:not(:disabled) {
	background: var(--primary-active);
}
.btn-secondary {
	background: var(--surface);
	color: var(--ink);
	border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) {
	background: var(--surface-hover);
	border-color: var(--primary);
	color: var(--primary-soft-ink);
}
.btn-ghost {
	background: transparent;
	color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
	background: var(--surface-hover);
	color: var(--ink);
}
.btn-danger {
	background: var(--danger);
	color: #fff;
}
.btn-danger:hover:not(:disabled) {
	background: var(--danger-hover);
}
.btn-danger-outline {
	background: var(--surface);
	color: var(--danger);
	border-color: currentColor;
}
.btn-danger-outline:hover:not(:disabled) {
	background: var(--danger-soft);
}
.btn-link {
	height: auto;
	padding: 0;
	background: none;
	color: var(--primary);
	font-weight: 550;
}
.btn-link:hover {
	text-decoration: underline !important;
}
.btn-sm {
	height: var(--control-h-sm);
	padding: 0 10px;
	font-size: 13px;
}
.btn-icon {
	width: var(--control-h);
	padding: 0;
}
.btn-icon.btn-sm {
	width: var(--control-h-sm);
}
.btn .spin {
	animation: spin 0.8s linear infinite;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

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

.form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.form-section {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding-top: 16px;
	border-top: 1px solid var(--line);
}
.form-error:empty {
	display: none;
}
.form-section:first-child,
.form-error:empty + .form-section {
	padding-top: 0;
	border-top: 0;
}
.form-section-title {
	font-size: 14px;
	font-weight: 650;
	color: var(--ink);
}
.form-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px 16px;
}
.form-grid .span-2 {
	grid-column: 1 / -1;
}
@media (max-width: 640px) {
	.form-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}
.field > label,
.field-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--ink-2);
}
.field .req {
	color: var(--danger);
	margin-left: 2px;
}
.field-help {
	font-size: 12.5px;
	color: var(--ink-muted);
}
.field-error {
	font-size: 12.5px;
	font-weight: 550;
	color: var(--danger);
}

.input,
.select,
.textarea {
	width: 100%;
	height: var(--control-h);
	padding: 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	transition:
		border-color 120ms,
		box-shadow 120ms;
}
.textarea {
	height: auto;
	min-height: 88px;
	padding: 8px 10px;
	resize: vertical;
	line-height: 1.5;
}
.select {
	appearance: none;
	padding-right: 30px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7787' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 8px center;
}
.input::placeholder,
.textarea::placeholder {
	color: var(--ink-faint);
}
.input:hover,
.select:hover,
.textarea:hover {
	border-color: var(--ink-muted);
}
.input:focus,
.select:focus,
.textarea:focus {
	outline: none;
	border-color: var(--focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
	background: var(--surface-2);
	color: var(--ink-muted);
	cursor: not-allowed;
}
.input[aria-invalid='true'],
.select[aria-invalid='true'],
.textarea[aria-invalid='true'] {
	border-color: var(--danger);
}
.input-sm,
.select.input-sm {
	height: var(--control-h-sm);
	font-size: 13px;
}
.input.mono {
	font-family: var(--mono);
}

.check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
	cursor: pointer;
}
.check input[type='checkbox'],
.check input[type='radio'] {
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: var(--primary);
}

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span></label> */
.switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}
.switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}
.switch .track {
	width: 36px;
	height: 20px;
	border-radius: 999px;
	background: var(--line-strong);
	position: relative;
	transition: background 120ms;
}
.switch .track::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
	transition: transform 120ms;
}
.switch input:checked + .track {
	background: var(--primary);
}
.switch input:checked + .track::after {
	transform: translateX(16px);
}
.switch input:focus-visible + .track {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}
.switch input:disabled + .track {
	opacity: 0.5;
}

.toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.toolbar .input,
.toolbar .select {
	width: auto;
	min-width: 160px;
}

/* ---------- Alerts ---------- */

.alert {
	display: flex;
	gap: 10px;
	padding: 12px 14px;
	border: 1px solid;
	border-left-width: 4px;
	border-radius: var(--radius);
}
.alert-title {
	font-weight: 650;
}
.alert-info {
	background: var(--info-soft);
	border-color: var(--info);
}
.alert-warning {
	background: var(--warning-soft);
	border-color: var(--warning);
}
.alert-danger {
	background: var(--danger-soft);
	border-color: var(--danger);
}
.alert-success {
	background: var(--success-soft);
	border-color: var(--success);
}

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

.table-wrap {
	overflow-x: auto;
}
.table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}
.table th {
	position: sticky;
	top: 0;
	padding: 9px 14px;
	background: var(--surface-2);
	border-bottom: 1px solid var(--line);
	color: var(--ink-2);
	font-size: 12.5px;
	font-weight: 650;
	text-align: left;
	white-space: nowrap;
}
.table td {
	padding: 10px 14px;
	border-bottom: 1px solid var(--line-soft);
	vertical-align: middle;
}
.table tbody tr:hover td {
	background: var(--surface-hover);
}
.table tr.selected td {
	background: var(--surface-selected);
}
.table tr.clickable {
	cursor: pointer;
}
.table .actions {
	text-align: right;
	white-space: nowrap;
}
.table .actions .btn + .btn {
	margin-left: 6px;
}
.table td.primary-cell {
	font-weight: 600;
}

/* ---------- Badges ---------- */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	height: 22px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--neutral-soft);
	color: var(--ink-2);
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}
.badge .dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}
.badge-success {
	background: var(--success-soft);
	color: var(--success);
}
.badge-warning {
	background: var(--warning-soft);
	color: var(--warning);
}
.badge-danger {
	background: var(--danger-soft);
	color: var(--danger);
}
.badge-info {
	background: var(--info-soft);
	color: var(--info);
}
.badge-primary {
	background: var(--primary-soft);
	color: var(--primary-soft-ink);
}
.badge-outline {
	background: transparent;
	border: 1px solid var(--line-strong);
}

/* ---------- Empty / loading ---------- */

.empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 44px 24px;
	text-align: center;
}
.empty .empty-icon {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin-bottom: 6px;
	border-radius: 50%;
	background: var(--neutral-soft);
	color: var(--ink-muted);
}
.empty-title {
	font-weight: 650;
	font-size: 15px;
}
.empty-desc {
	max-width: 52ch;
	color: var(--ink-muted);
}
.empty .btn {
	margin-top: 10px;
}

.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 48px;
	color: var(--ink-muted);
}
.loading .icon {
	animation: spin 0.8s linear infinite;
}

/* ---------- Menus ---------- */

.menu {
	position: fixed;
	z-index: 60;
	min-width: 220px;
	padding: 6px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	color: var(--ink);
}
.menu-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: 0;
	border-radius: var(--radius);
	background: none;
	color: var(--ink);
	font: inherit;
	text-align: left;
	cursor: pointer;
	text-decoration: none !important;
}
.menu-item .icon {
	color: var(--ink-muted);
}
.menu-item:hover,
.menu-item:focus-visible {
	outline: none;
	background: var(--surface-hover);
}
.menu-item.active {
	background: var(--primary-soft);
	color: var(--primary-soft-ink);
	font-weight: 600;
}
.menu-item.active .icon {
	color: var(--primary-soft-ink);
}
.menu-item.danger {
	color: var(--danger);
}
.menu-sep {
	height: 1px;
	margin: 6px 4px;
	background: var(--line);
}
.menu-label {
	padding: 6px 10px 4px;
	color: var(--ink-muted);
	font-size: 12px;
	font-weight: 600;
}

/* ---------- Dialogs ---------- */

dialog.dialog {
	width: min(560px, calc(100vw - 32px));
	max-height: calc(100vh - 64px);
	padding: 0;
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	background: var(--surface);
	color: var(--ink);
	box-shadow: var(--shadow-lg);
	overflow: hidden;
}
dialog.dialog.wide {
	width: min(820px, calc(100vw - 32px));
}
dialog.dialog[open] {
	display: flex;
	flex-direction: column;
}
dialog.dialog::backdrop {
	background: rgb(10 18 28 / 0.55);
}
.dialog-header {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--line);
	background: var(--surface-2);
}
.dialog-title {
	font-size: 17px;
	font-weight: 700;
}
.dialog-desc {
	margin-top: 2px;
	color: var(--ink-muted);
	font-size: 13px;
}
.dialog-header .btn-icon {
	margin-left: auto;
	margin-top: -4px;
	margin-right: -8px;
}
.dialog-body {
	padding: 20px;
	overflow-y: auto;
}
.dialog-footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 14px 20px;
	border-top: 1px solid var(--line);
	background: var(--surface-2);
}

/* ---------- Toasts ---------- */

.toasts {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 100;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: min(380px, calc(100vw - 40px));
}
.toast {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 12px 14px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 4px solid var(--info);
	border-radius: var(--radius);
	box-shadow: var(--shadow-md);
	animation: toast-in 160ms ease-out;
}
.toast.success {
	border-left-color: var(--success);
}
.toast.success > .icon {
	color: var(--success);
}
.toast.error {
	border-left-color: var(--danger);
}
.toast.error > .icon {
	color: var(--danger);
}
.toast > .icon {
	margin-top: 1px;
	color: var(--info);
}
.toast-msg {
	flex: 1;
	font-weight: 550;
}
.toast-desc {
	margin-top: 2px;
	color: var(--ink-muted);
	font-weight: 400;
	font-size: 13px;
}
@keyframes toast-in {
	from {
		transform: translateY(8px);
		opacity: 0;
	}
}

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

.tabs {
	display: flex;
	gap: 2px;
	border-bottom: 1px solid var(--line);
	padding: 0 12px;
}
.tab {
	position: relative;
	padding: 11px 14px;
	border: 0;
	background: none;
	color: var(--ink-muted);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.tab:hover {
	color: var(--ink);
}
.tab[aria-selected='true'] {
	color: var(--primary);
}
.tab[aria-selected='true']::after {
	content: '';
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: -1px;
	height: 3px;
	border-radius: 3px 3px 0 0;
	background: var(--primary);
}

/* ---------- Trees ---------- */

.tree {
	list-style: none;
	margin: 0;
	padding: 6px;
}
.tree ul {
	list-style: none;
	margin: 0;
	padding-left: 18px;
	border-left: 1px solid var(--line);
	margin-left: 13px;
}
.tree-row {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 32px;
	padding: 0 6px;
	border-radius: var(--radius);
	cursor: pointer;
	user-select: none;
}
.tree-row:hover {
	background: var(--surface-hover);
}
.tree-row.selected {
	background: var(--primary-soft);
	color: var(--primary-soft-ink);
	font-weight: 600;
}
.tree-row .icon {
	color: var(--ink-muted);
}
.tree-row.selected .icon {
	color: var(--primary-soft-ink);
}
.tree-toggle {
	display: grid;
	place-items: center;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 0;
	border-radius: var(--radius);
	background: none;
	color: var(--ink-muted);
	cursor: pointer;
}
.tree-toggle:hover {
	background: var(--neutral-soft);
}
.tree-toggle .icon {
	transition: transform 120ms;
}
.tree-toggle[aria-expanded='true'] .icon {
	transform: rotate(90deg);
}
.tree-label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---------- Description lists ---------- */

.dl {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: 10px 24px;
	margin: 0;
}
.dl dt {
	color: var(--ink-muted);
	font-weight: 550;
}
.dl dd {
	margin: 0;
	word-break: break-word;
}

/* ---------- Auth screens (login / setup) ---------- */

.auth {
	min-height: 100vh;
	display: grid;
	grid-template-rows: 56px 1fr;
}
.auth-bar {
	display: flex;
	align-items: center;
	padding: 0 16px;
	background: var(--bar);
	color: var(--bar-ink);
}
.auth-main {
	display: grid;
	place-items: start center;
	padding: 72px 16px;
}
.auth-card {
	width: min(420px, 100%);
}
.auth-card.wide {
	width: min(640px, 100%);
}

/* ---------- Charts ---------- */

.chart {
	width: 100%;
	height: auto;
	display: block;
	font-family: var(--font);
}
.chart .gridline {
	stroke: var(--line-soft);
}
.chart .axis-label {
	fill: var(--ink-muted);
	font-size: 11px;
}
.legend {
	display: flex;
	gap: 16px;
	font-size: 13px;
	color: var(--ink-2);
}
.legend .swatch {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 2px;
	margin-right: 6px;
	vertical-align: -1px;
}

/* ---------- Fax queue ---------- */

main.fullscreen {
	display: flex;
	flex-direction: column;
	height: 100vh;
	overflow: hidden;
}

.trunk-strip {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 12px;
}
.trunk-tile {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px 14px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-top: 4px solid var(--line-strong);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
}
.trunk-tile.tone-success {
	border-top-color: var(--success);
}
.trunk-tile.tone-danger {
	border-top-color: var(--danger);
}
.trunk-tile.tone-warning {
	border-top-color: var(--warning);
}
.trunk-tile-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}
.trunk-name {
	font-weight: 650;
	font-size: 15px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.trunk-meters {
	display: grid;
	gap: 6px;
}
.trunk-sub {
	color: var(--ink-muted);
	font-size: 12.5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.meter {
	display: grid;
	grid-template-columns: 30px 1fr auto;
	align-items: center;
	gap: 8px;
	font-size: 12.5px;
}
.meter-label {
	color: var(--ink-muted);
	font-weight: 600;
}
.meter-track {
	height: 8px;
	border-radius: 999px;
	background: var(--neutral-soft);
	overflow: hidden;
}
.meter-fill {
	display: block;
	height: 100%;
	border-radius: inherit;
	background: var(--primary);
	transition: width 300ms ease-out;
}
.meter-value {
	font-weight: 600;
	min-width: 40px;
	text-align: right;
}

.queue-table td {
	vertical-align: top;
}
.queue-table td > .badge:first-child,
.queue-table td > .tree-toggle {
	margin-top: 1px;
}
.table tr.live-row td {
	background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
}
.table tr.live-row td:first-child {
	box-shadow: inset 4px 0 0 var(--primary);
}
.live-pulse {
	display: inline-block;
	width: 10px;
	height: 10px;
	margin: 6px 0 0 6px;
	border-radius: 50%;
	background: var(--primary);
	animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent);
	}
	100% {
		box-shadow: 0 0 0 10px transparent;
	}
}
.table tr.row-new td {
	animation: row-arrive 2.4s ease-out;
}
@keyframes row-arrive {
	0% {
		background: color-mix(in srgb, var(--accent-arrive, #f5b83d) 45%, var(--surface));
	}
}
.table tr.detail-row td {
	background: var(--surface-2);
	padding: 16px 20px 20px 50px;
}
.table tr.detail-row:hover td {
	background: var(--surface-2);
}

.fax-parties {
	display: flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}
.dir-icon {
	color: var(--ink-faint);
}
.dir-inbound {
	color: var(--success);
}
.dir-outbound {
	color: var(--primary);
}
.strong {
	font-weight: 600;
}
.error-text {
	color: var(--danger);
	margin-top: 4px;
}
.email-cell {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	max-width: 300px;
}
.delivery-cell {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	max-width: 320px;
}
.delivery-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.email-addr {
	max-width: 180px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.job-detail {
	display: flex;
	flex-direction: column;
	gap: 20px;
}
.job-detail-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 24px;
}
@media (max-width: 900px) {
	.job-detail-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}
.job-detail .form-section-title {
	margin-bottom: 8px;
}
.email-list,
.timeline {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.email-list li,
.timeline li {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}
.timeline-time {
	width: 190px;
	flex-shrink: 0;
	color: var(--ink-muted);
	font-size: 13px;
}

/* ---------- Navigation ---------- */

.nav-progress {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 100;
	height: 3px;
	width: 0;
	background: var(--primary);
	box-shadow: 0 0 6px var(--primary);
	transition: width 8s cubic-bezier(0.1, 0.7, 0.2, 1);
}
.nav-progress.running {
	width: 85%;
}
.nav-progress.done {
	width: 100%;
	opacity: 0;
	transition:
		width 150ms ease-out,
		opacity 250ms 100ms;
}


dialog.dialog.xl {
	width: min(1100px, calc(100vw - 32px));
	height: calc(100vh - 64px);
}
dialog.dialog.xl .dialog-body {
	flex: 1;
	padding: 0;
	overflow: hidden;
}
.doc-frame {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: var(--neutral-soft);
}

.dir {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: 600;
	font-size: 13px;
}
.dir-in {
	color: var(--success);
}
.dir-out {
	color: var(--primary);
}
.tag {
	display: inline-block;
	margin-left: 6px;
	padding: 0 5px;
	border: 1px solid var(--line-strong);
	border-radius: 3px;
	color: var(--ink-muted);
	font-size: 11px;
	font-weight: 650;
	line-height: 16px;
}
.quality {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 3px;
	min-width: 150px;
}
.queue-table td,
.queue-table th {
	padding-left: 10px;
	padding-right: 10px;
}

.tree-actions {
	display: none;
	gap: 2px;
	margin-left: auto;
}
.tree-row:hover .tree-actions,
.tree-row:focus-within .tree-actions,
.tree-row.selected .tree-actions {
	display: inline-flex;
}
.tree-row.tree-placeholder {
	color: var(--ink-faint);
	font-style: italic;
	cursor: default;
}
.tree-row.tree-placeholder:hover {
	background: none;
}

/* Fullscreen editors: the page root fills the area below the app bar. */
main.fullscreen > .page-root {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

/* Row actions stay in view when the table is wider than the page. */
.queue-table th.actions,
.queue-table td.actions {
	position: sticky;
	right: 0;
	background: var(--surface);
	box-shadow: -1px 0 0 var(--line-soft);
}
.queue-table th.actions {
	background: var(--surface-2);
}
.queue-table tbody tr:hover td.actions {
	background: var(--surface-hover);
}
.queue-table tr.selected td.actions {
	background: var(--surface-selected);
}
.queue-table tr.live-row td.actions {
	background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
}
.queue-table td.time-cell {
	min-width: 96px;
}
