:root {
  color-scheme: light;
  --font-ui: "Geist", Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --surface-page: #f4f4f2;
  --surface-panel: #ffffff;
  --surface-subtle: #eeeeeb;
  --surface-raised: #fafaf8;
  --text-primary: #1f211f;
  --text-secondary: #646864;
  --border-default: #dedfda;
  --border-strong: #c9cbc5;
  --danger: #b84a43;
  --warning: #9a6a18;
  --success: #3f755f;
  --focus: #424844;
  --radius-panel: 12px;
  --radius-control: 8px;
}

/* 异常中心：清单、白板和案例共用同一业务入口。 */
.exception-center {
  display: block;
  min-width: 0;
}

.exception-tabs {
  min-height: 46px;
  display: flex;
  gap: 24px;
  align-items: flex-end;
  border-bottom: 1px solid var(--border-default);
}

.exception-tab {
  min-width: 44px;
  min-height: 45px;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.exception-tab:hover,
.exception-tab:focus-visible {
  color: var(--text-primary);
}

.exception-tab.active {
  border-bottom-color: var(--text-primary);
  color: var(--text-primary);
  font-weight: 600;
}

.exception-tab-panel {
  padding-top: 20px;
}

.exception-list-grid {
  display: grid;
}

.exception-board,
.exception-cases {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  overflow: hidden;
}

.exception-board-head,
.exception-section-copy {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-default);
}

.exception-board-head h2,
.exception-section-copy h2,
.case-card h3 {
  margin: 0;
  font-weight: 600;
}

.exception-board-head h2,
.exception-section-copy h2 {
  margin-top: 10px;
  font-size: 18px;
}

.exception-board-head p,
.exception-section-copy > p:last-child,
.case-card p {
  margin: 7px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}

.exception-kicker,
.case-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.semantic-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.semantic-badge.simulated {
  color: var(--warning);
  background: var(--surface-subtle);
}

.exception-board-frame {
  display: block;
  width: 100%;
  height: min(680px, calc(100vh - 190px));
  min-height: 540px;
  border: 0;
  background: var(--surface-subtle);
}

.exception-cases {
  padding-bottom: 22px;
}

.case-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 20px 22px 0;
}

.case-card {
  padding: 18px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
}

.case-card-meta {
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 11px;
}

.case-card h3 {
  margin-top: 18px;
  font-size: 15px;
}

.case-card .secondary-button {
  min-height: 44px;
  margin-top: 18px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}

@media (max-width: 760px) {
  .exception-tabs {
    gap: 18px;
    overflow-x: auto;
  }

  .exception-tab {
    flex: 0 0 auto;
    min-height: 44px;
  }

  .exception-board-head,
  .exception-section-copy,
  .case-list {
    padding-left: 15px;
    padding-right: 15px;
  }

  .exception-board-frame {
    height: 620px;
    min-height: 620px;
  }

  .case-list {
    grid-template-columns: 1fr;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #191b1a;
  --surface-panel: #222422;
  --surface-subtle: #2a2d2b;
  --surface-raised: #252725;
  --text-primary: #f1f2ef;
  --text-secondary: #aaaea9;
  --border-default: #373a37;
  --border-strong: #4a4e4a;
  --danger: #dd766d;
  --warning: #d0a054;
  --success: #79a88f;
  --focus: #d7dad5;
}

:root {
  --font-reading: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --font-reading-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", "PingFang SC", monospace;
  --bg: var(--surface-page);
  --surface: var(--surface-panel);
  --surface-strong: var(--surface-panel);
  --soft: var(--surface-subtle);
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-default);
  --primary: var(--focus);
  --primary-dark: var(--text-primary);
  --primary-soft: var(--surface-subtle);
  --blue: var(--text-secondary);
  --blue-soft: var(--surface-subtle);
  --amber: var(--warning);
  --amber-soft: #f6efe3;
  --rose: var(--danger);
  --rose-soft: #faecea;
  --lavender: var(--text-secondary);
  --lavender-soft: var(--surface-subtle);
  --mint: var(--success);
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --shadow-soft: 0 1px 2px rgba(0,0,0,.04);
  --radius: var(--radius-panel);
  --radius-small: var(--radius-control);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  background: var(--surface-page);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

button,
select,
input {
  font: inherit;
}

textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

body.ai-resizing {
  cursor: col-resize;
  user-select: none;
}

body.ai-resizing .app-shell {
  transition: none;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--surface-page);
  box-shadow: none;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  background: var(--surface-panel);
  border-color: var(--border-default);
}

.sidebar {
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  transition: padding 180ms ease;
}

.brand {
  min-width: 0;
  overflow: hidden;
  transition: opacity 140ms ease;
}

.brand-name {
  color: var(--ink);
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-subtitle {
  white-space: nowrap;
}

.brand-subtitle,
.sidebar-card,
.lede,
.panel-head p,
.ai-head p,
.meta-text {
  color: var(--muted);
}

.brand-subtitle,
.sidebar-card {
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 7px;
  transition: gap 180ms ease;
}

.nav-item {
  min-height: 44px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  transition: padding 180ms ease, gap 180ms ease, min-height 180ms ease, color 140ms ease;
}

.nav-item span {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  transition: width 180ms ease, height 180ms ease, border-radius 180ms ease;
}

.nav-item span svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-primary);
  background: var(--surface-raised);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.nav-item.active span {
  background: var(--text-primary);
  color: var(--surface-panel);
  border-color: var(--text-primary);
  box-shadow: var(--shadow);
}

.sidebar-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.sidebar-card-title {
  color: var(--ink);
  font-weight: 650;
  margin-bottom: 4px;
}

.user-dock {
  margin-top: auto;
  min-width: 0;
  position: relative;
  width: calc(100% + 32px);
  margin-left: -16px;
  margin-right: -16px;
  margin-bottom: -24px;
  border-top: 1px solid var(--border-default);
  background: var(--surface-panel);
  transition: width 180ms ease, margin 180ms ease;
}

.user-card-button {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--border-default);
  border-radius: 16px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: var(--surface-raised);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: grid-template-columns 180ms ease, gap 180ms ease, padding 180ms ease, min-height 180ms ease;
}

.user-card-button:hover,
.user-card-button[aria-expanded="true"] {
  background: var(--surface-panel);
  border-color: var(--border-strong);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--text-primary);
  color: var(--surface-panel);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0;
  box-shadow: var(--shadow);
  transition: width 180ms ease, height 180ms ease, border-radius 180ms ease;
}

.user-avatar.large {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 15px;
}

.user-card-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
  transition: opacity 140ms ease;
}

