:root {
  color-scheme: light;
  --ink: #272636;
  --muted: #756b61;
  --line: #e7dfd2;
  --panel: #ffffff;
  --page: #f9f6f0;
  --green: #4fa578;
  --amber: #c38a31;
  --red: #cf5450;
  --blue: #b5823b;
  --violet: #8067bb;
  --sidebar-ink: #363448;
  --sidebar-muted: #7b6d5e;
  --sidebar-line: rgba(151, 119, 75, 0.18);
  --sidebar-soft: rgba(255, 255, 255, 0.68);
  --sidebar-active: rgba(243, 226, 196, 0.78);
  --shadow: 0 18px 42px rgba(91, 70, 45, 0.1);
}

.platform-switcher {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--sidebar-line);
}

.platform-switch-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 12px;
  border: 1px solid rgba(154, 128, 91, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--sidebar-ink);
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(91, 70, 45, 0.05);
}

.platform-switch-card:hover,
.platform-switch-card.is-active {
  border-color: rgba(181, 130, 59, 0.42);
  background: #fff;
}

.platform-switch-card.platform-story {
  border-color: rgba(116, 91, 172, 0.28);
}

.platform-switch-card.platform-story:hover,
.platform-switch-card.platform-story.is-active {
  border-color: rgba(116, 91, 172, 0.5);
}

.platform-switch-card.platform-irritation {
  border-color: rgba(181, 130, 59, 0.28);
}

.platform-switch-card.platform-irritation:hover,
.platform-switch-card.platform-irritation.is-active {
  border-color: rgba(181, 130, 59, 0.5);
}

.platform-switch-card.platform-survey {
  border-color: rgba(63, 120, 173, 0.28);
}

.platform-switch-card.platform-survey:hover,
.platform-switch-card.platform-survey.is-active {
  border-color: rgba(63, 120, 173, 0.5);
}

.platform-switch-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #f3e4c8;
  color: #704b19;
  font-size: 22px;
  font-weight: 900;
}

.platform-switch-card.platform-story .platform-switch-icon {
  background: #eee8fb;
  color: #6547ba;
}

.platform-switch-card.platform-irritation .platform-switch-icon {
  background: #f3e4c8;
  color: #704b19;
}

.platform-switch-card.platform-survey .platform-switch-icon {
  background: #e4f1fb;
  color: #2d5e88;
}

.platform-switch-card strong,
.platform-switch-card small {
  display: block;
}

.platform-switch-card strong {
  color: #272636;
  font-size: 16px;
  line-height: 1.2;
}

