:root {
  color-scheme: light;
  --ink: #2d2940;
  --muted: #746f85;
  --line: #ddd6ef;
  --panel: #ffffff;
  --page: #f5f1fb;
  --green: #6fba8f;
  --amber: #c99634;
  --red: #c9564f;
  --blue: #7b8fc8;
  --teal: #8d75c9;
  --mint: #eee8fb;
  --sidebar-ink: #3f3658;
  --sidebar-muted: #776f89;
  --sidebar-line: rgba(156, 133, 204, 0.2);
  --sidebar-soft: rgba(255, 255, 255, 0.64);
  --sidebar-active: rgba(213, 199, 246, 0.42);
  --shadow: 0 18px 42px rgba(61, 48, 91, 0.09);
}

.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(156, 133, 204, 0.26);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--sidebar-ink);
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(61, 48, 91, 0.05);
}

.platform-switch-card:hover,
.platform-switch-card.is-active {
  border-color: rgba(116, 91, 172, 0.46);
  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: #eee8fb;
  color: #6547ba;
  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: #2d2940;
  font-size: 16px;
  line-height: 1.2;
}

.platform-switch-card small {
  margin-top: 5px;
  color: #797286;
  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 18% 0%, rgba(168, 143, 220, 0.16), transparent 30%),
    radial-gradient(circle at 92% 16%, rgba(123, 143, 200, 0.12), transparent 28%),
    linear-gradient(135deg, #f4f0fb 0%, #fbf9fe 48%, #efe9f9 100%);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  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;
  padding: 0;
  border: 1px solid rgba(156, 133, 204, 0.24);
  border-left-color: rgba(156, 133, 204, 0.12);
  border-radius: 0 10px 10px 0;
  background: rgba(255, 255, 255, 0.78);
  color: #5d4b88;
  box-shadow: 0 8px 18px rgba(61, 48, 91, 0.07);
  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;
}

.sidebar-toggle:hover,
.sidebar-toggle[aria-pressed="true"] {
  border-color: rgba(93, 75, 136, 0.42);
  background: #f4efff;
  color: #3f3267;
}

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(221, 214, 239, 0.86);
  background:
    linear-gradient(180deg, rgba(248, 245, 253, 0.98) 0%, rgba(239, 233, 249, 0.98) 100%);
  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: #eee8fb;
  color: #4b3c78;
  font-weight: 800;
}

.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 {
  position: relative;
  margin-top: 24px;
  z-index: 1;
}

.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: #5b4a86;
  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 0.14s ease;
}

.data-access-group[open] summary::after {
  transform: translateY(-35%) rotate(225deg);
}

.data-access-group summary span {
  font-size: 13px;
  font-weight: 700;
}

.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(156, 133, 204, 0.18);
}

.data-access-body .filter-group {
  margin-top: 0;
}

.data-access-body .filter-title {
  margin-bottom: 9px;
  color: #766596;
  font-size: 12px;
  font-weight: 800;
}

.data-access-body .board-query-group {
  padding-bottom: 0;
  border-bottom: 0;
}

.board-query-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  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-admin-actions button,
.board-admin-panel-head button {
  min-height: 34px;
  border: 1px solid rgba(116, 91, 172, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #5a4888;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  padding: 0 9px;
}

.board-query-admin-actions button:hover,
.board-admin-panel-head button:hover {
  border-color: rgba(116, 91, 172, 0.44);
  background: #ffffff;
}

.page-nav {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 12px;
  padding-bottom: 20px;
  border: 1px solid rgba(156, 133, 204, 0.26);
  border-radius: 12px;
  border-bottom: 1px solid var(--sidebar-line);
  background:
    linear-gradient(180deg, rgba(238, 231, 252, 0.92), rgba(246, 241, 255, 0.84));
}

.page-nav .filter-title {
  margin-bottom: 2px;
}

.nav-section {
  --nav-accent: #7657c4;
  --nav-accent-soft: rgba(118, 87, 196, 0.14);
  position: relative;
  display: grid;
  gap: 4px;
  padding: 8px 9px 8px 12px;
  border: 1px solid rgba(156, 133, 204, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(118, 87, 196, 0.1), rgba(250, 247, 255, 0.76) 58%),
    rgba(250, 247, 255, 0.76);
}

.nav-section::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--nav-accent);
}

.nav-section-overview {
  --nav-accent: #7657c4;
  --nav-accent-soft: rgba(118, 87, 196, 0.16);
}

.nav-section-distribution {
  --nav-accent: #6d86c6;
  --nav-accent-soft: rgba(109, 134, 198, 0.14);
}

.nav-section-detail {
  --nav-accent: #b4668f;
  --nav-accent-soft: rgba(180, 102, 143, 0.13);
}

.nav-section-branch {
  --nav-accent: #9b7a35;
  --nav-accent-soft: rgba(155, 122, 53, 0.13);
}

.nav-section-title {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--nav-accent-soft);
  color: var(--nav-accent);
  font-size: 11px;
  font-weight: 900;
}

.page-nav a {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #5b4a86;
  text-decoration: none;
}

.page-nav a:hover {
  border-color: rgba(156, 133, 204, 0.22);
  background: rgba(255, 255, 255, 0.54);
  color: #4b3c78;
  transform: translateX(2px);
}

.page-nav a strong,
.page-nav a small {
  display: block;
}

.page-nav a strong {
  overflow: hidden;
  color: #40365f;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-nav a small {
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-title {
  position: relative;
  z-index: 2;
  display: block;
  margin-bottom: 10px;
  color: #5b4a86;
  font-size: 13px;
  font-weight: 700;
}

.filter-title-with-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  background: rgba(246, 241, 252, 0.94);
}

.filter-info-button {
  position: relative;
  display: inline-grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid rgba(141, 117, 201, 0.2);
  border-radius: 999px;
  background: rgba(238, 232, 251, 0.46);
  color: #8a789c;
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.filter-info-button:hover,
.filter-info-button:focus-visible {
  border-color: rgba(141, 117, 201, 0.34);
  background: rgba(238, 232, 251, 0.72);
  color: #6b5a8f;
}

.filter-info-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: 210px;
  max-width: calc(100vw - 32px);
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  background: #fff;
  color: #5f5573;
  box-shadow: 0 10px 24px rgba(61, 48, 91, 0.16);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.filter-info-button:hover::after,
.filter-info-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.board-query-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(156, 133, 204, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.56);
}

.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: 0.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;
  cursor: pointer;
}

.date-picker-field::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #6d5c93;
  pointer-events: none;
  transform: translateY(-38%);
}

.custom-date-input,
.custom-select-trigger,
.board-number-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(156, 133, 204, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--sidebar-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0 28px 0 9px;
  text-align: left;
}

.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 #6d5c93;
  transform: translateY(1px);
}