.user-card-copy strong,
.user-card-copy span,
.user-card-copy small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card-copy strong {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.user-card-copy span,
.user-card-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.user-popover {
  position: fixed;
  left: 16px;
  bottom: 18px;
  z-index: 30;
  width: min(430px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 36px));
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(174, 190, 211, 0.58);
  border-radius: 18px;
  background: rgba(250, 253, 255, 0.96);
  box-shadow: 0 28px 70px rgba(48, 83, 139, 0.22);
  backdrop-filter: blur(18px);
}

.user-popover[hidden] {
  display: none;
}

.user-popover-head {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 34px;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.user-popover-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.user-popover-head p:last-child {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.user-switch-field {
  margin-bottom: 12px;
}

.user-field,
.user-profile-form label {
  display: grid;
  gap: 6px;
}

.user-field span,
.user-profile-form label span {
  color: #657187;
  font-size: 12px;
  font-weight: 760;
}

.user-field input,
.user-field select,
.user-profile-form input,
.user-profile-form select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  padding: 0 10px;
  outline: none;
  background: var(--surface-panel);
  color: var(--text-primary);
}

.user-field input:focus,
.user-field select:focus,
.user-profile-form input:focus,
.user-profile-form select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 15%, transparent);
}

.user-profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.user-profile-form .wide {
  grid-column: 1 / -1;
}

.user-toggle {
  min-height: 38px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.user-toggle input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.user-save-policy {
  padding: 10px 12px;
  border: 1px solid rgba(193, 207, 225, 0.62);
  border-radius: 12px;
  display: grid;
  gap: 3px;
  background: rgba(239, 245, 253, 0.78);
}

.user-save-policy strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.user-save-policy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 640;
}

.user-form-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.primary-action,
.secondary-action {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 650;
}

.primary-action {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(36, 107, 254, 0.18);
}

.primary-action:hover {
  background: var(--primary-dark);
}

.secondary-action {
  background: rgba(239, 245, 253, 0.92);
  border-color: rgba(193, 207, 225, 0.72);
  color: #435168;
}

.secondary-action:hover {
  background: rgba(255, 255, 255, 0.95);
}

.secondary-action.small {
  min-height: 32px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 12px;
}

.secondary-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-db-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(193, 207, 225, 0.5);
  color: var(--muted);
  font-size: 12px;
}

.user-card-button {
  min-height: 66px;
  padding: 11px 16px;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--surface-panel);
  font-size: 11px;
  box-shadow: none;
}

.user-card-copy {
  display: grid;
  gap: 1px;
  align-content: center;
}

.user-card-copy strong {
  max-width: 136px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 500;
}

.user-card-copy span {
  max-width: 136px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 450;
}

.user-card-copy strong::after {
  content: none;
}

.user-card-chevron {
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  transition: opacity 140ms ease;
}

.user-card-chevron svg,
.user-menu-arrow svg,
.user-menu-close svg,
.user-menu-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  width: 100%;
  max-height: min(440px, calc(100vh - 112px));
  padding: 8px;
  border: 1px solid rgba(199, 211, 228, 0.78);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, 0.98);
  overflow: auto;
  box-shadow: 0 -18px 44px rgba(28, 48, 88, 0.15);
}

.user-menu-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: center;
  padding: 2px 4px 8px;
}

.user-menu-email {
  min-width: 0;
  overflow: hidden;
  color: #85827d;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #7b8190;
}

.user-menu-close:hover {
  background: rgba(237, 241, 247, 0.9);
}

.user-switch-field {
  margin: 0 0 8px;
  display: grid;
  gap: 5px;
}

.user-switch-field span {
  padding-left: 4px;
  color: #8b93a0;
  font-size: 11px;
  font-weight: 760;
}

.user-switch-field select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  padding: 0 7px;
  background: var(--surface-panel);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 720;
}

.user-menu-list {
  display: grid;
  gap: 1px;
}

.user-menu-item {
  width: 100%;
  min-height: 38px;
  padding: 7px 6px;
  border: 0;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 14px;
  gap: 6px;
  align-items: center;
  background: transparent;
  color: #141923;
  text-align: left;
}

.user-menu-item:hover:not(.disabled):not(.passive) {
  background: rgba(238, 240, 244, 0.86);
}

.user-menu-item.disabled {
  color: #b3bbc7;
  cursor: not-allowed;
}

.user-menu-item.passive {
  cursor: default;
}

.user-menu-icon {
  display: grid;
  place-items: center;
  color: currentColor;
}

.user-menu-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-menu-copy strong,
.user-menu-copy small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-copy strong {
  font-size: 12px;
  font-weight: 720;
}

.user-menu-copy small {
  color: #858b96;
  font-size: 10px;
  font-weight: 620;
}

.user-menu-item.disabled .user-menu-copy small {
  color: #b8bec8;
}

.user-menu-arrow {
  color: #8a919d;
}

.user-menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: rgba(220, 225, 233, 0.9);
}

.user-db-note {
  margin-top: 8px;
  padding: 8px 4px 2px;
  font-size: 11px;
}

.user-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 27, 45, 0.18);
  backdrop-filter: blur(6px);
}

.user-modal {
  width: min(460px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 36px));
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(202, 213, 228, 0.82);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 76px rgba(28, 48, 88, 0.22);
}

.user-modal-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.user-modal-head h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.user-modal .user-profile-form label span {
  font-size: 11px;
}

.user-modal .user-profile-form input,
.user-modal .user-profile-form select {
  min-height: 44px;
  border-radius: 9px;
  font-size: 12px;
}

.page-main {
  min-width: 0;
  height: 100vh;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--surface-page);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 28px;
  line-height: 1.14;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 650;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 10px;
  min-width: 432px;
  padding: 10px;
  background: var(--surface-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}

.context-ai-button {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
  font-weight: 650;
  white-space: nowrap;
}

.context-ai-button:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.context-ai-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar label,
.detail-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
}

select,
input {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
}

.summary-strip {
  margin-bottom: 18px;
}

.kpi-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  box-shadow: var(--shadow);
}

.kpi-cell {
  min-width: 0;
  min-height: 128px;
  padding: 18px;
  display: grid;
  grid-template-rows: 40px auto 18px;
  row-gap: 10px;
}

.kpi-cell + .kpi-cell {
  border-left: 1px solid var(--border-default);
}

.priority-section {
  margin-bottom: 18px;
}

.priority-section[hidden] {
  display: none;
}

.priority-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 10px;
}

.priority-section-head h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1.25;
}

