:root {
	--bg: #f3f5f8;
	--surface: #ffffff;
	--surface-2: #f8fafc;
	--border: #e1e6ec;
	--border-strong: #c9d2dc;
	--text: #14202e;
	--text-2: #4f5d6e;
	--text-3: #7d8896;
	--brand: #1a82e2;
	--brand-hover: #146ec2;
	--brand-soft: #e6f1fc;
	--navy: #0f2440;
	--ok: #1a9e5c;
	--ok-soft: #e4f6ec;
	--warn: #c77700;
	--warn-soft: #fff3df;
	--bad: #d14343;
	--bad-soft: #fdeaea;
	--series-sent: #1a82e2;
	--series-failed: #d14343;
	--radius: 10px;
	--shadow: 0 1px 2px rgba(20, 32, 46, 0.06), 0 1px 3px rgba(20, 32, 46, 0.04);
	--sidebar-w: 240px;
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
	box-sizing: border-box;
}

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

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

a {
	color: var(--brand);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

code {
	font-family: var(--mono);
	font-size: 12.5px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1px 5px;
}

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

h1 {
	font-size: 22px;
}

/* Layout */
.shell {
	display: flex;
	min-height: 100vh;
}

.sidebar {
	width: var(--sidebar-w);
	flex-shrink: 0;
	background: var(--navy);
	color: #d5deea;
	display: flex;
	flex-direction: column;
	position: sticky;
	top: 0;
	height: 100vh;
}

.main {
	flex: 1;
	min-width: 0;
	padding: 28px 32px 48px;
	max-width: 1400px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 20px 20px 16px;
	color: #fff;
	font-weight: 600;
	font-size: 16px;
}

.brand:hover {
	text-decoration: none;
}

.brand-mark {
	width: 28px;
	height: 28px;
	border-radius: 7px;
	background: var(--brand);
	position: relative;
	flex-shrink: 0;
}

.brand-mark::after {
	content: "";
	position: absolute;
	inset: 8px 6px;
	border: 2px solid #fff;
	border-radius: 3px;
	background: linear-gradient(to bottom right, transparent 45%, #fff 45%, #fff 55%, transparent 55%) no-repeat;
}

.nav {
	padding: 0 12px;
	flex: 1;
	overflow-y: auto;
}

.nav-section {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #7f93ad;
	padding: 16px 10px 6px;
}

.nav-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 7px;
	color: #d5deea;
	font-weight: 500;
}

.nav-link:hover {
	background: rgba(255, 255, 255, 0.07);
	text-decoration: none;
	color: #fff;
}

.nav-link.active {
	background: var(--brand);
	color: #fff;
}

.icon {
	width: 17px;
	height: 17px;
	flex-shrink: 0;
	opacity: 0.9;
}

.sidebar-footer {
	padding: 14px 16px 18px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.user-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	color: #fff;
	min-width: 0;
}

.user-chip:hover {
	text-decoration: none;
}

.user-chip-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.25;
}

.user-chip-name {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.user-chip-sub {
	font-size: 12px;
	color: #9fb0c6;
}

.avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--brand);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	flex-shrink: 0;
}

.sidebar .btn-ghost {
	color: #c4d0df;
	border-color: transparent;
}

.sidebar .btn-ghost:hover {
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
}

/* Page header */
.page-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
}

.page-sub {
	margin: 4px 0 0;
	color: var(--text-2);
}

.back {
	font-size: 13px;
	color: var(--text-3);
	display: inline-block;
	margin-bottom: 4px;
}

/* Cards and grids */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px;
	margin-bottom: 20px;
}

.card-flush {
	padding: 0;
	overflow: hidden;
}

.card-flush .table {
	border: 0;
}

/* Wide list tables scroll sideways inside their card instead of being clipped. */
.table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.table-scroll .table {
	min-width: 720px;
}

