:root {
    --navy: #0f172a;
    --indigo: #4f46e5;
    --indigo-deep: #4338ca;
    --blue: #2563eb;
    --teal: #0f766e;
    --emerald: #059669;
    --bg: #f8fafc;
    --bg-muted: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-active: #3730a3;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --info: #2563eb;
    --info-bg: #eff6ff;
    --focus: #4f46e5;
    --disabled: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.16);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar: 268px;
    --font: "Plus Jakarta Sans", "Noto Sans Devanagari", "Noto Nastaliq Urdu", "Nirmala UI", "Segoe UI", sans-serif;
    --ink: var(--text);
    --muted: var(--text-muted);
    --maroon: var(--error);
    --gold: var(--indigo);
    --paper: var(--bg);
    --card: var(--surface);
    --line: var(--border);
    --ok: var(--success);
    --bad: var(--error);
    --shadow: var(--shadow-sm);
    --sans: var(--font);
    --serif: var(--font);
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #020617;
    --bg-muted: #1e293b;
    --surface: #0f172a;
    --surface-2: #1e293b;
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-strong: #475569;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-active: #4f46e5;
    --indigo: #6366f1;
    --indigo-deep: #818cf8;
    --success-bg: rgba(22, 163, 74, 0.16);
    --warning-bg: rgba(217, 119, 6, 0.16);
    --error-bg: rgba(220, 38, 38, 0.16);
    --info-bg: rgba(37, 99, 235, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font);
    font-size: 13.5px;
    line-height: 1.6;
    font-weight: 400;
}

h1, h2, h3, .brand strong, .stat b {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
}