.priority-section-head p:last-child,
.priority-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.priority-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.priority-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  box-shadow: var(--shadow);
}

.priority-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.priority-card h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.45;
}

.priority-severity {
  flex: none;
  padding: 2px 6px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.3;
}

.priority-severity.high { color: var(--danger); }
.priority-severity.medium { color: var(--warning); }
.priority-severity.low { color: var(--success); }

.priority-details {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.priority-details div {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
}

.priority-details dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.priority-details dd {
  min-width: 0;
  margin: 0;
  color: var(--text-primary);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.priority-board-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.priority-board-link:hover,
.priority-board-link:focus-visible {
  color: var(--focus);
  text-decoration: underline;
}

.summary-card,
.panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 124px;
  padding: 18px;
  display: grid;
  grid-template-rows: 40px auto 18px;
  align-content: stretch;
  row-gap: 10px;
  position: relative;
  overflow: hidden;
}

.summary-card.good {
  border-left: 0;
}

.summary-card.warn {
  border-left: 0;
}

.summary-card.bad {
  border-left: 0;
}

.summary-card::before {
  content: "";
  width: 38px;
  height: 38px;
  border-radius: 999px;
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-default);
}

.summary-card::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  position: absolute;
  top: 30px;
  left: 30px;
  background: var(--primary);
}

.summary-card.warn::after {
  background: var(--amber);
}

.summary-card.bad::after {
  background: var(--rose);
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  padding-left: 50px;
  min-height: 38px;
  display: flex;
  align-items: center;
}

.summary-value {
  font-family: var(--font-reading-sans);
  font-size: 28px;
  line-height: 1;
  font-weight: 660;
  letter-spacing: 0;
  align-self: end;
  padding-top: 4px;
}

.summary-value-missing {
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1.16;
  font-weight: 560;
}

.summary-foot {
  color: var(--muted);
  font-size: 12px;
}

.summary-trend {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.summary-delta {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--muted);
  white-space: nowrap;
}

.summary-delta.pos {
  color: var(--success);
}

.summary-delta.neg {
  color: var(--rose);
}

.summary-sparkline {
  width: 72px;
  height: 22px;
  flex: none;
  opacity: 0.85;
}

.summary-sparkline path {
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 图表共享 tooltip */
#chartTip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  max-width: 320px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(20, 27, 45, 0.92);
  color: #f4f8ff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
}

/* 明细行可点击 */
#detailTable tbody tr[data-row-index] {
  cursor: pointer;
}

#detailTable tbody tr[data-row-index]:hover td {
  background: var(--primary-soft);
}

#detailTable tbody tr[data-row-index]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* 明细详情抽屉 */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(24, 34, 56, 0.32);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface-strong);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: drawer-slide-in 0.22s ease;
}

@keyframes drawer-slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

body.drawer-open {
  overflow: hidden;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 2px 0 0;
  font-size: 19px;
  letter-spacing: 0;
  font-weight: 650;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.drawer-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 750;
}

.drawer-chip.muted {
  background: var(--soft);
  color: var(--muted);
}

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0;
}

.drawer-fields {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.drawer-field dt {
  font-size: 11px;
  color: var(--muted);
  font-weight: 750;
}

.drawer-field dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.drawer-path-chain {
  flex-wrap: wrap;
}

.drawer-entity,
.drawer-evidence {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--soft);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.drawer-entity p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.drawer-entity-head {
  font-size: 13px;
  font-weight: 650;
}

.drawer-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.drawer-table-wrap {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
}

.drawer-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
}

.drawer-mini-table th,
.drawer-mini-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.drawer-mini-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface-strong);
}

.drawer-raw summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.drawer-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}

.drawer-action-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.drawer-action-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.drawer-action-btn:disabled {
  background: var(--soft);
  color: var(--muted);
  cursor: not-allowed;
}

.drawer-action-btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.drawer-action-btn.ghost:hover:not(:disabled) {
  background: var(--soft);
}

.ai-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.ai-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 6px 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 11px;
}

.ai-attachment-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.ai-attachment-size {
  color: var(--muted);
  white-space: nowrap;
}

.ai-attachment-remove {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.ai-attachment-remove:hover {
  background: var(--rose-soft);
  color: var(--rose);
}

.ai-attachment-note {
  flex-basis: 100%;
  font-size: 11px;
  color: #9a6b1f;
}

.ai-offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #9a6b1f;
  font-size: 11px;
  font-weight: 650;
}

/* 风险传导管线 */
.panel.wide {
  grid-column: 1 / -1;
}

