/* AgentUsage.io — brand layer (shell, tokens, login, base components).
   A Fedelta Media product. Loaded after Tabler + Tabler Icons so it wins. */

:root {
	--canvas:     #0B0F17;
	--panel:      #141A24;
	--panel-2:    #0F141D;
	--line:       #232B38;
	--ink:        #E8EDF5;
	--muted:      #8B98AC;

	--brand:      #7C5CFF;
	--brand-700:  #6947E0;
	--brand-300:  #A78BFA;
	--brand-50:   rgba(124, 92, 255, .12);
	--accent:     #22D3EE;

	--ok:         #34D399;
	--ok-bg:      rgba(52, 211, 153, .14);
	--warn:       #FBBF24;
	--warn-bg:    rgba(251, 191, 36, .14);
	--danger:     #F87171;
	--danger-bg:  rgba(248, 113, 113, .14);

	--shadow-sm:  0 1px 2px rgba(0, 0, 0, .3);
	--shadow-md:  0 10px 30px -12px rgba(0, 0, 0, .55);

	--radius-lg:  18px;
	--radius-md:  13px;
	--radius-sm:  9px;

	--font-sans:  system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-mono:  ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

	/* Native form widgets (number spinners, select arrows, scrollbars)
	   follow the app theme instead of defaulting to light. */
	color-scheme: dark;
}

[data-theme="light"] {
	color-scheme: light;
}

[data-theme="light"] {
	--canvas:     #F6F8FB;
	--panel:      #FFFFFF;
	--panel-2:    #EFF3F9;
	--line:       #E3E9F2;
	--ink:        #101828;
	--muted:      #5B6B80;

	--brand:      #6D4AFF;
	--brand-700:  #5836D9;
	--brand-300:  #8F72FF;
	--brand-50:   rgba(109, 74, 255, .08);
	--accent:     #0891B2;

	--ok:         #059669;
	--ok-bg:      rgba(5, 150, 105, .1);
	--warn:       #B45309;
	--warn-bg:    rgba(180, 83, 9, .1);
	--danger:     #DC2626;
	--danger-bg:  rgba(220, 38, 38, .1);

	--shadow-sm:  0 1px 2px rgba(16, 29, 43, .06);
	--shadow-md:  0 10px 30px -12px rgba(16, 29, 43, .18);
}

/* Map onto Tabler CSS variables so vendor components inherit our tokens. */
:root,
[data-theme="light"] {
	--tblr-primary:          var(--brand);
	--tblr-primary-fg:       #ffffff;
	--tblr-body-bg:          var(--canvas);
	--tblr-body-color:       var(--ink);
	--tblr-border-color:     var(--line);
	--tblr-link-color:       var(--brand-300);
	--tblr-link-hover-color: var(--brand);
	--tblr-font-sans-serif:  var(--font-sans);
	--tblr-card-bg:          var(--panel);
}

* {
	box-sizing: border-box;
}

body {
	background: var(--canvas);
	color: var(--ink);
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.num,
.tabular {
	font-variant-numeric: tabular-nums;
}

a {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}

/* Shell — sidebar + main */
.shell {
	display: flex;
	min-height: 100vh;
	max-width: 1180px;
	margin: 0 auto;
}

.side {
	width: 236px;
	flex: 0 0 236px;
	background: var(--panel);
	border-right: 1px solid var(--line);
	padding: 22px 16px;
	display: flex;
	flex-direction: column;
	gap: 26px;
	position: sticky;
	top: 0;
	height: 100vh;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 4px 8px;
	color: var(--ink);
}
.brand svg {
	flex: 0 0 auto;
	width: 34px;
	height: 20px;
}
.brand .word {
	font-weight: 500;
	font-size: 16px;
	letter-spacing: -.01em;
}
.brand .word .dim {
	color: var(--muted);
}

.nav {
	display: flex;
	flex-direction: column;
	gap: 3px;
}
.nav-label {
	font-size: 11px;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--muted);
	padding: 10px 10px 2px;
}
.nav a {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 9px 11px;
	border-radius: 10px;
	color: var(--muted);
	font-weight: 500;
	font-size: 14px;
	transition: background .15s, color .15s;
}
.nav a .ti {
	font-size: 18px;
	width: 18px;
	flex: 0 0 18px;
	opacity: .85;
}
.nav a:hover {
	background: var(--panel-2);
	color: var(--ink);
}
.nav a.active {
	background: var(--brand);
	color: #fff;
	box-shadow: 0 6px 16px -8px rgba(124, 92, 255, .8);
}
.nav a.active .ti {
	opacity: 1;
}
.nav-soon {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 9px 11px;
	border-radius: 10px;
	color: var(--muted);
	font-weight: 500;
	font-size: 14px;
	opacity: .45;
	cursor: default;
}
.nav-soon .ti {
	font-size: 18px;
	width: 18px;
	flex: 0 0 18px;
}

