:root {
  --bg: #eef1f2;
  --surface: #ffffff;
  --surface-subtle: #f6f8f8;
  --line: #d8dee0;
  --line-strong: #bdc8cc;
  --text: #172328;
  --muted: #64737a;
  --accent: #117276;
  --accent-dark: #0b595d;
  --nav: #172327;
  --nav-hover: #243438;
  --success: #28764c;
  --warning: #946200;
  --danger: #ad3329;
  --radius: 6px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { touch-action: manipulation; }

.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px 14px;
  overflow-y: auto;
  background: var(--nav);
  color: #eef3f4;
  border-right: 1px solid #151c20;
}
.brand { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 0 7px; font-size: 15px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 5px; background: #d9eeee; color: #0a6266; font-size: 16px; }
.brand-copy { min-width: 0; }
.brand small { display: block; margin-top: 2px; color: #9fb0b7; font-size: 11px; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 15px; margin-top: 22px; }
.nav-group { display: grid; gap: 2px; }
.nav-label { padding: 0 9px 5px; color: #7f949b; font-size: 10px; font-weight: 700; }
.nav a { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; min-height: 35px; padding: 7px 9px; border-radius: 4px; color: #d6e0e3; text-decoration: none; line-height: 20px; }
.nav-glyph { display: inline-grid; place-items: center; width: 20px; height: 20px; color: #91a8ae; font-size: 14px; font-weight: 400; }
.nav a:hover { background: var(--nav-hover); color: #fff; }
.nav a:hover .nav-glyph { color: #d9eeee; }
.nav a.active { background: #d8ecec; color: #103f42; font-weight: 700; }
.nav a.active .nav-glyph { color: #0c6569; }
.sidebar-meta { margin-top: auto; padding: 17px 8px 0; border-top: 1px solid #314044; color: #9fb0b7; font-size: 11px; }
.sidebar-state { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: #c8d5d8; }
.db-label { margin-bottom: 9px; overflow-wrap: anywhere; }
.btn-link { padding: 0; border: 0; background: transparent; color: #c7d3d7; cursor: pointer; }

.main { width: 100%; min-width: 0; max-width: 1720px; margin: 0 auto; padding: 24px 32px 52px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 58px; margin-bottom: 19px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: 0; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; min-width: 0; }
.global-search { display: grid; grid-template-columns: minmax(210px, 300px) auto; gap: 6px; }
.global-search label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.global-search input { min-height: 36px; }
.topbar-sync { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.topbar-sync:hover { color: var(--text); text-decoration: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.dot.warn { background: var(--warning); }
.dot.bad { background: var(--danger); }

.metrics { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 24px; }
.metric { min-width: 0; padding: 15px 16px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 5px; font-size: 23px; font-weight: 750; font-variant-numeric: tabular-nums; }
.metric-value.small { font-size: 17px; }
.metric.warning .metric-value { color: var(--warning); }
.metric.danger .metric-value { color: var(--danger); }

.dashboard-command { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 -32px 18px; padding: 25px 32px 24px; border-bottom: 1px solid #b8c7c9; background: #dce9e9; }
.dashboard-command h2 { margin: 5px 0 6px; font-size: 25px; line-height: 1.25; }
.dashboard-command p { margin: 0; color: #4d6268; }
.command-date { color: #3d6266; font-size: 11px; font-weight: 700; }
.command-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.health-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.health-cell { position: relative; display: grid; min-width: 0; min-height: 88px; padding: 14px 16px; border-right: 1px solid var(--line); color: var(--text); text-decoration: none; }
.health-cell:last-child { border-right: 0; }
.health-cell::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 3px; background: #89999e; }
.health-cell.status-ok::before { background: var(--success); }
.health-cell.status-warn::before { background: var(--warning); }
.health-cell.status-failed::before { background: var(--danger); }
.health-cell:hover { background: var(--surface-subtle); color: var(--text); text-decoration: none; }
.health-cell span { color: var(--muted); font-size: 11px; }
.health-cell strong { margin-top: 4px; font-size: 18px; }
.health-cell small { margin-top: 5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); gap: 22px; align-items: start; }
.content-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 22px; }
.panel { min-width: 0; padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid var(--line); }
.stack > .panel { margin-bottom: 0; }
.panel h2 { margin: 0 0 12px; font-size: 16px; line-height: 1.35; }
.panel h3 { margin: 0 0 10px; font-size: 14px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1.7fr) repeat(2, minmax(150px, .7fr)) auto; gap: 8px; margin-bottom: 12px; }
.filter-bar.two { grid-template-columns: minmax(220px, 1fr) minmax(160px, .45fr) auto; }
.filter-bar.message-filters { grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(140px, .65fr)) auto; }
.filter-bar.approval-filters { grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(135px, .65fr)) auto; }
.filter-bar label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: #edf1f2; color: #3e4a52; font-size: 12px; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafb; }
.projects-table { min-width: 1260px; }
.events-table { min-width: 1050px; }
.messages-table { min-width: 1120px; }
.rooms-table { min-width: 1180px; }
.documents-table { min-width: 1030px; }
.people-table { min-width: 820px; table-layout: fixed; }
.people-table th:nth-child(1) { width: 17%; }
.people-table th:nth-child(2) { width: 17%; }
.people-table th:nth-child(3) { width: 12%; }
.people-table th:nth-child(4) { width: 25%; }
.people-table th:nth-child(5) { width: 8%; }
.people-table th:nth-child(6) { width: 13%; }
.people-table th:nth-child(7) { width: 8%; }
.people-table td { overflow-wrap: anywhere; }
.people-projects { line-height: 1.55; }
.approval-table { min-width: 1080px; }
.capability-table { min-width: 820px; }
.cell-id { max-width: 190px; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.cell-nowrap { white-space: nowrap; }
.cell-summary { min-width: 220px; max-width: 480px; line-height: 1.45; overflow-wrap: anywhere; }
.cell-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.empty-state { padding: 28px 14px; text-align: center; color: var(--muted); }

.chip { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 7px; border-radius: 4px; background: #e7ecee; color: #3b474e; font-size: 11px; white-space: nowrap; }
.chip.status-done, .chip.status-ok, .chip.status-active { background: #ddefe4; color: #225f3e; }
.chip.status-pending, .chip.status-warn, .chip.status-ready { background: #fff0c7; color: #755000; }
.chip.status-offline { background: #fff0c7; color: #755000; }
.chip.status-failed, .chip.status-missing { background: #f8dfdc; color: #8b2a22; }
.chip.status-limited { background: #e7e8f3; color: #4a4d75; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 12px; border: 1px solid transparent; border-radius: 5px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--text); }
.btn.secondary:hover { background: #edf1f2; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled, .btn.disabled { opacity: .48; cursor: not-allowed; pointer-events: none; }
.text-danger { padding: 0; border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.text-action { padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.form-span { grid-column: 1 / -1; }
label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid rgba(23, 107, 135, .13); }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.actions form { margin: 0; }
.inline-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 6px; align-items: center; }
.reindex-form { max-width: 430px; margin-top: 12px; }

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.detail-item { min-width: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.detail-item:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-item:nth-last-child(-n+2) { border-bottom: 0; }
.detail-item dt { margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.detail-item dd { margin: 0; overflow-wrap: anywhere; }
.progress-list { display: grid; gap: 11px; }
.progress-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 44px; gap: 9px; align-items: center; }
.progress-track { height: 7px; overflow: hidden; border-radius: 3px; background: #dfe5e8; }
.progress-fill { height: 100%; background: var(--accent); }
.progress-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.link-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.link-row:last-child { border-bottom: 0; }
.link-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.signal-list { display: grid; border-top: 1px solid var(--line); }
.signal-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 11px; align-items: center; min-height: 56px; padding: 9px 3px; border-bottom: 1px solid var(--line); color: var(--text); }
.signal-row:hover { background: var(--surface-subtle); color: var(--text); text-decoration: none; }
.signal-state { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.signal-state.ok { background: var(--success); }
.signal-copy { display: grid; min-width: 0; gap: 3px; }
.signal-copy strong { font-size: 12px; }
.signal-copy span { overflow: hidden; color: #44535a; text-overflow: ellipsis; white-space: nowrap; }
.signal-row time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.search-results { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.search-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search-result:last-child { border-bottom: 0; }
.search-result-main { min-width: 0; }
.search-result-main strong { overflow-wrap: anywhere; }
.search-result-main p { margin: 5px 0 0; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.search-meta { margin-top: 4px; color: #47555e; font-size: 12px; overflow-wrap: anywhere; }
.task-list { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.task-item { display: grid; grid-template-columns: 5px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-priority { align-self: stretch; min-height: 46px; background: #7f8c93; }
.task-item.severity-critical .task-priority { background: var(--danger); }
.task-item.severity-warning .task-priority { background: var(--warning); }
.task-item.severity-info .task-priority { background: var(--accent); }
.task-main { min-width: 0; }
.task-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-main strong, .task-main p { overflow-wrap: anywhere; }
.task-main p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.task-meta { margin-top: 6px; color: var(--muted); font-size: 11px; }
.task-list.compact .task-item { grid-template-columns: 4px minmax(0, 1fr); padding-top: 10px; padding-bottom: 10px; }
.task-list.compact .task-priority { min-height: 38px; }
.settings-row { display: grid; grid-template-columns: minmax(180px, 260px); margin-bottom: 12px; }
.input-suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.input-suffix span { color: var(--muted); }
.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.rule-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 9px; align-items: start; min-width: 0; min-height: 68px; margin: 0; padding: 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.rule-option:hover { background: var(--surface-subtle); }
.rule-option input { width: 16px; min-height: 16px; margin: 2px 0 0; }
.rule-option strong, .rule-option small { display: block; overflow-wrap: anywhere; }
.rule-option small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.flash { padding: 10px 12px; margin-bottom: 14px; border: 1px solid #95c5a9; border-radius: 5px; background: #e4f2e9; color: #205b3a; overflow-wrap: anywhere; }
.flash.error { border-color: #dfa39d; background: #f9e7e4; color: #80271f; }
.muted { color: var(--muted); }
.help-box { color: var(--muted); line-height: 1.65; }
.help-box code, code { padding: 2px 4px; border-radius: 3px; background: #e7ecee; color: #29434e; }
.sheet-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.sheet-status > div { min-height: 54px; padding: 10px 12px; background: var(--surface); }
.sheet-status strong { display: block; margin-top: 3px; color: var(--text); }
.danger-zone { border-bottom-color: #dfa9a4; }
.confirm-dialog { width: min(480px, calc(100vw - 28px)); padding: 20px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--text); }
.member-dialog { width: min(720px, calc(100vw - 28px)); }
.confirm-dialog::backdrop { background: rgba(23, 29, 32, .48); }
.confirm-dialog h2 { margin-top: 0; }
.dialog-actions { justify-content: flex-end; }
pre.result { max-height: 320px; padding: 12px; overflow: auto; border: 1px solid #34454d; border-radius: var(--radius); background: #202b30; color: #e3edef; white-space: pre-wrap; }
.message-content { margin: 0; min-height: 70px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font-family: inherit; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.raw-json { max-height: 520px; }

.activity-timeline { position: relative; border-top: 1px solid var(--line); }
.activity-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.activity-item::before { content: ""; position: absolute; top: 0; bottom: 0; left: 7px; width: 1px; background: var(--line-strong); }
.activity-item:first-child::before { top: 21px; }
.activity-item:last-child::before { bottom: calc(100% - 22px); }
.activity-marker { position: relative; z-index: 1; width: 15px; height: 15px; margin-top: 3px; border: 3px solid var(--surface); border-radius: 50%; background: #7b8b93; box-shadow: 0 0 0 1px var(--line-strong); }
.activity-item.kind-event .activity-marker { background: var(--accent); }
.activity-item.kind-document .activity-marker { background: var(--success); }
.activity-item.kind-asset .activity-marker { background: #6a6593; }
.activity-item.kind-approval .activity-marker { background: #4f6b42; }
.activity-item.kind-sync .activity-marker { background: var(--warning); }
.activity-body { min-width: 0; }
.activity-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.activity-heading strong { overflow-wrap: anywhere; }
.activity-body p { margin: 5px 0 0; color: #46545c; line-height: 1.5; overflow-wrap: anywhere; }
.activity-meta { margin-top: 6px; color: var(--muted); font-size: 11px; }

.pagination { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr); gap: 14px; align-items: center; margin-top: 12px; color: var(--muted); font-size: 12px; }
.pagination-pages { display: flex; align-items: center; justify-content: center; gap: 4px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--text); }
.page-link:hover { background: #edf1f2; text-decoration: none; }
.page-link.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.pagination-sizes { justify-self: end; }
.pagination-sizes a { margin-left: 7px; color: var(--muted); }
.pagination-sizes a.active { color: var(--accent); font-weight: 700; }
.audit-table { min-width: 940px; }

.pipeline-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.pipeline-step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; min-height: 88px; padding: 14px 18px 14px 13px; border-right: 1px solid var(--line); }
.pipeline-step:last-child { border-right: 0; }
.pipeline-step::after { content: ""; position: absolute; top: 42px; right: -5px; z-index: 2; width: 9px; height: 9px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); background: var(--surface); transform: rotate(45deg); }
.pipeline-step:last-child::after { display: none; }
.pipeline-index { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--line-strong); border-radius: 50%; background: #edf1f2; color: #49565d; font-weight: 700; }
.pipeline-step.status-ok .pipeline-index { border-color: #8fbea2; background: #e0f0e6; color: var(--success); }
.pipeline-step.status-warn .pipeline-index, .pipeline-step.status-offline .pipeline-index { border-color: #d4b56d; background: #fff3d3; color: var(--warning); }
.pipeline-step.status-failed .pipeline-index, .pipeline-step.status-missing .pipeline-index { border-color: #d7a29c; background: #f9e4e1; color: var(--danger); }
.pipeline-step strong { display: block; font-size: 13px; }
.pipeline-step p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.source-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-top: 3px solid #88959b; border-radius: var(--radius); background: var(--surface); }
.source-card.status-ok { border-top-color: var(--success); }
.source-card.status-warn, .source-card.status-offline, .source-card.status-ready { border-top-color: var(--warning); }
.source-card.status-failed, .source-card.status-missing { border-top-color: var(--danger); }
.source-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 68px; }
.source-card-head h3 { margin: 0; font-size: 15px; }
.source-card-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.source-card-head .chip { flex: 0 0 auto; }
.source-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.source-metrics > div { min-width: 0; padding: 10px 8px; border-right: 1px solid var(--line); }
.source-metrics > div:first-child { padding-left: 0; }
.source-metrics > div:last-child { padding-right: 0; border-right: 0; }
.source-metrics span, .source-metrics strong { display: block; overflow-wrap: anywhere; }
.source-metrics span { color: var(--muted); font-size: 11px; }
.source-metrics strong { margin-top: 3px; font-size: 17px; font-variant-numeric: tabular-nums; }
.source-scope { min-height: 52px; color: #47545b; font-size: 12px; line-height: 1.5; }
.source-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.boundary-list { margin: 0; border-top: 1px solid var(--line); }
.boundary-list > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.boundary-list dt { font-weight: 700; }
.boundary-list dd { margin: 0; color: var(--muted); line-height: 1.5; }
.coverage-progress { padding-top: 5px; }
.run-error { border-color: #8c302a; background: #3b2423; }
.compact-empty { padding: 40px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.run-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.run-summary-item { min-width: 0; min-height: 82px; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.run-summary-item > span { display: block; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.run-summary-item > strong { display: block; margin-top: 7px; font-size: 18px; overflow-wrap: anywhere; }
.run-summary-item > pre { max-height: 180px; margin: 8px 0 0; overflow: auto; color: #3a474e; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
.raw-panel summary { cursor: pointer; font-weight: 700; }
.raw-panel[open] summary { margin-bottom: 12px; }
.directory-tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.directory-tool-grid > form { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-subtle); }
.directory-tool-grid h3 { margin: 0 0 12px; font-size: 14px; }
.record-subline { margin-top: 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.privacy-note { margin-top: 22px; padding: 13px 14px; border-left: 3px solid var(--accent); background: #edf4f5; color: #3e5058; }
.privacy-note strong { display: block; color: var(--text); }
.privacy-note p { margin: 5px 0 0; line-height: 1.55; }
.scope-banner { display: grid; grid-template-columns: 210px repeat(3, minmax(0, 1fr)); margin-bottom: 24px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); background: var(--surface); }
.scope-banner-title { display: flex; flex-direction: column; justify-content: center; padding: 15px 17px; background: #edf1f2; }
.scope-banner-title strong { font-size: 14px; }
.scope-banner-title span { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.scope-path { position: relative; min-width: 0; padding: 14px 16px; border-left: 1px solid var(--line); }
.scope-path::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 3px; background: #89999e; }
.scope-path.status-ok::before { background: var(--success); }
.scope-path.status-limited::before { background: #686b96; }
.scope-path.status-ready::before { background: var(--warning); }
.scope-path span, .scope-path strong, .scope-path small { display: block; }
.scope-path span { color: var(--muted); font-size: 11px; }
.scope-path strong { margin-top: 4px; font-size: 13px; }
.scope-path small { margin-top: 5px; color: #4d5c63; line-height: 1.5; }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); background: #e8edef; }
.login-context { display: flex; align-items: flex-end; padding: 48px; background: #233037; color: #edf4f5; }
.login-context h1 { margin: 0; font-size: 26px; }
.login-context p { max-width: 520px; margin: 9px 0 0; color: #b7c7cd; line-height: 1.6; }
.login-panel { display: flex; flex-direction: column; justify-content: center; width: 100%; padding: 44px; background: var(--surface); }
.login-panel h2 { margin: 0 0 6px; font-size: 21px; }
.login-panel > p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }

.message-admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.message-admin-summary { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.message-admin-separator { color: var(--line-strong); }
.status-pill { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pill.safe { background: #ddefe4; color: #225f3e; }
.status-pill.draft { background: #e8edf0; color: #4d5b62; }
.admin-tabs { display: flex; align-items: flex-end; gap: 2px; margin-bottom: 22px; overflow-x: auto; border-bottom: 1px solid var(--line-strong); }
.admin-tabs a { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 9px 14px; border-bottom: 3px solid transparent; color: var(--muted); white-space: nowrap; text-decoration: none; }
.admin-tabs a:hover { background: var(--surface-subtle); color: var(--text); }
.admin-tabs a.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 700; }
.admin-tabs small { display: inline-grid; min-width: 20px; min-height: 20px; place-items: center; padding: 0 5px; border-radius: 10px; background: #e4eaec; color: #54636a; font-size: 10px; }
.admin-tabs a.active small { background: #d8ecec; color: #0b6266; }
.editor-panel, .preview-panel { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.code-input { min-height: 150px; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.55; }
.field-help { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.message-draft-table { min-width: 980px; }
.message-draft-table td:first-child { min-width: 190px; }
.table-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 400; }
.message-draft-table .cell-actions form { display: inline; margin: 0; }
.table-action-danger { padding: 0; border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.request-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-subtle); }
.method-badge { display: inline-flex; min-width: 44px; justify-content: center; padding: 3px 7px; border-radius: 4px; background: #d8ecec; color: #0b6266; font-size: 11px; font-weight: 800; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .content-grid, .content-grid.equal { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipeline-step:nth-child(3) { border-right: 0; }
  .pipeline-step:nth-child(3)::after { display: none; }
  .pipeline-step:nth-child(n+4) { border-top: 1px solid var(--line); }
  .run-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .health-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-cell:nth-child(2) { border-right: 0; }
  .health-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .scope-banner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scope-banner-title { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; max-height: none; padding: 12px 12px 10px; }
  .brand { min-height: 38px; }
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .nav { display: flex; flex-direction: row; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .nav a { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; min-height: 34px; padding: 7px 9px; text-align: center; }
  .nav-glyph { width: auto; }
  .sidebar-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
  .sidebar-state { margin: 0; }
  .db-label { display: none; }
  .main { padding: 18px 14px 36px; }
  .topbar { align-items: flex-start; min-height: 0; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; gap: 8px; }
  .topbar h1 { font-size: 20px; }
  .filter-bar, .filter-bar.two { grid-template-columns: 1fr 1fr; }
  .filter-bar.message-filters { grid-template-columns: 1fr 1fr; }
  .filter-bar.approval-filters { grid-template-columns: 1fr 1fr; }
  .filter-bar > :first-child { grid-column: 1 / -1; }
  .rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory-tool-grid { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-item:nth-child(odd) { border-right: 0; }
  .detail-item:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .login-page { grid-template-columns: 1fr; }
  .login-context { min-height: 180px; padding: 28px 24px; }
  .login-panel { padding: 30px 24px; }
  .pagination { grid-template-columns: 1fr; gap: 8px; }
  .pagination-summary, .pagination-sizes { justify-self: center; }
  .pipeline-strip { grid-template-columns: 1fr; }
  .pipeline-step, .pipeline-step:nth-child(3), .pipeline-step:last-child { border-top: 1px solid var(--line); border-right: 0; }
  .pipeline-step:first-child { border-top: 0; }
  .pipeline-step::after { display: none; }
  .source-grid { grid-template-columns: 1fr; }
  .dashboard-command { margin: 0 -14px 16px; padding: 21px 14px 19px; }
  .dashboard-command h2 { font-size: 21px; }
  .command-actions { align-self: stretch; flex-direction: column; align-items: stretch; }
  .command-actions .btn { min-width: 104px; }
  .health-strip { grid-template-columns: 1fr; }
  .health-cell, .health-cell:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .health-cell:last-child { border-bottom: 0; }
  .scope-banner { grid-template-columns: 1fr; }
  .scope-banner-title { grid-column: auto; }
  .scope-path { border-top: 1px solid var(--line); border-left: 0; }
  .source-card-head { min-height: 0; }
  .run-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .nav { margin-right: -12px; margin-left: -12px; padding-right: 12px; padding-left: 12px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .metric:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .topbar { flex-direction: column; gap: 10px; }
  .topbar-actions, .global-search { width: 100%; }
  .topbar-actions { align-items: stretch; }
  .global-search { grid-template-columns: minmax(0, 1fr) auto; }
  .task-item { grid-template-columns: 4px minmax(0, 1fr); }
  .task-item > .btn { grid-column: 2; justify-self: start; }
  .filter-bar, .filter-bar.two { grid-template-columns: 1fr; }
  .filter-bar.message-filters { grid-template-columns: 1fr; }
  .filter-bar.approval-filters { grid-template-columns: 1fr; }
  .filter-bar > :first-child { grid-column: auto; }
  .section-heading { flex-direction: column; }
  .section-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .progress-row { grid-template-columns: 88px minmax(0, 1fr) 34px; }
  .rule-grid { grid-template-columns: 1fr; }
  .customer-table, .customer-table tbody, .customer-table tr, .customer-table td,
  .people-table, .people-table tbody, .people-table tr, .people-table td,
  .asset-table, .asset-table tbody, .asset-table tr, .asset-table td,
  .mobile-stack-table, .mobile-stack-table tbody, .mobile-stack-table tr, .mobile-stack-table td { display: block; width: 100%; min-width: 0; }
  .customer-table thead, .people-table thead, .asset-table thead, .mobile-stack-table thead { display: none; }
  .customer-table tr, .people-table tr, .asset-table tr, .mobile-stack-table tr { padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .customer-table tr:last-child, .people-table tr:last-child, .asset-table tr:last-child, .mobile-stack-table tr:last-child { border-bottom: 0; }
  .customer-table td, .people-table td, .asset-table td, .mobile-stack-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 7px 0; border: 0; white-space: normal; }
  .customer-table td::before, .people-table td::before, .asset-table td::before, .mobile-stack-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .mobile-stack-table td.empty-state { display: block; padding: 24px 8px; }
  .mobile-stack-table td.empty-state::before { content: none; }
  .customer-cell-value, .record-cell-value { min-width: 0; overflow-wrap: anywhere; }
  .customer-table .cell-summary, .mobile-stack-table .cell-summary { max-width: none; }
  .source-card-head { flex-direction: column; }
  .source-scope { min-height: 0; }
  .boundary-list > div { grid-template-columns: 1fr; gap: 4px; }
  .run-summary-grid { grid-template-columns: 1fr; }
  .message-admin-head { align-items: stretch; flex-direction: column; }
  .message-admin-summary { align-items: flex-start; flex-direction: column; }
  .message-admin-separator { display: none; }
}