.platform-switch-card small {
  margin-top: 5px;
  color: #7b6d5e;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 1180px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(195, 138, 49, 0.14), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(207, 84, 80, 0.08), transparent 24%),
    linear-gradient(135deg, #fbf8f1 0%, #fffdf9 52%, #f4eee4 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
button, input { font: inherit; }

.app-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 100vh; }
body.is-sidebar-collapsed .app-shell { grid-template-columns: minmax(0, 1fr); }
body.is-sidebar-collapsed .sidebar { display: none; }
.sidebar-toggle {
  position: fixed; top: 50vh; left: 286px; z-index: 30; display: grid; width: 22px; height: 54px; place-items: center;
  border: 1px solid rgba(154, 128, 91, 0.25); border-left-color: rgba(154, 128, 91, 0.12); border-radius: 0 10px 10px 0;
  background: rgba(255,255,255,.8); color: #706454; box-shadow: 0 8px 18px rgba(91,70,45,.08); cursor: pointer; transform: translateY(-50%);
}
.sidebar-toggle::before { content: ""; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 6px solid currentColor; }
body.is-sidebar-collapsed .sidebar-toggle { left: 0; }
body.is-sidebar-collapsed .sidebar-toggle::before { border-right: 0; border-left: 6px solid currentColor; }

.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 20px; border-right: 1px solid rgba(231,223,210,.9);
  background: linear-gradient(180deg, rgba(255,253,248,.98), rgba(247,240,228,.98)); color: var(--sidebar-ink); overflow: auto;
}
.brand { display: flex; gap: 14px; align-items: center; padding-bottom: 24px; border-bottom: 1px solid var(--sidebar-line); }
.brand-mark { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 8px; background: #f3e4c8; color: #704b19; font-weight: 900; }
.brand p, .eyebrow, .panel-heading p, .drill-card p { margin: 0; color: var(--muted); }
.brand p { color: var(--sidebar-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.brand h1 { margin: 4px 0 0; font-size: 18px; }
.filter-group { margin-top: 24px; }
.brand + .filter-group { margin-top: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--sidebar-line); }
.board-query-group { padding-bottom: 20px; border-bottom: 1px solid var(--sidebar-line); }
.data-access-group { margin-top: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--sidebar-line); }
.data-access-group summary {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; margin-bottom: 10px;
  padding: 0 22px 0 0; color: #684d30; cursor: pointer; list-style: none;
}
.data-access-group summary::-webkit-details-marker { display: none; }
.data-access-group summary::after {
  content: ""; position: absolute; right: 2px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(45deg); transition: transform .14s ease;
}
.data-access-group[open] summary::after { transform: translateY(-35%) rotate(225deg); }
.data-access-group summary span { font-size: 13px; font-weight: 800; }
.data-access-group summary small {
  overflow: hidden; color: var(--sidebar-muted); font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap;
}
.data-access-body { position: relative; display: grid; gap: 18px; margin-left: 14px; padding-left: 16px; }
.data-access-body::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 2px; border-radius: 999px; background: rgba(181,130,59,.18); }
.data-access-body .filter-group { margin-top: 0; }
.data-access-body .filter-title { margin-bottom: 9px; color: #80623e; font-size: 12px; font-weight: 900; }
.data-access-body .board-query-group { padding-bottom: 0; border-bottom: 0; }
.filter-title { display: block; margin-bottom: 10px; color: #684d30; font-size: 13px; font-weight: 800; }
.page-nav { display: grid; gap: 6px; margin-top: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--sidebar-line); }
.page-nav a { display: block; padding: 7px 10px 7px 12px; border-radius: 8px; color: #705b41; font-size: 12px; font-weight: 800; text-decoration: none; }
.page-nav a:hover { background: var(--sidebar-soft); }

.upload-card {
  display: grid; gap: 5px; padding: 14px; border: 1px dashed rgba(181,130,59,.36); border-radius: 8px;
  background: rgba(255,255,255,.62); cursor: pointer;
}
.upload-card strong { color: #684d30; font-size: 13px; }
.upload-card span, .upload-status, .drill-card p { color: var(--sidebar-muted); font-size: 12px; line-height: 1.5; }
.upload-card.is-dragging { border-color: #b5823b; background: #fff4df; }
.template-link {
  margin-top: 10px; width: 100%; min-height: 34px; border: 1px solid rgba(181,130,59,.22); border-radius: 8px;
  background: rgba(255,255,255,.72); color: #75552b; cursor: pointer; font-size: 12px; font-weight: 800;
}
.template-link:hover { border-color: rgba(181,130,59,.42); background: #fff; }
.demo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.demo-actions .template-link { margin-top: 10px; }
.upload-status { margin: 8px 0 0; }
.board-query-card { display: grid; gap: 10px; padding: 12px; border: 1px solid rgba(181,130,59,.2); border-radius: 10px; background: rgba(255,255,255,.56); }
.board-query-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.board-query-head .filter-title { margin-bottom: 0; }
.board-query-admin-actions { display: flex; gap: 6px; align-items: center; }
.board-query-admin-actions[hidden] { display: none; }
.board-query-card label { display: grid; gap: 7px; color: var(--sidebar-muted); font-size: 12px; font-weight: 800; }
.field-hint { color: var(--sidebar-muted); font-size: 11px; font-weight: 700; line-height: 1.45; opacity: .82; }
.date-range { display: grid; grid-template-columns: minmax(0, 1fr) 10px minmax(0, 1fr); gap: 6px; align-items: center; }
.date-range em { display: block; color: var(--sidebar-muted); font-style: normal; font-weight: 900; text-align: center; }
.date-picker-field { position: relative; min-width: 0; }
.date-picker-field::after, .custom-select-trigger::after { content: ""; position: absolute; right: 12px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #755f43; pointer-events: none; }
.date-picker-field::after { top: 50%; right: 8px; transform: translateY(-38%); }
.custom-date-input, .custom-select-trigger { width: 100%; min-width: 0; height: 34px; border: 1px solid rgba(154,128,91,.24); border-radius: 8px; background: rgba(255,255,255,.76); color: var(--sidebar-ink); font-size: 11px; font-weight: 800; outline: none; }
.custom-date-input { cursor: default; padding: 0 18px 0 8px; }
.board-number-input { width: 100%; height: 34px; border: 1px solid rgba(154,128,91,.24); border-radius: 8px; background: rgba(255,255,255,.76); color: var(--sidebar-ink); padding: 0 9px; outline: none; font-size: 12px; font-weight: 800; }
.board-number-input:focus { border-color: rgba(181,130,59,.42); background: #fff; }
.custom-select { position: relative; }
.custom-select-trigger { position: relative; display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 0 28px 0 9px; text-align: left; }
.custom-select-trigger::after { top: 50%; transform: translateY(-20%); }
.custom-select-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 120; display: grid; width: 100%; gap: 4px; padding: 6px; border: 1px solid rgba(154,128,91,.28); border-radius: 10px; background: rgba(255,255,255,.98); box-shadow: 0 14px 30px rgba(91,70,45,.14); }
.custom-select-menu[hidden] { display: none; }
.custom-select-menu button { width: 100%; min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--sidebar-ink); cursor: pointer; padding: 0 10px; text-align: left; font-size: 11px; font-weight: 800; }
.custom-select-menu button:hover, .custom-select-menu button.is-selected { background: #fff4df; color: #7b551f; }
.custom-date-input:hover, .custom-select-trigger:hover, .custom-select.is-open .custom-select-trigger { border-color: rgba(181,130,59,.42); background: rgba(255,255,255,.92); }
.custom-date-input:focus, .custom-select-trigger:focus, .board-number-input:focus, .custom-select.is-open .custom-select-trigger {
  border-color: rgba(181,130,59,.58);
  box-shadow: 0 0 0 3px rgba(243,226,196,.52), inset 0 1px 0 rgba(255,255,255,.74);
}
.custom-date-popover {
  position: absolute;
  z-index: 5000;
  width: 272px;
  padding: 10px;
  border: 1px solid rgba(181,130,59,.36);
  border-radius: 10px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 16px 36px rgba(91,70,45,.18);
}
.custom-date-head {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.custom-date-head strong {
  color: var(--sidebar-ink);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}
.custom-date-head button {
  position: relative;
  width: 32px;
  height: 30px;
  border: 1px solid rgba(181,130,59,.28);
  border-radius: 8px;
  background: #fff8ed;
  color: #755f43;
  cursor: pointer;
}
.custom-date-head button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}
.custom-date-head [data-date-prev]::before { transform: translate(-35%, -50%) rotate(45deg); }
.custom-date-head [data-date-next]::before { transform: translate(-65%, -50%) rotate(225deg); }
.custom-date-head button:hover {
  border-color: rgba(181,130,59,.5);
  background: #fff4df;
  color: #7b551f;
}
.custom-date-week, .custom-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.custom-date-week {
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(231,223,210,.82);
}
.custom-date-week span {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}
.custom-date-day {
  display: grid;
  place-items: center;
  width: 100%;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}
.custom-date-day:hover {
  background: #fff4df;
  color: #7b551f;
}
.custom-date-day.is-muted { color: #c1b4a2; }
.custom-date-day.is-today { border-color: rgba(181,130,59,.46); }
.custom-date-day.is-selected {
  border-color: #b5823b;
  background: #b5823b;
  color: #fff;
  box-shadow: 0 6px 14px rgba(181,130,59,.24);
}
.board-query-button { min-height: 36px; border: 0; border-radius: 8px; background: #b5823b; color: #fff; cursor: pointer; font-size: 12px; font-weight: 900; }
.board-query-button:hover { background: #9e6f2d; }
.board-query-status { margin: 0; color: var(--sidebar-muted); font-size: 11px; line-height: 1.5; }
.board-query-status.is-stale { color: #8b6d23; }
.board-query-status.is-loading { color: #75552b; }
.board-query-status.is-success { color: #2f7d55; }
.board-query-status.is-error { color: #bd514b; }
.drill-card { display: grid; gap: 5px; padding: 12px; border: 1px solid rgba(154,128,91,.18); border-radius: 8px; background: rgba(255,255,255,.6); }
.drill-card + .drill-card { margin-top: 10px; }
.drill-card strong { color: #55483b; font-size: 13px; }

.filter-scroll, .node-filter-scroll { max-height: 220px; overflow: auto; padding: 4px 10px 4px 0; scrollbar-width: thin; }
.node-filter-scroll { max-height: 320px; }
.segmented, .chip-list { display: grid; gap: 8px; }
.segmented button, .chip-list button, .top-actions button {
  min-height: 38px; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.segmented button, .chip-list button {
  width: 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow: hidden; background: var(--sidebar-soft);
  color: #5f554b; padding: 0 14px 0 12px; text-align: left; font-size: 12px; text-overflow: ellipsis; white-space: nowrap;
}
.segmented button.is-active, .chip-list button.is-active { background: var(--sidebar-active); color: #5c4121; font-weight: 800; }
.segmented button.is-active::after, .chip-list button.is-active::after { content: ""; width: 6px; height: 6px; border-radius: 999px; background: #b5823b; }

.workspace { min-width: 0; padding: 26px 30px 42px; }
.topbar { display: flex; align-items: stretch; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar > div:first-child { min-width: 0; flex: 1 1 auto; }
.topbar h2 { margin: 0; font-size: 28px; letter-spacing: 0; line-height: 1.28; }
.eyebrow { display: block; max-width: 100%; margin-bottom: 6px; font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; flex: 0 0 auto; flex-wrap: nowrap; align-items: center; gap: 8px; min-height: 38px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.anomaly-action-group { display: inline-flex; flex: 0 0 auto; align-items: center; position: relative; padding: 0; border: 0; background: transparent; white-space: nowrap; }
#searchInput {
  width: 100%; height: 38px; border: 1px solid rgba(154,128,91,.24); border-radius: 8px; background: rgba(255,255,255,.82);
  color: var(--ink); padding: 0 12px; outline: none;
}
.top-actions button {
  flex: 0 0 auto; min-height: 34px; border: 1px solid rgba(154,128,91,.22); border-radius: 7px; background: rgba(255,255,255,.9); color: #5f554b; font-size: 12px; font-weight: 900; line-height: 1.25; white-space: nowrap; cursor: pointer; padding: 0 12px; box-shadow: none;
}
.top-actions .anomaly-info-button {
  display: inline-grid;
  position: absolute;
  top: -8px;
  right: -4px;
  z-index: 2;
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  height: 16px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(154, 128, 91, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  color: rgba(128, 83, 30, 0.78);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}

.top-actions .anomaly-info-button:hover,
.top-actions .anomaly-info-button:focus-visible {
  border-color: rgba(128, 83, 30, 0.34);
  background: rgba(255, 248, 237, 0.82);
  color: #80531e;
  outline: none;
}
.clear-drill-button {
  min-height: 34px; border: 1px solid rgba(154,128,91,.22); border-radius: 8px; background: #fff; color: #5f554b; font-size: 12px; font-weight: 900; line-height: 1.25; white-space: nowrap; cursor: pointer; padding: 0 14px;
}
.top-actions button[hidden],
.ai-heading-actions button[hidden] {
  display: none;
}

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card, .panel {
  border: 1px solid rgba(231,223,210,.92); border-radius: 8px; background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,252,246,.96)); box-shadow: var(--shadow);
}
.kpi-card { position: relative; min-height: 116px; padding: 16px; overflow: hidden; }
.kpi-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, #b5823b, #e4b56f); }
.kpi-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-card strong { display: block; margin-top: 8px; color: #4a3823; font-size: 30px; line-height: 1.05; }
.kpi-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading h3 { margin: 0 0 5px; font-size: 18px; line-height: 1.28; }
.panel-heading p { font-size: 13px; line-height: 1.5; }
.panel-count-badge { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: #f6ead4; color: #755f43; font-size: 12px; font-weight: 800; white-space: nowrap; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(360px, .62fr); gap: 18px; }
#sectionQueue { display: block; margin-bottom: 18px; }
#sectionQueue .queue-panel,
#sectionQueue .action-list {
  min-width: 0;
  overflow: hidden;
}
#sectionQueue .action-item {
  grid-template-columns: 76px minmax(0, 1fr) auto;
}
#sectionQueue .action-title strong { max-width: 100%; }
.lower-grid { grid-template-columns: minmax(0, 1.2fr) minmax(380px, .8fr); }

.ai-workbench { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 14px; }
.ai-heading-actions { display: flex; gap: 8px; align-items: center; }
.ai-field { display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 900; }
.ai-field textarea { min-height: 96px; resize: vertical; border: 1px solid rgba(154,128,91,.2); border-radius: 8px; background: #fffdfa; color: var(--ink); padding: 11px 12px; outline: none; line-height: 1.5; }
.ai-field textarea:focus { border-color: rgba(181,130,59,.45); box-shadow: 0 0 0 4px rgba(181,130,59,.12); }
.ai-primary-button { min-height: 38px; border: 0; border-radius: 8px; background: #b5823b; color: #fff; cursor: pointer; font-weight: 900; padding: 0 14px; white-space: nowrap; }
.ai-primary-button:disabled { cursor: not-allowed; background: #dfd3bf; color: #8a8074; }
.ai-result-card { min-height: 96px; border: 1px dashed rgba(154,128,91,.22); border-radius: 8px; background: #fffdfa; padding: 13px; }
.ai-result-empty { display: grid; min-height: 68px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 800; line-height: 1.5; }
.ai-result-empty.is-error { color: #b94340; }
.ai-status { margin: 10px 0 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.ai-status.is-loading { color: #75552b; }
.ai-status.is-success { color: #2f7d55; }
.ai-status.is-error { color: #b94340; }
.ai-markdown { display: grid; gap: 9px; max-height: none; overflow: visible; margin: 0; color: var(--ink); font: inherit; font-size: 13px; line-height: 1.65; }
.ai-markdown[hidden] { display: none; }
.ai-markdown h1,
.ai-markdown h2,
.ai-markdown h3,
.ai-markdown p,
.ai-markdown ul,
.ai-markdown ol { margin: 0; }
.ai-markdown h1 { font-size: 18px; line-height: 1.35; font-weight: 950; color: #342a22; }
.ai-markdown h2 { padding-top: 4px; border-top: 1px solid rgba(154,128,91,.16); font-size: 16px; line-height: 1.4; font-weight: 950; color: #3b3027; }
.ai-markdown h3 { font-size: 14px; line-height: 1.4; font-weight: 950; color: #574535; }
.ai-markdown p { color: #443a32; line-height: 1.75; }
.ai-markdown ul,
.ai-markdown ol { padding-left: 20px; color: #443a32; }
.ai-markdown li { margin: 4px 0; }
.ai-markdown strong { color: #2d261f; font-weight: 950; }
.ai-markdown hr { width: 100%; height: 1px; border: 0; background: rgba(154,128,91,.16); }
.ai-table-wrap { max-height: 420px; overflow: auto; border: 1px solid rgba(154,128,91,.16); border-radius: 8px; }
.ai-markdown-table { width: 100%; border-collapse: collapse; min-width: 680px; background: #fffdfa; }
.ai-markdown-table th,
.ai-markdown-table td { padding: 9px 10px; border-bottom: 1px solid rgba(154,128,91,.14); text-align: left; vertical-align: top; color: #443a32; }
.ai-markdown-table th { position: sticky; top: 0; z-index: 1; background: #fff5e0; color: #594228; font-size: 12px; font-weight: 950; }

.ai-result-content { display: grid; gap: 12px; }
.ai-result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(154,128,91,.16);
}
.ai-result-meta > span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff4df;
  color: #756a5d;
  font-size: 12px;
  font-weight: 900;
}
.ai-result-toggle {
  margin-left: auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(181,130,59,.22);
  border-radius: 8px;
  background: #fff;
  color: #75552b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}
.mini-log-button { min-height: 30px; border: 1px solid rgba(181,130,59,.22); border-radius: 8px; background: rgba(255,255,255,.72); color: #75552b; cursor: pointer; font-size: 11px; font-weight: 900; padding: 0 9px; white-space: nowrap; }
.mini-log-button:hover { border-color: rgba(181,130,59,.42); background: #fff; }
.record-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 28px; background: rgba(39,38,54,.28); }
.record-modal[hidden] { display: none; }
.record-card { display: grid; gap: 14px; width: min(1080px, 100%); max-height: min(760px, calc(100vh - 56px)); overflow: hidden; border: 1px solid rgba(154,128,91,.24); border-radius: 8px; background: #fffdfa; box-shadow: 0 22px 60px rgba(91,70,45,.24); padding: 16px; }
.record-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-head h3 { margin: 0 0 4px; font-size: 18px; }
.record-head p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.record-close { min-height: 32px; border: 1px solid rgba(181,130,59,.22); border-radius: 8px; background: #fff; color: #75552b; cursor: pointer; font-weight: 900; padding: 0 10px; }
.record-table-wrap { overflow: auto; border: 1px solid rgba(154,128,91,.16); border-radius: 8px; }
.record-table { width: 100%; min-width: 880px; border-collapse: collapse; background: #fff; }
.record-table th, .record-table td { padding: 10px; border-bottom: 1px solid #f1eadf; color: #3d332a; font-size: 12px; text-align: left; vertical-align: top; }
.record-table th { position: sticky; top: 0; background: #fbf6ee; color: #6f604f; font-weight: 900; }
.record-code { max-width: 220px; font-family: "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.permission-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.permission-badge.is-admin { background: #fff1d8; color: #80531e; }
.permission-badge.is-member { background: #f8f1e7; color: #7a6a58; }
.record-empty { min-height: 120px; display: grid; place-items: center; color: var(--muted); font-size: 13px; font-weight: 800; }
.record-empty.is-error { color: #b94340; }

.anomaly-rule-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(39, 38, 54, 0.22);
  backdrop-filter: blur(4px);
}

.anomaly-rule-modal {
  width: min(430px, 100%);
  padding: 14px;
  border: 1px solid rgba(154, 128, 91, 0.24);
  border-radius: 8px;
  background: #fffdfa;
  box-shadow: 0 18px 42px rgba(91, 70, 45, 0.18);
}

.anomaly-rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.anomaly-rule-head strong {
  color: #3d332a;
  font-size: 15px;
}

.anomaly-rule-head button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(181, 130, 59, 0.22);
  border-radius: 8px;
  background: #fff;
  color: #75552b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.anomaly-rule-modal ol {
  margin: 0;
  padding-left: 20px;
  color: #6f604f;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
}

.ai-panel {
  margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,253,249,.98));
}

.ai-heading-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.ai-usage-meter {
  position: relative;
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid rgba(231,223,210,.9);
  border-radius: 8px;
  background: #fffaf2;
  color: #756a5d;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-usage-meter span + span {
  padding-left: 8px;
  border-left: 1px solid rgba(231,223,210,.9);
}

.ai-device-link,
.ai-log-link,
.ai-secondary-button {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid rgba(181,130,59,.24);
  border-radius: 8px;
  background: #fff;
  color: #75552b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.ai-device-link {
  border: 0;
  background: transparent;
  font-weight: 800;
}

.ai-secondary-button {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.ai-device-link:hover,
.ai-device-link[aria-expanded="true"],
.ai-log-link:hover,
.ai-log-link[aria-expanded="true"],
.ai-secondary-button:hover,
.ai-secondary-button[aria-expanded="true"] {
  border-color: rgba(181,130,59,.42);
  background: #fff8ed;
  color: #7b551f;
}

.ai-primary-button {
  position: relative;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #b5823b;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 10px 18px rgba(91,70,45,.14);
  white-space: nowrap;
}

.ai-primary-button:hover {
  background: #9e6f2d;
}

.ai-primary-button:disabled {
  cursor: wait;
  opacity: .58;
}

.ai-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.ai-control-column {
  display: grid;
  grid-template-columns: minmax(360px, 620px) 190px 190px;
  gap: 12px;
  align-content: start;
  align-items: start;
  justify-content: start;
  min-width: 0;
}

.ai-control-column .ai-status {
  grid-column: 1 / -1;
}

.ai-field,
.ai-option-grid label {
  display: grid;
  gap: 7px;
  color: #6f604f;
  font-size: 13px;
  font-weight: 800;
}

.ai-field textarea,
.ai-dropdown-trigger {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.ai-field textarea {
  height: 38px;
  min-height: 38px;
  padding: 8px 12px;
  resize: vertical;
  color: #3d332a;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
}

.ai-option-grid {
  display: contents;
}

.ai-dropdown {
  display: grid;
  gap: 6px;
  min-width: 0;
  position: relative;
}

.ai-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 11px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
}

.ai-dropdown-trigger::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 2px solid #755f43;
  border-bottom: 2px solid #755f43;
  transform: translateY(-2px) rotate(45deg);
}

.ai-dropdown.is-open .ai-dropdown-trigger::after {
  transform: translateY(2px) rotate(225deg);
}

.ai-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(181,130,59,.26);
  border-radius: 8px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 14px 30px rgba(91,70,45,.14);
}

.ai-dropdown-menu[hidden],
.ai-prompt-panel[hidden],
.ai-device-panel[hidden],
.ai-log-panel[hidden] {
  display: none;
}

.ai-dropdown-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
}

.ai-dropdown-menu button:hover,
.ai-dropdown-menu button.is-selected {
  background: #fff4df;
  color: #7b551f;
}

.ai-field textarea:focus,
.ai-dropdown-trigger:focus {
  border-color: rgba(181,130,59,.58);
  box-shadow: 0 0 0 3px rgba(243,226,196,.42);
}

.ai-status {
  min-height: 34px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff4df;
  color: #756a5d;
  font-size: 12px;
  line-height: 1.5;
}

.ai-status.is-loading { color: #75552b; }
.ai-status.is-stale { background: #fffdfa; color: #756a5d; }
.ai-status.is-error { background: #fff2f0; color: #bd514b; }
.ai-status.is-success { background: #eef8f2; color: #438666; }

.ai-prompt-panel,
.ai-device-panel,
.ai-log-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(231,223,210,.84);
  border-radius: 8px;
  background: #fffdfa;
}

.ai-prompt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-prompt-head strong {
  color: #3d332a;
  font-size: 13px;
}

.ai-device-grid {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(320px, 2fr) minmax(120px, .8fr) auto;
  gap: 10px;
  align-items: stretch;
}

.ai-device-grid > div {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(231,223,210,.76);
  border-radius: 8px;
  background: #fff;
}

.ai-device-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-device-grid strong,
.ai-device-grid code {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.ai-device-grid code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.ai-device-copy {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: #b5823b;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  padding: 0 12px;
}

.ai-result-card {
  min-height: 224px;
  padding: 14px;
  border: 1px solid rgba(231,223,210,.84);
  border-radius: 8px;
  background: #fff;
  overflow: auto;
}

.ai-result-empty {
  display: grid;
  min-height: 194px;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.ai-result-empty strong {
  color: var(--ink);
}

.ai-prompt-template {
  display: block;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
  color: #443a32;
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
}

.ai-prompt-data-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ai-prompt-data-block {
  border: 1px solid rgba(231,223,210,.76);
  border-radius: 8px;
  background: #fffdfa;
  overflow: hidden;
}

.ai-prompt-data-block summary {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  color: #5a4630;
  cursor: pointer;
  list-style: none;
}

.ai-prompt-data-block summary::-webkit-details-marker {
  display: none;
}

.ai-prompt-data-block summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid #8b642f;
  border-bottom: 2px solid #8b642f;
  transform: rotate(-45deg);
}

.ai-prompt-data-block[open] summary::before {
  transform: translateY(-2px) rotate(45deg);
}

.ai-prompt-data-block summary strong {
  color: #3d332a;
  font-size: 12px;
}

.ai-prompt-data-block summary span {
  color: #756a5d;
  font-size: 12px;
  line-height: 1.45;
}

.ai-prompt-data-block pre {
  max-height: 360px;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  border-top: 1px solid rgba(231,223,210,.76);
  background: #fff;
  color: #443a32;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.ai-log-empty {
  display: grid;
  min-height: 84px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ai-log-empty.is-error {
  color: #bd514b;
}

.ai-log-table {
  max-width: 100%;
  max-height: 360px;
  overflow: auto;
  border: 1px solid rgba(231,223,210,.84);
  border-radius: 8px;
  background: #fff;
}

.ai-log-table .ai-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 0;
  border-radius: 0;
}

.ai-log-mini-table {
  width: 100%;
  min-width: 1560px;
  border-collapse: collapse;
  background: #fff;
  color: #443a32;
  font-size: 12px;
  table-layout: fixed;
}

.ai-log-mini-table th,
.ai-log-mini-table td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(231,223,210,.68);
  text-align: left;
  vertical-align: middle;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.ai-log-mini-table th {
  background: #fff4df;
  color: #6f604f;
  font-weight: 900;
}

.ai-log-mini-table th:nth-child(1),
.ai-log-mini-table td:nth-child(1) { width: 44px; }
.ai-log-mini-table th:nth-child(2),
.ai-log-mini-table td:nth-child(2) { width: 138px; }
.ai-log-mini-table th:nth-child(3),
.ai-log-mini-table td:nth-child(3) { width: 72px; }
.ai-log-mini-table th:nth-child(4),
.ai-log-mini-table td:nth-child(4) { width: 72px; }
.ai-log-mini-table th:nth-child(5),
.ai-log-mini-table td:nth-child(5) { width: 92px; }
.ai-log-mini-table th:nth-child(6),
.ai-log-mini-table td:nth-child(6) { width: 220px; }
.ai-log-mini-table th:nth-child(7),
.ai-log-mini-table td:nth-child(7) { width: 150px; }
.ai-log-mini-table th:nth-child(8),
.ai-log-mini-table td:nth-child(8) { width: 120px; }
.ai-log-mini-table th:nth-child(9),
.ai-log-mini-table td:nth-child(9) { width: 210px; }
.ai-log-mini-table th:nth-child(10),
.ai-log-mini-table td:nth-child(10) { width: 220px; }
.ai-log-mini-table th:nth-child(11),
.ai-log-mini-table td:nth-child(11) { width: 150px; }
.ai-log-mini-table th:nth-child(12),
.ai-log-mini-table td:nth-child(12) { width: 74px; }

.ai-loading-card {
  display: grid;
  gap: 14px;
  min-height: 194px;
  align-content: center;
  padding: 20px;
  border: 1px dashed rgba(181,130,59,.24);
  border-radius: 8px;
  background: #fffdfa;
}

.ai-loading-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #443a32;
}

.ai-loading-head > div {
  display: grid;
  gap: 4px;
}

.ai-loading-head strong {
  color: #3d332a;
  font-size: 16px;
  font-weight: 950;
}

.ai-loading-head span,
.ai-loading-note {
  color: #756a5d;
  font-size: 12px;
  font-weight: 800;
}

.ai-loading-stop {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(199, 72, 72, 0.24);
  border-radius: 8px;
  background: #fff4f1;
  color: #bf4742;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.ai-loading-stop:hover {
  border-color: rgba(199, 72, 72, 0.38);
  background: #ffebe7;
}

.ai-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #f2eadf;
}

.ai-progress-track i {
  display: block;
  width: var(--ai-progress, 10%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d3a15a, #b5823b);
  transition: width 0.45s ease;
}

.ai-loading-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-loading-steps span {
  padding: 8px 9px;
  border-radius: 8px;
  background: #f7efe3;
  color: #756a5d;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.ai-loading-steps span.is-active {
  background: #fff4df;
  color: #75552b;
}

.action-list { display: grid; gap: 12px; }
.action-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 16px; align-items: center; width: 100%; min-width: 0; min-height: 86px; overflow: hidden; padding: 14px 16px; border: 1px solid rgba(154,128,91,.16); border-radius: 8px; background: #fffdfa; text-align: left; }
.action-item.is-active { border-color: rgba(181,130,59,.42); background: #fff8ed; }
.score { display: grid; place-items: center; width: 60px; height: 58px; border-radius: 8px; background: #f6ead4; font-size: 21px; font-weight: 900; }
.score.is-high { background: #ffeceb; color: #b94340; }
.score.is-mid { background: #fff3dc; color: #986715; }
.score.is-low { background: #e9f6ef; color: #2f7d55; }
.action-item > span:nth-child(2) { display: grid; justify-items: start; min-width: 0; text-align: left; }
.action-title { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; width: 100%; max-width: 100%; min-width: 0; margin-bottom: 5px; }
.action-title strong {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(100%, 420px);
  overflow: hidden;
  font-size: 18px;
  line-height: 1.25;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-item p { margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.mini-metrics { display: flex; flex-wrap: nowrap; gap: 8px; justify-content: flex-end; min-width: 0; max-width: none; }
.metric-pill, .tag {
  display: inline-flex; align-items: center; min-width: 0; max-width: 100%; min-height: 24px; overflow: hidden; padding: 0 8px; border-radius: 999px; background: #f6ead4; color: #706454; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap;
}
.action-title .tag { flex: 0 0 auto; max-width: 180px; }
.mini-metrics .metric-pill { flex: 0 0 auto; padding-inline: 10px; }
.tag-flow { background: #e7f4ed; color: #2f7d55; }
.tag-light { background: #fff4de; color: #986715; }
.tag-dialog { background: #ffece7; color: #b25237; }
.tag-speed { background: #eceafe; color: #6552a3; }
.tag-exit { background: #ffe8e8; color: #b94340; }
.tag-heavy { background: #f7dddd; color: #963836; }

.node-detail { display: grid; gap: 12px; min-height: 170px; }
.detail-empty { display: grid; place-items: center; min-height: 170px; border: 1px dashed rgba(154,128,91,.24); border-radius: 8px; color: var(--muted); font-weight: 800; }
.detail-hero { display: grid; gap: 8px; padding: 14px; border-radius: 8px; background: linear-gradient(135deg, #f4f7fb, #fff); border: 1px solid rgba(154,128,91,.15); }
.detail-hero strong { font-size: 20px; }
.evidence-grid, .score-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; padding: 0 0 8px; }
.evidence-card, .score-detail-grid div { display: grid; gap: 3px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.evidence-card span, .score-detail-grid span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.evidence-card strong, .score-detail-grid strong { color: var(--ink); font-size: 13px; font-weight: 800; }

.distribution-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.distribution-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: linear-gradient(180deg, #fff 0%, #fffaf2 100%); }
.distribution-card h4 { margin: 0 0 10px; font-size: 14px; }
.dist-row { display: grid; grid-template-columns: 94px minmax(0, 1fr) 42px; gap: 8px; align-items: center; width: 100%; min-height: 32px; border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer; color: var(--ink); padding: 2px 4px; text-align: left; }
.dist-row:hover,
.dist-row.is-active { border-color: #ead8b8; background: #fff8ed; }
.dist-row span { font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-bar { height: 9px; border-radius: 999px; background: #f1eadf; overflow: hidden; }
.dist-fill { display: block; height: 100%; border-radius: inherit; background: #b5823b; box-shadow: inset 0 -1px 0 rgba(38,53,79,.12); }
.dist-row.is-active span { color: #7b551f; }

.legend { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 999px; background: var(--dot); }
.node-map { display: grid; gap: 12px; min-width: 0; padding: 10px; border: 1px solid #eadfca; border-radius: 8px; background: #fff; }
.map-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: center; }
.map-row-title { color: #6f604f; font-size: 12px; font-weight: 900; }
.map-nodes { display: flex; align-items: center; gap: 4px; min-height: 34px; padding: 5px; border-radius: 8px; background: #fffaf2; overflow-x: auto; }
.map-node { position: relative; flex: 0 0 auto; height: 24px; min-width: 22px; border: 0; border-radius: 5px; background: var(--node-color); cursor: pointer; box-shadow: inset 0 -1px 0 rgba(0,0,0,.12); transition: transform .12s ease, box-shadow .12s ease, outline-color .12s ease; }
.map-node:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(91,70,45,.16), inset 0 -1px 0 rgba(0,0,0,.12); }
.map-node.is-active { outline: 4px solid rgba(181,130,59,.34); box-shadow: 0 0 0 2px #fff, 0 9px 20px rgba(91,70,45,.2); transform: translateY(-1px); }
.map-node.is-active::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 7px; height: 7px; border-radius: 999px; background: #6d4b1f; transform: translateX(-50%); }

.interval-drill { display: grid; gap: 12px; }
.interval-selected { margin-bottom: 14px; }
.interval-selected-empty { display: grid; min-height: 76px; place-items: center; padding: 12px; border: 1px dashed rgba(154,128,91,.24); border-radius: 8px; background: #fffdfa; color: var(--muted); font-size: 13px; font-weight: 800; line-height: 1.5; text-align: center; }
.interval-selected-card { display: grid; gap: 12px; padding: 13px; border: 1px solid rgba(181,130,59,.26); border-radius: 8px; background: #fff8ed; }
.interval-selected-card strong { display: block; margin-top: 8px; font-size: 17px; }
.interval-selected-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; font-weight: 800; }
.interval-selected-metrics { display: flex; flex-wrap: wrap; gap: 7px; }
.interval-selected-metrics span { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; background: #fff; color: #755f43; font-size: 12px; font-weight: 900; }
.interval-card { display: grid; gap: 8px; }
.interval-head { display: flex; justify-content: space-between; color: #6f604f; font-size: 12px; font-weight: 900; }
.interval-row { display: grid; grid-template-columns: 74px minmax(0,1fr) 34px; gap: 8px; align-items: center; min-height: 25px; color: var(--muted); font-size: 12px; font-weight: 800; padding: 0 4px; border-radius: 6px; }
.interval-row.is-selected { background: #fff4df; color: #7b551f; }
.interval-bar { height: 9px; border-radius: 999px; background: #f1eadf; overflow: hidden; }
.interval-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #d8ac65, #b5823b); box-shadow: inset 0 -1px 0 rgba(38,53,79,.12); }
.interval-row.is-selected .interval-fill { background: linear-gradient(90deg, #e98b80, #cf5450); }

canvas { display: block; width: 100%; max-width: 100%; height: 360px; border: 1px solid rgba(154,128,91,.14); border-radius: 8px; background: #fffdfa; }
.table-wrap { height: 640px; max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; min-width: 1360px; border-collapse: separate; border-spacing: 0; background: #fff; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { position: sticky; top: 0; z-index: 12; background: #fbf6ee; color: #6f604f; font-size: 12px; box-shadow: 0 1px 0 var(--line); }
td { color: #3d332a; }
th:nth-child(-n+9),
td:nth-child(-n+9) {
  white-space: nowrap;
}
td:last-child {
  min-width: 220px;
  white-space: normal;
}
.sort-button { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; font-weight: 800; }
.sort-button::after { content: "↕"; color: #a49a90; font-size: 11px; }
.sort-button.is-active { color: #7b551f; }
.sort-button.is-active::after { content: "↓"; color: #b5823b; }
.sort-button.is-active.asc::after { content: "↑"; }
.metric-help { position: relative; cursor: default; }
.metric-definition-tooltip {
  position: fixed;
  z-index: 5000;
  width: min(360px, calc(100vw - 32px));
  padding: 9px 10px;
  border: 1px solid rgba(231, 214, 186, .95);
  border-radius: 8px;
  background: #fff;
  color: #5a4327;
  box-shadow: 0 12px 28px rgba(91, 70, 45, .18);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity .08s ease, transform .08s ease;
}
.metric-definition-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.node-name { display: grid; gap: 2px; }
.node-name strong { font-size: 13px; }
.node-name span { color: var(--muted); font-size: 11px; }

@media (max-width: 900px) {
  body { min-width: 0; }
  .app-shell { display: block; }
  .sidebar, .sidebar-toggle { display: none; }
  .workspace { padding: 18px 14px 30px; }
  .topbar, .panel-heading { display: grid; }
  .top-actions { display: grid; }
  #searchInput { width: 100%; }
  .kpi-grid, .main-grid, .lower-grid, .distribution-grid, .evidence-grid, .score-detail-grid, .ai-workbench { grid-template-columns: 1fr; }
  .ai-heading-actions { flex-wrap: wrap; }
  .ai-usage-meter { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; white-space: normal; }
  .ai-control-column, .ai-device-grid { grid-template-columns: 1fr; }
}