.pipeline-svg {
  width: 100%;
  max-width: 980px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.pipeline-col-label {
  font-size: 12px;
  font-weight: 600;
  fill: var(--muted);
}

.pipeline-node rect {
  fill: var(--surface-strong);
  stroke: var(--line);
  stroke-width: 1.2;
}

.pipeline-node.high rect {
  fill: var(--rose-soft);
  stroke: var(--rose);
}

.pipeline-node.medium rect {
  fill: var(--amber-soft);
  stroke: var(--amber);
}

.pipeline-node text {
  font-size: 11.5px;
  font-weight: 650;
  fill: var(--ink);
}

.pipeline-edge {
  fill: none;
  stroke-width: 2.4;
  stroke: #9db4d6;
  opacity: 0.75;
  cursor: pointer;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.pipeline-edge.medium {
  stroke: var(--amber);
}

.pipeline-edge.high {
  stroke: var(--rose);
  stroke-width: 3;
}

.pipeline-edge:hover {
  opacity: 1;
  stroke-width: 4;
}

@media (max-width: 760px) {
  .drawer-fields {
    grid-template-columns: 1fr;
  }

  .detail-drawer {
    width: 100vw;
  }
}

.page-visuals {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.visual-grid-2 {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr);
}

.visual-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.visual-grid-wide {
  grid-template-columns: 1fr;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.soft {
  background: rgba(255, 255, 255, 0.62);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.chart {
  min-height: 286px;
}

.chart.small {
  min-height: 238px;
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.grid-line {
  stroke: rgba(98, 115, 143, 0.17);
  stroke-width: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.list-visual,
.path-flow,
.action-cards {
  display: grid;
  gap: 10px;
}

.metric-row,
.path-card,
.action-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-panel);
  box-shadow: var(--shadow);
}

.metric-row-head,
.path-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 7px;
  font-weight: 650;
}

.metric-row-meta,
.path-meta,
.action-card p {
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-subtle);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.bar-fill.good {
  background: var(--primary);
}

.bar-fill.warn {
  background: var(--amber);
}

.bar-fill.bad {
  background: var(--rose);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.badge.high,
.badge.bad {
  color: var(--danger);
  background: var(--surface-subtle);
}

.badge.medium,
.badge.warn {
  color: var(--warning);
  background: var(--surface-subtle);
}

.badge.low,
.badge.good {
  color: var(--success);
  background: var(--surface-subtle);
}

.path-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}

.path-node {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-default);
}

.path-arrow {
  color: var(--text-secondary);
}

.detail-panel {
  padding: 18px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.detail-filters {
  display: grid;
  grid-template-columns: 150px 150px 210px;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-family: var(--font-reading-sans);
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(244, 249, 253, 0.96);
  color: #4c5a70;
  font-weight: 600;
}

.ai-rail {
  padding: 22px 18px 18px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  transition: transform 180ms ease, opacity 180ms ease;
}

.ai-resize-handle {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: -6px;
  width: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.ai-resize-handle::after {
  content: "";
  position: absolute;
  top: 48px;
  bottom: 48px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: rgba(36, 107, 254, 0);
  transition: background 140ms ease;
}

.ai-resize-handle:hover::after,
.ai-resize-handle:focus-visible::after,
body.ai-resizing .ai-resize-handle::after {
  background: rgba(36, 107, 254, 0.38);
}

.ai-topbar {
  flex: 0 0 auto;
  min-height: 34px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ai-history-panel {
  position: relative;
  height: min(470px, calc(100vh - 180px));
  max-height: min(470px, calc(100vh - 180px));
  border: 1px solid rgba(188, 199, 214, 0.7);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  background: rgba(250, 253, 255, 0.94);
  box-shadow: 0 18px 42px rgba(48, 83, 139, 0.14);
  overflow: clip;
}

.ai-history-panel[hidden] {
  display: none;
}

.ai-history-section {
  min-height: 0;
  padding: 14px 16px 6px;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}

.ai-history-section.all {
  flex: 1 1 auto;
  padding-bottom: 14px;
}

.ai-history-section + .ai-history-section {
  padding-top: 8px;
}

.ai-history-section-title {
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  color: #2f343d;
  text-align: left;
  font-size: 14px;
  font-weight: 650;
}

.ai-history-chevron {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #7d858c;
  transition: transform 140ms ease;
}

.ai-history-chevron.collapsed {
  transform: rotate(180deg);
}

.ai-history-chevron svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-history-section-body {
  min-height: 0;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
}

.ai-history-section:not(.all) .ai-history-list {
  max-height: 178px;
}

.ai-history-section.all .ai-history-list {
  max-height: none;
  flex: 1 1 auto;
}

.ai-history-list {
  min-height: 0;
  padding-right: 9px;
  padding-bottom: 12px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 138, 150, 0.42) transparent;
}

.ai-history-list.all {
  padding-bottom: 42px;
}

.ai-history-list::-webkit-scrollbar {
  width: 7px;
}

.ai-history-list::-webkit-scrollbar-track {
  background: transparent;
}

.ai-history-list::-webkit-scrollbar-thumb {
  min-height: 34px;
  border: 2px solid transparent;
  border-radius: 999px;
  background-color: rgba(127, 138, 150, 0.42);
  background-clip: content-box;
}

.ai-history-list::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 112, 128, 0.58);
}

.ai-history-item {
  position: relative;
  min-width: 0;
}

.ai-history-restore {
  width: 100%;
  min-height: 32px;
  padding: 4px 34px 4px 0;
  border: 0;
  border-radius: 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: transparent;
  color: #7d858c;
  text-align: left;
}

.ai-history-item:hover .ai-history-restore,
.ai-history-item:focus-within .ai-history-restore {
  padding-left: 8px;
  background: rgba(20, 27, 45, 0.055);
}

.ai-history-title,
.ai-history-date,
.ai-history-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-history-title {
  font-size: 12.5px;
  font-weight: 620;
}

.ai-history-date {
  color: #a1a6ac;
  font-size: 12px;
  font-weight: 640;
}

.ai-history-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.ai-history-status {
  flex: none;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #536574;
  font-size: 11px;
  font-weight: 760;
}

.ai-history-status.interrupted,
.ai-history-status.failed {
  background: var(--amber-soft);
  color: #806127;
}

.ai-history-row-menu {
  position: absolute;
  z-index: 3;
  top: 2px;
  right: 3px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  color: #7d858c;
  opacity: 0;
  pointer-events: auto;
}

.ai-history-item:hover .ai-history-row-menu,
.ai-history-item:focus-within .ai-history-row-menu,
.ai-history-row-menu[aria-expanded="true"] {
  opacity: 1;
  pointer-events: auto;
}

.ai-history-row-menu:hover,
.ai-history-row-menu[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.98);
  color: #4d5663;
  box-shadow: 0 8px 18px rgba(48, 83, 139, 0.12);
}

.ai-history-row-menu svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: none;
}

.ai-history-menu {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 0;
  min-width: 112px;
  padding: 8px;
  border: 1px solid rgba(218, 225, 235, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(48, 83, 139, 0.16);
}

.ai-history-menu[hidden] {
  display: none;
}

.ai-history-menu button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #eb4d5c;
  text-align: left;
  font-size: 14px;
  font-weight: 650;
}

.ai-history-menu button:hover {
  background: var(--rose-soft);
}

.ai-history-empty {
  min-height: 116px;
  margin: 0;
  display: grid;
  place-items: center;
  color: #8a8f95;
  font-size: 17px;
  font-weight: 450;
  text-align: center;
}

.ai-icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #3f4a5d;
}

.ai-icon-button:hover {
  background: rgba(226, 235, 247, 0.78);
}

.ai-icon-button svg,
.ai-send-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-welcome-spacer {
  flex: 1 1 auto;
  min-height: 76px;
}

.ai-welcome {
  padding: 0 20px;
}

.ai-rail.ai-has-answer .ai-welcome-spacer,
.ai-rail.ai-has-answer .ai-welcome,
.ai-rail.ai-has-answer .ai-questions {
  display: none;
}

.ai-rail.ai-has-answer .ai-answer {
  padding-top: 10px;
}

.ai-hello {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 26px;
  line-height: 1.12;
  font-weight: 650;
}

.ai-welcome h2 {
  margin: 0;
  color: #303642;
  font-size: 25px;
  line-height: 1.22;
  font-weight: 650;
}

.ai-provider-status {
  width: fit-content;
  display: none;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid rgba(202, 213, 228, 0.68);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
  white-space: nowrap;
}

.ai-provider-status.good,
.ai-provider-status.warn,
.ai-provider-status.loading {
  display: inline-flex;
}

