/* ==========================================================================
   lens — design system (shadcn-inspired, no dependency)
   ========================================================================== */

:root {
	--bg:               hsl(0 0% 100%);
	--fg:               hsl(240 10% 3.9%);
	--card:             hsl(0 0% 100%);
	--card-fg:          hsl(240 10% 3.9%);
	--muted:            hsl(240 4.8% 95.9%);
	--muted-fg:         hsl(240 3.8% 46.1%);
	--border:           hsl(240 5.9% 90%);
	--input:            hsl(240 5.9% 90%);
	--ring:             hsl(240 5% 64.9%);
	--primary:          hsl(240 5.9% 10%);
	--primary-fg:       hsl(0 0% 98%);
	--accent:           hsl(240 4.8% 95.9%);
	--accent-fg:        hsl(240 5.9% 10%);
	--destructive:      hsl(0 72% 51%);
	--destructive-fg:   hsl(0 0% 98%);
	--success:          hsl(142 71% 45%);
	--warning:          hsl(38 92% 50%);

	--radius-sm: 0.375rem;
	--radius:    0.5rem;
	--radius-lg: 0.75rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg:             hsl(240 10% 3.9%);
		--fg:             hsl(0 0% 98%);
		--card:           hsl(240 10% 5%);
		--card-fg:        hsl(0 0% 98%);
		--muted:          hsl(240 3.7% 15.9%);
		--muted-fg:       hsl(240 5% 64.9%);
		--border:         hsl(240 3.7% 15.9%);
		--input:          hsl(240 3.7% 15.9%);
		--ring:           hsl(240 4.9% 33.9%);
		--primary:        hsl(0 0% 98%);
		--primary-fg:     hsl(240 5.9% 10%);
		--accent:         hsl(240 3.7% 15.9%);
		--accent-fg:      hsl(0 0% 98%);
		--destructive:    hsl(0 62.8% 30.6%);
		--destructive-fg: hsl(0 0% 98%);
		--success:        hsl(142 60% 50%);
		--warning:        hsl(38 92% 60%);
	}
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
}

body {
	font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	font-feature-settings: "cv11", "ss01";
	background: var(--bg);
	color: var(--fg);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

code {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, monospace;
	font-size: 0.85em;
	background: var(--muted);
	padding: 0.1em 0.35em;
	border-radius: var(--radius-sm);
}

h1, h2, h3, h4 {
	margin: 0;
	font-weight: 600;
	letter-spacing: -0.01em;
}

h2 {
	font-size: 1.5rem;
	margin-bottom: 1rem;
}

h3 {
	font-size: 1.05rem;
	margin: 1.25rem 0 0.5rem;
}

a {
	color: inherit;
	text-decoration: none;
}

a:hover {
	color: var(--fg);
}

/* --- top nav --------------------------------------------------------------- */

.topbar {
	border-bottom: 1px solid var(--border);
	background: var(--bg);
	position: sticky;
	top: 0;
	z-index: 30;
}

.topbar-inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0.65rem 1.25rem;
	display: flex;
	align-items: center;
	gap: 1.5rem;
}

.brand {
	font-weight: 600;
	letter-spacing: -0.02em;
	font-size: 1rem;
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.brand-dot {
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 9999px;
	background: var(--fg);
}

.nav {
	display: flex;
	gap: 0.25rem;
	margin-left: auto;
}

.nav-link {
	padding: 0.4rem 0.75rem;
	border-radius: var(--radius-sm);
	color: var(--muted-fg);
	font-size: 0.875rem;
	transition: background 0.1s, color 0.1s;
}

.nav-link:hover {
	background: var(--accent);
	color: var(--accent-fg);
}

.nav-link[aria-current="page"] {
	color: var(--fg);
	background: var(--accent);
}

/* --- container ------------------------------------------------------------- */

.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 1.5rem 1.25rem 3rem;
}

.page-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

.muted {
	color: var(--muted-fg);
}

.right {
	text-align: right;
}

.center {
	text-align: center;
}

.row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.grow {
	flex: 1 1 auto;
	min-width: 200px;
}

