:root {
  --nav: #0f1b33;
  --nav-hover: #1a2b4d;
  --nav-active: #243a66;
  --nav-muted: #8b9bb8;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --ok: #0f9f6e;
  --ok-soft: #e6f7f0;
  --warn: #c98500;
  --warn-soft: #fff4db;
  --danger: #d14343;
  --danger-soft: #fdeceb;
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e4e8f0;
  --text: #152033;
  --muted: #6b778f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 51, 0.06), 0 8px 24px rgba(15, 27, 51, 0.04);
  --font: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* —— sidebar —— */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--nav);
  color: #e8eef8;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
}
.nav-section { margin-bottom: 14px; }
.nav-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--nav-muted);
  padding: 6px 12px 4px;
  font-weight: 700;
  text-transform: uppercase;
}
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c9d4e8;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  margin: 1px 0;
  font-weight: 500;
}
.sidebar a.nav-item:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.sidebar a.nav-item.active { background: var(--nav-active); color: #fff; }
.sidebar a.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.9; }
.nav-badge {
  margin-left: auto;
  background: #f5c542;
  color: #3a2d00;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #3558a8; color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.user-chip .name { font-weight: 600; font-size: 13px; color: #fff; }
.user-chip .role { font-size: 11px; color: var(--nav-muted); }
.impersonate-bar {
  background: #3b2d0a;
  color: #f5d98a;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.impersonate-bar a { color: #ffd56a; }

/* —— main —— */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page {
  padding: 28px 32px 40px;
  max-width: 1280px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.page-sub { margin: 0; color: var(--muted); font-size: 13px; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); }
.err { color: var(--danger); white-space: pre-wrap; }

.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-warn { background: var(--warn-soft); border-color: #f0d48a; color: #6a4a00; }
.alert .btn { margin-left: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-muted { background: #eef1f6; color: var(--muted); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-blue { background: var(--accent-soft); color: var(--accent); }
.pill-purple { background: #efe8ff; color: #6b4bc4; }

/* —— forms / buttons —— */
label { display: block; margin: 10px 0 4px; font-size: 12px; font-weight: 650; color: var(--muted); }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #9bb7f0;
  box-shadow: 0 0 0 3px rgba(47,111,237,0.15);
}
input.inline, select.inline { width: auto; display: inline-block; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.05); text-decoration: none; }
button.secondary, .btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger, .btn.danger { background: var(--danger); color: #fff; }
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
button.ghost:hover, .btn.ghost:hover { background: #eef1f6; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs a {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { color: var(--text); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
table.data th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fafbfd;
  font-weight: 700;
}
table.data td.num, table.data th.num { text-align: right; }
table.data tr:hover td { background: #fafbfd; }

.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: right;
}
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table th { background: #eef1f6; }
.row-income td:first-child { font-weight: 650; }
.row-calc td { font-weight: 750; background: #f7f9fc; }
.row-info td { color: var(--muted); }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: #c45a12; font-weight: 600; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  font-weight: 500;
}
.check-inline input { width: auto; margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* —— base cards —— */
.bases-grid { display: grid; gap: 14px; }
.base-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.base-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.base-card h3 { margin: 0; font-size: 16px; }
.base-meta { display: grid; gap: 8px; margin-bottom: 14px; }
.meta-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
}
.meta-row .k { color: var(--muted); }
.masked {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.08em;
  color: #334;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.masked code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; letter-spacing: 0; }
.org-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.base-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  flex-wrap: wrap;
}

/* —— drawer —— */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,27,51,0.35);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: #fff;
  z-index: 50;
  box-shadow: -12px 0 40px rgba(15,27,51,0.18);
  display: flex;
  flex-direction: column;
  padding: 22px;
}
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding-top: 8px; }
.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.mode-pick { display: grid; gap: 8px; margin: 8px 0 14px; }
.mode-option {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  gap: 10px;
  cursor: pointer;
}
.mode-option:has(input:checked) {
  border-color: #9bb7f0;
  background: var(--accent-soft);
}
.mode-option input { width: auto; margin-top: 3px; }
.mode-option strong { display: block; font-size: 13px; }
.mode-option span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.actions-inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions-inline form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.actions-inline input { width: auto; min-width: 90px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .v { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 4px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 10% -10%, #2b4d8f 0%, transparent 55%),
    radial-gradient(800px 400px at 100% 0%, #1a335f 0%, transparent 50%),
    var(--nav);
  font-family: var(--font);
}
.login-card {
  width: min(380px, 92vw);
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.28);
}
.login-card h1 { margin: 0 0 18px; font-size: 22px; }
.login-card .page-sub { margin-bottom: 18px; }
.login-card button { width: 100%; margin-top: 14px; }

/* —— AI chat (viewport-locked: scroll inside .ai-log) —— */
body.page-ai {
  overflow: hidden;
}
body.page-ai .layout {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
body.page-ai .main {
  min-height: 0;
  overflow: hidden;
}
body.page-ai .page {
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 16px;
  overflow: hidden;
}
body.page-ai .page-head-ai {
  margin-bottom: 10px;
  flex-shrink: 0;
}
body.page-ai .page-head-ai h1 { font-size: 20px; }
body.page-ai .alert {
  flex-shrink: 0;
  margin-bottom: 10px;
  padding: 8px 12px;
  font-size: 13px;
}
.ai-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
}
@media (max-width: 900px) {
  .ai-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(110px, 26%) minmax(0, 1fr);
  }
}
.ai-sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.ai-dialog-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.ai-dialog-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f3f6fb;
}
.ai-dialog-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ai-dialog-open {
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  box-shadow: none;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ai-dialog-open:hover { filter: none; opacity: 0.9; }
.ai-dialog-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-dialog-time { font-size: 11px; }
.ai-dialog-del {
  padding: 0 10px;
  margin: 4px;
  min-width: 32px;
  font-size: 16px;
  line-height: 1;
}
.ai-dialog-empty { margin: 8px 4px; font-size: 13px; }
.ai-wait {
  font-variant-numeric: tabular-nums;
}
.ai-wait-line { color: var(--muted); }
.ai-wait-count {
  font-weight: 700;
  color: var(--accent);
  margin-left: 6px;
}
.ai-wait-dots::after {
  content: "…";
  margin-left: 2px;
  opacity: 0.35;
  animation: ai-pulse 1s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.ai-shell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.ai-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  background:
    linear-gradient(180deg, #f7f9fc 0%, #fff 40%);
}
.ai-bubble {
  max-width: min(720px, 92%);
  padding: 10px 14px 12px;
  border-radius: 12px;
  line-height: 1.5;
  white-space: normal;
}
.ai-bubble-time {
  font-size: 11px;
  opacity: 0.65;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.ai-bubble.user .ai-bubble-time { color: rgba(255,255,255,0.85); opacity: 1; }
.ai-bubble.bot .ai-bubble-time { color: var(--muted); opacity: 1; }
.ai-bubble-body { white-space: normal; }
.ai-bubble.bot {
  align-self: flex-start;
  background: #eef2f8;
  color: var(--text);
  border: 1px solid var(--line);
}
.ai-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.ai-pre {
  background: #0f1b33;
  color: #e8eef8;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0 0;
}
.ai-files { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.ai-chart {
  display: block;
  width: 100%;
  max-width: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.ai-trace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
  margin-left: 4px;
}
.ai-trace-toggle input { margin: 0; }
.ai-trace {
  display: none;
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  font-size: 12px;
}
body.ai-show-trace .ai-trace { display: block; }
.ai-trace summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  outline: none;
}
.ai-trace-pre {
  margin: 8px 0 0;
  padding: 10px;
  background: #0f1b33;
  color: #c9d6ea;
  border-radius: 8px;
  overflow: auto;
  max-height: 280px;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-bg-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: #fff6e0;
  color: #7a4d00;
}
.ai-bg-banner[data-state="running"] {
  background: #fff3d6;
  color: #7a4d00;
}
.ai-bg-banner[data-state="done"] {
  background: #e5f7ee;
  color: #0f6b3c;
}
.ai-bg-banner[data-state="error"],
.ai-bg-banner[data-state="warn"] {
  background: #fdecec;
  color: #9b1c1c;
}
.ai-bg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: ai-pulse 1s ease-in-out infinite;
}
.ai-bg-banner[data-state="done"] .ai-bg-dot,
.ai-bg-banner[data-state="error"] .ai-bg-dot {
  animation: none;
}
body.ai-bg-running .ai-shell {
  box-shadow: 0 0 0 2px #e8b84a, var(--shadow);
}
body.ai-bg-done .ai-shell {
  box-shadow: 0 0 0 2px #3caf74, var(--shadow);
}
body.ai-bg-error .ai-shell {
  box-shadow: 0 0 0 2px #d9534f, var(--shadow);
}
body.ai-bg-need_user .ai-shell {
  box-shadow: 0 0 0 2px #d9534f, var(--shadow);
}
.ai-bg-banner[data-state="need_user"] {
  background: #fdecec;
  color: #9b1c1c;
}
.ai-scope-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
  flex-shrink: 0;
}
.ai-scope-label {
  font-size: 12px;
  font-weight: 700;
  color: #4a5568;
  white-space: nowrap;
}
.ai-scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ai-scope-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #152033;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.3;
}
.ai-scope-chip .muted {
  font-weight: 500;
  font-size: 11px;
  margin-left: 4px;
}
.ai-scope-chip.on {
  border-color: #2f6fed;
  background: #eaf1ff;
  color: #1a3f8a;
}
.ai-scope-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-scope-all {
  padding: 4px 10px;
  font-size: 12px;
  flex-shrink: 0;
}
.ai-chat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
  flex-shrink: 0;
}
.ai-chat-bar select {
  min-width: 72px;
  margin: 0;
}
.ai-job-hint {
  font-size: 12px;
  margin-left: auto;
  font-weight: 600;
}
.ai-job-hint-running { color: #9a6a00; }
.ai-job-hint-done { color: #0f6b3c; }
.ai-job-hint-error,
.ai-job-hint-warn { color: #9b1c1c; }
#aiSendBg.ai-bg-btn-run {
  background: #e8b84a;
  color: #1a1200;
  border-color: #c99220;
}
#aiSendBg.ai-bg-btn-done {
  background: #3caf74;
  color: #fff;
  border-color: #2e8f5c;
}
#aiSendBg.ai-bg-btn-err {
  background: #d9534f;
  color: #fff;
  border-color: #b33b37;
}
.ai-compose-flash-warn {
  outline: 2px solid #d9534f;
  outline-offset: 2px;
  animation: ai-pulse 0.4s ease-in-out 2;
}
.ai-compose-flash-ok {
  outline: 2px solid #3caf74;
  outline-offset: 2px;
}
.ai-bubble.ai-bg-status {
  border-color: #e8b84a;
  background: #fff8e8;
}
.ai-bg-live { font-variant-numeric: tabular-nums; }
.ai-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}
.ai-compose-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-compose-actions button {
  white-space: nowrap;
}
#aiStopBtn {
  background: #d9534f;
  color: #fff;
  border-color: #b33b37;
}
#aiStopBtn:hover {
  filter: brightness(0.95);
}
#aiStopBtn.ai-stop-armed {
  box-shadow: 0 0 0 2px #f0b8b8;
  font-weight: 700;
}
.ai-compose textarea {
  resize: none;
  min-height: 52px;
  max-height: 120px;
  margin: 0;
}
.ai-files a.secondary {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  text-decoration: none;
}
.ai-confirm {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--warn-soft);
  flex-shrink: 0;
  max-height: 30%;
  overflow-y: auto;
}
.ai-confirm-card {
  background: #fff;
  border: 1px solid #f0d59a;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}
.ai-confirm-card pre {
  margin: 8px 0;
  max-height: 160px;
  overflow: auto;
  font-size: 12px;
  background: #f7f9fc;
  padding: 8px;
  border-radius: 6px;
}
.ai-confirm-card button { margin-right: 6px; }

@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .grid2, .grid3, .stat-grid { grid-template-columns: 1fr; }
  .meta-row { grid-template-columns: 1fr; }
  .page { padding: 18px; }
}