.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(156, 133, 204, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 30px rgba(61, 48, 91, 0.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: 700;
}

.custom-select-menu button:hover {
  background: #f1ecff;
  color: #5b4a86;
}

.custom-select-menu button.is-selected {
  background: var(--sidebar-active);
  color: #3f315f;
}

.custom-date-input {
  cursor: pointer;
  padding: 0 17px 0 6px;
  font-variant-numeric: tabular-nums;
}

.board-number-input {
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
}

.custom-date-input:hover,
.custom-select-trigger:hover,
.board-number-input:hover {
  border-color: rgba(141, 117, 201, 0.42);
  background: rgba(255, 255, 255, 0.9);
}

.custom-date-input:focus,
.custom-select-trigger:focus,
.board-number-input:focus,
.custom-select.is-open .custom-select-trigger {
  border-color: rgba(118, 96, 180, 0.7);
  box-shadow:
    0 0 0 3px rgba(213, 199, 246, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.custom-date-popover {
  position: absolute;
  z-index: 5000;
  width: 272px;
  padding: 10px;
  border: 1px solid rgba(156, 133, 204, 0.36);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(61, 48, 91, 0.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(156, 133, 204, 0.28);
  border-radius: 8px;
  background: #faf8ff;
  color: #6d5c93;
  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(118, 96, 180, 0.5);
  background: #f1ecff;
  color: #5b4a86;
}

.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(221, 214, 239, 0.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: #f1ecff;
  color: #5b4a86;
}

.custom-date-day.is-muted {
  color: #b9b0c9;
}

.custom-date-day.is-today {
  border-color: rgba(156, 133, 204, 0.46);
}

.custom-date-day.is-selected {
  border-color: #7660b4;
  background: #7660b4;
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(118, 96, 180, 0.24);
}

.board-query-button {
  position: relative;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: #7660b4;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.board-query-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: 250px;
  max-width: min(250px, calc(100vw - 48px));
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  background: #fff;
  color: #5f5573;
  box-shadow: 0 10px 24px rgba(61, 48, 91, 0.16);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.board-query-button:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.board-query-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.board-query-status {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.5;
}

.board-query-status.is-loading {
  color: #5b4a86;
}

.board-query-status.is-success {
  color: #4f9a72;
}

.board-query-status.is-stale {
  color: #8a789c;
}

.board-query-status.is-error {
  color: #bd514b;
}

.board-admin-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(116, 91, 172, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.board-admin-panel.is-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: rgba(37, 31, 50, 0.28);
  backdrop-filter: blur(6px);
}

.board-admin-modal-card {
  display: grid;
  gap: 10px;
  width: min(1180px, 96vw);
  max-height: min(760px, 86vh);
  padding: 16px;
  border: 1px solid rgba(221, 214, 239, 0.86);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(48, 39, 72, 0.2);
  overflow: hidden;
}

.board-admin-panel.is-modal .board-admin-table-wrap {
  max-height: 620px;
}

.board-admin-panel[hidden] {
  display: none;
}

.board-admin-panel-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.board-admin-panel-head div {
  display: grid;
  gap: 3px;
}

.board-admin-panel-head strong {
  color: #3e315f;
  font-size: 13px;
}

.board-admin-panel-head span {
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 800;
}

.board-admin-table-wrap {
  overflow: auto;
  border: 1px solid rgba(116, 91, 172, 0.16);
  border-radius: 8px;
}

.board-admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

.board-admin-table th,
.board-admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #eee9f8;
  color: #342d45;
  font-size: 11px;
  text-align: left;
  vertical-align: top;
}

.board-admin-table th {
  background: #f4effd;
  color: #5a4888;
  font-weight: 900;
}

.board-admin-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: #f0e9ff;
  color: #5b3fa4;
}

.permission-badge.is-member {
  background: #f3f0f8;
  color: #74668e;
}

.board-admin-empty {
  padding: 10px;
  border-radius: 8px;
  background: #f7f3ff;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 800;
}

.board-admin-empty.is-error {
  background: #fff0f0;
  color: #bd514b;
}

.filter-block {
  display: grid;
  gap: 8px;
}

.filter-collapse {
  padding: 10px 0 0;
  border-top: 1px solid var(--sidebar-line);
}

.filter-collapse summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding-right: 22px;
  cursor: pointer;
  list-style: none;
}

.filter-collapse summary::-webkit-details-marker {
  display: none;
}

.filter-collapse summary::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid #7d69a5;
  border-bottom: 2px solid #7d69a5;
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.14s ease;
}

.filter-collapse[open] summary::after {
  transform: translateY(-35%) rotate(225deg);
}

.filter-collapse summary .filter-title {
  margin-bottom: 0;
}

.filter-collapse .filter-block,
.filter-collapse > .chip-list {
  margin-top: 10px;
}

.filter-block .chip-list,
.filter-block .segmented,
#labelFilters {
  padding-left: 0;
  border-left: 0;
}

.filter-block + .filter-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

.filter-subtitle {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-scroll,
.node-filter-scroll {
  max-height: 220px;
  overflow: auto;
  overscroll-behavior: contain;
  contain: paint;
  padding: 4px 10px 4px 0;
  background: rgba(246, 241, 252, 0.82);
  scrollbar-width: thin;
}

.node-filter-scroll {
  max-height: 320px;
}

.segmented,
.chip-list {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: 1fr;
}

.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 {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  border-color: transparent;
  background: var(--sidebar-soft);
  color: #44385f;
  padding: 0 14px 0 12px;
  text-align: left;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented button.filter-child,
.chip-list button.filter-child {
  width: calc(100% - 24px);
  margin-left: 16px;
  margin-right: 8px;
  min-height: 34px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.5);
  color: #554b68;
  font-size: 12px;
}

.segmented button.filter-child.is-active,
.chip-list button.filter-child.is-active {
  background: var(--sidebar-active);
  color: #3f315f;
}

.segmented button.filter-child.is-anchor,
.chip-list button.filter-child.is-anchor {
  border-color: rgba(141, 117, 201, 0.42);
}

.segmented button.is-active,
.chip-list button.is-active {
  border-color: transparent;
  background: var(--sidebar-active);
  color: #3f315f;
}

.segmented button.is-active::after,
.chip-list button.is-active::after {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #e4d7ff;
}

.segmented button.is-active::before,
.chip-list button.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: #d5c7f6;
}

.segmented button.filter-all,
.chip-list button.filter-all {
  min-height: 38px;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.72);
  color: #493d66;
  font-weight: 800;
  font-size: 13px;
}

.segmented button.filter-all em,
.chip-list button.filter-all em {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(141, 117, 201, 0.08);
  color: #7a6b9c;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.segmented button.filter-all.is-active,
.chip-list button.filter-all.is-active {
  border-color: transparent;
  background: rgba(213, 199, 246, 0.26);
  color: #3f315f;
}

.segmented button.filter-all.is-active em,
.chip-list button.filter-all.is-active em {
  background: rgba(238, 232, 251, 0.2);
  color: #5b4a86;
}

.segmented button.filter-all.is-active::after,
.chip-list button.filter-all.is-active::after {
  display: none;
}

.segmented button.filter-all.is-active::before,
.chip-list button.filter-all.is-active::before {
  top: 9px;
  bottom: 9px;
  background: rgba(213, 199, 246, 0.8);
}

#labelFilters button.is-active {
  background: rgba(186, 172, 226, 0.24);
}

#labelFilters button.is-active::before {
  background: #b4a0e2;
}

#labelFilters button.is-active::after {
  background: #e4d7ff;
}

#labelFilters button.label-all {
  background: rgba(255, 255, 255, 0.52);
}

#labelFilters button.label-all.is-active {
  background: rgba(174, 153, 219, 0.24);
}