.card-highlight {
	border-color: var(--brand);
	background: var(--brand-soft);
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.card-title {
	font-size: 15px;
	margin-bottom: 12px;
}

.card-head .card-title {
	margin-bottom: 0;
}

.card-subtitle {
	font-size: 13px;
	margin: 18px 0 8px;
	color: var(--text-2);
}

.grid {
	display: grid;
	gap: 20px;
	margin-bottom: 0;
}

.grid > .card {
	margin-bottom: 0;
}

.grid {
	margin-bottom: 20px;
}

.grid-2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3-1 {
	grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
}

/* Stat tiles */
.stats {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	margin-bottom: 20px;
}

.stat {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px 18px;
	display: flex;
	flex-direction: column;
	color: var(--text);
}

.stat:hover {
	text-decoration: none;
	border-color: var(--border-strong);
}

.stat-label {
	font-size: 12px;
	color: var(--text-2);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.stat-value {
	font-size: 30px;
	font-weight: 600;
	line-height: 1.2;
	margin: 6px 0 2px;
	font-variant-numeric: tabular-nums;
}

.stat-foot {
	font-size: 12px;
	color: var(--text-3);
}

.stat-foot.bad {
	color: var(--bad);
}

.stat-foot.warn {
	color: var(--warn);
}

/* Chart */
.legend {
	display: flex;
	gap: 14px;
	font-size: 12px;
	color: var(--text-2);
}

.legend-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

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

.swatch-sent {
	background: var(--series-sent);
}

.swatch-failed {
	background: var(--series-failed);
}

.chart {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	height: 180px;
	padding: 8px 4px 0;
	border-bottom: 1px solid var(--border);
}

.chart-col {
	flex: 1;
	min-width: 0;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	position: relative;
	outline: none;
}

.chart-bars {
	flex: 1;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	gap: 2px;
	padding-bottom: 4px;
}

.bar {
	width: 40%;
	max-width: 18px;
	min-height: 0;
	border-radius: 4px 4px 0 0;
	transition: opacity 0.15s;
}

.bar-sent {
	background: var(--series-sent);
}

.bar-failed {
	background: var(--series-failed);
}

.chart-col:hover .bar, .chart-col:focus .bar {
	opacity: 0.8;
}

.chart-label {
	font-size: 11px;
	color: var(--text-3);
	text-align: center;
	padding-top: 6px;
	border-top: 1px solid var(--border);
	white-space: nowrap;
}

.chart-tip {
	display: none;
	position: absolute;
	bottom: calc(100% + 4px);
	left: 50%;
	transform: translateX(-50%);
	background: var(--navy);
	color: #fff;
	font-size: 12px;
	padding: 6px 9px;
	border-radius: 6px;
	white-space: nowrap;
	z-index: 5;
	pointer-events: none;
}

.chart-col:hover .chart-tip, .chart-col:focus .chart-tip {
	display: block;
}

.table-view {
	margin-top: 12px;
	font-size: 13px;
}

.table-view summary {
	cursor: pointer;
	color: var(--text-2);
}

/* Tables */
.table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13.5px;
}

.table th, .table td {
	text-align: left;
	padding: 10px 14px;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}

.table thead th {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-2);
	background: var(--surface-2);
	font-weight: 600;
}

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

.table tbody tr:hover {
	background: #f9fbfd;
}

.table-compact th, .table-compact td {
	padding: 7px 10px;
}

.th-inline {
	width: 30%;
	color: var(--text-2);
	font-weight: 500;
	font-family: var(--mono);
	font-size: 12px;
}

.num {
	text-align: right !important;
	font-variant-numeric: tabular-nums;
}

.nowrap {
	white-space: nowrap;
}

.row-link {
	cursor: pointer;
}

.row-muted {
	opacity: 0.6;
}

.actions {
	white-space: nowrap;
	text-align: right;
}

.actions .btn + .btn, .actions .inline + .inline, .actions .popover + .inline {
	margin-left: 6px;
}

/* Badges and pills */
.badge {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	line-height: 18px;
	text-transform: capitalize;
}

.badge-lg {
	font-size: 13px;
	padding: 4px 12px;
}

.badge-ok {
	background: var(--ok-soft);
	color: var(--ok);
}

.badge-warn {
	background: var(--warn-soft);
	color: var(--warn);
}

.badge-bad {
	background: var(--bad-soft);
	color: var(--bad);
}

.badge-muted {
	background: #eef1f4;
	color: var(--text-2);
}

.pill {
	display: inline-block;
	font-size: 11px;
	padding: 1px 7px;
	border-radius: 999px;
	background: #eef1f4;
	color: var(--text-2);
	margin-left: 4px;
}

.muted {
	color: var(--text-3);
}

.small {
	font-size: 12.5px;
}

.mono {
	font-family: var(--mono);
	font-size: 12.5px;
}

.bad-text {
	color: var(--bad);
}

.ok-text {
	color: var(--ok);
}

.mt {
	margin-top: 12px;
}

.empty {
	padding: 28px 16px;
	text-align: center;
	color: var(--text-3);
	margin: 0;
}

.list {
	list-style: none;
	margin: 0;
	padding: 0;
}

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

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

/* Definition lists */
.dl {
	display: grid;
	grid-template-columns: 130px 1fr;
	gap: 6px 14px;
	margin: 0;
}

.dl dt {
	color: var(--text-2);
	font-size: 13px;
}

.dl dd {
	margin: 0;
	word-break: break-word;
}

.dl-stacked {
	grid-template-columns: 1fr;
	gap: 2px;
}

.dl-stacked dt {
	font-weight: 600;
	margin-top: 8px;
	color: var(--text);
}

/* Forms */
.form .field {
	display: block;
	margin-bottom: 14px;
}

.field-label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	margin-bottom: 5px;
	color: var(--text-2);
}

.input {
	width: 100%;
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: 7px;
	padding: 8px 10px;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
	outline: none;
	border-color: var(--brand);
	box-shadow: 0 0 0 3px rgba(26, 130, 226, 0.18);
}

.input-sm {
	padding: 5px 8px;
	font-size: 13px;
}

textarea.input {
	resize: vertical;
	min-height: 80px;
}

select.input {
	appearance: auto;
}

.input-group {
	display: flex;
	align-items: stretch;
}