/* --- buttons --------------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1;
	padding: 0.5rem 0.9rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--fg);
	cursor: pointer;
	transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.btn:hover {
	background: var(--accent);
}

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

.btn:disabled,
.btn[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.btn-sm {
	padding: 0.35rem 0.65rem;
	font-size: 0.8rem;
}

.btn-xs {
	padding: 0.2rem 0.5rem;
	font-size: 0.75rem;
}

.btn-primary {
	background: var(--primary);
	color: var(--primary-fg);
	border-color: var(--primary);
}

.btn-primary:hover {
	background: color-mix(in srgb, var(--primary) 88%, white);
	color: var(--primary-fg);
	border-color: color-mix(in srgb, var(--primary) 88%, white);
}

.btn-ghost {
	border-color: transparent;
	background: transparent;
}

.btn-ghost:hover {
	background: var(--accent);
}

.btn-destructive {
	background: transparent;
	color: var(--destructive);
	border-color: color-mix(in srgb, var(--destructive) 40%, transparent);
}

.btn-destructive:hover {
	background: color-mix(in srgb, var(--destructive) 10%, transparent);
}

/* --- inputs / selects ------------------------------------------------------ */

.input,
.select {
	font-family: inherit;
	font-size: 0.875rem;
	padding: 0.45rem 0.7rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--input);
	background: var(--bg);
	color: var(--fg);
	transition: border-color 0.1s, box-shadow 0.1s;
	width: 100%;
	max-width: 100%;
}

.input-sm,
.select-sm {
	padding: 0.32rem 0.55rem;
	font-size: 0.8rem;
}

.input:focus,
.select:focus {
	outline: none;
	border-color: var(--ring);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}

.input::placeholder {
	color: var(--muted-fg);
}

.select {
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--muted-fg) 50%),
	                  linear-gradient(135deg, var(--muted-fg) 50%, transparent 50%);
	background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
	background-size: 5px 5px;
	background-repeat: no-repeat;
	padding-right: 2rem;
}

.label {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.8rem;
	color: var(--muted-fg);
	cursor: pointer;
}

.checkbox {
	appearance: none;
	width: 1rem;
	height: 1rem;
	border: 1px solid var(--input);
	border-radius: var(--radius-sm);
	background: var(--bg);
	cursor: pointer;
	transition: background 0.1s, border-color 0.1s;
	display: inline-grid;
	place-content: center;
}

.checkbox:checked {
	background: var(--primary);
	border-color: var(--primary);
}

.checkbox:checked::before {
	content: "";
	width: 0.6rem;
	height: 0.6rem;
	background: var(--primary-fg);
	clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

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

.card {
	background: var(--card);
	color: var(--card-fg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1rem 1.25rem;
}

.card-header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 0.5rem;
}

.card-title {
	font-size: 0.9rem;
	font-weight: 500;
}

/* --- badges ---------------------------------------------------------------- */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.1rem 0.5rem;
	font-size: 0.75rem;
	font-weight: 500;
	border-radius: 9999px;
	background: var(--muted);
	color: var(--muted-fg);
	border: 1px solid var(--border);
}

.badge-soft {
	background: var(--muted);
	border-color: transparent;
}

/* --- tabs (underline style) ------------------------------------------------ */

.tabs {
	display: flex;
	gap: 0;
	margin: 1rem 0 1.25rem;
	border-bottom: 1px solid var(--border);
}

.tab {
	padding: 0.55rem 0.9rem;
	background: transparent;
	border: 0;
	border-bottom: 2px solid transparent;
	color: var(--muted-fg);
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.1s, border-color 0.1s;
	margin-bottom: -1px;
}

.tab:hover:not([disabled]) {
	color: var(--fg);
}

.tab-active {
	color: var(--fg);
	border-bottom-color: var(--fg);
}

.tab[disabled] {
	opacity: 0.4;
	cursor: not-allowed;
}

/* --- table ----------------------------------------------------------------- */

.table-wrap {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--card);
}

.table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.875rem;
}

.table thead th {
	text-align: left;
	font-weight: 500;
	color: var(--muted-fg);
	background: var(--muted);
	padding: 0.55rem 0.85rem;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	border-bottom: 1px solid var(--border);
}

.table tbody td {
	padding: 0.55rem 0.85rem;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
}

.table tbody tr:last-child td {
	border-bottom: 0;
}

.table tbody tr:hover {
	background: var(--muted);
}

.table-sm thead th,
.table-sm tbody td {
	padding: 0.4rem 0.7rem;
}

/* --- alerts ---------------------------------------------------------------- */

