:root {
    color-scheme: light;
    --ink: #182234;
    --muted: #718096;
    --line: #e6ebf1;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --blue: #4359e8;
    --blue-dark: #3448ce;
    --mint: #e7f8f1;
    --green: #167a54;
    --red: #a33c45;
    --shadow: 0 12px 34px rgba(34, 51, 84, .06);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
a { color: inherit; }
button, input, select { font: inherit; }
.topbar { height: 72px; padding: 0 clamp(20px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; font: 800 20px/1 system-ui, sans-serif; letter-spacing: -.8px; }
.brand span { color: var(--blue); }
.brand small { margin-left: 7px; color: #98a3b6; font: 700 10px system-ui, sans-serif; letter-spacing: 1.3px; }
.topbar nav { display: flex; align-items: center; gap: 26px; }
.topbar nav > a, .nav-button { color: #647187; text-decoration: none; font-size: 14px; font-weight: 600; }
.topbar nav > a:hover, .nav-button:hover, .text-link:hover, .link-button:hover { color: var(--blue); }
.page-shell { width: min(1180px, calc(100% - 40px)); margin: 38px auto 72px; }
.auth-shell { min-height: calc(100vh - 76px); display: grid; place-items: center; margin-top: 0; margin-bottom: 0; }
.auth-card { width: min(440px, 100%); padding: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: system-ui, sans-serif; letter-spacing: -.7px; }
h1 { margin-bottom: 7px; font-size: clamp(27px, 4vw, 34px); }
h2 { margin-bottom: 4px; font-size: 18px; }
.eyebrow { margin-bottom: 7px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; }
.muted { color: var(--muted); }
.auth-card > .muted { margin-bottom: 27px; }
.page-heading { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.page-heading p { margin-bottom: 0; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 700; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: #46536a; background: #fff; border-color: var(--line); }
.button-secondary:hover { border-color: #bdc7d8; }
.stack-form, .form-grid { display: grid; gap: 18px; }
.stack-form label, .form-grid label { display: grid; gap: 7px; color: #38465c; font-size: 13px; font-weight: 700; }
input, select { width: 100%; height: 44px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid #dbe2ec; border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: #8795f2; box-shadow: 0 0 0 3px rgba(67, 89, 232, .12); }
.stack-form .button { width: 100%; margin-top: 2px; }
.text-link, .link-button { color: var(--blue); font-size: 13px; font-weight: 700; text-decoration: none; }
.link-button, .nav-button { padding: 0; background: none; border: 0; cursor: pointer; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.inline-form { display: inline-flex; margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 23px; }
.stat-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.stat-card { padding: 19px 21px; display: grid; gap: 4px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card strong { font: 800 28px/1.2 system-ui, sans-serif; }
.panel { overflow: hidden; }
.panel-heading { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-heading p { margin-bottom: 0; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 18px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
th { color: #8a95a7; background: #fbfcfe; font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; white-space: nowrap; }
td { color: #39465a; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
.cell-subtitle { display: block; margin-top: 2px; color: #98a2b1; font-size: 11px; }
.status { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.status-active { color: var(--green); background: var(--mint); }
.status-paused { color: #657184; background: #eef1f5; }
.empty-state { padding: 32px; color: var(--muted); text-align: center; }
.form-panel { max-width: 850px; padding: 26px; }
.narrow-panel { max-width: 560px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding-top: 4px; }
.optional { display: block; color: #929cad; font-size: 11px; font-weight: 500; }
.identity-strip { margin-bottom: 22px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); background: #f8f9fc; border-radius: 8px; font-size: 13px; }
.identity-strip strong { color: var(--ink); }
.alert { margin: 0 0 18px; padding: 12px 14px; border-radius: 8px; font-size: 13px; }
.alert-error { color: var(--red); background: #fff0f0; border: 1px solid #f6d7d9; }
.audit-action { color: #4758be; font-size: 11px; font-weight: 700; letter-spacing: .3px; }

@media (max-width: 760px) {
    .topbar { height: auto; min-height: 66px; padding: 14px 20px; align-items: flex-start; gap: 16px; }
    .topbar nav { gap: 13px; flex-wrap: wrap; justify-content: flex-end; }
    .topbar nav > a, .nav-button { font-size: 12px; }
    .page-shell { width: min(100% - 28px, 600px); margin-top: 25px; }
    .auth-shell { min-height: calc(100vh - 66px); margin-top: 0; }
    .auth-card { padding: 30px 24px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .stat-grid { gap: 9px; }
    .stat-card { padding: 14px; }
    .stat-card span { font-size: 11px; }
    .stat-card strong { font-size: 24px; }
    .form-panel { padding: 18px; }
}
@media (max-width: 500px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .form-actions { grid-column: auto; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { display: flex; justify-content: space-between; align-items: center; }
    .topbar { align-items: center; }
    .topbar nav { gap: 9px; }
}
