:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d9e1ea;
  --surface: #ffffff;
  --wash: #f4f7fa;
  --blue: #1769aa;
  --blue-dark: #12558b;
  --green: #1e8e5a;
  --red: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef3f7; }
.auth-shell { width: min(100%, 900px); display: grid; grid-template-columns: 1fr 390px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 48px rgba(16, 24, 40, .1); }
.auth-intro { padding: 62px 54px; background: #173b5c; color: white; }
.auth-intro .eyebrow { color: #b8d4e8; }
.auth-intro h1 { font-size: 38px; margin: 16px 0 12px; }
.auth-intro p:last-child { max-width: 300px; color: #d7e5ef; }
.auth-card {
  width: min(100%, 390px);
  background: var(--surface);
  padding: 34px;
}
.auth-card h2 { font-size: 22px; margin-top: 0; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--blue); color: white; font-size: 22px; font-weight: 700;
}
.brand-mark.small { width: 28px; height: 28px; display: inline-grid; font-size: 15px; margin-right: 8px; vertical-align: middle; }
h1 { margin: 18px 0 2px; font-size: 25px; }
h2 { margin: 0 0 5px; font-size: 18px; }
.muted, .help { color: var(--muted); }
.help { margin: 0 0 20px; font-size: 13px; }
label { display: block; margin: 0 0 6px; font-weight: 600; }
input {
  width: 100%; min-height: 42px; border: 1px solid var(--line); padding: 9px 11px;
  background: white; color: var(--ink); font: inherit;
}
select, textarea {
  width: 100%; border: 1px solid var(--line); padding: 9px 11px;
  background: white; color: var(--ink); font: inherit;
}
select { min-height: 42px; }
textarea { resize: vertical; }
input:focus { outline: 2px solid rgba(23, 105, 170, .22); border-color: var(--blue); }
select:focus, textarea:focus { outline: 2px solid rgba(23, 105, 170, .22); border-color: var(--blue); }
button {
  min-height: 42px; border: 0; padding: 0 18px; background: var(--blue); color: white;
  font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--blue-dark); }
button.secondary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
button.secondary:hover { background: var(--wash); }
.auth-card button { width: 100%; margin-top: 18px; }
.setup-hint { margin: 18px 0 0; color: var(--red); font-size: 13px; }
.notice { margin: 0 0 18px; padding: 11px 13px; border: 1px solid var(--line); background: white; }
.notice.error { color: var(--red); border-color: #f0b5ae; background: #fff7f6; }
.notice.success { color: var(--green); border-color: #b5dfc8; background: #f4fcf7; }
.console-body { display: flex; min-height: 100vh; }
.sidebar { width: 238px; flex: 0 0 238px; background: #173b5c; color: white; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 23px 20px; border-bottom: 1px solid rgba(255,255,255,.13); }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { margin-top: 2px; color: #b8d4e8; font-size: 11px; }
.sidebar-nav { padding: 24px 12px; }
.nav-label { padding: 0 10px 8px; color: #9bb7ca; font-size: 11px; letter-spacing: .08em; }
.nav-label:not(:first-child) { margin-top: 22px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; color: #d7e5ef; text-decoration: none; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: white; }
.nav-item.active { box-shadow: inset 3px 0 #67b4e8; }
.nav-item.disabled { color: #7895a9; cursor: default; }
.nav-item em { margin-left: auto; font-size: 10px; font-style: normal; color: #7f9eb3; }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.sidebar-footer { margin-top: auto; padding: 18px 20px; border-top: 1px solid rgba(255,255,255,.13); font-size: 12px; }
.secure-badge { display: block; margin-bottom: 5px; color: #9ee0bb; }
.console-main { min-width: 0; flex: 1; }
.console-topbar { min-height: 78px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; background: white; border-bottom: 1px solid var(--line); }
.console-topbar h1 { margin: 2px 0 0; font-size: 23px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.user-avatar, .profile-avatar { display: grid; place-items: center; background: #dcecf7; color: var(--blue-dark); font-weight: 700; }
.user-avatar { width: 30px; height: 30px; font-size: 13px; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.console-content { width: min(100% - 68px, 980px); margin: 28px auto 60px; }
.welcome { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.welcome h2 { margin-bottom: 2px; }
.welcome p { margin: 0; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; background: var(--blue); color: white; text-decoration: none; font-weight: 600; }
.button:hover { background: var(--blue-dark); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card { min-height: 126px; padding: 18px; background: white; border: 1px solid var(--line); }
.metric-link { display: block; color: inherit; text-decoration: none; }
.metric-link:hover { border-color: #a7c9e1; background: #f8fbfd; }
.metric-label, .metric-note { display: block; color: var(--muted); font-size: 13px; }
.metric-value { display: block; margin: 8px 0 6px; font-size: 22px; }
.metric-value small { color: var(--muted); font-size: 14px; font-weight: 500; }
.warning-value { color: var(--red); }
.metric-note { overflow-wrap: anywhere; font-size: 12px; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.shortcut-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.monitor-actions { display: flex; align-items: center; gap: 12px; }
.live-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.last-updated, .message-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.test-guide { background: #f8fbfd; }
.test-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 0; padding: 0; list-style: none; }
.test-steps li { display: flex; align-items: flex-start; gap: 10px; }
.test-steps li > span { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; border: 1px solid #a7c9e1; color: var(--blue-dark); background: white; font-size: 12px; }
.test-steps strong, .test-steps small { display: block; }
.test-steps small { margin-top: 3px; color: var(--muted); }
.message-list { min-height: 120px; }
.message-entry { padding: 16px 0; border-top: 1px solid var(--line); }
.message-entry:first-child { border-top: 0; padding-top: 0; }
.message-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.message-meta strong { color: var(--ink); }
.message-meta span, .message-meta time { color: var(--muted); font-size: 12px; }
.message-meta span { padding: 2px 7px; border: 1px solid var(--line); background: var(--wash); }
.message-entry pre { max-height: 280px; overflow: auto; margin: 0; padding: 13px 14px; border: 1px solid var(--line); background: #fbfcfd; color: var(--ink); font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.compact-empty { min-height: 220px; }
.security-panel { background: #f8fbfd; }
.inline-security { margin-top: 20px; padding: 14px 16px; }
.security-list { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.security-list li { margin: 5px 0; }
.empty-state { min-height: 300px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-state h2 { margin: 12px 0 4px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--blue); font-size: 24px; }
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.profile-card { text-align: center; }
.profile-avatar { width: 64px; height: 64px; margin: 4px auto 16px; font-size: 26px; }
.profile-card h2 { margin: 0 0 2px; }
.profile-card p { margin: 0 0 14px; }
.role-badge { display: inline-block; padding: 3px 9px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.role-badge.admin { border-color: #a7c9e1; color: var(--blue-dark); background: #eff7fc; }
.role-badge.active { border-color: #b5dfc8; color: var(--green); background: #f4fcf7; }
.role-badge.inactive { color: var(--red); border-color: #f0b5ae; background: #fff7f6; }
.password-card label { margin-top: 13px; }
.password-card .actions { margin-top: 18px; }
.table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { padding: 12px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
.user-table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.user-table td strong, .user-table td small { display: block; }
.user-table td small { color: var(--muted); margin-top: 2px; }
.user-table select { min-height: 34px; border: 1px solid var(--line); padding: 4px 8px; background: white; }
.inline-form { display: inline; }
.text-button { min-height: auto; padding: 3px 5px; background: transparent; color: var(--blue); font-size: 13px; font-weight: 600; }
.text-button:hover { background: #eef5fb; color: var(--blue-dark); }
.reset-details { display: inline-block; margin-left: 8px; color: var(--blue); font-size: 13px; }
.reset-details summary { cursor: pointer; }
.reset-form { display: flex; gap: 5px; margin-top: 8px; }
.reset-form input { min-width: 130px; min-height: 32px; padding: 5px 7px; }
.step-list { margin: 0; padding: 0; list-style: none; }
.step-list li { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.step-list li > span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.step-list li.done > span { background: #e6f6ed; border-color: #a8d8ba; color: var(--green); }
.step-list strong, .step-list small { display: block; }
.step-list small { margin-top: 2px; color: var(--muted); }
.status-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.status-card, .panel { background: var(--surface); border: 1px solid var(--line); }
.status-card { padding: 15px 17px; color: var(--muted); }
.status-card strong { display: block; margin: 2px 0 0 18px; color: var(--ink); }
.status-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; margin-right: 8px; }
.status-dot.ok { background: var(--green); }
.status-dot.off { background: #98a2b3; }
.panel { padding: 22px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 17px 20px; }
.full { grid-column: 1 / -1; }
.callback-box { margin-top: 20px; padding: 12px 14px; background: #f2f8fc; border-left: 3px solid var(--blue); }
.callback-box span { display: block; color: var(--muted); font-size: 13px; }
.callback-box code { display: block; margin-top: 3px; color: var(--blue-dark); overflow-wrap: anywhere; }
.actions { display: flex; justify-content: flex-end; }
.dashboard-columns, .two-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dashboard-columns .panel, .two-panels .panel { min-width: 0; }
.trend-list { display: grid; gap: 12px; }
.trend-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 54px; gap: 10px; align-items: center; font-size: 13px; }
.trend-day { color: var(--muted); }
.trend-bar { height: 9px; background: #e8eef3; overflow: hidden; }
.trend-bar span { display: block; height: 100%; min-width: 2px; background: var(--blue); }
.runtime-list { display: grid; gap: 0; }
.runtime-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.runtime-list > div:first-child { border-top: 0; padding-top: 0; }
.runtime-list strong { color: var(--muted); font-weight: 600; }
.runtime-list .state-ok { color: var(--green); }
.quick-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-link { display: block; padding: 14px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; background: #fbfcfd; }
.quick-link:hover { border-color: #a7c9e1; background: #f4f9fc; }
.quick-link strong, .quick-link small { display: block; }
.quick-link small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { color: var(--muted); margin-top: 3px; }
.data-table code { color: var(--blue-dark); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.action-cell { white-space: nowrap; }
.danger-button { color: var(--red); }
.danger-button:hover { color: #8c1d18; background: #fff0ee; }
.empty-cell { padding: 28px 10px !important; color: var(--muted); text-align: center !important; }
.form-check { display: flex; align-items: end; padding-bottom: 8px; }
.form-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-check input { width: 18px; min-height: 18px; }
.select-dropdown { position: relative; }
.select-dropdown summary {
  min-height: 42px; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 35px 9px 11px; border: 1px solid var(--line); background: white;
  color: var(--muted); cursor: pointer; list-style: none; position: relative;
}
.select-dropdown summary::-webkit-details-marker { display: none; }
.select-dropdown summary::after { content: "⌄"; position: absolute; right: 12px; color: var(--blue); font-size: 18px; }
.select-dropdown[open] summary { outline: 2px solid rgba(23, 105, 170, .18); border-color: var(--blue); }
.select-dropdown[open] summary::after { content: "⌃"; }
.select-dropdown-menu {
  position: absolute; z-index: 10; top: calc(100% + 5px); left: 0; right: 0; max-height: 220px;
  overflow-y: auto; padding: 6px; border: 1px solid var(--line); background: white;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .14);
}
.select-dropdown-menu label { display: flex; align-items: center; gap: 9px; padding: 9px 8px; margin: 0; font-weight: 500; cursor: pointer; }
.select-dropdown-menu label:hover { background: #f2f8fc; }
.select-dropdown-menu input { width: 17px; min-height: 17px; accent-color: var(--blue); }
.dropdown-empty { margin: 9px; color: var(--muted); font-size: 13px; }
.stack-form { display: grid; gap: 8px; }
.stack-form label { margin-top: 5px; }
.entry-url { display: grid; gap: 5px; margin-top: 18px; padding: 14px; background: #f2f8fc; border-left: 3px solid var(--blue); }
.entry-url span { color: var(--muted); font-size: 13px; }
.entry-url code { overflow-wrap: anywhere; color: var(--blue-dark); }
.qr-placeholder { display: flex; align-items: center; gap: 18px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.qr-box { width: 126px; height: 126px; display: grid; place-items: center; flex: 0 0 126px; border: 1px dashed #91abc0; color: var(--blue); text-align: center; background: repeating-linear-gradient(45deg, #f4f8fb, #f4f8fb 5px, #fff 5px, #fff 10px); }
.qr-image { width: 148px; height: 148px; flex: 0 0 148px; border: 1px solid var(--line); background: white; padding: 8px; }
.date-filter { display: flex; align-items: center; gap: 8px; }
.date-filter input { width: 160px; }
.date-filter button { min-height: 42px; }
.cell-wide { min-width: 220px; max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-sheet { padding: 0; overflow: hidden; }
.sheet-table { min-width: 1320px; table-layout: fixed; background: white; }
.sheet-table th { position: sticky; top: 0; z-index: 1; background: #f7fafc; border-bottom: 1px solid var(--line); }
.sheet-table th, .sheet-table td { border-right: 1px solid var(--line); }
.sheet-table th:last-child, .sheet-table td:last-child { border-right: 0; }
.sheet-table tbody tr:hover { background: #fbfdff; }
.sheet-cell { min-width: 160px; max-width: 280px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.sheet-cell strong { display: inline; margin-right: 6px; color: var(--muted); font-size: 12px; }
.work-cell { min-width: 300px; max-width: 420px; }
.problem-cell { color: #7a271a; background: #fffaf9; }
.sticky-name { position: sticky; left: 0; z-index: 2; background: white; min-width: 118px; }
.sheet-table th:first-child { left: 0; z-index: 3; }
.missing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.missing-person { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid #f0b5ae; background: #fff7f6; }
.missing-person strong, .missing-person small { display: block; }
.missing-person small { color: var(--muted); margin-top: 2px; }
.toggle-pill { min-height: 30px; min-width: 54px; padding: 0 12px; border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 999px; }
.toggle-pill.on { border-color: #9bd0b2; color: var(--green); background: #f3fbf6; }
.toggle-pill.off { border-color: #f0b5ae; color: var(--red); background: #fff7f6; }
.row-editor { display: inline-block; margin-right: 6px; position: relative; }
.row-editor summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; list-style: none; }
.row-editor summary::-webkit-details-marker { display: none; }
.row-edit-form { position: absolute; right: 0; top: 26px; z-index: 20; width: 360px; max-width: 78vw; padding: 14px; border: 1px solid var(--line); background: white; box-shadow: 0 14px 34px rgba(16, 24, 40, .16); white-space: normal; }
.row-edit-form label { margin-top: 8px; font-size: 13px; }
.row-edit-form input { min-height: 34px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; max-height: 120px; overflow: auto; padding: 8px; border: 1px solid var(--line); }
.check-grid label, .inline-check { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 500; }
.check-grid input, .inline-check input { width: 16px; min-height: 16px; }
.h5-body { min-height: 100vh; background: #eef3f7; }
.h5-shell { width: min(100% - 24px, 720px); margin: 0 auto; padding: 22px 0 44px; }
.h5-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.h5-header h1 { margin: 0; font-size: 24px; }
.h5-header p { margin: 2px 0 0; color: var(--muted); }
.h5-identity { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 13px 15px; border: 1px solid #b5dfc8; background: #f4fcf7; }
.h5-identity span, .h5-identity strong { display: block; }
.h5-identity span { color: var(--muted); font-size: 12px; }
.h5-identity strong { margin-top: 2px; color: var(--green); font-size: 18px; }
.h5-identity a { color: var(--blue); font-weight: 600; text-decoration: none; white-space: nowrap; }
.h5-form { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); background: white; }
.h5-form label { margin: 0; }
.h5-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
@media (max-width: 650px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { padding: 32px; }
  .auth-intro h1 { font-size: 30px; }
  .auth-card { width: 100%; }
  .console-body { display: block; }
  .sidebar { width: 100%; }
  .sidebar-nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; }
  .sidebar-nav .nav-label, .sidebar-footer, .nav-item.disabled { display: none; }
  .nav-item { white-space: nowrap; }
  .console-topbar { padding: 0 16px; }
  .console-content { width: min(100% - 20px, 980px); margin-top: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .welcome { align-items: flex-start; flex-direction: column; gap: 13px; }
  .shortcut-panel { align-items: flex-start; flex-direction: column; }
  .monitor-actions { width: 100%; justify-content: space-between; }
  .topbar-actions { gap: 7px; }
  .user-chip span:last-child { display: none; }
  .profile-grid { grid-template-columns: 1fr; }
  .grid, .status-row, .test-steps { grid-template-columns: 1fr; }
  .dashboard-columns, .two-panels { grid-template-columns: 1fr; }
  .quick-links, .missing-grid { grid-template-columns: 1fr; }
  .date-filter { width: 100%; }
  .date-filter input { flex: 1; width: auto; }
  .qr-placeholder { align-items: flex-start; flex-direction: column; }
  .h5-actions { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .panel { padding: 17px; }
}