select,
input[type="search"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.upload-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px dashed rgba(156, 133, 204, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.upload-card.is-dragging {
  border-color: #c8b6ef;
  background: rgba(228, 215, 255, 0.28);
}

.upload-card strong {
  font-size: 14px;
}

.upload-card span,
.upload-status {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.upload-status {
  margin: 9px 0 0;
  line-height: 1.5;
}

.demo-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.branch-data-tools {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

.branch-upload-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px dashed rgba(156, 133, 204, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--sidebar-ink);
  cursor: pointer;
}

.branch-upload-card.is-dragging {
  border-color: #c8b6ef;
  background: rgba(228, 215, 255, 0.24);
}

.branch-upload-card strong {
  font-size: 13px;
}

.branch-upload-card span {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.template-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  margin-top: 10px;
  padding: 0 8px;
  border: 1px solid rgba(156, 133, 204, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: #5b4a86;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

.template-link:hover,
.template-link:focus-visible,
.template-link:visited {
  background: rgba(255, 255, 255, 0.72);
  color: #4b3c78;
  text-decoration: none;
}

.sidebar select {
  border-color: rgba(156, 133, 204, 0.22);
  background: rgba(255, 255, 255, 0.68);
  color: var(--sidebar-ink);
}

.drill-card {
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid rgba(156, 133, 204, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.drill-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.drill-card p {
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.7;
}

.workspace {
  padding: 24px;
}

#kpiGrid,
#sectionTopNodes,
#sectionAiInsight,
#sectionBranchFlow,
#sectionDistribution,
#sectionIntervals,
#sectionMatrix,
#sectionScatter,
#sectionTable {
  scroll-margin-top: 18px;
}

.ai-panel {
  margin-bottom: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 250, 255, 0.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(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fbf8ff;
  color: #706683;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-usage-meter::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: 320px;
  max-width: min(320px, calc(100vw - 40px));
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  background: #fff;
  color: #5f5573;
  box-shadow: 0 10px 24px rgba(61, 48, 91, 0.13);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.ai-usage-meter:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.ai-usage-meter span + span {
  padding-left: 8px;
  border-left: 1px solid rgba(221, 214, 239, 0.82);
}

.ai-log-link {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  color: #74668e;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.ai-log-link:hover,
.ai-log-link[aria-expanded="true"] {
  border-color: rgba(156, 133, 204, 0.42);
  background: #fbf8ff;
  color: #4b3c78;
}

.ai-device-link {
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #74668e;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-device-link:hover,
.ai-device-link[aria-expanded="true"] {
  background: #fbf8ff;
  color: #4b3c78;
}

.ai-primary-button {
  position: relative;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #5d4b88;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(61, 48, 91, 0.13);
}

.ai-primary-button::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: 260px;
  max-width: min(260px, calc(100vw - 48px));
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  background: #fff;
  color: #5f5573;
  box-shadow: 0 10px 24px rgba(61, 48, 91, 0.16);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.ai-primary-button:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.ai-secondary-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(156, 133, 204, 0.28);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.ai-secondary-button:hover,
.ai-secondary-button[aria-expanded="true"] {
  border-color: rgba(93, 75, 136, 0.4);
  background: #f4efff;
  color: #3f3267;
}

.ai-primary-button:hover {
  background: #4c3b74;
}

.ai-primary-button:disabled {
  cursor: wait;
  opacity: 0.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: #615872;
  font-size: 13px;
  font-weight: 800;
}

.ai-field textarea,
.ai-fixed-value,
.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, 0.7);
}

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

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

.ai-fixed-value,
.ai-dropdown-trigger {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 800;
}

.ai-fixed-value {
  background: #f8f5ff;
  color: #4d416a;
}

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

.ai-dropdown-trigger {
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}

.ai-dropdown-trigger::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 2px solid #6d5c93;
  border-bottom: 2px solid #6d5c93;
  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(156, 133, 204, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 30px rgba(61, 48, 91, 0.14);
}

.ai-dropdown-menu[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: #f1ecff;
  color: #49376f;
}

.ai-field textarea:focus,
.ai-dropdown-trigger:focus {
  border-color: rgba(118, 96, 180, 0.62);
  box-shadow: 0 0 0 3px rgba(213, 199, 246, 0.34);
}

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

.ai-status.is-loading {
  color: #5b4a86;
}

.ai-status.is-stale {
  background: #fbf8ff;
  color: #625971;
}

.ai-status.is-error {
  background: #fff2f0;
  color: #bd514b;
}

.ai-status.is-success {
  background: #f0fbf4;
  color: #438666;
}

.ai-prompt-panel,
.ai-device-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(221, 214, 239, 0.76);
  border-radius: 8px;
  background: #fdfcff;
}

.ai-log-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(221, 214, 239, 0.76);
  border-radius: 8px;
  background: #fdfcff;
}

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

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

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

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

.ai-device-grid > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(221, 214, 239, 0.58);
  border-radius: 8px;
  background: #fff;
}

.ai-device-grid span {
  color: #7b728d;
  font-size: 12px;
  font-weight: 800;
}

.ai-device-grid strong,
.ai-device-grid code {
  min-width: 0;
  color: #3c334f;
  font-size: 13px;
  font-weight: 800;
}

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

.ai-device-copy {
  align-self: stretch;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fbf8ff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.whitelist-panel {
  display: grid;
  gap: 8px;
  max-width: 100%;
  max-height: 320px;
  padding: 10px;
  overflow: auto;
  border: 1px solid rgba(221, 214, 239, 0.58);
  border-radius: 8px;
  background: #fff;
}

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

.whitelist-panel-head {
  display: flex;
  position: sticky;
  top: -10px;
  z-index: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 8px;
  background: #fff;
  color: #5b4a86;
  font-size: 12px;
  font-weight: 900;
}

.whitelist-panel-head span {
  margin-left: auto;
  color: #746a88;
  font-weight: 800;
}

.whitelist-close {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fbf8ff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.whitelist-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  color: #4c435f;
  font-size: 12px;
}

.whitelist-table th,
.whitelist-table td {
  padding: 8px;
  border-top: 1px solid rgba(221, 214, 239, 0.56);
  text-align: left;
  vertical-align: top;
}

.whitelist-table th {
  color: #5b4a86;
  font-weight: 900;
}

.whitelist-device-id {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(37, 31, 50, 0.28);
  backdrop-filter: blur(6px);
}

.admin-modal {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(48, 39, 72, 0.18);
}

.admin-modal h4 {
  margin: 0 0 6px;
  color: #302943;
  font-size: 18px;
}

.admin-modal p {
  margin: 0 0 14px;
  color: #746a88;
  font-size: 13px;
  line-height: 1.6;
}

.admin-modal input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  color: #302943;
  font-size: 14px;
  outline: none;
}

.admin-modal input:focus {
  border-color: #a88ddd;
  box-shadow: 0 0 0 3px rgba(168, 141, 221, 0.16);
}

.admin-modal-error {
  min-height: 18px;
  margin-top: 8px;
  color: #bd514b;
  font-size: 12px;
  font-weight: 800;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.admin-modal-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.admin-modal-actions button:last-child {
  border-color: #5d4b88;
  background: #5d4b88;
  color: #fff;
}

.ai-prompt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

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

.ai-prompt-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-log-download {
  min-height: 28px;
  margin-left: auto;
  padding: 0 10px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.ai-log-download:hover {
  background: #fbf8ff;
  border-color: rgba(156, 133, 204, 0.42);
}

.ai-prompt-preview {
  max-height: 520px;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(221, 214, 239, 0.58);
  border-radius: 8px;
  background: #fff;
  color: #4c435f;
}

.ai-log-table {
  max-height: 360px;
  overflow: auto;
  border: 1px solid rgba(221, 214, 239, 0.58);
  border-radius: 8px;
  background: #fff;
}

.ai-log-table table {
  width: 100%;
  min-width: 1508px;
  border-collapse: collapse;
  color: #4c435f;
  font-size: 12px;
  table-layout: fixed;
}

.ai-log-col-index {
  width: 44px;
}

.ai-log-col-time {
  width: 146px;
}

.ai-log-col-method {
  width: 76px;
}

.ai-log-col-user {
  width: 70px;
}

.ai-log-col-source {
  width: 72px;
}

.ai-log-col-detail {
  width: 298px;
}

.ai-log-col-mode {
  width: 150px;
}

.ai-log-col-nodes {
  width: 154px;
}

.ai-log-col-token {
  width: 160px;
}

.ai-log-col-device {
  width: 286px;
}

.ai-log-col-model {
  width: 68px;
}

.ai-log-table th,
.ai-log-table td {
  max-width: 0;
  overflow: hidden;
  padding: 8px 8px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.56);
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: top;
  white-space: nowrap;
}

.ai-log-table th {
  user-select: none;
}

.ai-log-table th:nth-child(2),
.ai-log-table td:nth-child(2) {
  padding-left: 8px;
  text-align: left;
}

.ai-log-method {
  text-align: left;
}

.ai-log-data-detail {
  overflow: hidden;
  color: #6a5f7e;
  text-overflow: ellipsis;
}

.ai-log-token span,
.ai-log-token small {
  display: block;
}

.ai-log-token small {
  margin-top: 2px;
  color: #756b86;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.ai-log-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 2;
  width: 8px;
  height: 100%;
  cursor: col-resize;
}

.ai-log-resizer::after {
  content: "";
  position: absolute;
  top: 22%;
  right: 3px;
  width: 1px;
  height: 56%;
  border-radius: 999px;
  background: rgba(126, 104, 181, 0);
  transition: background 0.12s ease;
}

.ai-log-resizer:hover::after,
.is-resizing-ai-log .ai-log-resizer::after {
  background: rgba(126, 104, 181, 0.42);
}

.ai-log-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f3ff;
  color: #5b4a86;
  font-size: 11px;
  font-weight: 900;
}

.ai-log-tooltip {
  position: fixed;
  z-index: 2000;
  max-width: min(520px, calc(100vw - 28px));
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.76);
  border-radius: 8px;
  background: rgba(62, 51, 91, 0.96);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
  white-space: pre-wrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.08s ease, transform 0.08s ease;
  box-shadow: 0 12px 28px rgba(50, 38, 76, 0.2);
}

.ai-log-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ai-log-cache,
.ai-log-live,
.ai-log-error {
  display: inline-flex;
  justify-content: flex-start;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.ai-log-cache {
  background: #eef9f2;
  color: #438666;
}

.ai-log-live {
  background: #f6f1ff;
  color: #5b4a86;
}

.ai-log-error {
  background: #fff0ee;
  color: #c74848;
}

.ai-log-device-name,
.ai-log-device-id {
  display: block;
}

.ai-log-device-id {
  margin-top: 2px;
  color: #8a8199;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9.8px;
  font-weight: 700;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.ai-log-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.ai-prompt-template,
.ai-prompt-data-block pre {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

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

.ai-prompt-data-block {
  border: 1px solid rgba(221, 214, 239, 0.64);
  border-radius: 8px;
  background: #fdfcff;
  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: #4c435f;
  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 #6d5c93;
  border-bottom: 2px solid #6d5c93;
  transform: rotate(-45deg);
}

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

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

.ai-prompt-data-block summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ai-prompt-data-block pre {
  max-height: 360px;
  padding: 10px 12px;
  overflow: auto;
  border-top: 1px solid rgba(221, 214, 239, 0.58);
  background: #fff;
}

.ai-result-card {
  min-height: 224px;
  padding: 14px;
  border: 1px solid rgba(221, 214, 239, 0.76);
  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: #fdfcff;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

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

.ai-result-content {
  display: grid;
  gap: 10px;
  color: #443a60;
  font-size: 14px;
  line-height: 1.72;
}

.ai-result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.66);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-result-meta span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f6f1ff;
}

.ai-result-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-result-toggle {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(156, 133, 204, 0.24);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.ai-markdown {
  display: grid;
  gap: 9px;
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}

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

.ai-markdown.is-collapsed {
  max-height: 360px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(141, 117, 201, 0.36) transparent;
}

.ai-raw-result {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(221, 214, 239, 0.74);
  border-radius: 8px;
  background: #fbf9ff;
  color: #4b4168;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.ai-raw-result[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 {
  color: #342a51;
  font-size: 21px;
  line-height: 1.35;
}

.ai-markdown h2 {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(221, 214, 239, 0.56);
  color: #40365d;
  font-size: 17px;
  line-height: 1.42;
}

.ai-markdown h3 {
  color: #51466c;
  font-size: 15px;
  line-height: 1.45;
}

.ai-markdown p {
  color: #51475f;
}

.ai-markdown ul,
.ai-markdown ol {
  display: grid;
  gap: 6px;
  padding-left: 20px;
}

.ai-markdown li {
  padding-left: 2px;
}

.ai-markdown strong {
  color: #32284b;
  font-weight: 900;
}

.ai-markdown hr {
  width: 100%;
  height: 1px;
  margin: 4px 0;
  border: 0;
  background: rgba(221, 214, 239, 0.72);
}

.ai-table-wrap {
  max-width: 100%;
  max-height: 420px;
  overflow: auto;
  border: 1px solid rgba(221, 214, 239, 0.72);
  border-radius: 8px;
  background: #fff;
}

.ai-markdown-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  color: #443a60;
  font-size: 13px;
  line-height: 1.55;
}

.ai-markdown-table th,
.ai-markdown-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.58);
  border-right: 1px solid rgba(221, 214, 239, 0.42);
  text-align: left;
  vertical-align: top;
}

.ai-markdown-table th:last-child,
.ai-markdown-table td:last-child {
  border-right: 0;
}

.ai-markdown-table tr:last-child td {
  border-bottom: 0;
}

.ai-markdown-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f1ff;
  color: #3f3658;
  font-weight: 900;
  white-space: nowrap;
}

.ai-loading-card {
  display: grid;
  gap: 14px;
  min-height: 194px;
  align-content: center;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fdfcff;
}

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

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

.ai-loading-head strong {
  color: #342a51;
  font-size: 16px;
}

.ai-loading-head span,
.ai-loading-note {
  color: var(--muted);
  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: #eeeaf4;
}

.ai-progress-track i {
  display: block;
  width: var(--ai-progress, 8%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8d75c9, #6fba8f);
  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: #f6f1ff;
  color: #756b87;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.ai-loading-steps span.is-active {
  background: #eee8fb;
  color: #49376f;
}

.topbar,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar {
  margin-bottom: 18px;
  align-items: stretch;
}

.eyebrow {
  display: block;
  max-width: 100%;
  margin-bottom: 6px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar h2,
.panel-heading h3 {
  margin: 0;
}

.panel-heading h3 {
  font-size: 18px;
  line-height: 1.28;
}

.topbar h2 {
  font-size: 28px;
}

.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;
}

.top-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border-color: var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  color: #74668e;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
  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;
  height: 16px;
  min-height: 16px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(156, 133, 204, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  color: rgba(106, 87, 150, 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(106, 87, 150, 0.34);
  background: rgba(246, 241, 252, 0.82);
  color: #5a468a;
  outline: none;
}

.top-actions button[aria-pressed="true"] {
  border-color: rgba(126, 95, 188, 0.36);
  background: #f4efff;
  color: #49376f;
}

.top-actions button:disabled {
  cursor: default;
  opacity: 0.64;
  box-shadow: none;
}

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

.anomaly-rule-modal {
  width: min(430px, 100%);
  padding: 14px;
  border: 1px solid rgba(221, 214, 239, 0.86);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(48, 39, 72, 0.18);
}

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

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

.anomaly-rule-head button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.top-node-panel {
  margin-bottom: 14px;
  border-color: rgba(205, 190, 235, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(250, 247, 255, 0.96));
}

.top-node-list {
  display: grid;
  gap: 12px;
}

.top-node-item {
  display: grid;
  grid-template-columns: 76px minmax(360px, 1fr) minmax(330px, auto);
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 86px;
  padding: 14px 16px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(252, 249, 255, 0.94));
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 26px rgba(61, 48, 91, 0.04);
}

.top-node-rank,
.top-node-tag,
.top-node-metrics em {
  white-space: nowrap;
  font-weight: 900;
}

.top-node-rank {
  display: grid;
  width: 60px;
  height: 58px;
  place-items: center;
  border-radius: 8px;
  background: #f0e9fb;
  color: #6b56a6;
  font-size: 21px;
  line-height: 1;
}

.top-node-rank.is-hot {
  background: #f7e7f0;
  color: #b84769;
}

.top-node-main strong,
.top-node-main small {
  display: block;
}

.top-node-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.top-node-main strong {
  overflow: hidden;
  color: #2d2940;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-node-main small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-node-tag {
  justify-self: start;
  max-width: 190px;
  overflow: hidden;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-overflow: ellipsis;
}

.top-node-tag.tag-severe,
.top-node-tag.tag-risk {
  background: #f8dfe8;
  color: #a84462;
}

.top-node-tag.tag-drag,
.top-node-tag.tag-stuck {
  background: #f5e6fb;
  color: #7652a4;
}

.top-node-tag.tag-skim {
  background: #f6ecff;
  color: #6950a1;
}

.top-node-tag.tag-highlight {
  background: #e7edff;
  color: #4d66ad;
}

.top-node-tag.tag-normal,
.top-node-tag.tag-neutral {
  background: #e9f7f0;
  color: #438666;
}

.top-node-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-node-metrics em {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: #f1ebfb;
  color: #6b607c;
  font-size: 12px;
  font-style: normal;
}

.top-node-item:nth-child(-n + 3) {
  border-color: rgba(168, 141, 221, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(249, 244, 255, 0.98));
}

.kpi-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(252, 250, 255, 0.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, var(--teal), #c6b4ee);
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  color: #3b315b;
  font-size: 30px;
  line-height: 1.05;
}

.kpi-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.kpi-scope-card {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: center;
  gap: 9px;
}

.scope-node-count {
  align-self: center;
  margin-top: 0;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 0.95;
  letter-spacing: 0;
}

.kpi-card .kpi-primary-label {
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  margin-top: 0;
  min-width: 0;
  max-width: 100%;
  color: var(--ink);
  font-size: var(--label-size, 15px);
  line-height: 1.15;
  white-space: nowrap;
  transform-origin: left center;
}

.kpi-distribution-card {
  display: grid;
  grid-template-rows: 16px 32px 26px;
  align-content: start;
  row-gap: 8px;
}

.kpi-card-metric {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-height: 24px;
  margin-top: 0;
}

.kpi-card-metric b {
  color: var(--teal);
  font-size: 19px;
  line-height: 1.2;
}

.kpi-card-metric em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.kpi-card.has-tip {
  cursor: help;
}

.kpi-card.has-tip::after {
  content: attr(data-kpi-tip);
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 8px);
  z-index: 20;
  padding: 10px 12px;
  border-radius: 8px;
  background: #3f3267;
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.kpi-card.has-tip:hover::after,
.kpi-card.has-tip:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  margin-bottom: 14px;
}

#sectionMatrix {
  grid-template-columns: minmax(0, 1fr) 304px;
}

.map-panel {
  overflow: visible;
}

.distribution-panel {
  margin-bottom: 14px;
  background:
    radial-gradient(circle at 0% 0%, rgba(168, 141, 221, 0.13), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(251, 247, 255, 0.98));
}

.interval-panel {
  margin-bottom: 14px;
  background:
    radial-gradient(circle at 100% 0%, rgba(123, 143, 200, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 247, 255, 0.98));
}

#sectionMatrix .map-panel,
#sectionScatter > .panel:first-child {
  background:
    radial-gradient(circle at 8% 0%, rgba(168, 141, 221, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 247, 255, 0.98));
}

.clear-drill-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.clear-drill-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.module-filter-tools {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: #5b4a86;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.module-count-text {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: #6b617d;
}

.module-clear-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(211, 201, 233, 0.95);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font: inherit;
}