.ai-provider-status.good {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: #d8e8e2;
}

.ai-provider-status.warn {
  color: #806127;
  background: var(--amber-soft);
  border-color: #ead9aa;
}

.ai-provider-status.loading {
  color: #536574;
  background: var(--blue-soft);
  border-color: #d9e6eb;
}

.ai-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px;
}

.ai-question {
  min-height: 38px;
  max-width: 100%;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(237, 243, 251, 0.92);
  color: #293241;
  text-align: left;
  font-weight: 520;
  line-height: 1.35;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: normal;
}

.ai-question:hover,
.ai-question.active {
  color: var(--primary-dark);
  background: rgba(226, 236, 255, 0.96);
  border-color: rgba(36, 107, 254, 0.18);
}

.ai-answer {
  display: none;
  min-height: 0;
  padding: 4px 20px 0;
  overflow-y: auto;
  overflow-x: hidden;
  color: #182033;
}

.ai-rail.ai-has-answer .ai-answer {
  display: block;
  flex: 1 1 0;
  min-height: 0;
}

.ai-turn {
  margin-bottom: 12px;
  display: flex;
}

.ai-turn p {
  max-width: min(88%, 520px);
  margin: 0;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.58;
}

.ai-turn-user {
  justify-content: flex-end;
}

.ai-turn-user p {
  border-bottom-right-radius: 6px;
  background: var(--primary);
  color: #fff;
}

.ai-turn-assistant {
  display: block;
}

.ai-turn-assistant + .ai-turn-user {
  margin-top: 4px;
}

.ai-response-body {
  min-width: 0;
}

.ai-thinking-panel {
  margin-bottom: 12px;
  border: 1px solid rgba(188, 199, 214, 0.68);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(247, 250, 254, 0.92), rgba(241, 247, 255, 0.74));
  overflow: hidden;
}

.ai-thinking-toggle {
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  background: transparent;
  color: #3c4656;
  text-align: left;
}

.ai-thinking-pulse {
  width: 10px;
  height: 10px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(36, 107, 254, 0.28);
  animation: aiPulse 1.4s ease-out infinite;
}

.ai-thinking-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ai-thinking-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.ai-thinking-copy small {
  overflow: hidden;
  color: #788396;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-thinking-action {
  color: var(--primary);
  font-size: 12px;
  font-weight: 650;
}

.ai-thinking-body {
  display: none;
  max-height: 220px;
  padding: 0 12px 12px;
  overflow: auto;
}

.ai-thinking-panel.expanded .ai-thinking-body {
  display: block;
}

.ai-thinking-body pre {
  min-height: 42px;
  margin: 8px 0 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: #647084;
  font-family: var(--font-reading);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.ai-thinking-progress {
  height: 4px;
  margin: 0 0 10px 25px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(203, 216, 234, 0.55);
}

.ai-thinking-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(36, 107, 254, 0.06), rgba(36, 107, 254, 0.72), rgba(36, 107, 254, 0.06));
  animation: aiProgressSweep 1.35s ease-in-out infinite;
}

.ai-thinking-steps {
  margin: 0;
  padding: 0 0 0 25px;
  display: grid;
  gap: 7px;
  list-style: none;
}

.ai-thinking-steps li {
  position: relative;
  color: #8390a4;
  font-size: 12px;
  font-weight: 500;
}

.ai-thinking-steps li::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 0.53em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(131, 144, 164, 0.45);
}

.ai-thinking-steps li.done {
  color: #536173;
}

.ai-thinking-steps li.done::before {
  background: var(--primary);
}

.ai-thinking-steps li.active {
  color: #253044;
}

.ai-thinking-steps li.active::before {
  background: var(--primary);
  box-shadow: 0 0 0 6px rgba(36, 107, 254, 0.12);
  animation: aiDotBreath 1.2s ease-in-out infinite;
}

.ai-thinking-live {
  margin: 10px 0 0 25px;
  color: #536173;
  font-size: 12px;
  font-weight: 500;
}

.ai-thinking-panel:not(.running) .ai-thinking-pulse,
.ai-thinking-panel:not(.running) .ai-thinking-progress span,
.ai-thinking-panel:not(.running) .ai-thinking-steps li.active::before {
  animation: none;
}

.ai-stream-answer {
  min-height: 38px;
}

.ai-stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--primary);
  vertical-align: -0.17em;
  animation: aiCursor 880ms steps(2, start) infinite;
}

@keyframes aiPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(36, 107, 254, 0.3);
  }
  80% {
    box-shadow: 0 0 0 9px rgba(36, 107, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(36, 107, 254, 0);
  }
}

@keyframes aiProgressSweep {
  0% {
    transform: translateX(-105%);
  }
  55% {
    transform: translateX(90%);
  }
  100% {
    transform: translateX(240%);
  }
}

@keyframes aiDotBreath {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(36, 107, 254, 0.1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(36, 107, 254, 0.18);
  }
}

@keyframes aiCursor {
  50% {
    opacity: 0;
  }
}

.ai-answer p {
  margin: 0 0 10px;
  font-family: var(--font-reading);
  font-size: 14.5px;
  line-height: 1.76;
}

.ai-answer ul {
  margin: 0 0 10px;
  padding-left: 19px;
}

.ai-answer li + li {
  margin-top: 7px;
}

.ai-answer strong {
  font-family: var(--font-reading-sans);
  font-weight: 650;
}

.ai-answer code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(226, 235, 247, 0.86);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.ai-quote {
  padding-left: 10px;
  border-left: 3px solid rgba(36, 107, 254, 0.26);
  color: #4a5568;
}

.ai-note {
  color: var(--muted);
  font-size: 12px;
}

.history-transcript {
  display: grid;
  gap: 10px;
}

.history-turn {
  padding: 10px 12px;
  border: 1px solid rgba(204, 215, 229, 0.72);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.history-turn.user {
  background: rgba(236, 242, 250, 0.72);
}

.history-turn.assistant {
  background: rgba(255, 255, 255, 0.86);
}

.history-role {
  margin-bottom: 5px;
  color: #536173;
  font-size: 12px;
  font-weight: 600;
}

.history-turn p {
  margin-bottom: 6px;
}

.ai-composer {
  flex: 0 0 auto;
  margin-top: auto;
  border: 1px solid rgba(188, 199, 214, 0.8);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(48, 83, 139, 0.08);
  overflow: hidden;
}

.ai-share-status {
  min-height: 38px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(188, 199, 214, 0.44);
  background: rgba(239, 245, 253, 0.88);
  color: #2e3748;
  font-size: 12px;
  font-weight: 720;
}

.ai-share-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 22%, transparent 24%),
    linear-gradient(135deg, #293241, #4c5870);
}

