/* ==========================================================================
   RMS Bridge Admin — Design System
   Shared by the admin shell and the guest (auth) pages.
   ========================================================================== */

:root {
    /* Brand */
    --brand-900: #072019;
    --brand-800: #0b2e23;
    --brand-700: #0f3d2e;
    --brand-600: #14593f;
    --brand-500: #157a50;
    --brand-400: #1f9d66;
    --mint: #81fbbf;
    --mint-soft: #e7fdf2;

    /* Neutrals */
    --canvas: #f6f7f7;
    --surface: #ffffff;
    --surface-2: #fafbfb;
    --border: #e5e8e7;
    --border-strong: #d3d8d6;
    --text: #101917;
    --text-2: #3c4744;
    --muted: #6b7672;
    --subtle: #98a19e;

    /* Status */
    --success: #12794a;  --success-bg: #e8f7ef;  --success-bd: #c4ead5;
    --warning: #9a5b00;  --warning-bg: #fff6e5;  --warning-bd: #f7dfac;
    --danger:  #c0362c;  --danger-bg:  #fdeeec;  --danger-bd:  #f6cdc8;
    --info:    #2459c9;  --info-bg:    #eaf1fe;  --info-bd:    #c9daf9;
    --neutral: #55605c;  --neutral-bg: #eff1f0;  --neutral-bd: #dde1df;

    /* Type */
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Shape & depth */
    --r-sm: 6px;
    --r: 8px;
    --r-lg: 12px;
    --shadow-xs: 0 1px 2px rgba(16, 25, 23, .05);
    --shadow-sm: 0 1px 2px rgba(16, 25, 23, .04), 0 1px 3px rgba(16, 25, 23, .06);
    --shadow-md: 0 4px 12px -2px rgba(16, 25, 23, .08), 0 2px 4px -2px rgba(16, 25, 23, .05);
    --shadow-lg: 0 24px 48px -12px rgba(16, 25, 23, .18);
    --ring: 0 0 0 3px rgba(21, 122, 80, .22);

    --sidebar-w: 248px;
    --topbar-h: 64px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font: 400 14px/1.5 var(--font);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--brand-500); text-decoration: none; }
a:hover { color: var(--brand-600); }
img, svg { display: block; }
button { font: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--mint); color: var(--brand-900); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; }

/* ==========================================================================
   App shell
   ========================================================================== */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky; top: 0; z-index: 40;
    height: 100vh; display: flex; flex-direction: column;
    background: var(--brand-800);
    background-image: radial-gradient(120% 60% at 0% 0%, rgba(129, 251, 191, .08), transparent 60%);
    color: #cfe0d9;
    border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-brand img { height: 20px; width: auto; filter: brightness(0) invert(1); }
.sidebar-brand .product {
    margin-left: auto; padding: 2px 7px; border-radius: 999px;
    background: rgba(129, 251, 191, .12); color: var(--mint);
    font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: 18px 10px 6px; color: #7f998f; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.nav-section:first-child { margin-top: 2px; }
.nav-link {
    position: relative; display: flex; align-items: center; gap: 11px;
    height: 38px; padding: 0 10px; border-radius: var(--r);
    color: #c3d5ce; font-size: 13.5px; font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.nav-link .icon { color: #8aa79c; transition: color .15s ease; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link:hover .icon { color: #e6f3ee; }
.nav-link.active { background: rgba(129, 251, 191, .12); color: #fff; }
.nav-link.active .icon { color: var(--mint); }
.nav-link.active::before {
    content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--mint);
}
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); }
.user-card:hover { background: rgba(255,255,255,.05); }
.user-card .who { min-width: 0; flex: 1; }
.user-card .name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .role { color: #8aa79c; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn-dark {
    display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: var(--r-sm); background: transparent; color: #8aa79c; cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.icon-btn-dark:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Workspace ---------- */
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    height: var(--topbar-h); padding: 0 32px;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.icon-btn.menu-toggle { display: none; }
.breadcrumb { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--subtle); }
.breadcrumb .current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.env-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
    color: var(--text-2); font-size: 12px; font-weight: 500;
}
.env-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-400); box-shadow: 0 0 0 3px rgba(31,157,102,.16); }

.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 32px 64px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.02em; }
.page-header .lede { margin-top: 6px; color: var(--muted); font-size: 14px; max-width: 64ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }

/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--r);
    font-size: 13.5px; font-weight: 550; line-height: 1; white-space: nowrap; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: #c3c9c6; color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef0ef; color: var(--text); }
.btn-danger { background: var(--surface); border-color: var(--danger-bd); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.icon-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
    border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: #eef0ef; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-subtitle { margin-top: 2px; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Toolbar (above tables) ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .count { color: var(--muted); font-size: 13px; }
.toolbar .count strong { color: var(--text); font-weight: 600; }
.toolbar .spacer { flex: 1; }
.toolbar select { width: auto; min-width: 180px; height: 34px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: 13.5px; }
.table th {
    position: sticky; top: 0; height: 40px; padding: 0 16px;
    background: var(--surface-2); border-bottom: 1px solid var(--border);
    color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
}
.table td { height: 56px; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover td { background: #fbfcfb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { vertical-align: middle; }
.table .actions form { display: inline; }
.table .nowrap { white-space: nowrap; }
.cell-primary { color: var(--text); font-weight: 550; }
.cell-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.cell-entity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }

/* ---------- Avatars ---------- */
.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--mint-soft); color: var(--brand-600);
    font-size: 12px; font-weight: 650; letter-spacing: .02em;
    box-shadow: inset 0 0 0 1px rgba(21,122,80,.12);
}
.avatar.square { border-radius: var(--r); }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.on-dark { background: rgba(129,251,191,.16); color: var(--mint); box-shadow: none; }
.avatar.tone-1 { background: #eaf1fe; color: #2459c9; box-shadow: inset 0 0 0 1px rgba(36,89,201,.12); }
.avatar.tone-2 { background: #f3ecfd; color: #6b3fc4; box-shadow: inset 0 0 0 1px rgba(107,63,196,.12); }
.avatar.tone-3 { background: #fff1e6; color: #b2560d; box-shadow: inset 0 0 0 1px rgba(178,86,13,.12); }
.avatar.tone-4 { background: #fdebf1; color: #b42e5e; box-shadow: inset 0 0 0 1px rgba(180,46,94,.12); }

/* ---------- Badges / pills ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
    border: 1px solid var(--neutral-bd); border-radius: 999px; background: var(--neutral-bg); color: var(--neutral);
    font-size: 12px; font-weight: 550; line-height: 1; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success); }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  border-color: var(--danger-bd);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    border-color: var(--info-bd);    color: var(--info); }
.badge-brand   { background: var(--brand-700);  border-color: var(--brand-700);  color: var(--mint); }
.tag {
    display: inline-flex; align-items: center; height: 22px; padding: 0 7px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
    color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.key-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
    color: var(--text); font: 500 12px/1 var(--mono); white-space: nowrap;
}
.key-chip .icon { width: 13px; height: 13px; color: var(--subtle); }
.method {
    display: inline-block; min-width: 44px; padding: 2px 6px; border-radius: 4px; margin-right: 8px;
    background: var(--info-bg); color: var(--info); font: 600 11px/1.4 var(--mono); text-align: center;
}
.method.post { background: var(--success-bg); color: var(--success); }
.method.put, .method.patch { background: var(--warning-bg); color: var(--warning); }
.method.delete { background: var(--danger-bg); color: var(--danger); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { position: relative; padding: 20px; overflow: hidden; }
.stat-head { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r); background: var(--mint-soft); color: var(--brand-600); }
.stat-value { margin-top: 14px; font-size: 30px; font-weight: 650; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-foot { margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.stat-foot a { font-weight: 550; }

.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }

/* ---------- Quick actions list ---------- */
.action-list { display: flex; flex-direction: column; }
.action-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); color: var(--text); transition: background-color .12s ease; }
.action-item:last-child { border-bottom: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.action-item:hover { background: var(--surface-2); color: var(--text); }
.action-item .stat-icon { width: 32px; height: 32px; }
.action-item .title { font-size: 13.5px; font-weight: 550; }
.action-item .desc { color: var(--muted); font-size: 12.5px; }
.action-item .chev { margin-left: auto; color: var(--subtle); }

/* ---------- Alerts ---------- */
.alert {
    display: flex; gap: 12px; align-items: flex-start; margin-bottom: 20px; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs);
    font-size: 13.5px;
}
.alert .icon { margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); }
.alert-text { color: var(--text-2); }
.alert-success { border-color: var(--success-bd); background: var(--success-bg); } .alert-success > .icon { color: var(--success); }
.alert-danger  { border-color: var(--danger-bd);  background: var(--danger-bg); }  .alert-danger  > .icon { color: var(--danger); }
.alert-warning { border-color: var(--warning-bd); background: var(--warning-bg); } .alert-warning > .icon { color: var(--warning); }
.alert-info    { border-color: var(--info-bd);    background: var(--info-bg); }    .alert-info    > .icon { color: var(--info); }
.alert .close { margin: -4px -6px -4px 0; }

/* Secret reveal (new API key) */
.secret { margin-bottom: 24px; border-color: var(--warning-bd); }
.secret .card-body { display: flex; gap: 16px; align-items: flex-start; }
.secret-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--r); background: var(--warning-bg); color: var(--warning); }
.secret-field { display: flex; gap: 8px; margin-top: 14px; }
.secret-field input { flex: 1; min-width: 0; font-family: var(--mono) !important; font-size: 13px !important; background: var(--surface-2) !important; letter-spacing: .01em; }