.module-clear-button:hover:not(:disabled) {
  border-color: #c8b9ec;
  background: #f7f3fc;
}

.module-clear-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.distribution-empty {
  grid-column: 1 / -1;
}

.distribution-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbf9fe 100%);
}

.distribution-card h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.distribution-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  min-height: 42px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.distribution-row:hover,
.distribution-row.is-active {
  border-color: #d2c4ef;
  background: #f5f0ff;
}

.distribution-row.is-zero {
  color: #91a0a3;
}

.distribution-row.is-zero .dist-bar i {
  width: 0;
}

.dist-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
}

.dist-name {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dist-pct {
  flex: 0 0 auto;
  color: #9a91aa;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  text-align: right;
}

.dist-bar {
  height: 8px;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeaf4;
}

.dist-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}


.distribution-readout {
  min-height: 34px;
  margin: 8px 0 0;
  padding: 8px 9px;
  border-radius: 7px;
  background: #f6f1ff;
  color: #554b68;
  font-size: 12px;
  line-height: 1.5;
}

.lower-grid {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.lower-grid > .panel:last-child {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 455px;
  overflow: visible;
}

.lower-grid > .panel:last-child .panel-heading {
  margin-bottom: 10px;
}

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

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading p {
  margin-top: 5px;
  font-size: 13px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: #615872;
  font-size: 12px;
}

.matrix-heading-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  max-width: min(720px, 62vw);
}