.side-foot {
	margin-top: auto;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px;
	border-top: 1px solid var(--line);
	color: inherit;
	border-radius: 10px;
	transition: background .15s;
}
a.side-foot:hover {
	background: var(--panel-2);
}
.side-foot .avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--brand-50);
	color: var(--brand-300);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 13px;
	flex: 0 0 34px;
	overflow: hidden;
}
.side-foot b {
	font-size: 13px;
}
.side-foot small {
	display: block;
	color: var(--muted);
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 140px;
}

/* Main */
.main {
	flex: 1;
	min-width: 0;
	padding: 26px 30px 40px;
}

.topbar {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 20px;
	margin-bottom: 22px;
}
.topbar h1 {
	font-size: 22px;
	margin: 0 0 3px;
	letter-spacing: -.02em;
	font-weight: 700;
	color: var(--ink);
}
.topbar p {
	margin: 0;
	color: var(--muted);
}

.userbox {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
}
.userbox .avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--brand-50);
	color: var(--brand-300);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 14px;
}
.userbox .who {
	text-align: right;
	line-height: 1.2;
}
.userbox .who b {
	font-size: 13px;
}
.userbox .who small {
	display: block;
	color: var(--muted);
	font-size: 12px;
}

/* Theme toggle */
.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--muted);
	cursor: pointer;
	transition: background .15s, color .15s;
}
.theme-toggle:hover {
	color: var(--ink);
	background: var(--panel);
}

/* Panels */
.panel,
.card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
}
.panel-h {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	padding: 18px 20px 8px;
}
.panel-h h2 {
	margin: 0;
	font-size: 15px;
	letter-spacing: -.01em;
	font-weight: 600;
	color: var(--ink);
}
.panel-h .meta {
	color: var(--muted);
	font-size: 12.5px;
}
.panel-h a {
	color: var(--brand-300);
	font-size: 12.5px;
	font-weight: 600;
}

/* Pills / status badges */
.pill,
.badge {
	font-size: 11.5px;
	font-weight: 600;
	padding: 3px 9px;
	border-radius: 20px;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
}
.pill.ok {
	background: var(--ok-bg);
	color: var(--ok);
}
.pill.warn {
	background: var(--warn-bg);
	color: var(--warn);
}
.pill.danger {
	background: var(--danger-bg);
	color: var(--danger);
}
.pill.muted {
	background: var(--line);
	color: var(--muted);
}

/* Buttons */
.btn {
	border-radius: var(--radius-sm);
	font-weight: 600;
	font-size: 13.5px;
}
.btn .ti {
	margin-right: 6px;
}
.btn-primary,
.btn.btn-primary {
	background: var(--brand);
	border-color: var(--brand);
	color: #fff;
	box-shadow: 0 6px 16px -8px rgba(124, 92, 255, .8);
}
.btn-primary:hover,
.btn-primary:focus {
	background: var(--brand-700);
	border-color: var(--brand-700);
	color: #fff;
}
.btn-outline,
.btn-outline-primary {
	color: var(--brand-300);
	border: 1px solid var(--line);
	background: transparent;
}
.btn-outline:hover,
.btn-outline-primary:hover {
	background: var(--brand-50);
	border-color: var(--brand-300);
	color: var(--brand);
}
.btn-ghost {
	background: transparent;
	border: 0;
	color: var(--muted);
}
.btn-ghost:hover {
	color: var(--ink);
}
.btn-danger-outline {
	color: var(--danger);
	border: 1px solid var(--danger-bg);
	background: transparent;
}
.btn-danger-outline:hover {
	background: var(--danger-bg);
	border-color: var(--danger);
	color: var(--danger);
}

/* Forms */
.form-label {
	font-weight: 600;
	color: var(--ink);
	font-size: 13px;
}
.form-control,
.form-select {
	background: var(--panel-2);
	border-color: var(--line);
	border-radius: var(--radius-md);
	color: var(--ink);
}
.form-control:focus,
.form-select:focus {
	background: var(--panel-2);
	border-color: var(--brand-300);
	color: var(--ink);
	box-shadow: 0 0 0 .2rem var(--brand-50);
}
.form-control::placeholder {
	color: var(--muted);
}