.input-group .input:first-child {
	border-radius: 7px 0 0 7px;
}

.input-group .input:last-child {
	border-radius: 0 7px 7px 0;
}

.input-addon {
	display: inline-flex;
	align-items: center;
	padding: 0 10px;
	border-top: 1px solid var(--border-strong);
	border-bottom: 1px solid var(--border-strong);
	background: var(--surface-2);
	color: var(--text-2);
}

.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 16px;
}

.filters .input {
	width: auto;
	min-width: 150px;
}

.filters input[type="search"] {
	flex: 1;
	min-width: 220px;
}

.inline {
	display: inline;
}

.inline-form {
	display: flex;
	gap: 6px;
	align-items: center;
}

.inline-form .input {
	min-width: 140px;
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font: inherit;
	font-weight: 500;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: 7px;
	padding: 8px 14px;
	cursor: pointer;
	line-height: 1.2;
	transition: background 0.15s, border-color 0.15s;
	white-space: nowrap;
}

.btn:hover {
	background: var(--surface-2);
	text-decoration: none;
}

.btn[aria-disabled="true"] {
	opacity: 0.5;
	cursor: default;
}

.btn-sm {
	padding: 5px 10px;
	font-size: 12.5px;
}

.btn-block {
	width: 100%;
}

.btn-primary {
	background: var(--brand);
	border-color: var(--brand);
	color: #fff;
}

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

.btn-danger {
	color: var(--bad);
	border-color: #f0c2c2;
}

.btn-danger:hover {
	background: var(--bad-soft);
}

.btn-ghost {
	background: transparent;
	border-color: transparent;
	color: var(--text-2);
}

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

/* Flash */
.flash {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	border-radius: 8px;
	margin-bottom: 18px;
	border: 1px solid;
}

.flash-success {
	background: var(--ok-soft);
	border-color: #bfe6cf;
	color: #12633a;
}

.flash-error {
	background: var(--bad-soft);
	border-color: #f0c2c2;
	color: #8f2626;
}

.flash-close {
	background: none;
	border: 0;
	font-size: 18px;
	cursor: pointer;
	color: inherit;
	opacity: 0.6;
}

/* Tabs and preview */
.tabs {
	display: inline-flex;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 3px;
	gap: 2px;
}

.tab {
	font: inherit;
	font-size: 13px;
	border: 0;
	background: transparent;
	padding: 5px 12px;
	border-radius: 6px;
	cursor: pointer;
	color: var(--text-2);
}

.tab.active {
	background: var(--surface);
	color: var(--text);
	box-shadow: var(--shadow);
}

.tab-panel {
	display: none;
}

.tab-panel.active {
	display: block;
}

.preview {
	width: 100%;
	height: 520px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #fff;
}

.pre {
	margin: 0;
	font-family: var(--mono);
	font-size: 12.5px;
	white-space: pre-wrap;
	word-break: break-word;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px 14px;
	max-height: 520px;
	overflow: auto;
}

.keybox {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 12px;
	margin-bottom: 10px;
}

.keybox code {
	border: 0;
	background: none;
	font-size: 14px;
	flex: 1;
	word-break: break-all;
}

.secret {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* A revealed key wraps instead of stretching the row. */
.secret[data-shown="1"] .secret-text {
	word-break: break-all;
	max-width: 260px;
}

/* Popover (details-based) */
.popover {
	display: inline-block;
	position: relative;
}

.popover summary {
	list-style: none;
}

.popover summary::-webkit-details-marker {
	display: none;
}

.popover-body {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	z-index: 10;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(20, 32, 46, 0.14);
	padding: 12px;
	width: 260px;
	text-align: left;
}

/* Pagination */
.pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border-top: 1px solid var(--border);
	font-size: 13px;
	color: var(--text-2);
}

.pagination-links {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

/* Auth */
.auth-shell {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background: linear-gradient(160deg, var(--navy) 0%, #163a66 60%, var(--brand) 140%);
}

.auth-card {
	background: var(--surface);
	border-radius: 14px;
	box-shadow: 0 20px 60px rgba(4, 16, 32, 0.35);
	padding: 32px;
	width: 100%;
	max-width: 400px;
}

.auth-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 22px;
}

.auth-brand .brand-mark {
	width: 40px;
	height: 40px;
	border-radius: 10px;
}

.auth-title {
	font-size: 18px;
	font-weight: 600;
}

.auth-sub {
	font-size: 13px;
	color: var(--text-2);
}

/* Responsive */
@media (max-width: 1000px) {
	.grid-2, .grid-3-1 {
		grid-template-columns: 1fr;
	}

	.stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 760px) {
	.shell {
		flex-direction: column;
	}

	.sidebar {
		width: 100%;
		height: auto;
		position: static;
	}

	.nav {
		display: flex;
		flex-wrap: wrap;
		gap: 2px;
		padding-bottom: 8px;
	}

	.nav-section {
		display: none;
	}

	.main {
		padding: 18px 16px 40px;
	}

	.page-head {
		flex-direction: column;
	}

	.table {
		display: block;
		overflow-x: auto;
	}
}