#aiSharedPage {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 126px;
  padding: 14px 16px 8px;
  border: 0;
  resize: none;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.ai-composer textarea::placeholder {
  color: #707986;
}

.ai-composer-actions {
  min-height: 48px;
  padding: 0 10px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-add-button,
.ai-send-button {
  border: 0;
  display: grid;
  place-items: center;
}

.ai-add-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: #384253;
  font-size: 30px;
  line-height: 1;
  font-weight: 300;
}

.ai-add-button:hover {
  background: rgba(226, 235, 247, 0.72);
}

.ai-model-select-wrap {
  margin-left: auto;
  position: relative;
}

.ai-model-select-wrap select {
  height: 30px;
  min-width: 72px;
  padding: 0 24px 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5a6172;
  font-size: 12px;
  font-weight: 600;
  appearance: none;
}

.ai-model-select-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  color: #5a6172;
  pointer-events: none;
}

.ai-send-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.ai-send-button:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

.shell-button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(219, 228, 241, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: #54637b;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: var(--shadow-soft);
}

.shell-button:hover {
  background: rgba(255, 255, 255, 0.96);
}

.sidebar-toggle {
  margin-left: auto;
  transition: transform 180ms ease;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

/* 收起态：与展开态共用同一套网格骨架，只改可过渡的属性（padding/gap/尺寸/透明度），
   保证 180ms 宽度动画期间内容不换行、不重排，只被裁切与淡出。 */
.app-shell.sidebar-collapsed .sidebar {
  padding-left: 10px;
  padding-right: 10px;
}

.app-shell.sidebar-collapsed .brand {
  opacity: 0;
}

.app-shell.sidebar-collapsed .sidebar-card {
  display: none;
}

.app-shell.sidebar-collapsed .user-dock {
  width: calc(100% + 20px);
  margin-left: -10px;
  margin-right: -10px;
}

.app-shell.sidebar-collapsed .user-card-button {
  min-height: 58px;
  padding: 11px 17px;
  grid-template-columns: 30px minmax(0, 1fr) 0px;
  gap: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.app-shell.sidebar-collapsed .user-card-copy,
.app-shell.sidebar-collapsed .user-card-chevron {
  opacity: 0;
}

.app-shell.sidebar-collapsed .user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.app-shell.sidebar-collapsed .nav-item {
  min-height: 44px;
  gap: 0;
  padding: 5px;
  color: transparent;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  transform: translateX(-5px);
}

.app-shell.sidebar-collapsed .nav-list {
  gap: 10px;
}

.app-shell.sidebar-collapsed .nav-item span {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  color: var(--primary-dark);
}

.app-shell.sidebar-collapsed .nav-item.active span {
  color: var(--surface-panel);
}

.app-shell.ai-collapsed .ai-rail {
  width: 0;
  min-width: 0;
  padding: 0;
  border-left: 0;
  transform: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.app-shell.ai-collapsed .ai-rail > * {
  display: none;
}

.ai-open-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(219, 228, 241, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--primary);
  box-shadow: 0 14px 34px rgba(48, 83, 139, 0.16);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.ai-open-button:hover {
  background: #ffffff;
}

.app-shell:not(.ai-collapsed) + .ai-open-button {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .sidebar,
  .sidebar-toggle,
  .brand,
  .nav-list,
  .nav-item,
  .nav-item span,
  .user-dock,
  .user-card-button,
  .user-avatar,
  .user-card-copy,
  .user-card-chevron {
    transition: none;
  }
}

.ai-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
}

.ai-head {
  position: relative;
  padding-right: 38px;
}

body.settings-open {
  overflow: hidden;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 22, 21, 0.42);
}

.settings-dialog {
  position: relative;
  width: min(1040px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.settings-nav {
  min-width: 0;
  padding: 24px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--border-default);
  background: var(--surface-subtle);
}

.settings-nav-head {
  padding: 0 10px 20px;
  display: grid;
  gap: 3px;
}

.settings-nav > .settings-business-back {
  min-height: 34px;
  margin: 0 0 18px;
  grid-template-columns: 16px minmax(0, 1fr);
  border-color: transparent;
  color: var(--text-secondary);
  font-size: 12px;
}

.settings-business-back svg {
  transform: rotate(180deg);
}

.settings-nav-head strong {
  font-size: 16px;
  font-weight: 650;
}

.settings-nav-head span {
  color: var(--text-secondary);
  font-size: 12px;
}

.settings-nav > button {
  width: 100%;
  min-height: 44px;
  margin: 2px 0;
  padding: 0 10px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
}

.settings-nav > button:hover,
.settings-nav > button.active {
  border-color: var(--border-default);
  background: var(--surface-panel);
  color: var(--text-primary);
}

.settings-nav > button > span,
.settings-close,
.settings-mobile-back svg,
.settings-account-link svg,
.settings-logout > svg {
  display: grid;
  place-items: center;
}

.settings-nav svg,
.settings-business-back svg,
.settings-close svg,
.settings-mobile-back svg,
.settings-account-link svg,
.settings-logout > svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-detail {
  min-width: 0;
  padding: 64px clamp(28px, 6vw, 76px) 40px;
  overflow-y: auto;
  outline: none;
  scrollbar-gutter: stable;
}

.settings-detail-content {
  width: min(680px, 100%);
  margin: 0 auto;
}

.settings-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-secondary);
}

.settings-close:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.settings-mobile-back {
  display: none;
}

.settings-section-head {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-default);
}

.settings-section-head h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.settings-section-head p:last-child,
.settings-status-card p,
.settings-note {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

.settings-profile-card {
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
}

.settings-profile-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--surface-panel);
  font-size: 13px;
  font-weight: 700;
}

.settings-profile-card > div,
.settings-toggle-list label > span,
.settings-logout > span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-profile-card span:last-child,
.settings-toggle-list small,
.settings-logout small {
  color: var(--text-secondary);
  font-size: 12px;
}

.settings-definition-list {
  margin: 20px 0;
  border-top: 1px solid var(--border-default);
}

.settings-definition-list > div {
  min-height: 52px;
  padding: 12px 2px;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--border-default);
}