/* Alerts */
.alert {
	border-radius: var(--radius-md);
	border: 1px solid var(--line);
}
.alert-success {
	background: var(--ok-bg);
	color: var(--ok);
	border-color: transparent;
}
.alert-danger {
	background: var(--danger-bg);
	color: var(--danger);
	border-color: transparent;
}
.alert-warning {
	background: var(--warn-bg);
	color: var(--warn);
	border-color: transparent;
}

/* Two-column dashboard layout */
.grid-2 {
	display: grid;
	grid-template-columns: 1.55fr 1fr;
	gap: 18px;
	margin-top: 18px;
	align-items: start;
}

/* Stat cards */
.stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 16px;
	margin-bottom: 18px;
}
.stat {
	padding: 18px;
	position: relative;
	overflow: hidden;
	animation: rise .4s ease backwards;
}
.stat:nth-child(1) { animation-delay: .02s; }
.stat:nth-child(2) { animation-delay: .06s; }
.stat:nth-child(3) { animation-delay: .10s; }
.stat:nth-child(4) { animation-delay: .14s; }
.stat .icn {
	width: 36px;
	height: 36px;
	border-radius: 11px;
	background: var(--brand-50);
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 12px;
}
.stat .icn .ti {
	font-size: 19px;
	color: var(--brand-300);
}
.stat .lbl {
	color: var(--muted);
	font-size: 12.5px;
	font-weight: 500;
}
.stat .val {
	font-size: 28px;
	font-weight: 700;
	letter-spacing: -.02em;
	line-height: 1.15;
	margin-top: 2px;
	color: var(--ink);
	font-variant-numeric: tabular-nums;
}
.stat .sub {
	font-size: 12.5px;
	color: var(--muted);
	margin-top: 4px;
}
.stat .sub.pos { color: var(--ok); }
.stat .sub.accent { color: var(--accent); }
@keyframes rise {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

/* Gauge — donut meter, threshold-colored fill, muted track (dataviz: meter spec) */
.gauge-wrap {
	display: flex;
	align-items: center;
	gap: 14px;
}
.gauge {
	width: 76px;
	height: 76px;
	flex: 0 0 76px;
	position: relative;
}
.gauge svg {
	transform: rotate(-90deg);
}
.gauge .track {
	fill: none;
	stroke: var(--line);
	stroke-width: 8;
}
.gauge .fill {
	fill: none;
	stroke: var(--ok);
	stroke-width: 8;
	stroke-linecap: round;
	stroke-dasharray: 194.78;
	stroke-dashoffset: 194.78;
	animation: gauge 1.1s .2s cubic-bezier(.2, .8, .2, 1) forwards;
}
.gauge.warn .fill { stroke: var(--warn); }
.gauge.danger .fill { stroke: var(--danger); }
.gauge .pct {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 15px;
	font-variant-numeric: tabular-nums;
	color: var(--ink);
}
@keyframes gauge {
	to { stroke-dashoffset: var(--dash, 194.78); }
}
@media (prefers-reduced-motion: reduce) {
	.gauge .fill { animation: none; stroke-dashoffset: var(--dash, 194.78); }
	.stat { animation: none; }
}

/* Token display — scales to the container width instead of wrapping
   (e.g. the 40-char enrollment code). Falls back to a fixed size in
   browsers without container query units. */
.token-scale-wrap {
	container-type: inline-size;
}
.token-scale {
	display: block;
	font-size: 13px;
	font-size: clamp(9px, 4.3cqi, 15px);
	white-space: nowrap;
	overflow-x: auto;
}

/* Statusline preview strip (terminal-styled) — fixed terminal palette, kept
   identical in light mode, dark mode and system default so the strip always
   looks like the user's real terminal instead of following the page theme.
   Defined once, here, on :root — must NOT be redefined inside any
   prefers-color-scheme or [data-theme] block. */
:root {
	--term-bg:     #05070C;
	--term-fg:     #E8EDF5;
	--term-muted:  #8B98AC;
	--term-ok:     #34D399;
	--term-warn:   #FBBF24;
	--term-danger: #F87171;
	--term-accent: #22D3EE;
}
.term {
	background: var(--term-bg);
	color: var(--term-fg);
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	padding: 14px 16px;
	font-family: var(--font-mono);
	font-size: 13px;
	line-height: 1.7;
	overflow-x: auto;
	white-space: pre;
}
.term .term-line1 { color: #9AA5B8; }
.term .term-dim { color: var(--term-muted); }

/* Chart card */
.chart-card { padding-bottom: 6px; }
.chart-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 14px;
	padding: 0 20px 6px;
	flex-wrap: wrap;
}
.chart-big {
	font-size: 30px;
	font-weight: 700;
	letter-spacing: -.02em;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: var(--ink);
}
.chart-cap {
	color: var(--muted);
	font-size: 12.5px;
	margin-top: 4px;
}
.chart-body {
	padding: 4px 12px 10px;
}
.range-toggle {
	display: inline-flex;
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	padding: 2px;
	gap: 2px;
}
.range-toggle button {
	border: 0;
	background: transparent;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	padding: 5px 10px;
	border-radius: 7px;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.range-toggle button.active {
	background: var(--brand);
	color: #fff;
}
.range-toggle button:hover:not(.active) {
	color: var(--ink);
}

/* Tables */
.table { color: var(--ink); margin-bottom: 0; }
.table thead th { background: transparent; }
.table th {
	color: var(--muted);
	font-weight: 600;
	font-size: 11.5px;
	text-transform: uppercase;
	letter-spacing: .03em;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
.table td {
	color: var(--ink);
	border-color: var(--line);
	vertical-align: middle;
	font-size: 13.5px;
}
.table tbody tr:hover { background: var(--panel-2); }
.cell-link { color: inherit; text-decoration: none; }
.cell-link:hover { color: var(--brand-300); text-decoration: none; }
.cell-sub { color: var(--muted); font-size: 12px; }

/* Member row filtering */
.member-row { cursor: pointer; }
.member-row.selected { background: var(--brand-50); }

/* Live / working badges */
.live-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--muted);
	margin-right: 6px;
}
.live-dot.live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.live-dot.working { background: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe {
	0%, 100% { opacity: 1; }
	50%      { opacity: .4; }
}

/* Approval / offline banners */
.banner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: var(--warn-bg);
	color: var(--warn);
	border: 1px solid transparent;
	border-radius: var(--radius-md);
	padding: 11px 16px;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 16px;
}
.banner .btn { flex: 0 0 auto; }

/* Rows (recent events / row-item list style) */
.rows { padding: 4px 8px 10px; }
.row-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: 11px;
	transition: background .15s;
	color: inherit;
}
.row-item:hover { background: var(--panel-2); }
.row-item .rn { font-weight: 600; font-size: 13px; color: var(--ink); }
.row-item .rd { color: var(--muted); font-size: 12px; }
.row-item .ra { margin-left: auto; font-weight: 600; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Login */
.login-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--canvas);
	padding: 24px;
}
.login-card {
	width: 100%;
	max-width: 400px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	padding: 32px;
}
.login-brand {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	margin-bottom: 26px;
}
.login-brand svg {
	width: 84px;
	height: 48px;
}
.login-brand .word {
	font-size: 19px;
	font-weight: 500;
	color: var(--ink);
}
.login-brand .word .dim {
	color: var(--muted);
}
.login-brand .tagline {
	font-size: 12.5px;
	color: var(--muted);
	text-align: center;
}
.simple-page {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--canvas);
	padding: 24px;
	text-align: center;
}
.simple-page .card {
	max-width: 440px;
	padding: 34px;
}
.simple-page h1 {
	font-size: 19px;
	margin: 14px 0 8px;
	color: var(--ink);
}
.simple-page p {
	color: var(--muted);
	margin: 0;
}

