:root {
    --ink: #172033;
    --muted: #7d8595;
    --line: #e5e8ef;
    --paper: #fff;
    --canvas: #f4f6f9;
    --primary: #2856d8;
    --primary-dark: #1f46b6;
    --danger: #c63636;
    --success: #197348;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; }
.mobile-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; }
.mobile-card { width: min(100%, 420px); padding: 30px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(28, 40, 66, .06); }
.brand { margin: 0 0 26px; font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 14px; font-weight: 600; }
.input { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd5df; border-radius: 9px; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(40, 86, 216, .12); }
textarea.input { min-height: 90px; resize: vertical; }
.button { display: inline-grid; place-items: center; width: 100%; min-height: 48px; padding: 10px 18px; color: #fff; background: var(--primary); border: 0; border-radius: 9px; text-decoration: none; cursor: pointer; transition: background .15s ease; }
.button:hover { background: var(--primary-dark); }
.button.secondary { color: var(--ink); background: #edf0f5; }
.button.secondary:hover { background: #e1e5ec; }
.button.danger { background: var(--danger); }
.button.compact { width: auto; min-height: 36px; padding: 7px 12px; font-size: 13px; }
.channel-link { display: block; margin-top: 20px; color: var(--muted); font-size: 12px; text-align: center; text-decoration: none; }
.channel-link:hover { color: var(--ink); }
.error { margin: 0; padding: 10px 12px; color: #9a2727; background: #fff0f0; border-radius: 8px; font-size: 14px; }
.empty-page { min-height: 100vh; background: #fff; }

.admin-page { min-width: 1100px; padding: 30px; }
.admin-shell { max-width: 1440px; margin: 0 auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin-header h1 { margin: 0; font-size: 28px; }
.admin-subtitle { color: var(--muted); font-size: 14px; }
.admin-grid { display: grid; grid-template-columns: 360px 1fr; gap: 22px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head.with-actions, .statistics-head, .panel-head-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head-actions { justify-content: flex-end; }
.statistics-head { align-items: flex-end; }
.statistics-head p { margin: 7px 0 0; color: var(--success); font-weight: 700; }
.statistics-filter { display: flex; align-items: end; gap: 8px; }
.statistics-filter .input { width: auto; min-width: 130px; min-height: 46px; height: 46px; }
.statistics-filter input[name="q"] { min-width: 210px; }
.statistics-filter .button { min-height: 46px; height: 46px; }
.panel-head.with-actions > .button, .statistics-head .panel-head-actions > .button { min-height: 46px; height: 46px; }
.statistics-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.statistics-summary strong { color: var(--success); font-size: 16px; }
.panel-body { padding: 20px; }
.admin-form { display: grid; gap: 13px; }
.admin-form .field label { font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #596174; background: #fafbfc; font-weight: 650; white-space: nowrap; }
.admin-page .table-wrap:has(.resizable-table) { overflow-x: hidden; }
.admin-page .resizable-table { table-layout: fixed; width: 100%; min-width: 0; }
.admin-page .resizable-table th { position: relative; }
.column-resizer { position: absolute; z-index: 2; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; touch-action: none; user-select: none; }
.column-resizer::after { content: ""; position: absolute; top: 22%; bottom: 22%; left: 4px; width: 2px; background: #d9dee8; border-radius: 2px; }
.column-resizer:hover::after, .column-resizer.is-dragging::after { background: var(--primary); }
.admin-page.is-resizing-columns { cursor: col-resize; user-select: none; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 7px; white-space: nowrap; }
.link-button { padding: 0; color: var(--primary); background: none; border: 0; cursor: pointer; text-decoration: none; }
.link-button.delete { color: var(--danger); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { display: inline-flex; align-items: center; min-height: 46px; padding: 9px 16px; color: var(--muted); background: #e9edf3; border-radius: 8px; text-decoration: none; font-size: 14px; }
.tab.active { color: #fff; background: var(--ink); }
.flash { margin-bottom: 16px; padding: 12px 16px; color: var(--success); background: #eaf8f1; border: 1px solid #c8ead8; border-radius: 9px; }
.flash.error { color: #9a2727; background: #fff0f0; border-color: #ffd2d2; }
.note-cell { max-width: 220px; white-space: normal; word-break: break-word; }
.search-form { display: flex; gap: 8px; }
.search-form .input { width: 240px; min-height: 46px; height: 46px; }
.search-form .button { min-height: 46px; height: 46px; }
.muted { color: var(--muted); }
.qr-card { text-align: center; }
.qr-code { display: block; width: 232px; height: 232px; margin: 4px auto 18px; image-rendering: pixelated; }
.user-id { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .04em; }
.checkbox-field { display: flex; align-items: center; gap: 9px; min-height: 40px; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.data-config-grid { display: grid; grid-template-columns: 1fr 82px; gap: 9px; align-items: center; }
.data-config-grid .checkbox-field { justify-content: center; font-size: 13px; }
.readonly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.project-list { display: grid; gap: 10px; margin-top: 20px; }
.project-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 15px; color: var(--ink); background: #f3f5f8; border-radius: 9px; text-decoration: none; }
.project-item:hover { background: #e9edf3; }
.camera-box { display: none; margin-top: 12px; padding: 12px; background: #111827; border-radius: 10px; }
.camera-box.active { display: block; }
.camera-box video { display: block; width: 100%; max-height: 300px; border-radius: 7px; object-fit: cover; }
.camera-status { margin: 9px 0 0; color: #fff; font-size: 13px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.project-status { margin-top: 24px; text-align: left; }
.project-status h2 { margin: 0 0 10px; font-size: 16px; }
.project-status ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.project-status-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 13px; background: #f3f5f8; border-radius: 9px; }
.status-badge { color: #8a5b10; font-size: 12px; white-space: nowrap; }
.project-status.completed .status-badge { color: var(--success); }
.table-settings { margin-bottom: 18px; }
.table-settings summary { display: flex; align-items: center; cursor: pointer; list-style: none; }
.table-settings summary::-webkit-details-marker { display: none; }
.table-setting-row { display: grid; grid-template-columns: 150px 1fr 100px; gap: 10px; align-items: center; }
.dataset-panel { margin-top: 22px; }
.dataset-panel > .admin-grid { padding: 0; }
.admin-tabs-row { display: flex; align-items: flex-start; gap: 8px; }
.admin-tabs-row .tabs { flex: 1; }
.settings-popover { position: relative; }
.settings-popover summary { list-style: none; }
.settings-popover summary::-webkit-details-marker { display: none; }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; color: var(--ink); background: #e9edf3; border-radius: 8px; cursor: pointer; font-size: 20px; }
.settings-menu { position: absolute; z-index: 20; top: 54px; right: 0; width: 560px; box-shadow: 0 16px 40px rgba(28, 40, 66, .16); }
.admin-stack { display: grid; gap: 22px; }
.admin-create { overflow: hidden; }
.admin-create > summary.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none; }
.admin-create > summary.panel-head::-webkit-details-marker { display: none; }
.admin-create:not([open]) > summary.panel-head { border-bottom: 0; }
.admin-create .collapse-hint::before { content: "展开"; color: var(--primary); font-size: 13px; font-weight: 650; }
.admin-create[open] .collapse-hint::before { content: "收起"; }
.admin-stack > .panel:first-child .admin-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.admin-stack > .panel:first-child .admin-form .input:not(textarea) { min-height: 46px; height: 46px; }
.admin-stack > .panel:first-child .admin-form > .field:has(textarea),
.admin-stack > .panel:first-child .admin-form > .data-config-grid { grid-column: span 2; }
.admin-stack > .panel:first-child .admin-form > .field:has(.data-config-grid) { grid-column: 1 / -1; }
.admin-stack > .panel:first-child .admin-form > .button { width: auto; min-width: 150px; }
.admin-stack > .panel:first-child .admin-form > .form-submit { grid-column: 4; width: 100%; min-height: 46px; height: 46px; align-self: end; }
.admin-stack > .panel:first-child .admin-form > .form-cancel { grid-column: 3; grid-row: auto; width: 100%; min-height: 46px; height: 46px; }
.admin-stack > .panel:first-child .admin-form > .data-config-list { grid-column: 1 / -1; }
.statistics-status-field { grid-column: span 2; }
.status-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; min-height: 46px; }
.status-options .checkbox-field { min-height: 32px; }
.data-config-list { display: grid; gap: 14px; }
.data-config-item { padding: 14px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 10px; }
.data-config-head { display: grid; grid-template-columns: minmax(220px, 1fr) 110px 120px; gap: 10px; align-items: center; }
.data-option-grid { display: grid; grid-template-columns: minmax(140px, 1fr) 72px minmax(140px, 1fr) 72px; gap: 8px; align-items: center; margin-top: 10px; }
.data-option-grid .checkbox-field { justify-content: center; font-size: 12px; }
.dataset-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dataset-search, .report-search { display: flex; align-items: end; gap: 8px; }
.report-search .input, .report-search .button { min-height: 46px; height: 46px; }
.dataset-search .input { width: 280px; min-height: 46px; height: 46px; }
.dataset-search .button, .dataset-head > .panel-head-actions > .button { min-height: 46px; height: 46px; }
.dataset-stack { display: grid; }
.dataset-create { display: none; border-bottom: 1px solid var(--line); }
.dataset-create.is-editing { display: block; }
.dataset-create h3 { margin: 0 0 16px; font-size: 16px; }
.dataset-create .admin-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.dataset-create .admin-form .input:not(textarea) { min-height: 46px; height: 46px; }
.dataset-create .admin-form > .form-submit { grid-column: 4; width: 100%; min-height: 46px; height: 46px; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px; }
.page-link { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px; color: var(--ink); background: #edf0f5; border-radius: 7px; text-decoration: none; }
.page-link.active { color: #fff; background: var(--primary); }
.reception-user { margin-top: 18px; }
.history-day { margin-top: 24px; text-align: left; }
.history-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.history-day-head h2 { margin: 0; font-size: 17px; }
.history-day-head span { color: var(--success); font-size: 13px; font-weight: 650; }
.history-day ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history-item { display: flex; justify-content: space-between; gap: 12px; padding: 13px; background: #f3f5f8; border-radius: 9px; }
.history-item div { display: grid; gap: 4px; }
.history-item span { color: var(--muted); font-size: 12px; }
.history-item b { white-space: nowrap; }
.settlement-form { display: grid; }
.settlement-item { align-items: center; }
.settlement-check { display: flex; align-items: center; gap: 10px; min-width: 0; }
.settlement-check input { width: 19px; height: 19px; accent-color: var(--primary); flex: 0 0 auto; }
.settlement-check span, .settlement-meta { display: grid; gap: 4px; }
.settlement-check small, .settlement-meta small { color: var(--muted); font-size: 11px; }
.settlement-meta { justify-items: end; text-align: right; }
.status-badge.settled { color: var(--success); }
.status-badge.pending { color: #9a6412; }
.settlement-submit { margin-top: 20px; }
.settlement-submit:disabled { cursor: default; opacity: .55; }
.empty-history { margin-top: 24px; }
.report-search .field { min-width: 280px; }
.report-table th, .report-table td { text-align: center; vertical-align: middle; }

@media (max-width: 520px) {
    .mobile-page { padding: 0; place-items: stretch; background: #fff; }
    .mobile-card { width: 100%; min-height: 100vh; padding: 40px 22px; border: 0; border-radius: 0; box-shadow: none; }
    .readonly-grid { grid-template-columns: 1fr; }
}
