:root {
    --navy: #0c2340;
    --navy-2: #16375f;
    --sheet: #1e3f66;
    --gold: #d4b15a;
    --ink: #1c2834;
    --muted: #5d6d7e;
    --line: #d7e0ea;
    --bg: #e6eef5;
    --card: #ffffff;
    --green: #0e6b52;
    --danger: #9f1d1d;
    --shadow: 0 10px 30px rgba(12, 35, 64, 0.08);
    --font: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: 18px; letter-spacing: -0.02em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.topbar {
    background: var(--navy);
    color: white;
    border-bottom: 3px solid var(--gold);
}
.topbar-inner {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    min-height: 68px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 18px;
    row-gap: 8px;
    padding: 8px 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    margin-right: 8px;
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: var(--navy);
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 13px;
}
.brand strong, .brand small { display: block; }
.brand small { color: rgba(255, 255, 255, 0.72); font-size: 12px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
    color: rgba(255, 255, 255, 0.84);
    text-decoration: none;
    padding: 7px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
}
.nav a:hover, .nav a.is-active { background: rgba(255, 255, 255, 0.12); color: white; }
.nav-label {
    margin: 0 4px 0 10px;
    color: var(--gold);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
}
.top-right { display: flex; align-items: center; gap: 12px; justify-self: end; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
}
.user-chip strong, .user-chip small { display: block; }
.user-chip small { color: rgba(255, 255, 255, 0.7); font-size: 12px; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: var(--navy);
    font-size: 12px;
    font-weight: 800;
}
.signout { color: white; font-size: 13px; font-weight: 700; }

.wrap { width: min(1440px, calc(100% - 32px)); margin: 24px auto 56px; }
.page-head, .card-head, .row-actions, .row-tools, .filters, .pager, .form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.page-head { justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.lede, .muted, .pool-count { color: var(--muted); }
.pool-count { margin: 0; font-weight: 700; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(12, 35, 64, 0.04);
}
.card + .card, .stats + .card, .stats + .alert, .alert + .card { margin-top: 0; }
.card-head { justify-content: space-between; margin-bottom: 12px; }
.card-head a { font-weight: 700; }
.card-links { display: flex; gap: 14px; }
.narrow { max-width: 640px; }
.narrow h1 { margin-bottom: 8px; }
.spaced { margin-top: 22px; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stats article {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
}
.stats span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stats strong { display: block; margin-top: 4px; font-size: 30px; letter-spacing: -0.04em; }

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-success { background: #e7f6ef; color: #0d5c3d; }
.alert-error { background: #fdecec; color: #8d1c1c; }
.alert-warn { background: #fff6e5; color: #7a4e00; border: 1px solid #f0ddb4; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid #c5d1de;
    background: white;
    color: var(--navy);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: #8ea0b5; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: white; }
.btn-primary:hover { background: #16365c; }
.btn-green { background: var(--green); border-color: var(--green); color: white; }
.btn-green:hover { background: #0b5743; }
.btn-danger { color: var(--danger); border-color: #efc7c7; background: white; }
.btn-danger:hover { background: #fff5f5; }
.btn-small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.filters { margin-bottom: 14px; }
.filters input[type="search"], .filters select {
    flex: 1;
    min-width: 180px;
    height: 40px;
    border: 1px solid #c5d1de;
    border-radius: 8px;
    padding: 0 12px;
    background: white;
}
.filters select { flex: 0 0 auto; min-width: 160px; }
table.data.report { min-width: 1680px; }
table.data.report td.remarks { min-width: 220px; white-space: normal; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th {
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 10px 12px;
    background: #f6f9fc;
    border-bottom: 1px solid var(--line);
}
table.data td {
    padding: 12px;
    border-bottom: 1px solid #eef3f7;
    vertical-align: middle;
}
table.data tr:hover td { background: #f8fbfe; }
table.data.compact { min-width: 0; }
table.data.compact td, table.data.compact th { padding: 8px 10px; }
.actions { display: flex; gap: 12px; white-space: nowrap; }
.actions a { font-weight: 700; text-decoration: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #334455;
    font-size: 12px;
    font-weight: 700;
}
.badge-draft { background: #fff1d6; color: #8a5600; }
.badge-submitted, .badge-ok { background: #e5f6ee; color: #0d5c3d; }
.badge-admin { background: var(--navy); color: white; }
.empty { padding: 28px 8px; text-align: center; }
.empty p { margin-bottom: 12px; color: var(--muted); }
.pager { justify-content: flex-end; margin-top: 14px; }
.pager span { color: var(--muted); font-size: 13px; }

.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.signature-grid { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.meta-grid .field { margin-bottom: 0; }
.field span { font-size: 13px; font-weight: 700; }
.field em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 12px; }
.field input, .field select, .filters input {
    height: 40px;
    border: 1px solid #c5d1de;
    border-radius: 8px;
    padding: 0 10px;
    background: white;
}
.sheet-card { padding-bottom: 8px; }
.sheet-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.sheet-title p, .sheet-note { color: var(--muted); }
.sheet-note { margin: 12px 0; }
.sheet-scroll {
    overflow-x: auto;
    border: 1px solid #c5d2e0;
    border-radius: 10px;
}
table.entry { border-collapse: collapse; min-width: 1380px; width: 100%; }
table.entry th, table.entry td { border: 1px solid #d5dee8; }
table.entry th {
    background: var(--sheet);
    color: white;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    padding: 8px 6px;
}
table.entry td { padding: 4px; background: white; vertical-align: top; }
table.entry .row-no { text-align: center; color: #526173; width: 42px; padding-top: 10px; }
table.entry input, table.entry select, table.entry textarea {
    width: 100%;
    border: 1px solid #d5dee8;
    border-radius: 4px;
    padding: 6px;
    background: white;
    font-size: 13px;
}
table.entry textarea { resize: vertical; min-height: 42px; }
table.entry input[readonly] { background: #f3f6f9; }
.picker { min-width: 210px; }
.picked {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 38px;
    padding: 2px 4px;
}
.picked strong, .picked small { display: block; }
.picked strong { font-size: 13px; }
.picked small { color: var(--muted); font-size: 11px; }
.clear-player {
    border: 0;
    background: transparent;
    color: var(--navy);
    font-weight: 800;
    cursor: pointer;
    font-size: 12px;
}
.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: white;
    cursor: pointer;
}
.icon-btn:hover { background: #fdecec; color: var(--danger); }
.row-tools { justify-content: space-between; margin: 12px 0; align-items: center; }
.row-tools p { color: var(--muted); font-size: 13px; margin: 0; }
.legend {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    color: #314252;
}
.legend p + p { margin-top: 6px; }
.form-actions {
    position: sticky;
    bottom: 0;
    justify-content: flex-end;
    padding: 12px 0;
    background: rgba(230, 238, 245, 0.94);
    border-top: 1px solid transparent;
}
[hidden] { display: none !important; }

.suggest {
    position: fixed;
    z-index: 40;
    background: white;
    border: 1px solid #c5d2e0;
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 280px;
    overflow: auto;
}
.suggest-item, .suggest-empty {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: 0;
    border-bottom: 1px solid #f1f4f8;
    background: white;
    cursor: pointer;
}
.suggest-item strong, .suggest-item .meta { display: block; }
.suggest-item .meta { color: var(--muted); font-size: 12px; }
.suggest-item.is-active, .suggest-item:hover { background: #f3f7fb; }
.suggest-empty { color: var(--muted); cursor: default; }

.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.choices { display: grid; gap: 8px; margin: 12px 0 16px; }
.choice {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    align-items: start;
}
.choice strong, .choice small, .checkline { display: block; }
.choice small, .checkline { color: var(--muted); font-size: 13px; }
.checkline { margin: 0 0 12px; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.drop {
    display: grid;
    gap: 8px;
    place-items: center;
    text-align: center;
    border: 1.5px dashed #b7c5d4;
    border-radius: 12px;
    padding: 22px 14px;
    background: #f8fafc;
    margin: 12px 0;
}
.drop span { color: var(--muted); }

.paper {
    position: relative;
    overflow: hidden;
    width: min(1100px, 100%);
    margin: 0 auto;
    background: white;
    padding: 28px 26px 34px;
    box-shadow: var(--shadow);
}
.paper h2 { text-align: center; font-size: 22px; margin-bottom: 12px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0; font-size: 14px; }
.blank { display: inline-block; min-width: 90px; border-bottom: 1px solid #1c2834; transform: translateY(-2px); }
.paper table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.paper th { background: var(--sheet); color: white; }
.paper th, .paper td { border: 1px solid #9aabbd; padding: 6px 5px; vertical-align: top; }
.paper .center, .paper td.center { text-align: center; }
.paper .legend { margin-top: 12px; font-size: 11px; background: transparent; border: 0; padding: 0; }
.sig-row { display: flex; justify-content: space-between; gap: 24px; margin-top: 18px; }
.paper.is-draft::after {
    content: "DRAFT";
    position: absolute;
    left: 0;
    right: 0;
    top: 38%;
    text-align: center;
    font-size: 92px;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: #9f1d1d;
    opacity: 0.12;
    transform: rotate(-12deg);
    pointer-events: none;
}
.print-body { background: #d5e0eb; }
.print-toolbar {
    width: min(1100px, calc(100% - 32px));
    margin: 16px auto;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.login-body { background: white; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 0.85fr; }
.login-aside {
    background:
        linear-gradient(165deg, rgba(212, 177, 90, 0.2), transparent 36%),
        var(--navy);
    color: white;
    padding: 72px 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.eyebrow { letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); font-size: 12px; font-weight: 800; }
.login-aside h1 { font-size: 46px; max-width: 520px; margin: 10px 0 14px; }
.login-aside p { max-width: 460px; color: rgba(255, 255, 255, 0.86); font-size: 17px; }
.login-aside ol { margin: 22px 0; padding-left: 18px; max-width: 460px; }
.login-aside li { margin: 8px 0; }
.aside-stat { margin-top: 18px; color: var(--gold); font-weight: 800; }
.login-panel { display: grid; place-items: center; padding: 32px 20px; background: #f4f7fb; }
.login-card { width: min(420px, 100%); background: white; border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 14px; }

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

@media (max-width: 980px) {
    .meta-grid, .split, .login-page { grid-template-columns: 1fr; }
    .login-aside { padding: 36px 24px; }
    .login-aside h1 { font-size: 34px; }
    .page-head, .row-tools, .sheet-title { align-items: flex-start; flex-direction: column; }
    .topbar-inner { grid-template-columns: 1fr auto; }
    .nav { grid-column: 1 / -1; }
}
@media print {
    body.print-body { background: white; }
    .print-toolbar { display: none; }
    .paper { box-shadow: none; width: auto; margin: 0; padding: 0; }
    .paper.is-draft::after { opacity: 0.18; }
    @page { size: A4 landscape; margin: 8mm; }
}