.legend-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(221, 214, 239, 0.9);
  border-radius: 999px;
  background: #fbf9ff;
  color: #615872;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.legend-toggle:hover {
  border-color: rgba(126, 95, 188, 0.38);
  background: #f4efff;
  box-shadow: 0 6px 14px rgba(92, 72, 138, 0.1);
  transform: translateY(-1px);
}

.legend-toggle.is-active {
  border-color: rgba(126, 95, 188, 0.38);
  background: #f4efff;
  color: #49376f;
  box-shadow: inset 0 0 0 1px rgba(126, 95, 188, 0.08);
}

.legend-toggle-all {
  border-color: rgba(141, 117, 201, 0.34);
  background: #fff;
  color: #5d4b88;
}

.legend-toggle-all:hover,
.legend-toggle-all.is-active {
  border-color: rgba(93, 75, 136, 0.44);
  background: #eee8fb;
  color: #3f3267;
}

.legend-toggle-all::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: transparent;
}

.legend-toggle-all.is-active::before {
  background:
    linear-gradient(135deg, transparent 52%, rgba(255, 255, 255, 0.82) 52%),
    currentColor;
}

.legend-toggle span {
  white-space: nowrap;
}

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
}

.severe,
.tag-severe {
  background: #df5658;
}

.risk,
.tag-risk {
  background: #ee6a6b;
}

.drag,
.tag-drag {
  background: #f08a7f;
}

.stuck,
.tag-stuck {
  background: #ee9b4f;
}

.skim,
.tag-skim {
  background: #e7bd50;
}

.highlight,
.tag-highlight {
  background: #6393d9;
}

.normal,
.tag-normal {
  background: #5bb883;
}

.tag-neutral {
  background: #9aa7aa;
}

.node-map {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #e0d8ef;
  border-radius: 8px;
  background: #fff;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fdfcff;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.story-matrix {
  min-width: 0;
  border: 1px solid rgba(214, 205, 235, 0.74);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  overflow: visible;
}

.story-matrix-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.58);
  background: rgba(252, 250, 255, 0.72);
}

.story-matrix-heading strong {
  min-width: 0;
  color: #3b315b;
  font-size: 13px;
  line-height: 1.3;
}

.story-matrix-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.story-matrix-rows {
  display: grid;
  gap: 0;
  padding: 3px 9px;
  background: #fff;
  border-radius: 0 0 8px 8px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(134, 111, 190, 0.22) transparent;
}

.episode-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: max(100%, var(--story-canvas-width, 560px));
  padding: 3px 0;
  border: 0;
  background: transparent;
}

.episode-row + .episode-row {
  border-top: 0;
}

.episode-row h4 {
  margin: 0;
  color: #504766;
  font-size: 12px;
  line-height: 1.35;
}

.episode-row h4 span,
.episode-row h4 em {
  display: block;
}