.alert {
	padding: 0.75rem 1rem;
	border-radius: var(--radius);
	background: var(--muted);
	border: 1px solid var(--border);
	color: var(--fg);
	font-size: 0.875rem;
}

.alert-info {
	background: color-mix(in srgb, var(--ring) 10%, var(--bg));
	border-color: color-mix(in srgb, var(--ring) 30%, var(--border));
}

/* --- modal (native dialog) ------------------------------------------------- */

.modal {
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 0;
	background: var(--card);
	color: var(--fg);
	max-width: min(560px, 92vw);
	width: 100%;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal::backdrop {
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(2px);
}

.modal-body {
	padding: 1.25rem;
}

.modal-title {
	font-size: 1.05rem;
	font-weight: 600;
	margin: 0 0 0.25rem;
}

.modal-actions {
	margin-top: 1rem;
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
}

.modal-search {
	margin-top: 0.75rem;
	width: 100%;
}

/* --- popover / suggestion list -------------------------------------------- */

.suggest-list {
	margin: 0.5rem 0 0;
	padding: 0.25rem;
	list-style: none;
	max-height: 240px;
	overflow-y: auto;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.suggest-list:empty {
	display: none;
}

.suggest-item {
	display: block;
	padding: 0.45rem 0.6rem;
	border-radius: var(--radius-sm);
	cursor: pointer;
}

.suggest-item:hover {
	background: var(--accent);
}

.suggest-empty {
	padding: 0.45rem 0.6rem;
	color: var(--muted-fg);
}

/* --- pager ----------------------------------------------------------------- */

.pager {
	margin-top: 1rem;
	justify-content: space-between;
}

/* --- htmx ------------------------------------------------------------------ */

.htmx-request {
	opacity: 0.6;
	transition: opacity 0.1s;
}

/* --- KPI strip ------------------------------------------------------------- */

.kpi-strip {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 0.75rem;
	margin: 0.5rem 0 1.25rem;
}

.kpi-card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 0.85rem 1rem;
}

.kpi-label {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted-fg);
	font-weight: 500;
}

.kpi-value {
	font-size: 1.65rem;
	font-weight: 600;
	margin-top: 0.2rem;
	letter-spacing: -0.02em;
}

.kpi-sub {
	font-size: 0.75rem;
	color: var(--muted-fg);
	margin-top: 0.15rem;
}

.kpi-delta {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	font-size: 0.7rem;
	font-weight: 500;
	margin-top: 0.4rem;
	padding: 0.1rem 0.45rem;
	border-radius: 9999px;
	background: var(--muted);
}

.kpi-delta-up {
	color: var(--success);
	background: color-mix(in srgb, var(--success) 12%, transparent);
}

.kpi-delta-down {
	color: var(--warning);
	background: color-mix(in srgb, var(--warning) 14%, transparent);
}

/* --- per-tab metric cards -------------------------------------------------- */

.metric-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 0.5rem;
	margin: 0.75rem 0 1rem;
}

.metric-card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 0.65rem 0.85rem;
}

.metric-label {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted-fg);
	font-weight: 500;
}

.metric-value {
	font-size: 1.35rem;
	font-weight: 600;
	letter-spacing: -0.01em;
}

/* --- heatmap (24 hours x 7 days-of-week) ----------------------------------- */

.heatmap {
	display: grid;
	grid-template-columns: 2.25rem repeat(7, minmax(0, 1fr));
	grid-auto-rows: 1.05rem;
	gap: 2px;
	max-width: 540px;
	margin: 0.5rem 0 1.5rem;
	font-size: 0.7rem;
}

.heatmap-corner {
	grid-column: 1;
	grid-row: 1;
}

.heatmap-day-label {
	text-align: center;
	color: var(--muted-fg);
	align-self: end;
	padding-bottom: 2px;
	font-weight: 500;
}

.heatmap-hour-label {
	text-align: right;
	padding-right: 0.4rem;
	color: var(--muted-fg);
	align-self: center;
}

.heatmap-cell {
	background: var(--muted);
	border-radius: 2px;
}

/* --- daily trend bars ------------------------------------------------------ */

.trend-bars {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 140px;
	padding: 1.25rem 0.75rem 0.5rem;
	border-radius: var(--radius);
	background: var(--card);
	border: 1px solid var(--border);
	margin: 0.5rem 0 1.5rem;
	overflow-x: auto;
}