/* ---------- Forms ---------- */
.form-card { max-width: 960px; }
.form-section { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 32px; padding: 28px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.form-section-head p { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.form-fields { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { color: var(--text); font-size: 13px; font-weight: 550; }
.label .optional { margin-left: 4px; color: var(--subtle); font-weight: 400; }
.label .req { color: var(--danger); margin-left: 2px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.field-error { display: flex; align-items: center; gap: 5px; color: var(--danger); font-size: 12.5px; font-weight: 500; }
.field-error .icon { width: 14px; height: 14px; }

.input, .select,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="datetime-local"], input[type="search"], select {
    width: 100%; height: 38px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--r);
    background: var(--surface); color: var(--text);
    font: 400 14px/1.4 var(--font);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none; appearance: none;
}
select {
    padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7672' stroke-width='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 10px center; background-size: 16px;
}
input::placeholder { color: var(--subtle); }
input:hover, select:hover { border-color: #bcc3c0; }
input:focus, select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
input[readonly] { background: var(--surface-2); }
.is-invalid, .is-invalid:hover { border-color: var(--danger) !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px rgba(192,54,44,.18) !important; }
.input-group { position: relative; }
.input-group .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.input-group input { padding-left: 38px; }
.input-group .toggle-visibility { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group .toggle-visibility .icon { position: static; transform: none; pointer-events: auto; }
.input-group input.has-toggle { padding-right: 42px; }

/* Checkbox */
input[type="checkbox"] {
    -webkit-appearance: none; appearance: none; flex: none;
    width: 16px; height: 16px; margin: 0; border: 1px solid #b8c0bd; border-radius: 4px;
    background: var(--surface) center/12px no-repeat; cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}
input[type="checkbox"]:checked {
    border-color: var(--brand-600); background-color: var(--brand-600);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
    border-color: var(--brand-600); background-color: var(--brand-600);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }

/* Switch (checkbox with .switch) */
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); cursor: pointer; }
.switch-row .title { font-size: 13.5px; font-weight: 550; color: var(--text); }
.switch-row .desc { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
input[type="checkbox"].switch {
    position: relative; width: 36px; height: 20px; border: 0; border-radius: 999px;
    background: #cdd3d1; background-image: none; transition: background-color .18s ease;
}
input[type="checkbox"].switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s ease;
}
input[type="checkbox"].switch:checked { background: var(--brand-500); background-image: none; }
input[type="checkbox"].switch:checked::after { transform: translateX(16px); }

/* Choice tiles (roles / permissions) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.choice {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
    cursor: pointer; transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.choice:hover { border-color: #c3cac7; }
.choice:has(input:checked) { border-color: rgba(21,122,80,.45); background: #f3fbf7; box-shadow: inset 0 0 0 1px rgba(21,122,80,.25); }
.choice input { margin-top: 2px; }
.choice .title { font-size: 13.5px; font-weight: 550; color: var(--text); }
.choice .desc { color: var(--muted); font-size: 12px; }
.choice code { font-size: 11.5px; color: var(--muted); }

.perm-group { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.perm-group + .perm-group { margin-top: 12px; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.perm-group-head label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.perm-group-head .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.perm-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.perm-item:hover { background: var(--surface-2); }
.perm-item code { margin-left: auto; color: var(--subtle); font-size: 11px; }

.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 28px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form-actions .left { margin-right: auto; }

/* ---------- Empty states ---------- */
.empty { padding: 56px 24px; text-align: center; }
.empty-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { margin: 6px auto 0; max-width: 42ch; color: var(--muted); font-size: 13.5px; }
.empty .btn { margin-top: 18px; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager-info { color: var(--muted); font-size: 13px; }
.pager-info strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager-links { display: flex; gap: 4px; }
.pager-links a, .pager-links span {
    display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
    color: var(--text-2); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.pager-links a:hover { background: var(--surface-2); color: var(--text); }
.pager-links .active { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.pager-links .disabled { color: var(--subtle); background: var(--surface-2); }
.pager-links .gap { border-color: transparent; background: transparent; }

/* ---------- Profile ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head .avatar { width: 56px; height: 56px; font-size: 18px; }

/* ---------- Mobile overlay ---------- */
.scrim { display: none; }

/* ==========================================================================
   Guest / Auth
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--surface); }
.auth-aside {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
    padding: 40px 48px; color: #d3e4dd;
    background: var(--brand-800);
    background-image:
        radial-gradient(80% 60% at 100% 0%, rgba(129,251,191,.16), transparent 60%),
        radial-gradient(60% 50% at 0% 100%, rgba(31,157,102,.22), transparent 60%);
}
.auth-aside::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(70% 70% at 50% 40%, #000, transparent);
    -webkit-mask-image: radial-gradient(70% 70% at 50% 40%, #000, transparent);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .logo img { height: 24px; width: auto; filter: brightness(0) invert(1); }
.auth-pitch h2 { max-width: 18ch; color: #fff; font-size: 34px; line-height: 1.15; font-weight: 650; letter-spacing: -.025em; }
.auth-pitch p { margin-top: 14px; max-width: 44ch; color: #a9c4b9; font-size: 15px; line-height: 1.6; }
.auth-points { display: grid; gap: 12px; margin-top: 32px; }
.auth-point { display: flex; align-items: center; gap: 12px; color: #d3e4dd; font-size: 14px; }
.auth-point .icon-wrap { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); background: rgba(129,251,191,.1); color: var(--mint); border: 1px solid rgba(129,251,191,.16); }
.auth-legal { color: #7f998f; font-size: 12.5px; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .mobile-logo { display: none; margin-bottom: 32px; }
.auth-card .mobile-logo img { height: 22px; width: auto; }
.auth-card h1 { font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
.auth-card .lede { margin-top: 8px; margin-bottom: 28px; color: var(--muted); font-size: 14.5px; }
.auth-card form { display: flex; flex-direction: column; gap: 18px; }
.auth-card input[type="email"], .auth-card input[type="password"], .auth-card input[type="text"] { height: 42px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; font-size: 13.5px; }
.auth-foot { margin-top: 28px; color: var(--muted); font-size: 13.5px; text-align: center; }
.auth-foot a, .auth-row a { font-weight: 550; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
    .form-section { grid-template-columns: 1fr; gap: 16px; padding: 22px 20px; }
    .form-actions { padding: 14px 20px; }
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-card .mobile-logo { display: block; }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; width: 280px; height: 100dvh;
        transform: translateX(-100%); transition: transform .22s ease, box-shadow .22s ease; box-shadow: none;
    }
    body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(7, 32, 25, .45); }
    .icon-btn.menu-toggle { display: inline-grid; margin-left: -6px; }
    .topbar { padding: 0 16px; }
    .page { padding: 24px 16px 48px; }
    .page-header { flex-direction: column; align-items: stretch; gap: 14px; }
    .page-header h1 { font-size: 22px; }
    .env-chip { display: none; }
}
@media (max-width: 640px) {
    .stats { gap: 10px; }
    .stat { padding: 16px; }
    .stat-value { font-size: 24px; }
    .form-row { grid-template-columns: 1fr; }
    .toolbar select { flex: 1; min-width: 0; }
    .pager { flex-direction: column; align-items: stretch; }
    .pager-links { justify-content: center; flex-wrap: wrap; }
    .hide-sm { display: none !important; }
    .secret .card-body { flex-direction: column; }
    .secret-field { flex-direction: column; }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .btn { width: 100%; }
    .form-actions .left { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