.episode-row h4 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.episode-row h4 em {
  font-style: normal;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-strip {
  display: flex;
  gap: clamp(1px, 0.2vw, 3px);
  width: var(--strip-width, 100%);
  min-width: 0;
  max-width: 100%;
  min-height: 26px;
  padding: 1px 0;
  align-items: stretch;
  overflow: visible;
  overflow-y: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.node-pill {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(8px, 1.2vw, 18px);
  flex: 0 0 max(clamp(8px, 1.2vw, 18px), var(--node-width, 24px));
  border: 0;
  border-radius: 3px;
  background: var(--node-color) !important;
  background-color: var(--node-color) !important;
  background-image: none !important;
  color: inherit;
  cursor: pointer;
  opacity: 1;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
  transform: none;
  transition: none;
}

.node-pill.has-name {
  z-index: 1;
}

.node-pill-label {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  max-width: calc(100% - 8px);
  padding: 1px 5px;
  border: 0;
  border-radius: 4px;
  background: rgba(48, 39, 70, 0.52);
  overflow: hidden;
  color: rgba(255, 255, 255, 0.96);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(35, 26, 53, 0.16);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: none;
}

.node-pill::before,
.node-pill::after,
.node-pill.is-selected::before,
.node-pill.is-selected::after,
.node-pill:hover::before,
.node-pill:hover::after,
.node-pill:active::before,
.node-pill:active::after {
  display: none !important;
  content: none !important;
  border: 0 !important;
}

.node-pill:hover,
.node-pill:active,
.node-pill.is-selected {
  transform: none;
  opacity: 1;
  background: var(--node-color) !important;
  background-color: var(--node-color) !important;
  background-image: none !important;
  box-shadow: 0 0 0 1px rgba(73, 58, 112, 0.28);
}

.node-pill.is-selected {
  z-index: 3;
  outline: 4px solid rgba(141, 117, 201, 0.34);
  outline-offset: 0;
  box-shadow:
    0 0 0 2px #fff,
    0 8px 18px rgba(73, 58, 112, 0.22);
}

.matrix-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid rgba(221, 214, 239, 0.46);
  border-radius: 8px;
  background: #4f426f;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.1s ease, transform 0.1s ease;
  box-shadow: 0 10px 24px rgba(50, 38, 76, 0.18);
}

.matrix-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.node-pill:focus-visible {
  outline: 2px solid rgba(61, 49, 91, 0.45);
  outline-offset: 2px;
}

.node-detail {
  display: grid;
  gap: 11px;
}

.matrix-guide {
  display: grid;
  gap: 12px;
}

.matrix-guide-card,
.matrix-guide-list,
.story-readout-list {
  border: 1px solid rgba(221, 214, 239, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.matrix-guide-card {
  padding: 13px;
}

.matrix-guide-card strong {
  display: block;
  margin-bottom: 5px;
  color: #3b315b;
}

.matrix-guide-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.matrix-guide-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.matrix-guide-list div {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.matrix-guide-list div + div {
  border-top: 1px solid rgba(221, 214, 239, 0.54);
}

.matrix-guide-list strong {
  color: #3b315b;
}

.story-readout-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.story-readout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px 8px;
}

.story-readout-list h4 {
  margin: 0;
  color: #3b315b;
  font-size: 14px;
}

.matrix-label-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.matrix-label-dot {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dot-color);
  cursor: pointer;
  opacity: 1;
  box-shadow: none;
}

.matrix-label-dot:hover,
.matrix-label-dot.is-active {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95), 0 0 0 3px var(--dot-color);
}

.story-readout-current {
  margin: 0;
  padding: 0 13px 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.story-readout {
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border-top: 1px solid rgba(221, 214, 239, 0.54);
}

.story-readout strong {
  color: #3b315b;
  font-size: 13px;
  line-height: 1.35;
}

.story-readout p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.story-readout span {
  color: #887f99;
  font-size: 12px;
  line-height: 1.45;
}

.story-readout.is-empty {
  color: var(--muted);
}

.guide-mark {
  display: block;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 6px;
  background: #eee8fb;
}

.guide-mark.color {
  background: linear-gradient(135deg, #6fba8f, #c99634 50%, #c9564f);
}

.guide-mark.width {
  width: 22px;
  border-radius: 999px;
  background: linear-gradient(90deg, #cfc3ef 35%, #8d75c9 35%);
}

.guide-mark.click {
  border: 2px solid rgba(141, 117, 201, 0.5);
  background: #fff;
  box-shadow: inset 0 0 0 4px #eee8fb;
}

.detail-badge {
  position: relative;
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f4efff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.detail-hero {
  display: grid;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid rgba(141, 117, 201, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0% 0%, rgba(141, 117, 201, 0.16), transparent 42%),
    linear-gradient(135deg, #f7f4ff 0%, #ffffff 72%);
}

.detail-selected-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(156, 133, 204, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0% 0%, rgba(141, 117, 201, 0.16), transparent 42%),
    linear-gradient(135deg, #f7f4ff 0%, #ffffff 72%);
}

.detail-selected-card strong {
  display: block;
  margin-top: 9px;
  color: #302747;
  font-size: 18px;
  line-height: 1.42;
}

.detail-selected-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.detail-selected-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.detail-selected-metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #fff;
  color: #625383;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.detail-selected-note {
  padding-top: 2px;
}

.detail-hero strong {
  color: #302747;
  font-size: 18px;
  line-height: 1.45;
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.6;
}

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

.detail-stat {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(221, 214, 239, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,247,255,.98));
}

.detail-stat span,
.metric-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.detail-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.detail-stat strong {
  display: block;
  margin-top: 4px;
  color: #32284b;
  font-size: 17px;
  line-height: 1.25;
}

.detail-stat em {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8a829b;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-signal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.detail-signal-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f1ebfb;
  color: #6e6188;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.detail-signal-row b {
  margin-right: 4px;
  color: #4b3f70;
}

.metric-help {
  position: relative;
  cursor: default;
}

.metric-help-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid rgba(137, 116, 188, 0.42);
  border-radius: 50%;
  background: #fff;
  color: #6f5c9c;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.metric-definition-tooltip {
  position: fixed;
  z-index: 5000;
  width: min(360px, calc(100vw - 32px));
  padding: 9px 10px;
  border: 1px solid rgba(211, 201, 233, 0.95);
  border-radius: 8px;
  background: #fff;
  color: #453a5d;
  box-shadow: 0 12px 28px rgba(48, 37, 72, 0.18);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.metric-definition-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.metric-stack {
  display: grid;
  gap: 7px;
}

.metric-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 50px;
  align-items: center;
  gap: 8px;
  min-height: 31px;
  padding: 5px 7px;
  border-radius: 8px;
  background: #fbf8ff;
  font-size: 12px;
  font-weight: 800;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeaf4;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.diagnosis {
  display: grid;
  gap: 5px;
  padding: 10px 11px;
  border: 1px solid rgba(221, 214, 239, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: #443a60;
  font-size: 12px;
  line-height: 1.6;
}

.diagnosis strong {
  font-size: 14px;
}

.diagnosis .muted {
  color: #7d778c;
}

canvas {
  display: block;
  width: 100%;
  height: 360px;
  border-radius: 8px;
  background: #fdfcff;
  cursor: pointer;
}

.action-list {
  display: grid;
  gap: 10px;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.score-note {
  margin: -8px 0 8px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #f6f1ff;
  color: #5a536b;
  font-size: 12px;
  line-height: 1.45;
}

.score-note.is-updated {
  animation: score-note-applied 900ms ease;
}

@keyframes score-note-applied {
  0% {
    background: #eee6ff;
    box-shadow: inset 0 0 0 1px rgba(141, 117, 201, 0.24);
  }
  100% {
    background: #f6f1ff;
    box-shadow: inset 0 0 0 1px rgba(141, 117, 201, 0);
  }
}

.queue-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.queue-tool-button {
  min-height: 30px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.queue-tool-button[aria-expanded="true"] {
  border-color: #c8b6ed;
  background: #f4efff;
}

.risk-legend {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: center;
  margin: -2px 0 8px;
}

.risk-chip {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(126, 88, 65, 0.18);
  border-radius: 3px;
}

.risk-chip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 8;
  width: max-content;
  max-width: 160px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #3f3267;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.risk-chip:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.risk-chip.is-low {
  background: #fff4e8;
}

.risk-chip.is-mid {
  background: #f6d7b7;
}

.risk-chip.is-high {
  background: #eba471;
}

.risk-chip.is-critical {
  background: #d6694f;
}

.score-detail-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  flex: 0 0 auto;
  max-height: 148px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfcff;
  overflow: hidden;
  color: #5a536b;
  font-size: 12px;
  line-height: 1.55;
}

.risk-panel.is-inspecting .action-list {
  display: none;
}

.risk-panel.is-inspecting .score-note,
.risk-panel.is-inspecting .risk-legend {
  display: none;
}

.risk-panel.is-inspecting .score-detail-panel,
.risk-panel.is-inspecting .weight-panel {
  flex: 1 1 auto;
  max-height: none;
  margin-bottom: 0;
}

.risk-panel.is-inspecting .score-detail-panel {
  gap: 10px;
  padding: 12px;
}

.risk-panel.is-inspecting .score-detail-grid {
  gap: 10px 12px;
}

.risk-panel.is-inspecting .score-detail-body p {
  line-height: 1.7;
}

.score-detail-panel[hidden] {
  display: none;
}

.score-detail-header {
  display: flex;
  align-items: center;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 7px;
  background: #f4efff;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}

.score-detail-body {
  min-height: 0;
  overflow: auto;
}

.score-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  padding: 0 0 8px;
}

.score-detail-grid div {
  display: grid;
  gap: 3px;
}

.score-detail-grid strong {
  color: var(--ink);
}

.score-detail-body p {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid #e8e1f4;
  color: var(--muted);
}

.weight-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
  flex: 0 0 auto;
  max-height: 178px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfcff;
  overflow: hidden;
}

.risk-panel.is-inspecting .weight-panel {
  gap: 10px;
  padding: 12px;
}

.risk-panel.is-inspecting .weight-panel-body {
  gap: 8px;
}

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

.weight-panel-body {
  display: grid;
  gap: 3px;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.weight-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 106px;
  align-items: center;
  gap: 6px;
  color: #5a536b;
  font-size: 12px;
}

.weight-label {
  color: var(--ink);
  font-weight: 800;
}

.weight-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeaf4;
}

.weight-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.weight-stepper {
  display: grid;
  grid-template-columns: 24px 38px 10px 24px;
  align-items: center;
  gap: 3px;
}

.weight-stepper button,
.weight-stepper input {
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.weight-stepper button {
  cursor: pointer;
}

.weight-stepper input {
  width: 38px;
  padding: 0 4px;
  text-align: center;
}

.weight-stepper em {
  color: var(--muted);
  font-style: normal;
}

.weight-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.weight-total {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.weight-total.is-valid {
  color: var(--green);
  font-weight: 800;
}

.weight-total.is-invalid {
  color: var(--red);
  font-weight: 800;
}

.weight-footer button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #5e4b8f;
  color: #fff;
  cursor: pointer;
}

.weight-footer button:disabled {
  background: #f0edf5;
  color: #879497;
  cursor: default;
}

.action-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #fdfcff;
}

.action-item.is-selected {
  border-color: #c8b6ed;
  background: #f4efff;
  box-shadow: inset 0 0 0 1px rgba(141, 117, 201, 0.16);
}

.action-item.is-anomaly-action {
  border-color: rgba(204, 145, 38, 0.34);
  background: #fff9e8;
}

.action-rank {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: #eee8fb;
  color: #493d66;
  font-size: 13px;
  font-weight: 800;
}

.action-item h4 {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.action-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.action-title-row h4 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-score {
  display: grid;
  flex: 0 0 auto;
  min-width: 48px;
  padding: 4px 7px 5px;
  place-items: center;
  border: 1px solid rgba(196, 109, 49, 0.2);
  border-radius: 7px;
  background: linear-gradient(180deg, #fff8ef 0%, #fff0df 100%);
  color: #9a5a27;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.risk-score.is-mid {
  border-color: rgba(198, 112, 47, 0.28);
  background: linear-gradient(180deg, #fff1df 0%, #f6d7b7 100%);
  color: #954c1e;
}

.risk-score.is-high {
  border-color: rgba(191, 83, 34, 0.36);
  background: linear-gradient(180deg, #ffe7cf 0%, #eba471 100%);
  color: #813717;
}

.risk-score.is-critical {
  border-color: rgba(170, 55, 38, 0.42);
  background: linear-gradient(180deg, #ffd9ca 0%, #d6694f 100%);
  color: #672417;
}

.risk-score b {
  font-size: 16px;
  line-height: 1;
}

.risk-score span {
  margin-top: 2px;
  color: currentColor;
  opacity: 0.72;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
}

.score-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.score-breakdown span {
  padding: 2px 5px;
  border-radius: 999px;
  background: #f4efff;
  color: #554b68;
  font-size: 11px;
  font-weight: 700;
}

.table-panel {
  margin-bottom: 24px;
}

.table-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(560px, 100%);
}

.table-heading-actions #searchInput {
  flex: 0 1 420px;
  min-width: 220px;
  font-size: 14px;
  font-weight: 400;
}

.table-heading-actions #searchInput::placeholder {
  color: #aaa4b2;
  font-size: 14px;
  font-weight: 400;
}

.metric-definition-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(211, 201, 233, 0.95);
  border-radius: 8px;
  background: #fff;
  color: #5b4a86;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.metric-definition-toggle:hover,
.metric-definition-toggle[aria-expanded="true"] {
  border-color: #c8b9ec;
  background: #f7f3fc;
}

.metric-definition-panel {
  display: grid;
  gap: 0;
  margin: 0 0 10px;
  overflow: hidden;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(48, 37, 72, 0.08);
}

.metric-definition-panel[hidden] {
  display: none;
}

.metric-definition-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  color: #5f5573;
  font-size: 13px;
  line-height: 1.55;
}

.metric-definition-row + .metric-definition-row {
  border-top: 1px solid rgba(221, 214, 239, 0.58);
}

.metric-definition-row strong {
  color: #3f315f;
  font-weight: 900;
}

.table-wrap {
  height: 640px;
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.interval-drill {
  margin-top: 14px;
  padding-top: 0;
  border-top: 0;
}

.panel-count-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1ebfb;
  color: #5b4a86;
  font-size: 12px;
  font-weight: 800;
}

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

.interval-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e3dbf1;
  border-radius: 8px;
  background: linear-gradient(180deg, #fdfcff 0%, #f7f3fc 100%);
}

.interval-card-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.interval-card-head strong {
  color: #3f315f;
  font-size: 13px;
}

.interval-card-head span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.interval-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.interval-row:hover,
.interval-row.is-active {
  border-color: #d2c4ef;
  background: #f5f0ff;
}

.interval-row.is-zero {
  color: #91a0a3;
}

.interval-name {
  color: inherit;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.interval-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeaf4;
}

.interval-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #c6b4ee);
}

.interval-row.is-zero .interval-bar i {
  width: 0;
}

.interval-row strong {
  color: #44385f;
  font-size: 12px;
  text-align: right;
}

.interval-empty:not(.empty-state) {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fdfcff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.interval-empty.compact {
  padding: 10px;
}

table {
  width: 100%;
  min-width: 1360px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: #f7f3fc;
  color: #554b68;
  font-size: 12px;
  box-shadow: 0 1px 0 var(--line);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 800;
}

.sort-button::after {
  content: "↕";
  color: #9aa7aa;
  font-size: 11px;
}

.sort-button.is-active::after {
  content: "↓";
  color: var(--teal);
}

.sort-button.is-active.asc::after {
  content: "↑";
}

th:first-child .sort-button,
td:first-child .ai-rank-badge {
  transform: translateX(4px);
}

.ai-rank-badge {
  display: inline-flex;
  min-width: 30px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1edf8;
  color: #6f628b;
  font-size: 12px;
  font-weight: 800;
}

tbody tr:hover {
  background: #f8f5fd;
}

tbody tr.is-ai-focus-row td {
  background: #fff3f1;
}

tbody tr.is-ai-focus-row td:first-child {
  box-shadow: inset 4px 0 0 rgba(174, 64, 70, 0.62);
}

tbody tr.is-ai-focus-row:hover td {
  background: #ffe9e5;
}

tbody tr.is-ai-focus-row .ai-rank-badge {
  border: 0;
  background: linear-gradient(180deg, #d7797f 0%, #b84f5a 100%);
  color: #fff;
  text-shadow: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 4px 10px rgba(174, 64, 70, 0.14);
}

tbody tr.is-anomaly-row td {
  background: #fff8df;
}

tbody tr.is-anomaly-row td:first-child {
  box-shadow: inset 4px 0 0 rgba(204, 145, 38, 0.72);
}

tbody tr.is-anomaly-row:hover td {
  background: #fff0bf;
}

tbody tr.is-anomaly-row .ai-rank-badge {
  background: #f0c66d;
  color: #543d13;
  box-shadow: none;
}

.anomaly-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff0bf;
  color: #8a5b08;
  font-size: 11px;
  font-weight: 900;
  vertical-align: middle;
}

.anomaly-badge::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: 280px;
  max-width: min(280px, 70vw);
  padding: 8px 10px;
  border: 1px solid rgba(126, 95, 188, 0.22);
  border-radius: 8px;
  background: #3f3267;
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.anomaly-badge:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.anomaly-action {
  color: #8a5b08;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: none;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.metric-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #f2edf8;
  color: #554b68;
  font-size: 11px;
  font-weight: 700;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a9a1b8;
}

.status-ok::before {
  background: var(--green);
}

.status-watch::before {
  background: var(--amber);
}

.status-warn::before {
  background: var(--red);
}

.branch-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 250, 255, 0.98));
  box-shadow: var(--shadow);
}

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

.branch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  min-height: 520px;
}

