/* ============================================================
   颐养智护 · 平台后台 —— 视觉系统
   与机构工作台共用：冷白底 / 石墨文字 / 医用青 / 细线 / 极轻圆角
   ============================================================ */

:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #2c343a;
  background: #f4f6f6;
  -webkit-font-smoothing: antialiased;

  --ink: #10161a;
  --text: #2c343a;
  --muted: #6b767d;
  --faint: #8d979d;
  --line: #e4e8ea;
  --line-2: #d3d9dd;
  --canvas: #f4f6f6;
  --surface: #fff;
  --surface-2: #f8f9f9;
  --surface-3: #eef1f1;
  --accent: #0d6e6a;
  --accent-2: #0a5551;
  --accent-wash: #e8f2f1;
  --danger: #a32b24;
  --danger-wash: #fbeceb;
  --warn: #8a6212;
  --warn-wash: #f9f2e3;
  --radius: 3px;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
h1, h2, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
::selection { background: #cfe8e5; color: #0a3d3a; }
:where(a, button, summary, input, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
small { font-size: .86em; }
em { color: var(--danger); font-style: normal; margin-left: 1px; }
svg { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 骨架 ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; z-index: 2;
  height: 100dvh; overflow: auto;
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  color: var(--text);
  background: #fbfcfc;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 0 2px; color: var(--ink); font-size: 14.5px; font-weight: 600; line-height: 1.25; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand > span:last-child { min-width: 0; }
.brand small { display: block; margin-top: 1px; color: var(--faint); font-size: 11px; font-weight: 400; letter-spacing: .04em; }
.brand-mark {
  flex: none; width: 30px; height: 30px;
  display: grid; place-items: center;
  color: #7ddfd1; background: #171d21;
  border-radius: 3px;
  font-size: 13px; font-weight: 500;
}

.sidebar nav { display: grid; gap: 1px; margin-top: 22px; }
.sidebar nav :where(a, summary) {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 34px; padding: 0 9px;
  color: var(--text); border-radius: var(--radius);
  font-size: 13px; font-weight: 500; text-decoration: none;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.sidebar nav :where(a, summary):hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }
.sidebar nav [aria-current="page"] { color: var(--ink); background: var(--surface-3); font-weight: 600; }
.sidebar nav [aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 2px; border-radius: 1px; background: var(--accent);
}
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
  content: ""; width: 5px; height: 5px; flex: none;
  border: solid var(--faint); border-width: 0 1px 1px 0;
  transform: rotate(45deg); margin: 0 3px 3px 0;
  transition: transform .18s var(--ease);
}
.nav-group[open] summary { color: var(--ink); }
.nav-group[open] summary::after { transform: rotate(-135deg); margin-bottom: -2px; }
.nav-group > div { display: grid; gap: 1px; margin: 2px 0 4px 14px; padding-left: 7px; border-left: 1px solid var(--line); }
.nav-group > div a { min-height: 30px; padding: 0 8px; font-size: 12.5px; color: var(--muted); }
.nav-group > div a[aria-current="page"] { color: var(--ink); background: var(--surface-3); font-weight: 600; }
.nav-group > div a[aria-current="page"]::before { display: none; }

.sidebar-user {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding: 11px 2px 2px;
  border-top: 1px solid var(--line);
}
.sidebar-user strong { display: block; color: var(--ink); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.sidebar-user small { color: var(--faint); font-size: 11px; }
.logout {
  min-height: 28px; padding: 0 9px;
  color: var(--muted); background: var(--surface); font-size: 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.logout:hover { color: var(--ink); background: var(--surface-2); border-color: #bcc4c9; }

.console { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 clamp(16px, 2.4vw, 34px);
  color: var(--muted); font-size: 12.5px;
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.topbar > span > span { margin-inline: 7px; color: var(--faint); }
.topbar strong { color: var(--ink); font-weight: 600; }
.topbar .dashboard-entry { margin-inline-start: auto; min-height: 32px; gap: 4px; }
.console > main { flex: 1; padding: 26px clamp(16px, 2.4vw, 34px) 48px; }

/* ---------- 页头 ---------- */
.page-head, .profile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-head h1, .profile-head h1 { color: var(--ink); font-size: 23px; line-height: 1.25; letter-spacing: -.022em; }
.page-head p, .profile-head p { margin-top: 5px; color: var(--muted); font-size: 12.5px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.back-link:hover { color: var(--accent); }

/* ---------- 按钮 ---------- */
.button {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 12px;
  color: var(--text); text-align: center; text-decoration: none;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; line-height: 1.3; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .06s var(--ease);
}
.button:hover { text-decoration: none; }
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: #171d21; border-color: #171d21; }
.button.primary:hover { color: #fff; background: #000; border-color: #000; }
.button.secondary { color: var(--text); background: var(--surface); border-color: var(--line-2); }
.button.secondary:hover { color: var(--ink); background: var(--surface-2); border-color: #bcc4c9; }
.button.danger-outline, .button.danger-outline:hover { color: var(--danger); border-color: #e7c6c3; }
.button.danger-outline:hover:not(:disabled) { background: var(--danger-wash); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: #87231d; border-color: #87231d; }
.button.compact { min-height: 28px; padding: 0 9px; font-size: 12px; }
.button:disabled { opacity: .45; cursor: default; }

.notice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 8px 11px;
  font-size: 12.5px;
  border: 1px solid var(--line); border-left: 2px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.notice.error { color: var(--danger); background: var(--danger-wash); border-color: #f0d3d0; border-left-color: var(--danger); }
.notice.success { color: var(--accent-2); background: var(--accent-wash); border-color: #cfe4e1; border-left-color: var(--accent); }
.login-card .notice { margin-bottom: 16px; }

/* ---------- 计量条 ---------- */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.metrics a {
  display: grid; gap: 3px; align-content: center;
  min-width: 0; padding: 13px 16px 14px;
  color: inherit; background: var(--surface); text-decoration: none;
  transition: background .15s var(--ease);
}
.metrics a:hover { background: var(--surface-2); text-decoration: none; }
.metrics a span { color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: .04em; }
.metrics a strong { color: var(--ink); font-size: 27px; font-weight: 600; line-height: 1.14; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metrics a strong small { margin-left: 3px; color: var(--faint); font-size: 11px; font-weight: 500; letter-spacing: 0; }
.metrics a small { color: var(--faint); font-size: 11px; }
.profile-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.profile-metrics a strong { font-size: 22px; }

/* ---------- 面板 ---------- */
.overview-panels, .profile-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { color: var(--ink); font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.panel-head a { font-size: 12px; }
.panel-foot { padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12px; }
.empty-note { padding: 18px 14px; color: var(--faint); font-size: 12.5px; }
.overview-org {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 11px 14px;
  color: inherit; text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background .14s var(--ease);
}
.overview-org:last-child { border-bottom: 0; }
.overview-org:hover { background: var(--surface-2); text-decoration: none; }
.overview-org strong { color: var(--ink); font-size: 13px; font-weight: 600; }
.overview-org small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.overview-org > span[aria-hidden] { color: var(--faint); }

/* ---------- 管理总览：指标、图表与清单 ---------- */
.ov-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.ov-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ov-metrics a { gap: 2px; padding: 12px 15px 13px; }
.ov-metrics a strong { font-size: 24px; }
.ov-metrics a strong.is-text { font-size: 17px; letter-spacing: -.01em; }
.ov-metrics a small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ov-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); gap: 14px; align-items: start; margin-bottom: 14px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.ov-col { display: grid; gap: 14px; min-width: 0; }
.ov-col:only-child { grid-column: 1 / -1; }
.panel-note { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

/* 机构床位规模：横向条 */
.ov-bars { display: grid; gap: 1px; padding: 9px 14px 12px; }
.ov-bar {
  display: grid; grid-template-columns: minmax(92px, 150px) minmax(0, 1fr) 60px 42px;
  align-items: center; gap: 10px;
  padding: 5px 6px; border-radius: 2px;
  color: inherit; text-decoration: none;
  transition: background .14s var(--ease);
}
.ov-bar:hover { background: var(--surface-2); text-decoration: none; }
.ov-bar-name { overflow: hidden; color: var(--text); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.ov-bar-track { display: block; height: 9px; overflow: hidden; border-radius: 1px; background: var(--surface-3); }
.ov-bar-track i { display: block; height: 100%; border-radius: 1px; background: linear-gradient(90deg, #0d6e6a, #43a79f); }
.ov-bar-value { color: var(--ink); font-family: var(--mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.ov-bar-value small { margin-left: 2px; color: var(--faint); font-size: 10px; }
.ov-bar-rate { color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }

/* 机构清单 */
.ov-table-head, .ov-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 92px 58px 52px 74px;
  align-items: center; gap: 10px; padding: 0 14px;
}
.ov-table-head { min-height: 33px; color: var(--faint); font-size: 11px; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.ov-row { min-height: 54px; color: inherit; border-bottom: 1px solid var(--line); transition: background .14s var(--ease); }
.ov-row:last-child { border-bottom: 0; }
.ov-row:hover { background: var(--surface-2); text-decoration: none; }
.ov-cell-name { min-width: 0; }
.ov-cell-name strong { display: block; overflow: hidden; color: var(--ink); font-size: 12.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ov-cell-name small { display: block; margin-top: 1px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.ov-cell-muted { overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.ov-cell-num { color: var(--text); font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* 比例图 */
.ov-chart-body { display: flex; align-items: center; gap: clamp(12px, 1.3vw, 20px); padding: 13px 15px; }
.ov-ring { position: relative; flex: none; width: min(96px, 36%); aspect-ratio: 1; border-radius: 50%; }
.ov-ring::after { position: absolute; inset: 20%; border-radius: 50%; background: var(--surface); content: ""; }
.ov-ring span { position: absolute; inset: 0; z-index: 1; display: flex; align-items: baseline; align-content: center; justify-content: center; flex-wrap: wrap; gap: 2px; color: var(--ink); font-family: var(--mono); font-size: clamp(15px, 1.4vw, 20px); font-weight: 600; letter-spacing: -.03em; }
.ov-ring span i { color: var(--faint); font-size: 10px; font-style: normal; }
.ov-legend { display: grid; flex: 1; gap: 5px; min-width: 0; margin: 0; }
.ov-legend > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ov-legend dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.ov-legend dt i { flex: none; width: 7px; height: 7px; border-radius: 1px; }
.ov-legend dd { margin: 0; color: var(--ink); font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-legend dd small { display: inline-block; min-width: 32px; margin-left: 4px; color: var(--faint); font-size: 10px; text-align: end; }
.ov-chart-empty { margin: 0; color: var(--muted); font-size: 12px; }

/* 地区分布 */
.ov-regions { display: grid; gap: 8px; padding: 14px 16px 16px; }
.ov-region { display: grid; grid-template-columns: minmax(48px, 78px) minmax(0, 1fr) 92px; align-items: center; gap: 9px; }
.ov-region-name { overflow: hidden; color: var(--text); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.ov-region-track { height: 7px; overflow: hidden; border-radius: 1px; background: var(--surface-3); }
.ov-region-track i { display: block; height: 100%; background: #7ba7b8; }
.ov-region-value { color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.ov-region-value small { margin-left: 4px; color: var(--faint); font-size: 10px; }

/* 近 7 日告警 */
.ov-trend-summary { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; justify-content: flex-end; }
.ov-trend-summary a { white-space: nowrap; }
.ov-trend, .ov-trend-unavailable { block-size: 110px; }
.ov-trend { display: flex; align-items: flex-end; gap: 6px; padding: 10px 14px; }
.ov-trend-unavailable { display: grid; place-items: center; padding: 10px 14px; color: var(--muted); font-size: 12px; }
.ov-trend-col { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.ov-trend-count { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.ov-trend-track { display: flex; flex: 1; align-items: flex-end; width: 100%; max-width: 42px; border-bottom: 1px solid var(--line-2); }
.ov-trend-track i { display: block; width: 100%; min-height: 3px; border-radius: 1px 1px 0 0; background: linear-gradient(180deg, #d59a2c, #e9cb8d); }
.ov-trend-col small { color: var(--faint); font-size: 9.5px; white-space: nowrap; }

/* 快捷入口 */
.ov-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr)); gap: 1px; background: var(--line); }
.ov-links a { display: grid; gap: 2px; padding: 11px 14px 12px; color: var(--ink); background: var(--surface); font-size: 12.5px; font-weight: 600; transition: background .14s var(--ease); }
.ov-links a:hover { background: var(--surface-2); text-decoration: none; }
.ov-links a small { color: var(--muted); font-size: 11px; font-weight: 400; }

.profile-head { align-items: center; padding: 14px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.profile-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.profile-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; overflow-wrap: anywhere; }
.profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.profile-grid > .panel:last-child:nth-child(odd) { grid-column: 1 / -1; }
.profile-grid > .panel:last-child:nth-child(odd) .facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); column-gap: 26px;
}
.profile-grid > .panel:last-child:nth-child(odd) .facts > div { grid-template-columns: minmax(96px, 42%) minmax(0, 1fr); }
.facts { margin: 0; padding: 2px 14px; }
.facts > div { display: grid; grid-template-columns: minmax(82px, 32%) minmax(0, 1fr); column-gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; color: var(--text); font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; }
.record-delete > form { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.profile-details { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 14px; align-items: start; }
.profile-details > .panel { min-width: 0; }
.profile-admins, .profile-residents { grid-column: 1 / -1; }
.profile-residents { scroll-margin-top: 60px; }
.profile-detail-table { border: 0; border-radius: 0; }
.profile-detail-table table { min-width: 520px; }
.profile-detail-count { color: var(--muted); font-size: 12px; }
@media (min-width: 1520px) {
  .profile-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 诊断条 ---------- */
.relay-state {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  margin-bottom: 12px; padding: 9px 12px;
  color: var(--muted); font-size: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.relay-state strong { color: var(--ink); margin-left: 3px; font-weight: 600; }

/* ---------- 筛选 ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.filters input { width: min(300px, 74vw); }
.filters input[type="date"] { width: auto; }
.filters select { width: min(190px, 62vw); }
.filters > label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.filters > label > select { width: auto; min-width: 150px; }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.list-toolbar > .filters { margin-bottom: 0; margin-inline-start: auto; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.result-count { min-width: 58px; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- 表格 ---------- */
.table-clip { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.menu-group-row { background: var(--surface-2); }
.menu-group-toggle {
  display: inline-flex; align-items: center; gap: 9px; min-height: 26px; padding: 0 4px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; text-align: start; cursor: pointer;
}
.menu-group-toggle:hover:not(:disabled) { color: var(--accent); background: var(--accent-wash); }
.menu-group-toggle:disabled { cursor: default; }
.menu-group-chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(-45deg); }
.menu-group-toggle[aria-expanded="true"] .menu-group-chevron { transform: rotate(45deg); }
.menu-child > td:first-child { padding-inline-start: 32px; }
.menu-child[hidden] { display: none; }
.bulk-choice { width: 48px; text-align: center; white-space: nowrap; }
.bulk-choice input { vertical-align: middle; }
.list-pagination, .pagination-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.list-pagination { margin-top: 12px; font-size: 12px; color: var(--muted); }
.page-range { margin-inline-end: auto; }
.page-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pagination-form label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.pagination-form input[type="number"] { width: 64px; min-height: 30px; padding-block: 3px; }
.pagination-form select { min-height: 30px; padding-block: 3px; background-position: calc(100% - 14px) 12px, calc(100% - 9px) 12px; }
table { width: 100%; min-width: 660px; border-collapse: collapse; text-align: left; }
thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 12px;
  color: var(--muted); background: var(--surface-2);
  font-size: 11px; font-weight: 600; letter-spacing: .05em; white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
}
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { color: var(--text); font-size: 12.5px; overflow-wrap: anywhere; }
td strong { color: var(--ink); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover td { background: #fafbfb; }
td small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.mono { font-family: var(--mono); font-size: .95em; letter-spacing: -.01em; color: var(--muted); }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { min-width: 88px; }
.actions > a { display: inline-block; margin-inline-end: 10px; font-size: 12px; }
.actions > a.danger-link { color: var(--danger); }
.row-removal { display: inline-block; }
.row-removal button:not(.button) { padding: 0; border: 0; background: none; color: var(--danger); cursor: pointer; font: inherit; font-size: 12px; }
.row-removal button:not(.button):hover { text-decoration: underline; }
.row-details { font-size: 12px; color: var(--accent); }
.row-details summary { width: fit-content; }
.row-details small { display: block; color: var(--faint); font-size: 11px; }
.role-name-column { width: 24%; min-width: 132px; }
.role-permissions ul {
  margin: 8px 0 0; padding: 0; list-style: none; color: var(--text);
}
.role-permissions li { display: flex; flex-wrap: wrap; column-gap: 8px; }
.role-permissions li + li { margin-top: 3px; }
.small-link { margin-inline-start: 6px; font-size: 12px; }

.status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  color: var(--muted); background: var(--surface-3);
  border-radius: 2px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em; line-height: 16px; white-space: nowrap;
}
.status.active { color: #0a5651; background: var(--accent-wash); }
.status.service-due { color: var(--warn); background: var(--warn-wash); }
.status.service-expired { color: var(--danger); background: var(--danger-wash); }
.status > i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------- 表单元件 ---------- */
input:not([type="hidden"]), select, textarea {
  width: 100%; min-width: 0; min-height: 34px;
  padding: 6px 9px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:not([type="hidden"]):hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #bcc4c9; }
input:not([type="hidden"]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(13 110 106 / 12%);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled, input[readonly], textarea:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
select {
  padding-inline-end: 26px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; max-height: 260px; line-height: 1.55; }
input[type="search"]::-webkit-search-cancel-button { appearance: none; }
input[type="checkbox"] {
  width: 15px; min-width: 15px; min-height: 15px; height: 15px;
  margin: 0; padding: 0; accent-color: var(--accent);
}
body:has(.modal[open]) { overflow: hidden; }

/* ---------- 弹窗 ---------- */
.modal[open] {
  position: fixed; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  width: min(760px, calc(100% - 32px)); max-width: none;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; overflow: hidden;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 6px;
  box-shadow: 0 24px 70px rgb(10 18 22 / 20%), 0 2px 6px rgb(10 18 22 / 8%);
}
.modal-compact[open] { width: min(560px, calc(100% - 32px)); }
.modal::backdrop, .modal-backdrop { background: rgb(12 18 22 / 46%); }
.modal::backdrop { backdrop-filter: blur(2px); }
.modal-backdrop { position: fixed; inset: 0; z-index: 1; }
.modal:modal + .modal-backdrop { display: none; }
.modal-header {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 50px; padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { color: var(--ink); font-size: 14.5px; font-weight: 600; letter-spacing: -.005em; }
/* 标题只用 tabindex="-1" 承接焦点供读屏播报，不是可操作元素，不显示聚焦框 */
.modal-header h2:focus,
.modal-header h2:focus-visible { outline: none; }
.dialog-close {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  color: var(--muted); border-radius: var(--radius);
  font-size: 20px; line-height: 1;
}
.dialog-close:hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }
.editor { display: flex; flex-direction: column; min-height: 0; }
.modal-body { overflow: auto; overscroll-behavior: contain; padding: 16px 18px; }
.editor fieldset {
  min-width: 0; margin: 0; padding: 14px 0 0;
  border: 0; border-top: 1px solid var(--line);
}
.editor fieldset:first-of-type { padding-top: 0; border-top: 0; }
.editor fieldset + fieldset { margin-top: 16px; }
.editor legend {
  display: block; width: 100%; padding: 0; margin-bottom: 11px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em;
}
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px 14px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .span-all { grid-column: 1 / -1; }
.editor label, .login-card label {
  display: block; min-width: 0;
  color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.editor label :where(input, select, textarea), .login-card label input {
  display: block; margin-top: 5px;
  color: var(--text); font-size: 14px; font-weight: 400;
}
.editor label small { display: block; margin-top: 4px; color: var(--faint); font-size: 11px; font-weight: 400; line-height: 1.45; }
.grant-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 14px; }
.grant-options label { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--text); font-size: 12.5px; cursor: pointer; overflow-wrap: anywhere; }
.grant-matrix { min-width: 360px; }
.grant-matrix tbody th { background: var(--surface); color: var(--text); font-weight: 600; }
.grant-matrix tr > :nth-child(n+2) { width: 16%; text-align: center; }
.grant-matrix td input { display: block; margin: 0 auto; }
.grant-matrix td span { color: var(--faint); }
.field-help { align-self: center; color: var(--faint); font-size: 11.5px; line-height: 1.5; }
.location-editor { display: grid; gap: 10px; }
.location-map-box { min-width: 0; }
.panel > .location-map-box { margin: 0 14px 14px; }
.location-map-box summary { width: fit-content; cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; }
.organization-map { position: relative; isolation: isolate; height: clamp(220px, 33vh, 340px); margin-top: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); }
.organization-map-status { margin-top: 6px; }
.location-map-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.location-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.location-editor .field-help { margin: 0; }

/* 地址搜索：输入即联想，选中后回填省市区与坐标 */
.address-search { position: relative; }
.address-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 4;
  max-height: 286px;
  margin: 0;
  padding: 4px;
  overflow: auto;
  overscroll-behavior: contain;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 16px 38px rgb(10 18 22 / 16%), 0 2px 6px rgb(10 18 22 / 6%);
}
.address-results[hidden] { display: none; }
.address-result {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 7px 9px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
}
.address-result strong { color: var(--text); font-size: 13px; font-weight: 600; }
.address-result span { overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.address-result:hover, .address-result:focus-visible { background: var(--accent-wash); outline: none; }
.address-empty { padding: 9px; color: var(--muted); font-size: 12px; }

/* 地图选点弹层 */
.location-dialog-body { display: grid; gap: 8px; }
.location-dialog-body .organization-map { height: clamp(300px, 46vh, 460px); margin-top: 0; }
.location-dialog-foot {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.form-actions {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.form-actions > small { margin-right: auto; color: var(--faint); font-size: 11.5px; }
.settings-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.settings-tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; }
.settings-tabs a:hover { color: var(--ink); }
.settings-tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-editor .settings-fields { padding: 14px; }
.settings-editor .form-actions { padding-inline: 14px; }
.binding-context { margin-bottom: 12px; color: var(--muted); font-size: 12.5px; }
.binding-context strong { color: var(--ink); font-size: 13px; }

/* ---------- 登录 ---------- */
.login-body {
  min-height: 100dvh;
  background-color: var(--canvas);
  background-image:
    linear-gradient(to right, rgb(16 22 26 / 4%) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(16 22 26 / 4%) 1px, transparent 1px);
  background-size: 30px 30px;
}
.login-body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% 0%, transparent 30%, #f4f6f6 88%);
}
.login-bar {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  min-height: 60px; padding: 0 clamp(18px, 4vw, 54px);
  color: var(--ink);
  background: rgb(255 255 255 / 86%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.login-bar .brand-mark { width: 28px; height: 28px; }
.login-bar strong { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.login-bar span:last-child { padding-left: 10px; margin-left: 2px; color: var(--faint); font-size: 12.5px; border-left: 1px solid var(--line-2); }
.login-shell { position: relative; z-index: 1; width: min(392px, calc(100% - 32px)); margin: clamp(40px, 11vh, 108px) auto 48px; }
.login-card {
  padding: 32px clamp(22px, 4vw, 34px) 30px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 5px;
  box-shadow: 0 1px 2px rgb(16 22 26 / 4%), 0 18px 46px -30px rgb(16 22 26 / 22%);
}
.login-card h1 { color: var(--ink); font-size: 22px; line-height: 1.3; letter-spacing: -.02em; }
.login-tagline { margin-top: 7px; margin-bottom: 22px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.login-foot { margin-top: 20px; color: var(--faint); font-size: 11.5px; letter-spacing: .03em; text-align: center; }
.login-card form { --login-control-height: 38px; display: grid; gap: 14px; }
.login-card label { gap: 6px; }
.login-card input { min-height: var(--login-control-height); }
.login-card input, .login-card button { font-size: 13.5px; }
.login-card button { min-height: var(--login-control-height); margin-top: 6px; }
.login-card .notice { margin-bottom: 0; }
.login-captcha { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.captcha-refresh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.login-captcha input, .captcha-refresh img { height: var(--login-control-height); }
.captcha-refresh img { width: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); }
.captcha-status { font-size: 12px; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-table-head, .ov-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 58px 52px 74px; }
  .ov-table-head > :nth-child(3), .ov-row > :nth-child(3) { display: none; }
}
@media (max-width: 1000px) {
  .shell { grid-template-columns: 196px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .profile-metrics { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar {
    position: sticky; height: auto;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
    padding: 10px 12px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar nav { grid-row: 2; grid-column: 1 / -1; margin-top: 0; }
  .nav-group > div { margin-left: 8px; }
  .sidebar-user { margin: 0; padding: 0; border: 0; }
  .topbar { min-height: 44px; }
  .console > main { padding-block: 18px 32px; }
  .overview-panels, .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head, .profile-head { flex-wrap: wrap; gap: 10px; }
  .page-head h1, .profile-head h1 { font-size: 20px; }
  .fields.three { grid-template-columns: minmax(0, 1fr); }
  .filters input { width: 100%; }
  .ov-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-table-head { display: none; }
  .ov-row { grid-template-columns: minmax(0, 1fr) 46px 72px; padding-block: 9px; }
  .ov-row > :nth-child(2), .ov-row > :nth-child(3), .ov-row > :nth-child(5) { display: none; }
  .ov-chart-body { gap: 14px; padding: 12px 13px; }
  .ov-ring { width: 84px; }
  .ov-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 460px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .profile-head { padding: 12px; }
  .metrics a { padding: 11px 12px; }
  .metrics a strong { font-size: 23px; }
  .ov-bar { grid-template-columns: minmax(0, 1fr) minmax(40px, 1.2fr) 52px; }
  .ov-bar-rate { display: none; }
  .modal[open] { width: calc(100% - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .modal-header, .modal-body, .form-actions { padding-inline: 13px; }
}