/* Pulse logo animation (app header) */
.pulse-mark .pulse-anim {
	stroke-dasharray: 26 74;
	stroke-dashoffset: 100;
	animation: pulse-sweep 2.2s linear infinite;
}
.pulse-mark .pulse-dot {
	transform-box: fill-box;
	transform-origin: center;
	animation: pulse-dot 2.2s linear infinite;
}
.pulse-mark .pulse-ring {
	transform-box: fill-box;
	transform-origin: center;
	animation: pulse-ring 2.2s linear infinite;
}
@keyframes pulse-sweep {
	from { stroke-dashoffset: 100; }
	to   { stroke-dashoffset: 0; }
}
@keyframes pulse-dot {
	0%, 80%, 100% { transform: scale(1); }
	40%           { transform: scale(1.35); }
}
@keyframes pulse-ring {
	0%   { opacity: .5; transform: scale(1); }
	80%  { opacity: 0;  transform: scale(1.9); }
	100% { opacity: 0;  transform: scale(1.9); }
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* Responsive */
@media (max-width: 880px) {
	.shell {
		flex-direction: column;
	}
	.side {
		width: 100%;
		flex: none;
		height: auto;
		position: static;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		gap: 14px;
	}
	.nav {
		flex-direction: row;
		flex-wrap: wrap;
	}
	.nav-label,
	.side-foot {
		display: none;
	}
	.main {
		padding: 20px;
	}
	.topbar {
		flex-direction: column;
	}
	.stats {
		grid-template-columns: repeat(2, 1fr);
	}
	.grid-2 {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 520px) {
	.stats {
		grid-template-columns: 1fr;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}