.branch-flow-card,
.branch-detail-card {
  min-width: 0;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 26px rgba(61, 48, 91, 0.045);
  overflow: hidden;
}

.branch-flow-note {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.68);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}

.branch-flow-wrap {
  height: 520px;
  min-height: 520px;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(90deg, rgba(156, 133, 204, 0.055) 1px, transparent 1px) 0 0 / 25% 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 247, 254, 0.94));
}

#branchFlowSvg {
  display: block;
  width: 100%;
  min-width: 940px;
}

.branch-level-label {
  fill: #766d88;
  font-size: 12px;
  font-weight: 900;
}

.branch-flow-link {
  fill: none;
  opacity: 0.24;
  stroke-linecap: round;
  transition: opacity 0.16s ease, stroke-width 0.16s ease;
}

.branch-flow-link.is-active {
  opacity: 0.68;
}

.branch-flow-link.is-dimmed {
  opacity: 0.045;
}

.branch-selection-band {
  fill: rgba(134, 116, 188, 0.065);
  stroke: rgba(134, 116, 188, 0.18);
  stroke-width: 1;
}

.branch-flow-node {
  cursor: pointer;
}

.branch-flow-node .branch-node-hit {
  fill: transparent;
}

.branch-flow-node .branch-node-bg {
  fill: rgba(255, 255, 255, 0.72);
  stroke: rgba(221, 214, 239, 0.62);
  stroke-width: 1;
  transition: fill 0.16s ease, stroke 0.16s ease, opacity 0.16s ease;
}

