:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    color: #17212b;
    background: #f2f5f7;
    font-synthesis: none;
    --ink: #17212b;
    --muted: #64717d;
    --line: #dce2e7;
    --line-strong: #c8d1d9;
    --surface: #ffffff;
    --surface-subtle: #f7f9fa;
    --canvas: #f2f5f7;
    --nav: #0d1b27;
    --nav-soft: #152838;
    --accent: #087f76;
    --accent-strong: #06675f;
    --accent-soft: #e5f5f2;
    --success: #177245;
    --success-soft: #e8f5ed;
    --warning: #9a6500;
    --warning-soft: #fff3d8;
    --danger: #b33b32;
    --danger-soft: #fdecea;
    --shadow: 0 1px 2px rgb(13 27 39 / 5%), 0 8px 24px rgb(13 27 39 / 5%);
}

* { box-sizing: border-box; }
html { min-width: 20rem; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: rgb(8 127 118 / 16%); }
a { color: var(--accent-strong); text-underline-offset: .16em; }
a:hover { color: #034f49; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, iframe:focus-visible {
    outline: 3px solid rgb(18 151 143 / 35%);
    outline-offset: 2px;
}
h1, h2, h3 { color: var(--ink); text-wrap: balance; }
h1 { margin: 0; font-size: clamp(1.65rem, 2vw, 2.15rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; letter-spacing: -.01em; }
h3 { margin: 0; font-size: .92rem; }
p { line-height: 1.55; }
code { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
time, .numeric { font-variant-numeric: tabular-nums; }
[id] { scroll-margin-top: 5rem; }

.skip-link {
    position: fixed;
    z-index: 100;
    top: .75rem;
    left: .75rem;
    transform: translateY(-180%);
    padding: .65rem .85rem;
    border-radius: .35rem;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    transition: transform 140ms ease;
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem 1rem;
    overflow-y: auto;
    background: var(--nav);
    color: #d9e3e9;
}
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding: .25rem .35rem 1.3rem;
    color: #fff;
    text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
    width: 2.15rem;
    height: 2.15rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgb(255 255 255 / 18%);
    border-radius: .45rem;
    background: #15998f;
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
}
.brand-copy { min-width: 0; }
.brand-name { display: block; font-size: 1rem; font-weight: 750; letter-spacing: -.01em; }
.brand-subtitle { display: block; margin-top: .1rem; color: #8fa4b2; font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; }
.nav-label { margin: .8rem .75rem .45rem; color: #708796; font-size: .66rem; font-weight: 750; text-transform: uppercase; letter-spacing: .13em; }
.side-nav { display: grid; gap: .18rem; }
.nav-item {
    min-height: 2.65rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .75rem;
    border-radius: .4rem;
    color: #afbec8;
    font-size: .88rem;
    font-weight: 620;
    text-decoration: none;
    transition: color 140ms ease, background-color 140ms ease;
}
.nav-item:hover { color: #fff; background: rgb(255 255 255 / 6%); }
.nav-item.is-active { color: #fff; background: var(--nav-soft); box-shadow: inset 3px 0 #22b4a9; }
.nav-icon { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; }
.sidebar-footer { margin-top: auto; padding-top: 1.25rem; }
.session-card { padding: .85rem; border-top: 1px solid rgb(255 255 255 / 9%); }
.session-label { color: #6f8796; font-size: .66rem; text-transform: uppercase; letter-spacing: .11em; }
.session-user { display: block; margin-top: .2rem; color: #f3f7f9; font-size: .88rem; font-weight: 680; overflow-wrap: anywhere; }
.session-role { color: #8fa4b2; font-size: .74rem; }
.signout-form { margin: .7rem 0 0; }
.signout-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 2.35rem;
    border: 1px solid rgb(255 255 255 / 13%);
    border-radius: .35rem;
    background: transparent;
    color: #b9c7cf;
    cursor: pointer;
}
.signout-button:hover { border-color: rgb(255 255 255 / 26%); color: #fff; background: rgb(255 255 255 / 5%); }

.app-main { min-width: 0; }
.topbar {
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem clamp(1.25rem, 3vw, 2.6rem);
    border-bottom: 1px solid var(--line);
    background: rgb(255 255 255 / 88%);
    backdrop-filter: blur(12px);
}
.topbar-context { min-width: 0; }
.topbar-label { color: #87939d; font-size: .66rem; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.topbar-title { margin-top: .12rem; font-size: .9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.secure-status { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.secure-dot { width: .45rem; height: .45rem; border-radius: 50%; background: #23a86b; box-shadow: 0 0 0 4px rgb(35 168 107 / 12%); }
.content { width: 100%; max-width: 104rem; margin: 0 auto; padding: 2rem clamp(1.25rem, 3vw, 2.6rem) 3rem; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.4rem; }
.page-heading { min-width: 0; }
.eyebrow { margin: 0 0 .4rem; color: var(--accent); font-size: .69rem; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.page-description { max-width: 48rem; margin: .5rem 0 0; color: var(--muted); font-size: .9rem; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: .55rem; flex-wrap: wrap; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-card { min-width: 0; padding: 1rem 1.05rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); box-shadow: 0 1px 2px rgb(13 27 39 / 3%); }
.stat-label { display: block; color: var(--muted); font-size: .69rem; font-weight: 720; text-transform: uppercase; letter-spacing: .09em; }
.stat-value { display: block; margin-top: .28rem; color: var(--ink); font-size: 1.45rem; line-height: 1.1; font-weight: 760; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-note { display: block; margin-top: .32rem; color: #84909a; font-size: .72rem; }

.panel { margin-bottom: 1rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.panel-header p { margin: .25rem 0 0; color: var(--muted); font-size: .8rem; }
.panel-body { padding: 1.15rem; }
.panel-flat { box-shadow: none; }
.narrow { max-width: 33rem; margin-inline: auto; }
.split-grid { display: grid; grid-template-columns: minmax(18rem, .72fr) minmax(0, 1.28fr); gap: 1rem; align-items: start; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(18rem, .6fr); gap: 1rem; align-items: start; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
label, .field-label { display: block; margin-bottom: .38rem; color: #34414c; font-size: .78rem; font-weight: 700; }
input, select {
    width: 100%;
    min-height: 2.7rem;
    padding: .62rem .72rem;
    border: 1px solid var(--line-strong);
    border-radius: .38rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:hover, select:hover { border-color: #aab7c1; }
input:focus-visible, select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(8 127 118 / 11%); }
input::placeholder { color: #96a1aa; }
.field-hint { display: block; margin-top: .32rem; color: #83909a; font-size: .72rem; line-height: 1.4; }
.form-actions { display: flex; align-items: center; gap: .55rem; margin-top: 1rem; }

button, .button {
    min-height: 2.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .58rem .9rem;
    border: 1px solid transparent;
    border-radius: .38rem;
    background: var(--accent);
    color: #fff;
    font-size: .8rem;
    font-weight: 720;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 100ms ease;
}
button:hover, .button:hover { background: var(--accent-strong); color: #fff; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .65; }
.button-secondary { border-color: var(--line-strong); background: #fff; color: #34414c; }
.button-secondary:hover { border-color: #96a5b0; background: #f5f7f8; color: var(--ink); }
.button-quiet { min-height: 2rem; padding: .38rem .62rem; border-color: var(--line); background: #fff; color: #42515d; font-size: .74rem; }
.button-quiet:hover { border-color: #9eabb5; background: var(--surface-subtle); color: var(--ink); }
button.danger, .button-danger { border-color: #efc3bf; background: #fff; color: var(--danger); }
button.danger:hover, .button-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.button-icon { width: 1rem; height: 1rem; stroke: currentColor; fill: none; stroke-width: 1.8; }
.inline-form { display: inline-flex; margin: 0; }
.inline-form button { margin: 0; }

.search-panel { padding: .85rem; }
.toolbar { display: flex; align-items: flex-end; gap: .6rem; margin: 0; }
.toolbar .search-field { position: relative; flex: 1 1 28rem; min-width: 0; }
.toolbar .search-field input { padding-left: 2.45rem; }
.search-icon { position: absolute; left: .8rem; bottom: .78rem; width: 1rem; height: 1rem; color: #788691; pointer-events: none; }

.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow: auto; overscroll-behavior: contain; }
table { width: 100%; min-width: 48rem; border-collapse: separate; border-spacing: 0; font-size: .8rem; }
th, td { padding: .72rem .85rem; border-bottom: 1px solid #e7ebee; text-align: left; vertical-align: middle; }
th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9fa;
    color: #5f6d78;
    font-size: .67rem;
    font-weight: 780;
    text-transform: uppercase;
    letter-spacing: .075em;
    white-space: nowrap;
}
tbody tr { background: #fff; }
tbody tr:hover { background: #f8fbfb; }
tbody tr:last-child td { border-bottom: 0; }
.primary-cell { max-width: 24rem; }
.cell-title { display: block; color: var(--ink); font-weight: 690; overflow-wrap: anywhere; }
.cell-title a { color: inherit; text-decoration-color: #a7c8c5; }
.cell-meta { display: block; margin-top: .18rem; color: #7b8892; font-size: .7rem; overflow-wrap: anywhere; }
.mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: .74rem; }
.empty-state { padding: 3.25rem 1.5rem !important; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: .3rem; color: var(--ink); font-size: .9rem; }
.empty-state span { font-size: .78rem; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .8rem 1rem; border-top: 1px solid var(--line); background: var(--surface); }
.pager > :last-child { justify-self: end; }
.pager-summary { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.pager-link { display: inline-flex; align-items: center; gap: .35rem; font-size: .77rem; font-weight: 700; text-decoration: none; }

.badge { display: inline-flex; align-items: center; gap: .35rem; min-height: 1.55rem; padding: .2rem .48rem; border-radius: 999px; background: #edf1f3; color: #4e5c67; font-size: .66rem; font-weight: 760; letter-spacing: .02em; white-space: nowrap; }
.badge::before { content: ""; width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--accent-soft); color: var(--accent-strong); }
.badge-neutral::before { display: none; }

.notice { display: flex; gap: .75rem; padding: .85rem 1rem; border: 1px solid #efd798; border-radius: .42rem; background: var(--warning-soft); color: #704c08; overflow-wrap: anywhere; }
.notice strong { color: #5d3e00; }
.notice-success { border-color: #b9dfca; background: var(--success-soft); color: #185d3c; }
.notice-danger { border-color: #edc2bd; background: var(--danger-soft); color: #872b24; }
.notice-content { min-width: 0; flex: 1; }
.notice-title { display: block; margin-bottom: .18rem; font-size: .79rem; font-weight: 760; }
.notice-copy { margin: 0; font-size: .76rem; line-height: 1.5; }
.token-value { display: block; margin-top: .65rem; padding: .75rem; border: 1px solid #b9dfca; border-radius: .35rem; background: #fff; color: #214236; font-size: .75rem; user-select: all; }
.validation, .error { display: block; margin-top: .3rem; color: var(--danger); font-size: .74rem; font-weight: 650; }
.validation-summary-valid { display: none; }
.validation-summary-errors { margin-bottom: 1rem; padding: .75rem .9rem; border: 1px solid #edc2bd; border-radius: .4rem; background: var(--danger-soft); }
.validation-summary-errors ul { margin: 0; padding-left: 1.2rem; }
.muted { color: var(--muted); }
.space-top { margin-top: 1rem; }

.metadata-list { display: grid; grid-template-columns: minmax(8rem, 11rem) minmax(0, 1fr); margin: 0; }
.metadata-list dt, .metadata-list dd { margin: 0; padding: .62rem 0; border-bottom: 1px solid #e8ecef; }
.metadata-list dt { color: #6b7882; font-size: .72rem; font-weight: 680; }
.metadata-list dd { color: var(--ink); font-size: .8rem; overflow-wrap: anywhere; }
.metadata-list dt:last-of-type, .metadata-list dd:last-of-type { border-bottom: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.mini-stat { padding: .75rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--surface-subtle); }
.mini-stat span { display: block; color: var(--muted); font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.mini-stat strong { display: block; margin-top: .2rem; font-size: .95rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hash-block { display: block; padding: .65rem; border-radius: .35rem; background: #f2f5f6; color: #34414c; font-size: .68rem; }
.preview-panel { overflow: hidden; }
.pdf { display: block; width: 100%; height: min(72vh, 58rem); min-height: 34rem; border: 0; background: #e7ebee; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .85rem; color: var(--muted); font-size: .75rem; font-weight: 680; text-decoration: none; }
.back-link:hover { color: var(--ink); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--nav); }
.auth-main { width: 100%; }
.login-card { width: min(58rem, 100%); display: grid; grid-template-columns: .9fr 1.1fr; margin: 0 auto; overflow: hidden; border: 1px solid rgb(255 255 255 / 12%); border-radius: .75rem; background: #fff; box-shadow: 0 28px 80px rgb(0 0 0 / 28%); }
.login-context { position: relative; padding: 2.6rem; overflow: hidden; background: #122c3b; color: #dce7ec; }
.login-context::after { content: ""; position: absolute; right: -5rem; bottom: -5rem; width: 13rem; height: 13rem; border: 1px solid rgb(59 190 178 / 30%); border-radius: 50%; box-shadow: 0 0 0 2.5rem rgb(59 190 178 / 5%), 0 0 0 5rem rgb(59 190 178 / 4%); }
.login-context .brand-mark { margin-bottom: 2rem; }
.login-context h1 { color: #fff; font-size: 1.85rem; }
.login-context p { max-width: 23rem; color: #9eb1bc; font-size: .84rem; }
.login-feature { display: flex; align-items: center; gap: .55rem; margin-top: 1.6rem; color: #c9d7de; font-size: .75rem; }
.login-feature::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: #31b8ac; box-shadow: 0 0 0 4px rgb(49 184 172 / 12%); }
.login-form { padding: 2.6rem; }
.login-form .eyebrow { margin-bottom: .55rem; }
.login-form h2 { font-size: 1.5rem; letter-spacing: -.03em; }
.login-form > p { margin: .45rem 0 1.5rem; color: var(--muted); font-size: .8rem; }
.login-form .field { margin-bottom: .9rem; }
.login-form button { width: 100%; margin-top: .35rem; }
.login-footnote { margin: 1rem 0 0 !important; color: #87939d !important; font-size: .68rem !important; text-align: center; }
.message-card { max-width: 36rem; margin: 10vh auto; padding: 2rem; text-align: center; }
.message-code { display: inline-block; margin-bottom: .8rem; color: var(--accent); font-size: .7rem; font-weight: 800; letter-spacing: .13em; }
.message-card p { color: var(--muted); font-size: .85rem; }

@media (max-width: 1080px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { position: static; height: auto; padding: .75rem; overflow: visible; }
    .brand { padding: .15rem .25rem .75rem; }
    .brand-subtitle, .nav-label { display: none; }
    .side-nav { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; overscroll-behavior-inline: contain; }
    .nav-item { flex: 0 0 auto; min-height: 2.35rem; padding: .55rem .7rem; }
    .nav-item.is-active { box-shadow: inset 0 -2px #22b4a9; }
    .sidebar-footer { position: absolute; top: .75rem; right: .75rem; margin: 0; padding: 0; }
    .session-card { padding: 0; border: 0; }
    .session-label, .session-role, .session-user { display: none; }
    .signout-form { margin: 0; }
    .signout-button { width: auto; min-height: 2.15rem; padding: .45rem .65rem; font-size: .72rem; }
    .topbar { display: none; }
    .content { padding-top: 1.4rem; }
}

@media (max-width: 620px) {
    .content { padding-inline: .85rem; }
    .page-header { display: block; }
    .page-actions { justify-content: flex-start; margin-top: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: .85rem; }
    .stat-value { font-size: 1.2rem; }
    .form-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar .search-field { flex-basis: auto; }
    .toolbar button { width: 100%; }
    .pager { grid-template-columns: 1fr 1fr; }
    .pager-summary { grid-column: 1 / -1; grid-row: 1; text-align: center; }
    .metadata-list { grid-template-columns: 1fr; }
    .metadata-list dt { padding-bottom: .15rem; border-bottom: 0; }
    .metadata-list dd { padding-top: 0; }
    .mini-stats { grid-template-columns: 1fr 1fr; }
    .pdf { min-height: 28rem; }
    .login-card { display: block; }
    .login-context { padding: 1.7rem; }
    .login-context p, .login-feature { display: none; }
    .login-context .brand-mark { margin-bottom: 1rem; }
    .login-context h1 { font-size: 1.35rem; }
    .login-form { padding: 1.7rem; }
}

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