:root {
    --ink: #141c24;
    --ink-2: #1c2834;
    --paper: #f3f4f2;
    --panel: #ffffff;
    --line: #d9ddd6;
    --text: #1a2228;
    --muted: #5c6770;
    --accent: #b45309;
    --accent-2: #9a3f07;
    --ok: #157a4b;
    --warn: #b45309;
    --err: #b42318;
    --radius: 8px;
    --shadow: 0 10px 30px rgba(20, 28, 36, 0.08);
    --sidebar: 248px;
    --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--paper);
    min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
h1, h2, h3 { margin: 0 0 12px; letter-spacing: -0.02em; }

.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.auth-body { background: #12181f; }
.auth-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-brand {
    padding: 48px 56px 36px;
    color: #d5ddd6;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        radial-gradient(ellipse 80% 50% at 0% 0%, rgba(180, 83, 9, 0.35), transparent 58%),
        linear-gradient(165deg, #171f28 0%, #10161c 55%, #0c1116 100%);
}
.auth-mark {
    display: inline-block;
    margin-bottom: 28px;
    padding: 6px 10px;
    border: 1px solid rgba(231, 176, 122, 0.35);
    color: #e7b07a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
}
.auth-brand h1 {
    font-size: clamp(28px, 3.4vw, 42px);
    line-height: 1.25;
    max-width: 14em;
    color: #fff;
    font-weight: 650;
}
.auth-brand p {
    max-width: 38ch;
    line-height: 1.7;
    color: #b7c0bb;
}
.auth-points {
    margin: 28px 0 0;
    padding: 0;
    list-style: none;
    color: #b7c0bb;
    line-height: 1.9;
    font-size: 14px;
}
.auth-points li {
    padding-left: 1.1em;
    position: relative;
}
.auth-points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 6px;
    height: 6px;
    background: #b45309;
}
.auth-foot {
    margin: 32px 0 0;
    font-size: 12px;
    color: #8a9590;
}
.eyebrow {
    margin: 0 0 18px;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #e7b07a;
}
.auth-panel {
    background: #f4f2ee;
    padding: 48px 8vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.auth-form { width: 100%; max-width: 400px; }
.auth-panel h2 { font-size: 28px; margin-bottom: 8px; }
.auth-submit { width: 100%; min-height: 44px; margin-top: 6px; }
.pw-field {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
}
.pw-field input {
    border: 0;
    box-shadow: none;
    border-radius: 0;
}
.pw-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}
.pw-toggle {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
}

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 12px;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}
textarea { min-height: 180px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    transition: transform .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-err { background: var(--err); color: #fff; }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 14px;
}
.alert-ok { background: #e8f6ee; color: #0f5132; }
.alert-err { background: #fdecec; color: #7a1d16; }

.app {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
}
.side {
    background: var(--ink);
    color: #d7ddd8;
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow: auto;
}
.brand {
    padding: 8px 12px 22px;
    font-weight: 700;
    color: #fff;
    font-size: 18px;
}
.nav a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #c9d1cb;
    margin-bottom: 4px;
}
.nav a:hover, .nav a.active {
    background: var(--ink-2);
    color: #fff;
}
.nav-group {
    margin-bottom: 4px;
}
.nav-group summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #c9d1cb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid #8a969c;
    border-bottom: 1.5px solid #8a969c;
    transform: rotate(-45deg);
    margin-right: 4px;
    transition: transform .15s ease;
}
.nav-group[open] summary,
.nav-group summary:hover {
    background: var(--ink-2);
    color: #fff;
}
.nav-group[open] summary::after {
    transform: rotate(45deg);
}
.nav-group a {
    margin-left: 10px;
    padding-left: 16px;
    font-size: 13px;
}
.nav .sep {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 12px 8px;
}
.side-user {
    margin-top: 24px;
    padding: 12px;
    color: #9aa6ad;
    font-size: 12px;
}

.main { padding: 28px 24px 48px; min-width: 0; overflow-x: hidden; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 26px; }
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.stat b {
    display: block;
    font-size: 28px;
    font-variant-numeric: tabular-nums;
    margin-top: 8px;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}
.table-wrap { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.reports-live table { table-layout: fixed; width: 100%; }
.reports-live th, .reports-live td {
    padding: 8px 6px;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.reports-live th:nth-child(1) { width: 12%; }
.reports-live th:nth-child(2) { width: 10%; }
.reports-live th:nth-child(3) { width: 8%; }
.reports-live th:nth-child(4) { width: 6%; }
.reports-live th:nth-child(5),
.reports-live th:nth-child(6),
.reports-live th:nth-child(7) { width: 12%; }
.reports-live th:nth-child(8) { width: 8%; }
.reports-live th:last-child,
.reports-live td:last-child { width: 22%; overflow-wrap: normal; word-break: normal; }
.reports-live .copy-cell {
    display: flex;
    flex-wrap: wrap;
    max-width: 100%;
}
.reports-live .btn-copy {
    padding: 2px 6px;
    font-size: 11px;
}
.ops {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.ops form { margin: 0; }
.ops .btn-sm { padding: 5px 8px; }
.reassign {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
}
.reassign select {
    min-width: 0;
    flex: 1;
    max-width: none;
    font-size: 12px;
    padding: 4px 6px;
}
.copy-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-copy {
    flex: none;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 4px;
    cursor: pointer;
}
.btn-copy:hover { color: var(--text); border-color: #b7bdb6; }
.btn-copy.is-copied {
    color: var(--ok);
    border-color: #b7dcc8;
    background: #eef8f2;
}
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
}
.badge-pending { background: #f3f4f2; color: #5c6770; }
.badge-valid { background: #e8f6ee; color: #0f5132; }
.badge-invalid { background: #fdecec; color: #7a1d16; }
.badge-noreply { background: #f3f4f2; color: #5c6770; }
.badge-on { background: #e8f6ee; color: #0f5132; }
.badge-off { background: #eee; color: #555; }
.badge-import { background: #eef2f6; color: #3d4d5c; }
.badge-review { background: #f4ece3; color: #8a4b12; }

.today-card {
    background: #f7f8f6;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    max-width: 420px;
}
.today-card-name {
    font-weight: 600;
    margin-bottom: 8px;
}
.today-card pre {
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 160px; }
.staff-checks {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.check-item {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 10px;
    font-size: 13px;
    white-space: nowrap;
    writing-mode: horizontal-tb;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}
.check-item:has(input:checked) {
    background: #f4ece3;
    border-color: #d4b08c;
}
.staff-bind { position: relative; min-width: 160px; }
.staff-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.staff-fold {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}
.staff-fold summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 10px;
    color: var(--text);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    user-select: none;
}
.staff-fold summary::-webkit-details-marker { display: none; }
.staff-fold summary::after {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid #8a969c;
    border-bottom: 1.5px solid #8a969c;
    transform: rotate(-45deg);
}
.staff-fold[open] { z-index: 12; }
.staff-fold[open] summary::after { transform: rotate(45deg); }
.staff-pop {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 13;
    width: min(420px, 70vw);
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.staff-pop .btn { margin-top: 10px; }
.pager { display: flex; gap: 8px; margin-top: 14px; }

.mobile-toggle { display: none; }

@media (max-width: 960px) {
    .auth-shell, .app, .grid-4 { grid-template-columns: 1fr; }
    .auth-brand {
        padding: 28px 22px 20px;
        min-height: auto;
    }
    .auth-brand h1 { font-size: 24px; max-width: none; }
    .auth-points { margin-top: 16px; }
    .auth-foot { display: none; }
    .auth-panel { padding: 28px 22px 40px; }
    .auth-form { max-width: none; }
    .side {
        position: fixed;
        z-index: 20;
        transform: translateX(-110%);
        transition: transform .2s ease;
        width: var(--sidebar);
    }
    .side.open { transform: none; }
    .main { padding: 18px 14px 40px; }
    .mobile-toggle { display: inline-flex; }
}

.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(20, 28, 36, 0.46);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-mask.is-open {
    display: flex;
}
.modal {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 8px; }