h1 { margin: 0; font-size: 18px; font-weight: 700; }
h2 { margin: 22px 0 10px; font-size: 15px; font-weight: 700; }
.main > h2:first-child { margin-top: 0; }
a { color: var(--indigo-deep); text-decoration: none; }
a:hover { color: var(--primary-hover); }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.signin {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 16px 40px;
    background: linear-gradient(165deg, #0f172a 0%, #1e1b4b 55%, #1e3a8a 100%);
}

.signin-stage {
    display: none;
}

.signin-aside {
    width: min(760px, 100%);
    padding: 0 8px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: #f8fafc;
}

.signin-copy { display: flex; flex-direction: column; align-items: center; }
.signin-aside h1 {
    margin: 8px 0 0;
    color: white;
    font-size: 22px;
    font-weight: 700;
}
.signin-aside .kicker { color: #c7d2fe; }
.signin-lead {
    margin: 0 0 8px;
    color: #64748b;
    font-size: 13px;
    text-align: left;
}
.crest {
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border: 0;
    border-radius: 50%;
    display: block;
    object-fit: cover;
    background: transparent;
    box-shadow: none;
}
.kicker, .eyebrow {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1.3;
}
.signin-aside .kicker { color: #c7d2fe; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li {
    margin: 0;
    padding: 10px 0 10px 28px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.45;
    position: relative;
    counter-increment: step;
    text-align: left;
}
.steps { counter-reset: step; }
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 14px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    font-size: 11px;
    display: grid;
    place-items: center;
    color: var(--indigo);
    background: var(--surface);
}
.signin-panel {
    width: min(420px, 100%);
    min-height: 0;
    display: block;
    padding: 0;
    background: transparent;
}
.login-split {
    width: min(420px, 100%);
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.panel .actions { margin-top: 16px; }
.panel .actions button { width: 100%; min-height: 42px; background: #2563eb; border-color: #2563eb; }
.panel .actions button:hover { background: #1d4ed8; }
.panel {
    position: relative;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e6ebf2;
    border-top: 3px solid #2563eb;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
    padding: 22px 22px 18px;
    text-align: left;
}
.login-part {
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}
.login-part:hover {
    transform: translateY(-4px);
    border-color: #93c5fd;
    background: #f8fbff;
    box-shadow: 0 16px 36px rgba(37, 99, 235, 0.16);
}
.panel .crest { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: transparent; }
.panel h1, .panel h2 { margin: 0 0 6px; font-size: 20px; text-align: left; color: #0f172a; }
.login-part .steps { margin-top: 8px; }
html[data-theme="dark"] .signin .panel,
html[data-theme="dark"] .signin input { background-color: #ffffff; color: #0f172a; }
html[data-theme="dark"] .signin label,
html[data-theme="dark"] .signin .signin-lead,
html[data-theme="dark"] .signin .field-note,
html[data-theme="dark"] .signin .steps li { color: #475569; }
.panel label, .panel .field-note, .panel .flash { text-align: left; }
.signin .theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid var(--border);
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    transition: grid-template-columns 200ms ease;
}
.side {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 72px;
}
.brand .crest { width: 44px; height: 44px; margin: 0; flex: none; background: #fff; }
.brand strong { display: block; font-size: 13px; line-height: 1.25; color: var(--text); letter-spacing: -0.02em; }
.brand span { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; line-height: 1.3; font-weight: 500; }
.side nav { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 24px; }
.side nav::-webkit-scrollbar { width: 8px; }
.side nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.nav-group { padding: 12px 0 4px; }
.nav-label {
    margin: 0 10px 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.side a {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 10px;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid transparent;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.side a .ico { width: 18px; height: 18px; flex: none; }
.side a:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.side a.active {
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
}
html[data-theme="dark"] .side a.active { background: rgba(99, 102, 241, 0.18); color: #c7d2fe; }
.workspace { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.top-start, .account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-title { min-width: 0; }
.topbar h1 { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .kicker { margin-bottom: 2px; }
.account { position: relative; flex-shrink: 0; }
.account form { margin: 0; }
.who { display: none; }
.search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-muted);
    color: var(--text-muted);
}
.search input {
    border: 0;
    background: transparent;
    min-height: 38px;
    padding: 0;
    box-shadow: none;
}
.search input:focus { outline: none; box-shadow: none; }
.search:focus-within {
    border-color: var(--indigo);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #0f172a, #4f46e5);
    color: white;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.avatar:hover { text-decoration: none; color: white; filter: brightness(1.08); }
.notice-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 72px;
    width: min(300px, 80vw);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    z-index: 30;
    animation: drop 180ms ease;
}
.notice-pop strong { display: block; margin-bottom: 4px; }
.notice-pop p { margin: 0; color: var(--text-muted); font-size: 13px; }
.main {
    padding: 24px 28px 72px;
    animation: rise 200ms ease;
}

.card, .table-wrap, .warn, .notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.pad { padding: 18px 20px; }
.narrow { max-width: 560px; }
.bill-side { display: grid; grid-template-columns: minmax(0, 210mm) minmax(280px, 360px); gap: 20px; align-items: start; }
.bill-side .bill-sheet { width: 100%; margin: 0; }
.bill-side-form { position: sticky; top: 16px; }
.voucher-form { max-width: none; margin: 0; }
.voucher-form h3 { margin: 0; }
.voucher-fields { display: grid; grid-template-columns: 1fr; gap: 0; }
.voucher-fields .wide { grid-column: auto; }
@media (max-width: 1180px) {
    .bill-side { grid-template-columns: 1fr; }
    .bill-side .bill-sheet { width: min(210mm, 100%); }
    .bill-side-form { position: static; }
}
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 18px;
    padding: 28px 28px 24px;
    border-radius: var(--radius-xl);
    color: white;
    background: linear-gradient(120deg, #0f172a 0%, #312e81 62%, #2563eb 130%);
    box-shadow: var(--shadow-md);
}
.hero h2 { margin: 6px 0 8px; color: white; font-size: 22px; font-weight: 700; }
.hero p { margin: 0; max-width: 54ch; color: #e2e8f0; }
.hero .eyebrow { color: #c7d2fe; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(180px, 240px)); gap: 12px; }
.quick a, .quick-card {
    display: block;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: white;
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}
.quick a:hover, .quick-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
    text-decoration: none;
    color: white;
}
.quick strong { display: block; font-size: 13px; }
.quick span { display: block; margin-top: 3px; color: #e2e8f0; font-size: 12.5px; font-weight: 500; }
.stat {
    display: grid;
    grid-template-columns: 1fr 42px;
    grid-template-rows: auto auto;
    gap: 4px 10px;
    padding: 16px 16px 14px;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.stat::before { content: none; }
.stat::after {
    content: "";
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    align-self: center;
    background: #eef2ff center / 20px no-repeat;
}
.stat b {
    grid-column: 1;
    display: block;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    margin: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat span { grid-column: 1; display: block; color: var(--text-muted); font-size: 12px; line-height: 1.35; font-weight: 500; }
.stat:hover { transform: translateY(-2px); border-color: #c7d2fe; box-shadow: var(--shadow-md); }
html[data-theme="dark"] .stat:hover { border-color: #6366f1; }
.stat-total::after, .stat-in_progress::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%234f46e5' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M4 19V5M4 19h16M8 16v-5M12 16V8M16 16v-3'/%3E%3C/svg%3E"); }
.stat-pending::after, .stat-locked::after { background-color: #fffbeb; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23d97706' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6l4 2'/%3E%3C/svg%3E"); }
.stat-released::after, .stat-opened::after, .stat-downloaded::after { background-color: #eff6ff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%232563eb' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E"); }
.stat-printed::after, .stat-completed::after { background-color: #f0fdf4; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2316a34a' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-muted);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 140ms ease; }
tbody tr:hover td { background: var(--bg); }
.table-wrap { overflow: auto; }

label { display: block; font-size: 12.5px; font-weight: 600; margin: 14px 0 6px; color: var(--text-secondary); line-height: 1.3; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1.4;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg-muted); color: var(--disabled); cursor: not-allowed; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    box-shadow: 0 0 0 1000px var(--surface) inset;
}
textarea { min-height: 120px; line-height: 1.75; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; align-items: end; }
.muted { color: var(--text-muted); font-size: 13px; margin: 6px 0 0; }
td.row-actions .paper-actions,
td.row-actions .paper-actions form {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 0;
    max-width: none;
}
td.row-actions .paper-actions button { width: auto; white-space: nowrap; }
.examiner-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 8px; }
.examiner-picks .check { margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.row > [hidden] { display: none !important; }
.main > form.row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 16px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

button, .button, .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 14px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    cursor: pointer;
    font: 600 13px/1.2 var(--font);
    vertical-align: middle;
    box-shadow: var(--shadow-sm);
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}
button:hover, .button:hover { background: var(--primary-hover); color: white; text-decoration: none; }
button:active, .button:active, .icon-btn:active { transform: scale(0.98); }
button:disabled, .button:disabled, a.button.is-disabled, a.button[aria-disabled="true"] {
    background: var(--disabled);
    border-color: transparent;
    color: white;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}
button.secondary, .button.secondary, button.signout, a.button.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: none;
}
button.secondary:hover, .button.secondary:hover, button.signout:hover {
    background: var(--bg-muted);
    color: var(--text);
    border-color: var(--border-strong);
}
button.secondary:disabled,
button.secondary:disabled:hover {
    background: #e2e8f0;
    color: #64748b;
    border-color: #e2e8f0;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1;
}
html[data-theme="dark"] button.secondary:disabled,
html[data-theme="dark"] button.secondary:disabled:hover {
    background: #334155;
    color: #94a3b8;
    border-color: #334155;
}
button.quiet, .button.quiet {
    width: auto;
    background: transparent;
    color: var(--error);
    border-color: transparent;
    box-shadow: none;
}
button.quiet:hover, .button.quiet:hover { background: var(--error-bg); color: var(--error); }
button.danger, .button.danger { background: var(--error); color: white; border-color: var(--error); }
button.danger:hover, .button.danger:hover { background: #b91c1c; color: white; }
.icon-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    box-shadow: none;
}
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.ico { width: 18px; height: 18px; display: block; }
.icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
button[aria-busy="true"] { color: transparent; position: relative; pointer-events: none; }
button[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: white;
    animation: spin 0.7s linear infinite;
}
h2 { color: var(--text); }
.bill-editor { width: 100%; border-collapse: collapse; }
.bill-editor th, .bill-editor td { padding: 8px 6px; text-align: left; vertical-align: middle; }
.bill-editor input { width: 100%; min-width: 0; }
.bill-money, .bill-summary th { text-align: right; }
.bill-summary { max-width: 320px; margin-left: auto; }
.bill-summary th { font-weight: 600; }
.side-tabs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; margin: 8px 0 18px; }
.side-tab-list { display: flex; flex-direction: column; gap: 8px; }
.side-tab-list button { width: 100%; justify-content: space-between; background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.side-tab-list button span { min-width: 22px; padding: 2px 7px; border-radius: 999px; background: var(--bg-muted); color: var(--text-secondary); font-size: 12px; }
.side-tab-list button[aria-selected="true"] { background: var(--primary); color: white; border-color: transparent; }
.side-tab-list button[aria-selected="true"] span { background: rgba(255, 255, 255, 0.2); color: white; }
.side-tab-panels { min-width: 0; }
.side-tab-panels h2:first-child { margin-top: 0; }
@media (max-width: 800px) {
    .side-tabs { grid-template-columns: 1fr; }
    .side-tab-list { flex-direction: row; }
}
.table-wrap .actions { margin: 8px 0 0; }
td.mark-col { text-align: center; white-space: nowrap; }
td.mark-col input { accent-color: var(--indigo); }
td.row-actions { width: 220px; vertical-align: top; }
.action-stack, td.row-actions form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0;
    max-width: 220px;
}
td.row-actions form .actions { display: contents; }
td.row-actions .check { margin: 0; font-size: 13px; line-height: 1.3; }
td.row-actions .button, td.row-actions button {
    width: 100%;
    min-height: 36px;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0; }
.actions form { margin: 0; display: flex; align-items: center; }
.actions + h2 { margin-top: 8px; }
.grid + .actions, .grid + form { margin-top: 18px; }
form .actions, .card .actions, .panel .actions { margin-top: 18px; margin-bottom: 0; }
.row > .actions { margin: 0; align-self: end; }
.segment { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-muted); border-radius: 12px; }
.segment .button { min-height: 36px; box-shadow: none; }
.segment .button.secondary { background: transparent; border-color: transparent; color: var(--text-secondary); }
.segment .button:not(.secondary) { background: var(--surface); color: var(--indigo-deep); border-color: var(--border); }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 700;
    background: var(--bg-muted);
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.badge-locked, .badge-printed, .badge-completed, .badge-active { background: var(--success-bg); color: var(--success); }
.badge-in_progress, .badge-viewed { background: #eef2ff; color: #4338ca; }
html[data-theme="dark"] .badge-in_progress, html[data-theme="dark"] .badge-viewed { background: rgba(99, 102, 241, 0.18); color: #c7d2fe; }
.badge-released, .badge-press_opened, .badge-downloaded { background: var(--info-bg); color: var(--info); }
.badge-assigned, .badge-ready, .badge-draft, .badge-vc_pending { background: var(--warning-bg); color: var(--warning); }
.badge-submitted { background: var(--info-bg); color: var(--info); }
.badge-processed { background: var(--success-bg); color: var(--success); }
.badge-cancelled, .badge-inactive { background: var(--error-bg); color: var(--error); }
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
}
.flash-ok { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.flash-error { background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 35%, var(--border)); color: var(--error); font-weight: 700; }
.flash-ok::before, .flash-error::before {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: none;
    margin-top: 1px;
    animation: pop 220ms ease;
}
.flash-ok::before { background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat; }
.flash-error::before { background: var(--error) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='M12 8v5M12 17h.01'/%3E%3C/svg%3E") center / 12px no-repeat; }
.secret {
    font-family: Consolas, "Courier New", monospace;
    font-size: 16px;
    letter-spacing: 0.06em;
    background: var(--navy);
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 12px;
}
.mode-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 20px; }
.mode-choice .check {
    margin: 0;
    align-items: flex-start;
    min-height: 0;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.mode-choice .check:hover { border-color: #c7d2fe; transform: translateY(-2px); }
.mode-choice .check:has(input:checked) { border-color: var(--indigo); box-shadow: inset 0 0 0 1px var(--indigo); }
.mode-choice .check input { width: 18px; height: 18px; min-height: 18px; margin-top: 3px; accent-color: var(--indigo); }
.mode-choice strong { display: block; font-size: 14px; color: var(--text); }
.mode-choice small { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 500; line-height: 1.45; color: var(--text-muted); }
[data-for-mode][hidden] { display: none !important; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-weight: 500; }
.field-note { margin: -2px 0 10px; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.scheme-note {
    margin: 16px 0 2px;
    padding: 10px 14px;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    background: var(--warning-bg);
    color: #b45309;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}
[data-scheme-field].is-missing label { color: #b45309; }
[data-scheme-field].is-missing select {
    border: 1px solid #d97706;
    background: #fff7ed;
    outline: 3px solid #f59e0b;
    outline-offset: 1px;
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.28);
}
.paper-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; width: 100%; margin-top: 12px; }
.paper-picks .check { margin: 0; align-items: flex-start; }
.paper-picks .check:has(input:disabled) { color: inherit; }
.paper-picks input:disabled { opacity: 1; }
.apply-papers { border: 1px solid var(--border); border-radius: 14px; margin: 16px 0 4px; padding: 12px 16px 16px; }
.apply-papers legend { padding: 0 6px; font-weight: 700; }
.scope-row { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.scope-row .check { margin: 0; }
.check input, input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; padding: 0; accent-color: var(--indigo); }
.question {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-top: 14px;
    background: var(--bg);
}
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.q-head label, .q-num { margin: 0; font-size: 14px; font-weight: 800; color: var(--text); }
.q-count { margin-top: 6px; text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.question textarea:focus { background: var(--surface); }
.question .check {
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    align-items: center;
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.question .check:hover { border-color: #c7d2fe; background: #f8faff; }
html[data-theme="dark"] .question .check:hover { background: #1e293b; border-color: #6366f1; }
.question .check:has(input:checked) { border-color: var(--indigo); background: #eef2ff; box-shadow: inset 0 0 0 1px var(--indigo); }
html[data-theme="dark"] .question .check:has(input:checked) { background: rgba(99, 102, 241, 0.16); }
.question .check:has(input:disabled) { opacity: 0.55; }
.question .check input[type="radio"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    display: grid;
    place-items: center;
    background: var(--surface);
    transition: border-color 160ms ease, background-color 160ms ease;
}
.question .check input[type="radio"]::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    transform: scale(0);
    transition: transform 160ms ease;
}
.question .check input[type="radio"]:checked { border-color: var(--indigo); background: var(--indigo); }
.question .check input[type="radio"]:checked::after { transform: scale(1); }
.question .check input[type="radio"]:focus-visible { outline-offset: 3px; }
.question .check input:not([type="radio"]):not([type="checkbox"]) { flex: 1; width: auto; min-height: 38px; }
.timeline { list-style: none; padding: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--indigo); margin-left: 6px; }
.timeline li.pass { color: var(--success); border-left-color: var(--success); font-weight: 600; }
.timeline li.fail { color: var(--error); border-left-color: var(--error); font-weight: 600; }
.timeline li.fail .issue { display: block; margin-top: 2px; font-weight: 500; font-size: 13px; line-height: 1.45; }
.validate-status.pass { color: var(--success); }
.validate-status.fail { color: var(--error); }
.log { margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.log summary { cursor: pointer; font-weight: 700; font-size: 14px; width: fit-content; }
.log summary:hover { color: var(--indigo-deep); }
.log .timeline { margin-top: 10px; }
.progress { display: flex; flex-wrap: nowrap; list-style: none; padding: 8px 0 4px; margin: 8px 0 18px; gap: 4px; }
.progress li { position: relative; flex: 1 1 0; min-width: 0; text-align: center; padding: 26px 2px 0; }
.progress li::before { content: ""; position: absolute; top: 7px; left: -50%; right: 50%; height: 3px; background: var(--border); border-radius: 99px; transition: background-color 200ms ease; }
.progress li:first-child::before { display: none; }
.progress li.done::before { background: var(--indigo); }
.progress .dot { position: absolute; top: 0; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); box-sizing: border-box; transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease; }
.progress li.done .dot { background: var(--indigo); border-color: var(--indigo); }
.progress li.current .dot { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18); }
.progress strong { display: block; font-size: 12px; line-height: 1.3; }
.progress small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; line-height: 1.3; }
.progress li:not(.done) strong, .progress li:not(.done) small { color: var(--text-muted); }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a { padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.pager .current { background: var(--navy); color: white; border-color: var(--navy); }
.menu-toggle, .collapse-toggle { display: inline-flex; }
.collapse-toggle { display: inline-flex; }
.warn, .notice { border-color: #fde68a; background: var(--warning-bg); padding: 16px 18px; box-shadow: none; line-height: 1.65; }
.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-color: #bfdbfe;
    background: var(--info-bg);
    color: var(--text);
}
.notice .ico { width: 20px; height: 20px; margin-top: 2px; color: var(--info); flex: none; }
.notice h2 { margin: 0 0 6px; font-size: 13px; }
.notice p { margin: 0; }
.notice.payment-note {
    margin: 0 0 14px;
    border-color: color-mix(in srgb, var(--success) 40%, var(--border));
    background: var(--success-bg);
    color: var(--success);
}
.notice.payment-note h2 { margin: 0 0 6px; font-size: 14px; color: var(--success); }
.notice.payment-note p { color: var(--success); }
.member-list { display: grid; gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.member-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px 16px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}
.member-list .member-id { flex: 1 1 220px; min-width: 220px; }
.member-list strong { display: block; }
.member-list span { color: var(--text-muted); font-size: 12.5px; }
.member-list .actions { margin: 0; }
.under-press { margin: 6px 0 0; padding-left: 18px; color: var(--text-secondary); }
.under-press span { color: var(--text-muted); }
.gate { display: grid; gap: 14px; margin-top: 16px; }
.gate h2 { margin: 0 0 8px; font-size: 15px; }
.gate p { margin: 0 0 10px; color: var(--text-secondary); }
.hand-preview {
    display: block;
    width: min(100%, 420px);
    height: auto;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
}
object.hand-preview { height: 480px; }
.paper-meta {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 22px 22px 18px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 8px;
}
.paper-meta h2 { margin: 4px 0 0; font-size: 20px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 0; }
.meta-grid div { background: var(--bg-muted); border-radius: 12px; padding: 10px 12px; }
.meta-grid dt { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.meta-grid dd { margin: 4px 0 0; font-weight: 700; color: var(--text); }
[data-save-state] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
[data-save-state]::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
[data-save-state].is-saved::before { background: var(--success); }
[data-save-state].is-error::before { background: var(--error); }
.dock { display: none; }
.nav-backdrop { display: none; }
fieldset.question { background: var(--surface); }

@media (min-width: 901px) {
    .menu-toggle { display: none; }
    html.nav-collapsed .shell { grid-template-columns: 84px 1fr; }
    html.nav-collapsed .brand { justify-content: center; padding-inline: 10px; }
    html.nav-collapsed .brand-copy,
    html.nav-collapsed .nav-label,
    html.nav-collapsed .side a span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    html.nav-collapsed .side a { justify-content: center; }
}

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

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .signin { padding: 36px 16px 28px; }
    .login-split { grid-template-columns: 1fr; }
    .side {
        display: flex;
        position: fixed;
        z-index: 40;
        width: min(300px, 88vw);
        transform: translateX(-105%);
        transition: transform 200ms ease;
        box-shadow: var(--shadow-lg);
    }
    .side.open { transform: none; }
    .nav-backdrop.show { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(2, 6, 23, 0.46); }
    .collapse-toggle { display: none; }
    .main, .topbar { padding-left: 16px; padding-right: 16px; }
    .main { padding-bottom: 96px; }
    .topbar { flex-wrap: wrap; }
    .search { order: 3; max-width: none; flex-basis: 100%; }
    .hero, .quick { display: block; }
    .quick { margin-top: 16px; }
    .quick a + a { margin-top: 10px; }
    .dock {
        display: flex;
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        z-index: 25;
        justify-content: space-around;
        gap: 4px;
        padding: 8px;
        border-radius: 18px;
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        backdrop-filter: blur(16px);
    }
    .dock a {
        flex: 1;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border-radius: 12px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 700;
    }
    .dock a.active, .dock a:hover { background: #eef2ff; color: #4338ca; text-decoration: none; }
    html[data-theme="dark"] .dock a.active { background: rgba(99, 102, 241, 0.2); color: #c7d2fe; }
    .progress { flex-direction: column; gap: 0; }
    .progress li { text-align: left; padding: 0 0 16px 28px; }
    .progress li::before { left: 7px; right: auto; top: 16px; bottom: 0; width: 3px; height: auto; }
    .progress .dot { left: 0; top: 2px; margin-left: 0; }
}

@media (max-width: 640px) {
    .grid, .paper-picks, .mode-choice, .meta-grid { grid-template-columns: 1fr; }
    .account .signout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .hero h2, .paper-meta h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
    html { scroll-behavior: auto; }
    .stat:hover, .quick a:hover, .mode-choice .check:hover, .login-part:hover, button:active, .button:active { transform: none; }
}

@media print {
    .side, .topbar, .actions, .no-print, .menu-toggle, .dock, .nav-backdrop, .search { display: none !important; }
    .shell { display: block; }
    body, .main { background: white; color: black; padding: 0; }
    .card, .table-wrap, .hero { box-shadow: none; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
@keyframes drop {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}
@keyframes pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