.settings-definition-list dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.settings-definition-list dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.settings-account-link {
  min-height: 40px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.settings-account-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.theme-options {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border: 0;
}

.theme-options legend {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.theme-option {
  position: relative;
  min-width: 0;
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
  cursor: pointer;
}

.theme-option:has(input:checked) {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

.theme-option input {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 16px;
  height: 16px;
  accent-color: var(--focus);
}

.theme-option > span:last-child {
  display: grid;
  gap: 3px;
}

.theme-option strong {
  font-size: 13px;
}

.theme-option small {
  color: var(--text-secondary);
  font-size: 11px;
}

.theme-preview {
  height: 116px;
  padding: 10px;
  display: grid;
  grid-template-columns: 28% 1fr;
  grid-template-rows: 28px 1fr;
  gap: 7px;
  overflow: hidden;
  border: 1px solid #cfd2cc;
  border-radius: 7px;
  background: #f2f2ef;
}

.theme-preview i {
  grid-row: 1 / -1;
  border-radius: 4px;
  background: #ffffff;
}

.theme-preview b,
.theme-preview em {
  display: block;
  border-radius: 4px;
  background: #ffffff;
}

.theme-preview em {
  background: #dedfda;
}

.theme-preview-dark {
  border-color: #4a4e4a;
  background: #191b1a;
}

.theme-preview-dark i,
.theme-preview-dark b {
  background: #252725;
}

.theme-preview-dark em {
  background: #373a37;
}

.settings-actions {
  margin-top: 28px;
  padding-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-default);
}

.settings-actions button {
  min-width: 44px;
  min-height: 44px;
}

.settings-actions .primary-action {
  background: var(--text-primary);
  color: var(--surface-panel);
  box-shadow: none;
}

.settings-actions .secondary-action {
  border-color: var(--border-default);
  background: var(--surface-panel);
  color: var(--text-primary);
}

.settings-status-card {
  padding: 18px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
}

.settings-status-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.settings-status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--success);
}

.settings-note {
  margin-top: 18px;
}

.settings-toggle-list {
  border-top: 1px solid var(--border-default);
}

.settings-toggle-list label {
  min-height: 72px;
  padding: 14px 2px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--border-default);
}

.settings-toggle-list strong {
  font-size: 13px;
}

.settings-toggle-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--focus);
}

.settings-logout {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  text-align: left;
}

.settings-inline-error,
.settings-inline-status {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.settings-inline-error {
  color: var(--danger);
}

.settings-status-dot.neutral {
  background: var(--text-secondary);
}

.settings-access-login {
  margin-top: 18px;
}

.access-capability-list,
.admin-record-list {
  margin-top: 20px;
  border-top: 1px solid var(--border-default);
}

.access-capability-list > div,
.admin-record-list article {
  min-height: 58px;
  padding: 12px 2px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--border-default);
}

.access-capability-list span,
.admin-record-list article > div,
.admin-selected-user span,
.admin-user-results button span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.access-capability-list strong,
.admin-record-list strong,
.admin-selected-user strong,
.admin-user-results strong {
  font-size: 13px;
  font-weight: 600;
}

.access-capability-list small,
.admin-record-list small,
.admin-record-list article > span,
.admin-selected-user small,
.admin-user-results small {
  color: var(--text-secondary);
  font-size: 12px;
}

.admin-record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.admin-record-actions button,
.admin-record-actions input {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
}

.admin-record-actions input {
  width: 174px;
}

.access-capability-list b {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 550;
}

.invite-redeem-form,
.admin-user-search {
  margin-top: 24px;
  padding-top: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--border-default);
}

.invite-redeem-form label,
.admin-user-search label,
.admin-form label {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}

.invite-redeem-form input,
.admin-user-search input,
.admin-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
}

.invite-redeem-form .settings-inline-status,
.admin-user-search + .admin-user-results {
  grid-column: 1 / -1;
}

.admin-subnav {
  margin-bottom: 22px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-default);
}

.admin-subnav button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
}

.admin-subnav button.active {
  border-bottom-color: var(--text-primary);
  color: var(--text-primary);
}

.admin-user-results {
  margin-top: 12px;
}

.admin-user-results button,
.admin-selected-user {
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  display: block;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-subtle);
  color: var(--text-primary);
  text-align: left;
}

.admin-form {
  margin-top: 22px;
  padding-top: 20px;
  display: grid;
  gap: 18px;
  border-top: 1px solid var(--border-default);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-form legend {
  margin-bottom: 9px;
  color: var(--text-secondary);
  font-size: 12px;
}

.admin-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-check-grid label,
.action-update-confirm label,
.code-secret-ack {
  min-height: 42px;
  padding: 9px 10px;
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.admin-check-grid input,
.action-update-confirm input,
.code-secret-ack input {
  width: 17px;
  min-height: 17px;
  padding: 0;
  accent-color: var(--focus);
}

.action-update-confirm label > span {
  display: grid;
  gap: 3px;
}

.action-update-confirm small {
  color: var(--text-secondary);
  font-size: 11px;
}

.code-secret-backdrop {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 22, 21, 0.58);
}

.code-secret-dialog {
  position: relative;
  width: min(480px, 100%);
  padding: 28px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.code-secret-dialog h3 {
  margin: 4px 0 8px;
  font-size: 20px;
}

.code-secret-dialog > p:not(.eyebrow) {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.code-secret-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-secondary);
}

.code-secret-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.code-secret-value {
  margin: 20px 0 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-subtle);
}