.branch-flow-node:hover .branch-node-bg {
  fill: rgba(250, 247, 255, 0.96);
  stroke: rgba(156, 133, 204, 0.26);
}

.branch-flow-node .branch-node-indicator {
  opacity: 0.56;
}

.branch-flow-node .branch-node-track {
  stroke: rgba(221, 214, 239, 0.86);
  stroke-width: 5;
  stroke-linecap: round;
}

.branch-flow-node .branch-node-share {
  opacity: 0.74;
  stroke-width: 5;
  stroke-linecap: round;
}

.branch-flow-node text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 850;
  paint-order: normal;
  stroke: none;
  pointer-events: none;
}

.branch-flow-node .branch-node-label {
  letter-spacing: 0;
}

.branch-flow-node .branch-node-value {
  fill: #62586f;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.branch-flow-node .branch-node-meta {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.branch-flow-node.is-level-0 .branch-node-bg {
  fill: rgba(248, 246, 254, 0.86);
}

.branch-flow-node.is-level-1 .branch-node-bg {
  fill: rgba(245, 248, 254, 0.86);
}

.branch-flow-node.is-level-2 .branch-node-bg {
  fill: rgba(241, 249, 253, 0.9);
}

.branch-flow-node.is-level-3 .branch-node-bg {
  fill: rgba(241, 250, 249, 0.9);
}

.branch-flow-node.is-active .branch-node-bg {
  fill: rgba(238, 232, 251, 0.92);
  stroke: rgba(141, 117, 201, 0.38);
  stroke-width: 1;
}

.branch-flow-node.is-level-0.is-active .branch-node-bg {
  fill: rgba(241, 239, 251, 0.96);
  stroke: rgba(139, 127, 199, 0.44);
}

.branch-flow-node.is-level-1.is-active .branch-node-bg {
  fill: rgba(235, 241, 252, 0.96);
  stroke: rgba(116, 139, 196, 0.44);
}

.branch-flow-node.is-level-2.is-active .branch-node-bg {
  fill: rgba(229, 245, 252, 0.96);
  stroke: rgba(101, 162, 197, 0.48);
}

.branch-flow-node.is-level-3.is-active .branch-node-bg {
  fill: rgba(229, 248, 247, 0.96);
  stroke: rgba(99, 180, 176, 0.48);
}

.branch-flow-node.is-active .branch-node-indicator {
  opacity: 0.92;
}

.branch-flow-node.is-active .branch-node-value,
.branch-flow-node.is-active .branch-node-label {
  fill: #3f315f;
}

.branch-flow-node.is-dimmed {
  opacity: 0.3;
}

.branch-detail-card {
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(255, 255, 255, 0.78);
}

.branch-detail-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid rgba(221, 214, 239, 0.74);
}

.branch-detail-head h4,
.branch-detail-head p {
  margin: 0;
}

.branch-detail-head h4 {
  color: #342d45;
  font-size: 15px;
}

.branch-detail-head p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.5;
}

.branch-detail-body {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  overflow: auto;
}

.branch-detail-empty,
.branch-detail-block,
.branch-warning {
  padding: 12px;
  border: 1px solid rgba(221, 214, 239, 0.66);
  border-radius: 10px;
  background: rgba(251, 248, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.55;
}

.branch-detail-block {
  display: grid;
  gap: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.branch-detail-block strong {
  color: #3f3658;
  font-size: 13px;
  font-weight: 900;
}

.branch-stat-row,
.branch-mini-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.branch-stat-row span,
.branch-mini-head span {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-stat-row b,
.branch-mini-head b {
  flex: 0 0 auto;
  color: #332c45;
  font-variant-numeric: tabular-nums;
}

.branch-mini-bars {
  display: grid;
  gap: 9px;
}

.branch-child-row {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 2px 0 9px;
  border: 0;
  border-bottom: 1px solid rgba(221, 214, 239, 0.58);
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.branch-child-row:hover {
  background: transparent;
}

.branch-child-row:hover .branch-mini-head span {
  color: #3f315f;
}

.branch-mini-bar {
  display: grid;
  gap: 5px;
}

.branch-mini-track {
  height: 6px;
  border-radius: 999px;
  background: #eee8fb;
  overflow: hidden;
}

.branch-mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--branch-mini-color, #c7bfeb);
}

.branch-warning {
  border-color: rgba(201, 150, 52, 0.24);
  background: #fff8e7;
  color: #7a5a20;
}

.branch-table-wrap {
  max-height: 360px;
  margin-top: 12px;
  border: 1px solid rgba(221, 214, 239, 0.82);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  overflow: auto;
}

.branch-table-wrap table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.muted {
  color: var(--muted);
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell,
  .main-grid,
  .lower-grid,
  .kpi-grid,
  .ai-control-column,
  .ai-option-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .top-actions,
  .anomaly-action-group {
    align-items: stretch;
  }

  .ai-heading-actions {
    flex-wrap: wrap;
  }

  .ai-usage-meter {
    order: 3;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    white-space: normal;
  }

  .score-detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-stat-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .weight-footer {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ai-option-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .branch-layout {
    grid-template-columns: 1fr;
  }

  .table-heading-actions {
    display: grid;
    min-width: 0;
  }

  .module-filter-tools {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .metric-definition-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
