:root {
    --bg: #f3f5f9;
    --ink: #1f2329;
    --muted: #8a919f;
    --line: #e6e8ee;
    --card: #ffffff;
    --side: #1c2434;
    --side-ink: rgba(255, 255, 255, 0.88);
    --side-dim: rgba(255, 255, 255, 0.62);
    --accent: #1677ff;
    --green: #1677ff;
    --red: #ff4d4f;
    --gold: #1677ff;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font: 14px/1.5 "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

h1, h2, p { margin: 0; }
h1 { font-size: 16px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0 14px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    box-shadow: none;
}
button.secondary {
    background: #fff;
    color: var(--ink);
    border-color: #d9d9d9;
}
button.secondary:hover { color: var(--accent); border-color: var(--accent); }
button.linkish {
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    border-radius: 0;
}
button.danger, .ops .danger {
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--red);
    border-radius: 6px;
    background: var(--red);
    color: #fff;
}
.quiet { color: var(--accent); padding: 0 4px; white-space: nowrap; }

.shell { min-height: 100vh; }
.side {
    background: var(--side);
    color: var(--side-ink);
    width: 216px;
    padding: 8px 10px 16px;
    position: fixed;
    z-index: 20;
    top: 14px;
    left: 14px;
    bottom: 14px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(16, 24, 40, 0.18);
    overflow: auto;
}
.nav-toggle {
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}
.nav-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}
.side-mask { display: none; }
.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #fff;
    height: 56px;
    padding: 0 10px;
    margin-bottom: 8px;
}
.brand strong { font-size: 16px; font-weight: 650; }
.logo, .mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    box-shadow: none;
}
.side nav { display: grid; gap: 4px; }
.side nav a {
    color: var(--side-dim);
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}
.side nav a.on, .side nav a:hover { background: var(--accent); color: #fff; }

.workspace {
    min-width: 0;
    height: 100vh;
    margin-left: 244px;
    overflow: auto;
    background: var(--bg);
    padding: 0 14px 28px 0;
}
.top-slot {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-top: 14px;
    background: var(--bg);
}
.topbar {
    position: relative;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 18px 0 20px;
    background: #fff;
    border: 1px solid #eef0f4;
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
}
.crumb { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.crumb p, .hint, .lead, .eyebrow { color: var(--muted); }
.crumb p { font-size: 13px; }
.who { display: flex; align-items: center; gap: 8px; color: var(--ink); white-space: nowrap; }
.who a { color: var(--muted); }
.who a:hover { color: var(--accent); }
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e8f1ff;
    color: var(--accent);
    font-size: 13px;
    font-weight: 650;
}
.page { padding: 16px 0 0; }
.sections { display: grid; gap: 16px; }
.block { padding: 20px 22px 22px; }
.block-head { margin-bottom: 16px; }
.block-head .hint { margin: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 32px; align-items: start; }
.split.rule { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
.guide { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 32px; }
.guide h3, .split h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; }
.guide p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.guide p:last-child, .guide .code { margin-bottom: 0; }
.block-foot { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.flash { border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.flash.ok { background: #f6ffed; color: #237804; border: 1px solid #b7eb8f; }
.flash.bad { background: #fff2f0; color: #a8071a; border: 1px solid #ffccc7; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.stats a, .panel, .setup, .sheet, .table-wrap, .card {
    background: var(--card);
    border: 1px solid #eef0f4;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.stats a { display: grid; gap: 6px; padding: 16px 18px; color: inherit; }
.stats a:hover { border-color: #c9ddff; }
.stats span { color: var(--muted); font-size: 13px; }
.stats strong { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }

.setup { padding: 16px 18px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.setup ol { grid-column: 1; margin: 6px 0 0; color: var(--muted); }

.panel { padding: 16px; margin-bottom: 12px; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.board > .panel { margin: 0; }
.board > .span { grid-column: 1 / -1; }
.sheet { margin-bottom: 12px; overflow: hidden; }
.toolbar, .sheet-bar, .sheet-note { padding: 14px 16px; }
.toolbar {
    display: grid;
    grid-template-columns: 160px 160px minmax(180px, 1fr) auto auto;
    gap: 10px 12px;
    align-items: end;
}
.sheet-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--line);
    background: #fafafa;
}
.sheet-bar p b { font-weight: 650; }
.sheet-note { margin: 0; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.filters, .summary-row, .row-actions, .inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sheet-bar .inline { flex: none; }
.sheet-bar input[type="date"] { width: 148px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
    width: 100%;
    height: 32px;
    border: 1px solid #d9d9d9;
    background: #fff;
    border-radius: 6px;
    padding: 0 10px;
    outline: none;
}
textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12); }
.hint { margin: 4px 0 12px; font-size: 13px; }
.lead { margin: 8px 0 18px; }

.table-wrap { overflow: auto; }
.sheet .table-wrap, .panel .table-wrap { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; text-align: left; vertical-align: middle; }
th { font-size: 13px; color: #667085; font-weight: 600; background: #fafafa; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
td b, td small { display: block; }
td small, .time { color: var(--muted); }
.time em { margin-left: 6px; font-style: normal; color: var(--accent); font-size: 12px; }
.link a { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { max-width: 220px; color: var(--muted); word-break: break-word; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }
.ops { white-space: nowrap; }
.ops form { display: inline; }
.ops form + form, .ops a + form { margin-left: 8px; }
.ops a, .ops .linkish {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background: #fff;
    color: var(--accent);
}
.ops .danger { background: var(--red); border-color: var(--red); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.pager { display: flex; gap: 12px; justify-content: flex-end; align-items: center; margin-top: 12px; color: var(--muted); }

.form-grid, .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fields .span, .fields .row-actions { grid-column: 1 / -1; }
.stack { display: grid; gap: 12px; justify-items: start; }
.stack > label, .stack > .code, .stack > input, .stack > textarea, .stack > select { width: 100%; }
.compact, .narrow { max-width: none; }
.password-form { max-width: 360px; }
.reply-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.reply-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.reply-list p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.reply-list b { font-weight: 650; }
.reply-sheet table { min-width: 560px; }
.reply-sheet td.trigger { font-weight: 650; white-space: nowrap; }
.reply-sheet td.preview { color: var(--muted); max-width: 520px; }
.reply-form { margin-top: 4px; }
input[type="file"] { height: auto; padding: 4px 0; border: 0; background: transparent; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; height: auto; }
img.qr { width: 180px; height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
td[data-login] { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
td small { margin-top: 2px; }
.code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    background: #fafafa;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    overflow-wrap: anywhere;
}

body.guest {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background: #f3f5f9;
}
.card { width: min(400px, 100%); padding: 28px 24px; }
.card h1 { margin: 12px 0 0; font-size: 20px; }
.mark { margin-bottom: 2px; }
body.guest .stack { justify-items: stretch; }
body.guest .stack > button { width: 100%; }

@media (max-width: 980px) {
    .toolbar { grid-template-columns: 1fr 1fr auto auto; }
    .toolbar .grow { grid-column: 1 / -1; }
    .toolbar button, .toolbar .quiet { justify-self: start; }
    .board, .fields, .form-grid, .split, .guide { grid-template-columns: 1fr; }
    .board > .span { grid-column: auto; }
}
@media (max-width: 760px) {
    .nav-toggle { display: inline-flex; }
    .side {
        transform: translateX(calc(-100% - 28px));
        transition: transform 0.2s ease;
    }
    body.nav-open .side { transform: none; }
    .side-mask {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    body.nav-open .side-mask { opacity: 1; pointer-events: auto; }
    .workspace { height: auto; min-height: 100vh; margin-left: 0; padding: 0 14px 24px; }
    .topbar { height: auto; min-height: 56px; padding: 10px 14px; align-items: center; }
    .crumb, .who { flex-wrap: wrap; }
    .page { padding: 14px 0 0; }
    .stats, .setup { grid-template-columns: 1fr 1fr; }
    .sheet-bar { flex-direction: column; align-items: stretch; }
}