.code-secret-value code {
  overflow-wrap: anywhere;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.code-secret-value button {
  min-height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
}

.code-secret-ack {
  margin: 18px 0 14px;
}

.code-secret-dialog > .primary-action {
  min-width: 96px;
}

@media (max-width: 719px) {
  .invite-redeem-form,
  .admin-user-search,
  .admin-form-grid,
  .admin-check-grid {
    grid-template-columns: 1fr;
  }

  .access-capability-list > div,
  .admin-record-list article {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-record-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .code-secret-backdrop {
    position: fixed;
    padding: 16px;
  }

  .code-secret-dialog {
    padding: 24px 20px;
  }
}

@media (max-width: 719px) {
  .settings-backdrop {
    padding: 0;
    background: var(--surface-panel);
  }

  .settings-dialog {
    width: 100vw;
    height: 100dvh;
    display: block;
    border: 0;
    border-radius: 0;
  }

  .settings-nav {
    width: 100%;
    height: 100%;
    padding: 68px 18px 24px;
    border: 0;
  }

  .settings-nav > button {
    min-height: 50px;
    border-bottom: 1px solid var(--border-default);
    border-radius: 0;
  }

  .settings-nav > .settings-business-back {
    display: none;
  }

  .settings-dialog.mobile-detail-open .settings-nav {
    display: none;
  }

  .settings-detail {
    display: none;
    height: 100%;
    padding: 72px 20px 28px;
  }

  .settings-dialog.mobile-detail-open .settings-detail {
    display: block;
  }

  .settings-mobile-back {
    position: absolute;
    top: 18px;
    left: 14px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--text-primary);
  }

  .settings-mobile-back svg {
    transform: rotate(180deg);
  }

  .settings-section-head h2 {
    font-size: 22px;
  }

  .theme-options {
    grid-template-columns: 1fr;
  }

  .settings-definition-list > div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

.empty {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

@media (max-width: 1280px) {
  body {
    padding: 0;
  }

  body::before {
    inset: 0;
  }

  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
    height: 100vh;
    min-height: 100vh;
  }

  .sidebar {
    top: 0;
    height: 100vh;
    min-height: 0;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .brand-name {
    font-size: 16px;
  }

  .visual-grid-2,
  .visual-grid-3 {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-cell:nth-child(odd) {
    border-left: 0;
  }

  .kpi-cell:nth-child(n + 3) {
    border-top: 1px solid var(--border-default);
  }

  .priority-list {
    grid-template-columns: 1fr;
  }

  .page-header,
  .detail-head {
    display: grid;
  }

  .toolbar,
  .detail-filters {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    padding: 0;
    overflow: auto;
  }

  body::before {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
    padding: 12px;
  }

  .shell-button,
  .context-ai-button {
    min-width: 44px;
    min-height: 44px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    height: 58px;
  }

  .app-shell.sidebar-collapsed .nav-list {
    display: none;
  }

  .app-shell.sidebar-collapsed .user-dock {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-popover {
    left: 0;
    right: 0;
    bottom: 100%;
    width: 100%;
    max-height: min(420px, calc(100vh - 96px));
  }

  .user-profile-form {
    grid-template-columns: 1fr;
  }

  .page-main {
    height: auto;
    padding: 14px;
    overflow: visible;
  }

  .ai-rail {
    position: static;
    height: auto;
    top: 0;
    min-height: 0;
    grid-column: auto;
    overflow: visible;
    padding: 16px;
    width: 100vw;
    max-width: 100vw;
  }

  .ai-resize-handle {
    display: none;
  }

  #aiExpandBtn {
    display: none;
  }

  .ai-composer {
    width: 100%;
    max-width: calc(100vw - 32px);
  }

  .ai-welcome-spacer {
    display: none;
  }

  .ai-welcome,
  .ai-questions,
  .ai-answer {
    padding-left: 6px;
    padding-right: 6px;
  }

  .ai-history-panel {
    max-height: none;
  }

  .ai-history-list {
    max-height: 260px;
  }

  .ai-open-button {
    top: 12px;
    right: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .toolbar,
  .summary-strip,
  .detail-filters {
    grid-template-columns: 1fr;
  }

  .kpi-band {
    grid-template-columns: 1fr;
  }

  .kpi-cell + .kpi-cell {
    border-top: 1px solid var(--border-default);
    border-left: 0;
  }

  .priority-section-head {
    display: grid;
  }

  .summary-card {
    min-height: 96px;
  }
}

/* Context AI is an overlay dialog; when closed it takes no dashboard width. */
body.context-ai-open { overflow: hidden; }

.context-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  justify-content: flex-end;
  background: rgba(25, 27, 26, 0.28);
}

.context-ai-backdrop[hidden] { display: none; }

.context-ai-dialog.ai-rail {
  position: relative;
  width: min(520px, 100vw);
  height: 100dvh;
  padding: 20px;
  gap: 14px;
  border: 0;
  border-radius: 0;
  background: var(--surface-panel);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.context-ai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-default);
}

.context-ai-header h2 { margin: 2px 0 5px; font-size: 19px; font-weight: 600; }
.context-ai-header p,
.context-ai-header small { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.context-ai-dialog .ai-topbar { min-height: 36px; flex: none; }

.context-ai-dialog .ai-icon-button,
.context-ai-dialog .ai-add-button,
.context-ai-dialog .ai-send-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-control);
}

.context-ai-dialog .ai-questions { flex: none; padding: 0; gap: 8px; }
.context-ai-dialog .ai-question {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-size: 12px;
}
.context-ai-dialog .ai-question:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-raised); color: var(--text-primary); }
.context-ai-dialog .ai-question:disabled { opacity: 0.55; cursor: not-allowed; }

.context-ai-dialog .ai-answer {
  display: block;
  flex: 1 1 auto;
  min-height: 120px;
  padding: 0 2px;
  overflow: auto;
  color: var(--text-primary);
}

.context-ai-dialog .ai-turn-user p { border-radius: 10px; background: var(--surface-subtle); color: var(--text-primary); }
.context-ai-dialog .ai-response-body,
.context-ai-dialog .ai-answer p { color: var(--text-primary); font-family: var(--font-ui); font-size: 14px; line-height: 1.7; }
.context-ai-dialog .ai-quote { padding: 8px 10px; border: 0; border-radius: var(--radius-control); background: var(--surface-subtle); }

.ai-progress,
.ai-error-card,
.ai-local-rules,
.ai-gate {
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
}

.ai-progress strong,
.ai-error-card strong,
.ai-local-rules > strong,
.ai-gate > strong { font-size: 13px; font-weight: 600; }
.ai-error-card p,
.ai-gate p { margin: 7px 0; color: var(--text-secondary); font-size: 13px; }
.ai-error-card button,
.ai-gate button {
  min-height: 40px;
  margin-top: 8px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--text-primary);
}
.ai-local-rules { margin-top: 12px; }

.ai-settlement {
  width: fit-content;
  margin-top: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: 12px;
}
.ai-settlement.good { color: var(--success); }
.ai-settlement.warn { color: var(--warning); }

.context-ai-dialog .ai-composer {
  margin-top: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  box-shadow: none;
}
.context-ai-dialog .ai-share-status { border-color: var(--border-default); background: var(--surface-subtle); color: var(--text-secondary); font-weight: 500; }
.context-ai-dialog .ai-model-select-wrap select { border: 1px solid var(--border-default); border-radius: var(--radius-control); color: var(--text-primary); }
.context-ai-dialog .ai-send-button { background: var(--text-primary); color: var(--surface-panel); }

.context-ai-dialog .ai-history-panel {
  position: absolute;
  z-index: 4;
  inset: 76px 20px auto;
  height: min(470px, calc(100dvh - 130px));
  border-color: var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (max-width: 600px) {
  .context-ai-dialog.ai-rail { width: 100vw; padding: 16px; }
  .context-ai-header { gap: 10px; }
  .context-ai-dialog .ai-history-panel { inset-inline: 16px; }
}
