:root {
    color-scheme: light dark;
    --ink: light-dark(#17283c, #e8eef8);
    --muted: light-dark(#52647b, #afbed4);
    --edge: light-dark(#dfe7f0, #34445d);
    --canvas: light-dark(#f3f6fa, #0d1626);
    --surface: light-dark(#fff, #172338);
    --surface-soft: light-dark(#eff4fa, #202f46);
    --link: light-dark(#1554c0, #a9c9ff);
    --accent: #1554c0;
    --accent-soft: light-dark(#eaf2ff, #263d64);
    --night: #111d31;
    --radius: 16px;
    --shadow: 0 2px 5px #162c4910;
    font: 15px/1.55 "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    padding: .57rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
button:hover, .button:hover { filter: brightness(.94); text-decoration: none; }
button:disabled { opacity: .6; cursor: wait; }
.secondary { color: var(--link); background: var(--surface-soft); border-color: var(--edge); }
.danger { background: #a12d42; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 10; border-radius: 8px; padding: .65rem 1rem; background: var(--surface); }
.skip-link:focus { top: 1rem; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 27px 16px 16px;
    background: var(--night);
    color: #fff;
}
.brand { display: flex; align-items: center; gap: 11px; padding-inline: 5px; font-size: 21px; letter-spacing: -.045em; }
.logo {
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: #377cf4;
    color: #fff;
    border-radius: 12px;
    font-weight: 800;
}
.sidebar-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.menu-toggle { display: none; }
nav {
    display: grid;
    align-content: start;
    min-height: 0;
    gap: 5px;
    margin-top: 33px;
    padding: 4px 5px 7px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: #6884ad #192940;
}
nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #c7d4e6;
}
nav a:hover, nav a.selected { color: #fff; background: #233756; text-decoration: none; }
nav a.selected { border-color: #365681; box-shadow: inset 3px 0 #71a5ff; }
nav i { width: 19px; color: #a8c7fe; text-align: center; font-style: normal; font-size: 17px; }
.session { flex-shrink: 0; margin-top: auto; padding: 13px 6px 0; display: flex; align-items: flex-start; gap: 9px; border-top: 1px solid #334157; overflow-wrap: anywhere; }
.session small { color: #d4dfef; font-size: 12px; }
.account-bar { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.account-bar form { margin: 0; }
.account-bar button { background: var(--surface); }
.theme-toggle[aria-pressed="true"] { border-color: var(--link); }
.avatar { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #304b73; font-weight: 700; }
.content { width: 100%; max-width: 1530px; margin-inline: auto; padding: 38px clamp(22px, 4vw, 64px) 64px; }
.page-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.page-toolbar .page-head { margin: 0; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 45px); line-height: 1.08; letter-spacing: -.055em; }
.page-head p { margin: .48rem 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric, .panel, .login { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric { display: grid; justify-items: start; align-content: start; gap: 5px; min-height: 128px; padding: 14px 17px; }
.metric-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--link); background: var(--accent-soft); font-size: 17px; }
.metric:nth-child(3n + 2) .metric-icon { background: light-dark(#e6f6ef, #1f433c); color: light-dark(#12634e, #a0e4cb); }
.metric:nth-child(3n) .metric-icon { background: light-dark(#f0eafa, #392d52); color: light-dark(#633eb1, #dbc2ff); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric strong { line-height: 1.12; font-size: clamp(20px, 3vw, 29px); letter-spacing: -.04em; overflow-wrap: anywhere; }
.panel { padding: 19px 21px; margin-bottom: 15px; overflow-wrap: anywhere; }
.dashboard-grid, .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.overview-panels { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.table { padding: 0; overflow-x: auto; }
.row, .actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.actions { justify-content: flex-start; }
.panel-heading { margin-bottom: 8px; }
.panel-heading h2 { margin: 0; }
.panel-heading a { font-size: 13px; font-weight: 650; }
small { display: block; color: var(--muted); margin-block: .2rem; }
.badge { display: inline-block; border-radius: 30px; padding: 3px 9px; background: light-dark(#e8f4ed, #1d4037); color: light-dark(#1a6044, #a0e4cb); font-size: 12px; font-weight: 650; }
.badge.muted { color: var(--muted); background: var(--surface-soft); }
form { margin: .65rem 0; }
label { display: grid; gap: 5px; margin: 6px 0 12px; font-weight: 600; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid light-dark(#c5d2e2, #465977); border-radius: 9px; padding: 9px 10px; background: light-dark(#fbfcfe, #101c30); color: inherit; font: inherit; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 9px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }
summary { cursor: pointer; font-weight: 700; }
details[open] > summary { margin-bottom: .65rem; }
h2 { margin: 0 0 .5rem; font-size: 19px; letter-spacing: -.025em; }
h3 { font-size: 16px; }
p { margin: .45rem 0 .8rem; }
.line { border-top: 1px solid var(--edge); padding: 12px 0; }
.result, .alert, .success, .empty { padding: 12px 14px; border-radius: 10px; background: var(--surface-soft); margin: .65rem 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); }
.result:empty { display: none; }
.alert { background: light-dark(#fdeef0, #4c2532); color: light-dark(#79283a, #ffc5d0); }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 12px 0; color: var(--muted); font-size: 13px; }
.page-links { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.page-links a, .page-links span { min-width: 36px; min-height: 38px; display: inline-grid; place-items: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 8px; }
.page-links a { border-color: var(--edge); background: var(--surface); }
.page-links .page-current { background: var(--accent); color: #fff; font-weight: 700; }
.success { background: light-dark(#e7f8ef, #1d4037); color: light-dark(#175b42, #a0e4cb); }
table { border-collapse: collapse; width: 100%; min-width: 480px; }
th, td { text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--edge); }
th { color: var(--muted); background: var(--surface-soft); font-size: 13px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-soft); }
.auth { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 15% 10%, light-dark(#d9e9ff, #20395f), transparent 64%), var(--canvas); }
.login { width: 100%; max-width: 450px; padding: clamp(23px, 6vw, 42px); }
.login-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 25px; }
.login .brand { padding-inline: 0; }
.login .page-head h1 { font-size: 30px; }
.login form button { width: 100%; margin-top: 6px; }
:focus-visible { outline: 3px solid #3e7df0; outline-offset: 3px; }
@media (max-width: 900px) {
    .shell { grid-template-columns: 190px minmax(0, 1fr); }
    .sidebar { padding-inline: 10px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 690px) {
    .shell { display: block; }
    .sidebar { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 9px; padding: 12px 14px; }
    .sidebar-body { grid-column: 1 / -1; overflow: visible; }
    .menu-ready .menu-toggle { display: inline-flex; background: #263b5c; border-color: #3b5275; }
    .menu-ready .menu-toggle[aria-expanded="false"] + .sidebar-body { display: none; }
    nav { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: min(45dvh, 16rem); margin: 6px 0 12px; }
    nav a { padding: 7px 6px; font-size: 13px; }
    .content { padding: 22px 14px 40px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric { min-height: 112px; padding: 11px 12px; }
    .panel { padding: 15px; }
    .panel.table { padding: 0; }
}
@media (max-width: 420px) {
    .fields { grid-template-columns: 1fr; gap: 3px; }
}