.trend-bar {
	min-width: 14px;
	background: var(--fg);
	border-radius: 2px 2px 0 0;
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	opacity: 0.85;
}

.trend-bar:hover {
	opacity: 1;
}

.trend-bar-label {
	font-size: 0.6rem;
	color: var(--muted-fg);
	transform: translateY(-1.1rem);
	white-space: nowrap;
}

/* --- comparison table cells ------------------------------------------------ */

.cell-good {
	color: var(--success);
	font-weight: 600;
}

.cell-bad {
	color: var(--destructive);
	font-weight: 600;
}

/* --- weekly bars (calendar tab) ------------------------------------------- */

.weekly-bars {
	display: flex;
	align-items: flex-end;
	gap: 1rem;
	height: 180px;
	padding: 1rem;
	border-radius: var(--radius);
	background: var(--card);
	border: 1px solid var(--border);
	overflow-x: auto;
}

.weekly-bar-group {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 60px;
	height: 100%;
	justify-content: flex-end;
	gap: 0.25rem;
}

.weekly-bar-group {
	flex-direction: row;
	align-items: flex-end;
	height: calc(100% - 1.4rem);
}

.weekly-bar {
	width: 14px;
	min-height: 1px;
	border-radius: 2px 2px 0 0;
}

.weekly-bar-scheduled {
	background: hsl(220 70% 60%);
}

.weekly-bar-attended {
	background: hsl(142 70% 45%);
}

.weekly-bar-label {
	font-size: 0.7rem;
	color: var(--muted-fg);
	margin-top: 0.4rem;
	width: 100%;
	text-align: center;
}

/* --- legend ----------------------------------------------------------------*/

.legend {
	display: flex;
	gap: 1.25rem;
	align-items: center;
	margin-top: 0.5rem;
	font-size: 0.8rem;
	color: var(--muted-fg);
}

.legend-item {
	display: inline-flex;
	gap: 0.4rem;
	align-items: center;
}

.swatch {
	display: inline-block;
	width: 0.85rem;
	height: 0.85rem;
	border-radius: 2px;
}

.swatch-scheduled { background: hsl(220 70% 60%); }
.swatch-attended  { background: hsl(142 70% 45%); }

/* --- success badge -------------------------------------------------------- */

.badge-success {
	background: color-mix(in srgb, var(--success) 18%, transparent);
	color: var(--success);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

/* --- team picker on user header ------------------------------------------ */

.team-picker {
	display: inline-flex;
	gap: 0.4rem;
	align-items: center;
	margin-top: 0.4rem;
	font-size: 0.85rem;
}

/* --- pager ---------------------------------------------------------------- */

.pager {
	margin-top: 1rem;
	padding: 0.5rem 0;
	border-top: 1px solid var(--border);
}

/* --- modal --------------------------------------------------------------- */

.modal {
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 1.25rem;
	background: var(--card);
	color: var(--card-fg);
	box-shadow: 0 20px 60px rgba(0,0,0,0.25);
	min-width: 360px;
	max-width: 480px;
}

.modal::backdrop {
	background: rgba(0,0,0,0.4);
}

.modal-title {
	margin: 0 0 0.5rem;
	font-size: 1.1rem;
}

.modal-search {
	margin-top: 0.75rem;
	width: 100%;
}

.modal-actions {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
	margin-top: 1rem;
	flex-wrap: wrap;
}

.suggest-list {
	list-style: none;
	margin: 0.25rem 0 0;
	padding: 0;
	max-height: 220px;
	overflow-y: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.suggest-list li {
	padding: 0;
	border-bottom: 1px solid var(--border);
}

.suggest-list li:last-child {
	border-bottom: 0;
}

.suggest-empty {
	padding: 0.75rem;
	color: var(--muted-fg);
	font-size: 0.85rem;
}

.suggest-item {
	display: block;
	padding: 0.5rem 0.75rem;
	cursor: pointer;
	transition: background 0.1s;
}

.suggest-item:hover {
	background: var(--accent);
}

/* --- sortable column header ---------------------------------------------- */

.sort-head {
	color: var(--muted-fg);
	text-decoration: none;
	white-space: nowrap;
}

.sort-head:hover {
	color: var(--fg);
}

/* --- stage drill link --------------------------------------------------- */

.stage-drill {
	color: var(--fg);
	cursor: pointer;
	border-bottom: 1px dotted var(--border);
}

.stage-drill:hover {
	color: var(--primary);
	border-bottom-color: var(--primary);
}

.modal {
	min-width: 540px;
	max-width: 720px;
}

/* --- KPI averages line ---------------------------------------------------- */

.kpi-avgs {
	display: flex;
	gap: 0.5rem;
	margin-top: 0.25rem;
	flex-wrap: wrap;
}

.kpi-avg {
	display: inline-flex;
	gap: 0.25rem;
	font-size: 0.75rem;
	color: var(--muted-fg);
	background: var(--muted);
	border-radius: var(--radius-sm);
	padding: 0.1rem 0.4rem;
}

.kpi-avg.kpi-delta-up {
	background: color-mix(in srgb, var(--success) 18%, transparent);
	color: var(--success);
}

.kpi-avg.kpi-delta-down {
	background: color-mix(in srgb, var(--destructive) 18%, transparent);
	color: var(--destructive);
}

/* --- ticket type priority list ------------------------------------------ */

.priority-list {
	margin-top: 0.5rem;
	font-size: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.priority-item {
	display: flex;
	justify-content: space-between;
}

/* --- chat drawer + FAB ---------------------------------------------------- */

.chat-fab {
	position: fixed;
	bottom: 1.25rem;
	right: 1.25rem;
	z-index: 40;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.55rem 0.95rem;
	font-family: inherit;
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--primary-fg);
	background: var(--primary);
	border: 1px solid var(--primary);
	border-radius: 9999px;
	cursor: pointer;
	box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.35);
	transition: transform 0.1s, box-shadow 0.1s;
}

.chat-fab:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.4);
}

