:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-muted: #eef2f7;
    --text: #172033;
    --text-strong: #0f172a;
    --muted: #64748b;
    --border: #dbe3ef;
    --border-strong: #c7d2e0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --danger: #b91c1c;
    --danger-dark: #991b1b;
    --success: #047857;
    --warning: #a16207;
    --info: #0369a1;
    --sidebar: #0f172a;
    --sidebar-soft: #172033;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #7f8ca3;
    --header-height: 68px;
    --sidebar-width: 264px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.045);
    --shadow: 0 12px 34px rgba(15, 23, 42, 0.075);
    --focus: 0 0 0 3px rgba(37, 99, 235, 0.24);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body.sidebar-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img, svg { max-width: 100%; }
code, pre, .token-box { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.skip-link {
    position: fixed;
    z-index: 10000;
    top: 8px;
    left: 8px;
    transform: translateY(-160%);
    padding: 10px 14px;
    border-radius: 8px;
    background: #fff;
    color: var(--text-strong);
    box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    z-index: 1000;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, var(--sidebar) 0%, #111b31 100%);
    color: var(--sidebar-text);
    box-shadow: 10px 0 28px rgba(15, 23, 42, 0.12);
}
.sidebar-brand {
    display: flex;
    min-height: var(--header-height);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-link { display: flex; min-width: 0; align-items: center; gap: 11px; color: #fff; }
.brand-mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 9px 20px rgba(37, 99, 235, 0.32);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: -0.02em;
}
.brand-copy { display: grid; min-width: 0; line-height: 1.16; }
.brand-copy strong { overflow: hidden; color: #fff; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { margin-top: 3px; color: #8fa0bb; font-size: 11px; font-weight: 650; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px 26px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-group + .nav-group { margin-top: 17px; }
.nav-group-label {
    padding: 0 11px 7px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}
.nav-link {
    position: relative;
    display: flex;
    min-height: 39px;
    align-items: center;
    gap: 10px;
    margin: 2px 0;
    padding: 8px 11px;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 690;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(1px); }
.nav-link.is-active { background: rgba(37, 99, 235, 0.24); color: #fff; box-shadow: inset 0 0 0 1px rgba(96,165,250,.18); }
.nav-indicator { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 99px; background: #475569; }
.nav-link.is-active .nav-indicator { background: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,.12); }
.sidebar-footer { display: grid; gap: 7px; padding: 14px 17px 18px; border-top: 1px solid rgba(255,255,255,.08); color: #8190a9; }
.sidebar-footer small { font-size: 10px; }
.environment-pill { display: inline-flex; width: fit-content; align-items: center; gap: 7px; color: #b7f7d1; font-size: 11px; font-weight: 800; }
.environment-pill span { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }

.app-workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.app-header {
    position: sticky;
    z-index: 800;
    top: 0;
    display: flex;
    min-height: var(--header-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 9px clamp(16px, 2.2vw, 32px);
    border-bottom: 1px solid rgba(203, 213, 225, .75);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-title { display: grid; line-height: 1.15; }
.header-title span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.header-title strong { margin-top: 3px; color: var(--text-strong); font-size: 15px; }
.icon-button {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text-strong);
    cursor: pointer;
}
.icon-button:hover { border-color: #b8c5d7; background: #f8fafc; }
.icon-button:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
.menu-button { display: none; }
.menu-bars { display: grid; gap: 4px; }
.menu-bars i { display: block; width: 18px; height: 2px; border-radius: 99px; background: currentColor; }
.sidebar-close { display: none; border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.06); color: #fff; font-size: 22px; }
.header-health { display: inline-flex; align-items: center; gap: 8px; color: #475569; font-size: 12px; font-weight: 750; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.user-dropdown { position: relative; }
.user-dropdown summary { display: flex; align-items: center; gap: 9px; padding: 4px 5px; border-radius: 10px; cursor: pointer; list-style: none; }
.user-dropdown summary::-webkit-details-marker { display: none; }
.user-dropdown summary:hover { background: #f1f5f9; }
.user-avatar { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 50%; background: #eaf1ff; color: #1d4ed8; font-size: 12px; font-weight: 900; }
.user-copy { display: grid; min-width: 0; line-height: 1.2; }
.user-copy strong { max-width: 170px; overflow: hidden; color: var(--text-strong); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.user-dropdown-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 230px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.user-dropdown-name { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.user-dropdown-menu a { display: block; padding: 11px 14px; color: var(--danger); font-size: 12px; font-weight: 750; }
.user-dropdown-menu a:hover { background: #fef2f2; }

.container { width: min(1540px, calc(100% - clamp(24px, 4vw, 64px))); margin: 24px auto 48px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-eyebrow { display: block; margin-bottom: 4px; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
h1, h2, h3, h4 { margin-top: 0; color: var(--text-strong); line-height: 1.22; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 2.4vw, 2.15rem); letter-spacing: -.035em; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }
p { margin-top: 0; }

.card, .panel {
    min-width: 0;
    margin-bottom: 18px;
    padding: clamp(16px, 2vw, 22px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.card > :last-child, .panel > :last-child { margin-bottom: 0; }
.card-header, .section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.metric strong { display: block; margin-top: 7px; color: var(--text-strong); font-size: clamp(1.65rem, 2.5vw, 2.1rem); letter-spacing: -.035em; }
.metric span, .muted { color: var(--muted); }

.actions, .row-actions, .bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions { margin-bottom: 16px; }
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-group { min-width: 0; margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; color: #334155; font-size: 12px; font-weight: 800; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #9fb0c5; }
input:focus, select:focus, textarea:focus { border-color: #5b8def; box-shadow: var(--focus); outline: none; }
input[type="checkbox"], input[type="radio"] { width: 16px; min-height: 16px; accent-color: var(--primary); }
input[disabled], select[disabled], textarea[disabled] { cursor: not-allowed; background: #f1f5f9; color: #94a3b8; }
textarea { min-height: 96px; resize: vertical; }

button, .button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
button:hover, .button:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
button:active, .button:active { transform: translateY(0); }
button[disabled], .button[aria-disabled="true"] { cursor: not-allowed; opacity: .55; transform: none; }
.button.secondary, button.secondary { border-color: #475569; background: #475569; }
.button.outline, button.outline { border-color: var(--border-strong); background: #fff; color: #334155; }
.button.outline:hover, button.outline:hover { border-color: #94a3b8; background: #f8fafc; color: #0f172a; }
.button.danger, button.danger { background: var(--danger); }
.button.danger:hover, button.danger:hover { background: var(--danger-dark); }
.button.warning-button, button.warning-button { background: #b45309; }
.button.small, button.small { min-height: 32px; padding: 5px 9px; border-radius: 7px; font-size: 11px; }
form[aria-busy="true"] button[type="submit"] { cursor: wait; opacity: .68; }

.table-wrap { width: 100%; max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.table-wrap > table { border: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; font-size: 12px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { position: sticky; z-index: 2; top: 0; background: #f8fafc; color: #475569; font-size: 10px; font-weight: 850; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }
td { color: #334155; }
td strong { color: var(--text-strong); }
td code { word-break: break-all; }
.table-wrap:focus-within { box-shadow: var(--focus); }
.checkbox-column { width: 42px; text-align: center; }
.empty-result, .empty-state { padding: 34px 18px !important; color: var(--muted); text-align: center; }

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge.success { background: #ecfdf3; color: var(--success); }
.badge.warning { background: #fffbeb; color: var(--warning); }
.badge.danger { background: #fef2f2; color: var(--danger); }
.badge.info { background: #eff6ff; color: #1d4ed8; }
.badge.neutral { background: #f1f5f9; color: #475569; }

.alert { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 12px 42px 12px 14px; border: 1px solid; border-radius: 11px; box-shadow: var(--shadow-sm); }
.alert.success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.alert.error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.alert.warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.alert-close { position: absolute; top: 7px; right: 7px; width: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; color: currentColor; font-size: 19px; opacity: .65; }
.alert-close:hover { background: rgba(15,23,42,.06); color: currentColor; transform: none; }

.token-box { overflow-wrap: anywhere; padding: 14px; border-radius: 9px; background: #0f172a; color: #fff; font-size: 12px; }
.help { color: var(--muted); font-size: 11px; line-height: 1.55; }
details { border-radius: 9px; }
summary { cursor: pointer; }

.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #dbeafe 0, transparent 34%), var(--bg); }
.login-card { width: min(430px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 18px 55px rgba(15,23,42,.13); }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px clamp(16px, 2.2vw, 32px) 28px; color: var(--muted); font-size: 10px; }

.pagination, .pf-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 16px; }
.pagination a, .pagination span, .pf-pagination a, .pf-pagination span { display: inline-flex; min-width: 34px; min-height: 34px; align-items: center; justify-content: center; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #334155; font-size: 11px; font-weight: 750; }
.pagination .active, .pf-pagination .active { border-color: var(--primary); background: var(--primary); color: #fff; }

.health-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.health-card { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.health-card span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.health-card strong { display: block; margin-top: 8px; color: var(--text-strong); font-size: 1.45rem; line-height: 1.1; }
.status-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.status-line:last-child { border-bottom: 0; }
.status-copy { min-width: 0; }
.status-copy strong { display: block; color: var(--text-strong); font-size: 12px; }
.status-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }

.sidebar-backdrop { position: fixed; z-index: 950; inset: 0; background: rgba(15,23,42,.58); backdrop-filter: blur(2px); }

@media (max-width: 1250px) {
    .grid, .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
    .app-sidebar { transform: translateX(-105%); transition: transform .22s ease; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-workspace { margin-left: 0; }
    .menu-button, .sidebar-close { display: inline-flex; }
    .container { width: min(100% - 28px, 1540px); margin-top: 18px; }
    .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
    :root { --header-height: 62px; }
    .app-header { padding-inline: 12px; }
    .header-health span:last-child, .user-copy { display: none; }
    .user-dropdown-menu { right: -3px; }
    .container { width: min(100% - 20px, 1540px); margin-bottom: 30px; }
    .page-title { margin-bottom: 14px; }
    .page-eyebrow { display: none; }
    h1 { font-size: 1.45rem; }
    .grid, .health-grid, .form-grid { grid-template-columns: 1fr; }
    .card, .panel { padding: 14px; border-radius: 14px; }
    .actions > *, .row-actions > * { flex: 1 1 auto; }
    .footer { flex-direction: column; align-items: flex-start; }
    table { min-width: 720px; }
}

@media (max-width: 480px) {
    .header-title span { display: none; }
    .header-title strong { margin: 0; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .health-grid { gap: 10px; }
    button, .button { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

@media print {
    .app-sidebar, .app-header, .footer, .actions, button { display: none !important; }
    .app-workspace { margin: 0; }
    .container { width: 100%; margin: 0; }
    .card, .panel { box-shadow: none; break-inside: avoid; }
}