.chat-fab:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 2px;
}

.chat-drawer {
	border: 1px solid var(--border);
	border-radius: var(--radius-lg) 0 0 var(--radius-lg);
	padding: 0;
	background: var(--card);
	color: var(--fg);
	box-shadow: -20px 0 60px -20px rgba(0, 0, 0, 0.35);
	margin: 0 0 0 auto;
	max-width: min(440px, 96vw);
	width: 100%;
	height: 100vh;
	max-height: 100vh;
	overflow: hidden;
}

.chat-drawer[open] {
	display: flex;
	flex-direction: column;
}

.chat-drawer::backdrop {
	background: rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(2px);
}

.chat-drawer #chat-drawer-body {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
}

.chat-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	padding: 0.85rem 1rem;
	border-bottom: 1px solid var(--border);
	gap: 0.5rem;
}

.chat-title {
	font-weight: 600;
	font-size: 0.95rem;
}

.chat-subtitle {
	font-size: 0.75rem;
	margin-top: 0.1rem;
}

.chat-header-actions {
	display: flex;
	gap: 0.25rem;
}

.chat-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 0.85rem 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	min-height: 0;
}

.chat-message {
	display: flex;
	max-width: 100%;
}

.chat-message-user {
	justify-content: flex-end;
}

.chat-bubble {
	max-width: 90%;
	padding: 0.55rem 0.75rem;
	border-radius: var(--radius);
	font-size: 0.875rem;
	line-height: 1.45;
	background: var(--muted);
	color: var(--fg);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.chat-message-user .chat-bubble {
	background: var(--primary);
	color: var(--primary-fg);
}

.chat-bubble p {
	margin: 0 0 0.5rem;
}

.chat-bubble p:last-child {
	margin-bottom: 0;
}

.chat-bubble h2 {
	font-size: 0.95rem;
	margin: 0.25rem 0 0.4rem;
}

.chat-bubble h3 {
	font-size: 0.85rem;
	margin: 0.4rem 0 0.3rem;
}

.chat-bubble ul,
.chat-bubble ol {
	margin: 0.25rem 0 0.5rem;
	padding-left: 1.25rem;
}

.chat-bubble li + li {
	margin-top: 0.15rem;
}

.chat-bubble table {
	border-collapse: collapse;
	font-size: 0.8rem;
	margin: 0.4rem 0;
	width: 100%;
}

.chat-bubble th,
.chat-bubble td {
	border: 1px solid var(--border);
	padding: 0.25rem 0.45rem;
	text-align: left;
}

.chat-bubble th {
	background: var(--accent);
	font-weight: 500;
}

.chat-bubble pre {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.5rem 0.65rem;
	overflow-x: auto;
	font-size: 0.8rem;
	margin: 0.4rem 0;
}

.chat-bubble code {
	font-size: 0.85em;
	background: rgba(0, 0, 0, 0.06);
	padding: 0.05em 0.3em;
	border-radius: 3px;
}

.chat-message-user .chat-bubble code {
	background: rgba(255, 255, 255, 0.15);
}

.chat-bubble a {
	color: inherit;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

.chat-stream-text {
	white-space: pre-wrap;
}

.chat-tool-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-top: 0.35rem;
	margin-right: 0.25rem;
	padding: 0.1rem 0.5rem;
	font-size: 0.7rem;
	color: var(--muted-fg);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 9999px;
}

.chat-tool-pill code {
	background: transparent;
	padding: 0;
}

.chat-tool-pill-ok {
	color: var(--success);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.chat-tool-pill-err {
	color: var(--destructive);
	border-color: color-mix(in srgb, var(--destructive) 30%, transparent);
}

.chat-tool-spinner {
	display: inline-block;
	width: 0.55rem;
	height: 0.55rem;
	border: 1.5px solid var(--muted-fg);
	border-top-color: transparent;
	border-radius: 50%;
	animation: chat-spin 0.7s linear infinite;
}

@keyframes chat-spin {
	to { transform: rotate(360deg); }
}

.chat-form {
	display: flex;
	gap: 0.5rem;
	padding: 0.65rem 0.85rem 0.85rem;
	border-top: 1px solid var(--border);
	align-items: flex-end;
}

.chat-input {
	flex: 1 1 auto;
	resize: none;
	font-family: inherit;
	min-height: 2.6rem;
	max-height: 8rem;
}

.chat-error {
	margin-top: 0.4rem;
	font-size: 0.8rem;
	color: var(--destructive);
	background: color-mix(in srgb, var(--destructive) 10%, transparent);
	border-color: color-mix(in srgb, var(--destructive) 30%, var(--border));
}

.chat-final {
	margin-top: 0.1rem;
}

/* --- auth pages (login / register / pending) ------------------------------ */

.auth-body {
	min-height: 100vh;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	background: var(--accent);
	padding: 4rem 1rem;
}

.auth-container {
	width: 100%;
	max-width: 24rem;
	background: var(--card);
	color: var(--card-fg);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 2rem;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.auth-container h1 {
	font-size: 1.25rem;
	margin: 0 0 0.5rem;
}

.auth-container > p {
	font-size: 0.875rem;
	color: var(--muted-fg);
	margin: 0 0 1.25rem;
}

.auth-form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin: 1rem 0 1.25rem;
}

.auth-form label {
	font-size: 0.8rem;
	color: var(--muted-fg);
	margin-top: 0.5rem;
}

.auth-form label:first-child {
	margin-top: 0;
}

.auth-form .btn {
	margin-top: 0.75rem;
	align-self: flex-start;
}

.auth-container .notice,
.auth-container .error {
	font-size: 0.8rem;
	padding: 0.55rem 0.75rem;
	border-radius: var(--radius-sm);
	margin: 0 0 1rem;
	border: 1px solid var(--border);
}

.auth-container .notice {
	background: color-mix(in srgb, var(--ring) 8%, transparent);
}

.auth-container .error {
	color: var(--destructive);
	background: color-mix(in srgb, var(--destructive) 8%, transparent);
	border-color: color-mix(in srgb, var(--destructive) 30%, var(--border));
}

/* --- nav user block ------------------------------------------------------- */

.nav-user {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	font-size: 0.8rem;
}

/* --- badges (used on admin user table) ------------------------------------ */

.badge {
	display: inline-block;
	font-size: 0.7rem;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	color: var(--muted-fg);
}

.badge-ok {
	border-color: color-mix(in srgb, hsl(142 71% 45%) 35%, var(--border));
	color: hsl(142 71% 35%);
	background: color-mix(in srgb, hsl(142 71% 45%) 8%, transparent);
}

.badge-warn {
	border-color: color-mix(in srgb, hsl(38 92% 50%) 35%, var(--border));
	color: hsl(32 80% 38%);
	background: color-mix(in srgb, hsl(38 92% 50%) 10%, transparent);
}
