:root {
  --bg: #f3f6f5;
  --surface: #fbfcfc;
  --surface-strong: #ffffff;
  --surface-muted: #eef2f1;
  --sidebar: #101918;
  --sidebar-soft: #172321;
  --ink: #17201f;
  --ink-soft: #566461;
  --ink-faint: #7a8784;
  --line: #dce4e2;
  --line-strong: #c9d4d1;
  --accent: #19766c;
  --accent-dark: #105e56;
  --accent-soft: #e2f2ef;
  --accent-pale: #f0f8f6;
  --danger: #b4463b;
  --danger-dark: #92372f;
  --danger-soft: #faece9;
  --warning: #9a6b17;
  --warning-soft: #fbf3df;
  --success: #2a7555;
  --success-soft: #e7f3ed;
  --info: #376f8a;
  --info-soft: #e9f2f6;
  --shadow: 0 18px 54px rgba(25, 47, 43, .08);
  --shadow-small: 0 8px 24px rgba(25, 47, 43, .07);
  --radius: 12px;
  --radius-small: 8px;
  --sidebar-width: 248px;
  --topbar-height: 66px;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); scroll-behavior: auto; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { color: inherit; font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.22; letter-spacing: -.025em; }
h1 { font-size: clamp(26px, 2.5vw, 34px); font-weight: 680; }
h2 { font-size: 18px; font-weight: 660; }
h3 { font-size: 15px; font-weight: 650; }
small { font-size: 12px; }

::selection { color: var(--accent-dark); background: #cbe9e3; }

:focus-visible {
  outline: 3px solid rgba(25, 118, 108, .28);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 100;
  padding: 9px 14px;
  color: #fff;
  background: var(--accent-dark);
  border-radius: var(--radius-small);
  transform: translate(-50%, -150%);
  transition: transform .18s ease;
}
.skip-link:focus { transform: translate(-50%, 0); }

.app-shell { min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100dvh;
  flex-direction: column;
  color: #dce8e5;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .05);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: #f3f8f7;
}

.sidebar > .brand { height: var(--topbar-height); padding: 0 18px; }

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  overflow: hidden;
  background: #d5efe9;
  border-radius: 10px;
}
.brand-mark span {
  position: absolute;
  bottom: 8px;
  width: 4px;
  background: var(--accent-dark);
  border-radius: 3px 3px 1px 1px;
}
.brand-mark span:nth-child(1) { left: 8px; height: 8px; }
.brand-mark span:nth-child(2) { left: 15px; height: 14px; }
.brand-mark span:nth-child(3) { left: 22px; height: 20px; }

.brand-copy { display: flex; min-width: 0; flex-direction: column; line-height: 1.25; }
.brand-copy strong { overflow: hidden; font-size: 16px; font-weight: 680; letter-spacing: .02em; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { margin-top: 2px; color: #8da09c; font-size: 10px; letter-spacing: .05em; }

.side-nav {
  flex: 1;
  min-height: 0;
  padding: 13px 11px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-label {
  margin: 18px 10px 7px;
  color: #728681;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}
.nav-label:first-child { margin-top: 6px; }

.nav-item {
  position: relative;
  display: grid;
  min-height: 42px;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 6px 11px;
  color: #aebdb9;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 570;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}
.nav-item:hover { color: #edf5f3; background: rgba(255, 255, 255, .045); }
.nav-item:active { transform: translateY(1px); }
.nav-item.active { color: #f5fbf9; background: #213330; }
.nav-item.active::before {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 0;
  width: 2px;
  content: "";
  background: #7bc8bb;
  border-radius: 0 2px 2px 0;
}
.nav-code {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #8fa49f;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .055);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
}
.nav-item.active .nav-code { color: #b9e8df; background: rgba(93, 175, 160, .13); border-color: rgba(126, 210, 195, .12); }

.nav-count {
  min-width: 21px;
  padding: 1px 6px;
  color: #c8f1ea;
  background: rgba(71, 159, 143, .24);
  border-radius: 99px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.nav-count.danger { color: #f3c8c2; background: rgba(193, 76, 63, .2); }

.sidebar-foot { padding: 13px 14px 15px; border-top: 1px solid rgba(255, 255, 255, .065); }
.environment-line { display: flex; align-items: center; gap: 7px; margin: 0 5px 12px; color: #7f928e; font-size: 11px; }
.status-light { width: 7px; height: 7px; background: #63ae8f; border-radius: 50%; box-shadow: 0 0 0 3px rgba(99, 174, 143, .1); }
.account-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.account-avatar { display: grid; width: 32px; height: 32px; place-items: center; color: #c6e5df; background: #213330; border-radius: 9px; font-size: 12px; font-weight: 700; }
.account-copy { display: flex; min-width: 0; flex-direction: column; line-height: 1.25; }
.account-copy strong { overflow: hidden; color: #dce8e5; font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { color: #70847f; font-size: 10px; }
.text-button { padding: 5px; color: #82948f; background: transparent; border: 0; font-size: 11px; }
.text-button:hover { color: #e4eeeb; }

.main-column { min-width: 0; min-height: 100dvh; margin-left: var(--sidebar-width); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  gap: 12px;
  padding: 0 clamp(20px, 3vw, 40px);
  background: rgba(251, 252, 252, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-title { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; }
.topbar-title strong { overflow: hidden; color: var(--ink); font-weight: 630; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb::after { margin-left: 8px; color: #abb6b3; content: "/"; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.sync-state { max-width: 260px; overflow: hidden; color: var(--ink-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.menu-button {
  display: none;
  width: 38px;
  height: 38px;
  place-content: center;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}
.menu-button > span:not(.sr-only) { display: block; width: 15px; height: 1.5px; margin: 3px auto; background: var(--ink); border-radius: 2px; }

.page-wrap { width: min(1480px, 100%); margin: 0 auto; padding: 34px clamp(20px, 3vw, 40px) 64px; }
.page[hidden] { display: none !important; }
.page.active { animation: page-in .24s ease both; }

@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.page-heading > div:first-child { min-width: 0; }
.page-heading h1 { margin-bottom: 8px; }
.page-heading p:not(.section-kicker) { max-width: 720px; color: var(--ink-soft); font-size: 14px; }
.section-kicker { margin-bottom: 7px; color: var(--accent-dark); font-size: 11px; font-weight: 750; letter-spacing: .1em; }
.heading-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font-size: 13px;
  font-weight: 630;
  line-height: 1;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease, box-shadow .16s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { color: #f7fffd; background: var(--accent); border-color: var(--accent); box-shadow: 0 5px 14px rgba(25, 118, 108, .16); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.quiet { color: #354440; background: var(--surface-strong); border-color: var(--line-strong); }
.button.quiet:hover { color: var(--accent-dark); background: var(--accent-pale); border-color: #afd1ca; }
.button.danger-soft { color: var(--danger-dark); background: var(--danger-soft); border-color: #efd1cc; }
.button.danger-soft:hover { background: #f5deda; border-color: #deb8b2; }
.button.text-only { min-height: 34px; padding: 6px 8px; color: var(--ink-soft); background: transparent; border: 0; }
.button.text-only:hover { color: var(--accent-dark); background: var(--accent-pale); }
.button.compact { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button.large { min-height: 46px; font-size: 14px; }
.button.full { width: 100%; }

.export-menu { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 25;
  width: 154px;
  padding: 5px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-small);
}
.popover a { display: block; padding: 9px 10px; border-radius: 6px; font-size: 12px; }
.popover a:hover { color: var(--accent-dark); background: var(--accent-pale); }

.notice { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; padding: 11px 14px; border: 1px solid; border-radius: var(--radius-small); font-size: 12px; }
.notice[hidden] { display: none; }
.notice.info { color: #315d70; background: var(--info-soft); border-color: #d2e4eb; }
.notice.warning { color: #72541d; background: var(--warning-soft); border-color: #e8d7aa; }
.notice strong { flex: 0 0 auto; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 16px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi-card { min-width: 0; min-height: 126px; padding: 20px; background: var(--surface-strong); }
.kpi-card > span { display: block; margin-bottom: 11px; color: var(--ink-soft); font-size: 12px; }
.kpi-card > strong { display: block; overflow: hidden; margin-bottom: 5px; font-size: 27px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.kpi-card > small { display: block; color: var(--ink-faint); font-size: 11px; }
.kpi-card .trend { margin-left: 6px; font-size: 11px; font-weight: 650; }
.kpi-error-wide { grid-column: 1 / -1; }
.trend.up, .trend.good { color: var(--success); }
.trend.down, .trend.bad { color: var(--danger); }

.health-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; padding: 13px 17px; background: #e9eeec; border-radius: var(--radius-small); }
.health-strip > div { min-width: 0; padding: 0 17px; border-left: 1px solid #d0d9d7; }
.health-strip > div:first-child { padding-left: 0; border-left: 0; }
.health-strip > div:last-child { padding-right: 0; }
.health-strip span { display: block; margin-bottom: 2px; color: var(--ink-faint); font-size: 10px; }
.health-strip strong { display: block; overflow: hidden; font-size: 12px; font-weight: 630; text-overflow: ellipsis; white-space: nowrap; }

.panel { margin-bottom: 20px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(34, 60, 55, .02); }
.panel-heading { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin-bottom: 4px; }
.panel-heading p { color: var(--ink-faint); font-size: 11px; }
.result-count { flex: 0 0 auto; color: var(--ink-faint); font-size: 11px; }
.panel-count { flex: 0 0 auto; padding: 5px 8px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 6px; font-size: 10px; font-weight: 680; white-space: nowrap; }

.toolbar { display: flex; align-items: center; gap: 9px; padding: 12px 18px; background: #fafcfc; border-bottom: 1px solid var(--line); }
.toolbar .search-field { width: min(310px, 100%); }

input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input, select { height: 38px; padding: 0 11px; }
select { min-width: 134px; padding-right: 30px; }
textarea { min-height: 96px; padding: 10px 11px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #899591; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #abbab6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 118, 108, .11); }
.search-field input { padding-left: 34px; background-image: radial-gradient(circle, transparent 46%, #6e7c79 48%, #6e7c79 59%, transparent 62%), linear-gradient(45deg, transparent 46%, #6e7c79 48%, #6e7c79 57%, transparent 59%); background-position: 12px 11px, 21px 22px; background-size: 12px 12px, 7px 7px; background-repeat: no-repeat; }

.table-scroll { max-width: 100%; overflow: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid #e5ebe9; text-align: left; vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 2; color: #64716e; background: #f6f9f8; font-size: 10px; font-weight: 720; letter-spacing: .035em; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .14s ease; }
.data-table tbody tr:not(.empty-row):not(.skeleton-row):hover { background: #f7faf9; }
.data-table .numeric { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.recommendations-table { min-width: 1060px; }
.recommendations-table tbody tr[data-id] { cursor: pointer; }
.recommendations-table td:first-child { min-width: 190px; }
.model-cell { display: flex; flex-direction: column; line-height: 1.35; }
.model-cell strong { max-width: 220px; overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.model-cell small { color: var(--ink-faint); font-size: 10px; }
.money { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-faint); }
.row-action { min-height: 30px; padding: 5px 9px; color: var(--accent-dark); background: transparent; border: 1px solid #bed6d1; border-radius: 7px; font-size: 11px; font-weight: 620; }
.row-action:hover { background: var(--accent-pale); border-color: #8fbeb5; }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.catalog-management-table { min-width: 920px; }
.alias-model-select { width: min(300px, 28vw); min-width: 220px; height: 34px; font-size: 11px; }

.badge { display: inline-flex; min-height: 23px; align-items: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 7px; font-size: 10px; font-weight: 680; line-height: 1; white-space: nowrap; }
.badge.priority, .badge.approved, .badge.active, .badge.healthy { color: #26684e; background: var(--success-soft); border-color: #d0e8db; }
.badge.watch, .badge.pending, .badge.medium { color: #815812; background: var(--warning-soft); border-color: #eddfb9; }
.badge.avoid, .badge.rejected, .badge.high, .badge.failed { color: #963b32; background: var(--danger-soft); border-color: #f0d0cb; }
.badge.insufficient, .badge.closed, .badge.inactive { color: #5e6c69; background: #edf1f0; border-color: #dce3e1; }
.badge.acknowledged, .badge.low, .badge.market { color: #356d84; background: var(--info-soft); border-color: #d2e5ec; }
.badge.upstream { color: #4e5a7a; background: #eceefa; border-color: #d9ddee; }

.confidence-cell { display: flex; min-width: 96px; align-items: center; gap: 8px; }
.confidence-mark { width: 34px; height: 3px; overflow: hidden; appearance: none; background: #dfe6e4; border: 0; border-radius: 2px; }
.confidence-mark::-webkit-progress-bar { background: #dfe6e4; border-radius: inherit; }
.confidence-mark::-webkit-progress-value { background: var(--accent); border-radius: inherit; }
.confidence-mark::-moz-progress-bar { background: var(--accent); border-radius: inherit; }
.confidence-cell span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.table-foot { display: flex; justify-content: space-between; gap: 16px; padding: 10px 18px; color: var(--ink-faint); background: #fbfcfc; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); font-size: 10px; }

.empty-row td { padding: 0 !important; }
.empty-state { display: grid; min-height: 230px; place-items: center; align-content: center; padding: 32px 20px; color: var(--ink-soft); text-align: center; }
.empty-state.tall { min-height: 100%; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state.compact { min-height: 150px; }
.empty-state h2, .empty-state h3 { margin: 9px 0 6px; color: var(--ink); }
.empty-state p { max-width: 470px; color: var(--ink-faint); font-size: 12px; }
.empty-state .button { margin-top: 15px; }
.empty-symbol { display: grid; width: 42px; height: 42px; place-items: center; color: var(--accent-dark); background: var(--accent-soft); border-radius: 10px; font-size: 16px; font-weight: 750; }
.error-state .empty-symbol { color: var(--danger-dark); background: var(--danger-soft); }

.skeleton-card > span, .skeleton-card > strong, .skeleton-card > small, .skeleton-row span, .drawer-loading span {
  display: block;
  background: linear-gradient(100deg, #e8edeb 20%, #f3f6f5 40%, #e8edeb 60%);
  background-size: 200% 100%;
  border-radius: 5px;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-card > span { width: 45%; height: 11px; }
.skeleton-card > strong { width: 58%; height: 27px; margin: 14px 0 9px; }
.skeleton-card > small { width: 70%; height: 9px; }
.skeleton-row td { padding: 14px !important; }
.skeleton-row span { width: 100%; height: 28px; }
@keyframes shimmer { 0% { background-position: 180% 0; } 100% { background-position: -30% 0; } }

.import-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 20px; align-items: stretch; margin-bottom: 20px; }
.upload-panel { margin: 0; }
.upload-panel form { padding: 18px; }
.drop-zone { display: grid; min-height: 230px; place-items: center; align-content: center; padding: 25px; color: var(--ink-soft); background: #f8faf9; border: 1px dashed #aebfbb; border-radius: 10px; text-align: center; transition: background .16s ease, border-color .16s ease, transform .16s ease; cursor: pointer; }
.drop-zone:hover, .drop-zone.dragging { background: var(--accent-pale); border-color: var(--accent); }
.drop-zone.dragging { transform: scale(.997); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-symbol { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 13px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 11px; font-size: 22px; line-height: 1; }
.drop-zone strong { max-width: 90%; overflow: hidden; margin-bottom: 6px; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone small { max-width: 580px; color: var(--ink-faint); }
.upload-actions { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.import-guide { padding: 20px; color: #dfeae7; background: var(--sidebar-soft); border-radius: var(--radius); }
.import-guide h2 { margin-bottom: 16px; color: #f3f8f7; }
.check-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; counter-reset: import-check; }
.check-list li { position: relative; padding: 13px 0 13px 33px; border-top: 1px solid rgba(255, 255, 255, .08); counter-increment: import-check; }
.check-list li::before { position: absolute; top: 14px; left: 0; display: grid; width: 21px; height: 21px; place-items: center; color: #94cfc3; background: rgba(105, 187, 171, .11); border-radius: 6px; content: counter(import-check); font-size: 10px; font-weight: 700; }
.check-list strong, .check-list span { display: block; }
.check-list strong { margin-bottom: 3px; font-size: 12px; }
.check-list span { color: #92a6a1; font-size: 11px; }
.security-note { margin-top: 16px; padding: 12px; color: #a5b7b3; background: rgba(0, 0, 0, .12); border-radius: var(--radius-small); font-size: 10px; }

.form-message { margin: 12px 0 0; padding: 10px 11px; border: 1px solid; border-radius: var(--radius-small); font-size: 12px; }
.form-message.error { color: #8b342c; background: var(--danger-soft); border-color: #efcbc5; }
.form-message.success { color: #28654d; background: var(--success-soft); border-color: #cde4d8; }

.catalog-summary, .approval-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 20px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); }
.catalog-summary > div, .approval-summary > div { min-height: 74px; padding: 14px 17px; background: var(--surface-strong); }
.catalog-summary span, .approval-summary span { display: block; color: var(--ink-faint); font-size: 10px; }
.catalog-summary strong, .approval-summary strong { display: block; margin-top: 4px; font-size: 21px; font-variant-numeric: tabular-nums; }
.approval-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.policy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.form-panel .panel-heading { min-height: 68px; }
.form-grid { display: grid; gap: 18px; padding: 20px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; min-width: 0; gap: 7px; }
.field > span, .field > label { color: #3a4845; font-size: 12px; font-weight: 620; }
.field > small { color: var(--ink-faint); font-size: 10px; }
.field.full { grid-column: 1 / -1; }
.checkbox-field { display: flex; min-height: 48px; align-items: flex-start; gap: 10px; padding: 11px 12px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius-small); cursor: pointer; }
.checkbox-field.full { grid-column: 1 / -1; }
.checkbox-field input { width: 17px; height: 17px; flex: 0 0 17px; margin: 2px 0 0; accent-color: var(--accent); }
.checkbox-field span { display: grid; gap: 2px; }
.checkbox-field strong { font-size: 12px; }
.checkbox-field small { color: var(--ink-faint); font-size: 10px; font-weight: 400; }
.suffix-input, .prefix-input, .password-field { position: relative; display: flex; align-items: center; }
.suffix-input input { padding-right: 43px; }
.prefix-input input { padding-left: 31px; }
.suffix-input > span, .prefix-input > span { position: absolute; z-index: 1; color: var(--ink-faint); font-size: 11px; pointer-events: none; }
.suffix-input > span { right: 11px; }
.prefix-input > span { left: 11px; }
.weight-total { flex: 0 0 auto; padding: 5px 8px; color: var(--success); background: var(--success-soft); border-radius: 6px; font-size: 10px; }
.weight-total.invalid { color: var(--danger-dark); background: var(--danger-soft); }
.policy-aside { position: sticky; top: calc(var(--topbar-height) + 18px); }
.formula-card { margin-bottom: 14px; padding: 19px; color: #dce8e5; background: var(--sidebar-soft); border-radius: var(--radius); }
.formula-card h2 { margin-bottom: 15px; color: #f5f9f8; }
.formula-card dl { margin: 0; }
.formula-card dl > div { padding: 11px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.formula-card dt { margin-bottom: 4px; color: #8ea39e; font-size: 10px; }
.formula-card dd { margin: 0; color: #d9e6e3; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.formula-card p { margin-top: 13px; color: #98aaa6; font-size: 10px; }
.sticky-actions { padding: 15px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); }
.sticky-actions .form-message { margin: 0 0 10px; }
.sticky-actions > small { display: block; margin-top: 9px; color: var(--ink-faint); text-align: center; }

.simulation-layout { display: grid; min-height: 560px; grid-template-columns: minmax(390px, .82fr) minmax(0, 1.18fr); gap: 20px; align-items: stretch; }
.simulation-layout > .panel { margin: 0; }
.simulation-output { min-width: 0; }
.simulation-result { display: grid; height: 100%; align-content: start; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.simulation-result-head { padding: 20px; color: #dce8e5; background: var(--sidebar-soft); }
.simulation-result-head span { color: #8ea29d; font-size: 10px; }
.simulation-result-head h2 { margin: 4px 0 6px; color: #f5faf8; font-size: 22px; }
.simulation-result-head p { color: #9bafaa; font-size: 11px; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.comparison-card { padding: 18px; background: var(--surface-strong); }
.comparison-card > span { color: var(--ink-faint); font-size: 10px; }
.comparison-card > strong { display: block; margin: 6px 0 4px; font-size: 20px; font-variant-numeric: tabular-nums; }
.comparison-card > small { color: var(--ink-faint); }
.comparison-card .impact { margin-left: 5px; font-size: 10px; font-weight: 700; }
.impact.good { color: var(--success); }
.impact.bad { color: var(--danger); }
.simulation-details { padding: 20px; }
.simulation-details h3 { margin-bottom: 11px; }
.simulation-details dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0; }
.simulation-details dl > div { padding: 11px; background: var(--surface-muted); border-radius: var(--radius-small); }
.simulation-details dt { color: var(--ink-faint); font-size: 10px; }
.simulation-details dd { margin: 4px 0 0; font-size: 12px; font-weight: 630; }
.warning-list { display: grid; gap: 7px; margin: 16px 0 0; padding: 0; list-style: none; }
.warning-list li { padding: 9px 11px; color: #795719; background: var(--warning-soft); border-radius: 7px; font-size: 11px; }

.alert-filters { display: flex; gap: 7px; margin-bottom: 15px; overflow-x: auto; }
.filter-chip { flex: 0 0 auto; min-height: 34px; padding: 6px 12px; color: var(--ink-soft); background: var(--surface-strong); border: 1px solid var(--line-strong); border-radius: 8px; font-size: 11px; font-weight: 620; }
.filter-chip:hover { border-color: #a6b8b4; }
.filter-chip.active { color: var(--accent-dark); background: var(--accent-soft); border-color: #afd2cb; }
.alert-list { display: grid; gap: 10px; }
.alert-card { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 104px; padding: 17px 18px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); }
.alert-card.severity-high { border-left: 3px solid #bf5146; }
.alert-card.severity-medium { border-left: 3px solid #b3832d; }
.alert-card.severity-low { border-left: 3px solid #5a8da4; }
.alert-meta { display: grid; gap: 6px; }
.alert-meta time { color: var(--ink-faint); font-size: 10px; }
.alert-content h2 { margin-bottom: 5px; font-size: 15px; }
.alert-content p { max-width: 760px; color: var(--ink-soft); font-size: 11px; }
.alert-content small { display: block; margin-top: 7px; color: var(--ink-faint); }
.alert-actions { display: flex; align-items: center; gap: 7px; }

.audit-toolbar { border-radius: var(--radius) var(--radius) 0 0; }
.audit-table td:last-child { max-width: 420px; }
.audit-detail { display: block; overflow: hidden; color: var(--ink-soft); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-scrim, .drawer-scrim { position: fixed; inset: 0; z-index: 29; padding: 0; background: rgba(12, 21, 19, .45); border: 0; backdrop-filter: blur(2px); }
.sidebar-scrim[hidden], .drawer-scrim[hidden] { display: none; }
.drawer-scrim { z-index: 48; }

.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 50;
  display: grid;
  width: min(630px, 94vw);
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface-strong);
  box-shadow: -20px 0 60px rgba(18, 36, 32, .16);
  transform: translateX(104%);
  transition: transform .24s cubic-bezier(.22, .8, .24, 1);
  visibility: hidden;
}
.detail-drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head { display: flex; min-height: 79px; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin-top: 2px; }
.drawer-eyebrow { color: var(--ink-faint); font-size: 10px; }
.icon-button { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; padding: 0; color: var(--ink-soft); background: transparent; border: 1px solid var(--line); border-radius: var(--radius-small); font-size: 21px; line-height: 1; }
.icon-button:hover { color: var(--ink); background: var(--surface-muted); }
.drawer-body { min-height: 0; padding: 20px; overflow-y: auto; }
.drawer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 20px; background: #fbfcfc; border-top: 1px solid var(--line); }
.drawer-loading { display: grid; gap: 13px; }
.drawer-loading span { height: 72px; }
.loading-block { width: min(420px, 80%); }

.detail-hero { margin: -20px -20px 20px; padding: 21px 20px 19px; color: #dce8e5; background: var(--sidebar-soft); }
.detail-hero-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-hero p { margin-top: 7px; color: #92a5a0; font-size: 11px; }
.detail-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 20px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-small); }
.detail-metric { min-width: 0; padding: 13px 11px; background: var(--surface-strong); }
.detail-metric span { display: block; color: var(--ink-faint); font-size: 9px; }
.detail-metric strong { display: block; overflow: hidden; margin-top: 3px; font-size: 14px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.detail-section { margin-top: 22px; }
.detail-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.detail-section-head h3 { font-size: 14px; }
.detail-section-head span { color: var(--ink-faint); font-size: 9px; }
.detail-table { min-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-small); overflow: hidden; }
.detail-table .data-table { min-width: 570px; }
.detail-table th, .detail-table td { padding: 9px 10px; }
.reason-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.reason-list li { padding: 10px 11px; color: #42504d; background: var(--surface-muted); border-radius: var(--radius-small); font-size: 11px; }
.trace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trace-item { min-width: 0; padding: 10px 11px; background: #f5f8f7; border: 1px solid #e3e9e7; border-radius: var(--radius-small); }
.trace-item span { display: block; margin-bottom: 3px; color: var(--ink-faint); font-size: 9px; }
.trace-item strong { display: block; overflow-wrap: anywhere; font-size: 11px; font-weight: 600; }
.calculation-steps { margin: 0; padding: 0; list-style: none; counter-reset: calc-step; }
.calculation-steps li { position: relative; padding: 9px 0 9px 32px; border-top: 1px solid var(--line); counter-increment: calc-step; font-size: 11px; }
.calculation-steps li::before { position: absolute; top: 9px; left: 0; display: grid; width: 21px; height: 21px; place-items: center; color: var(--accent-dark); background: var(--accent-soft); border-radius: 6px; content: counter(calc-step); font-size: 9px; font-weight: 700; }
.source-list { display: grid; gap: 7px; }
.source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-small); }
.source-row strong { display: block; font-size: 11px; }
.source-row small { display: block; color: var(--ink-faint); font-size: 9px; }
.source-row span { font-size: 10px; }
.source-copy { min-width: 0; }
.source-copy .source-conversion { margin-top: 4px; color: #40514d; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; overflow-wrap: anywhere; }

.review-dialog { width: min(480px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.review-dialog::backdrop { background: rgba(12, 21, 19, .5); backdrop-filter: blur(2px); }
.review-dialog form { margin: 0; }
.catalog-dialog { width: min(660px, calc(100vw - 28px)); }
.catalog-dialog .dialog-body { max-height: min(68vh, 680px); overflow-y: auto; }
.catalog-dialog .form-grid { padding: 0; }
.catalog-dialog .form-message { margin-top: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-head span { color: var(--ink-faint); font-size: 9px; }
.dialog-head h2 { margin-top: 2px; }
.dialog-body { padding: 18px; }
.dialog-body > p { margin-bottom: 15px; color: var(--ink-soft); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; background: #fafcfc; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; width: min(370px, calc(100vw - 36px)); gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 13px; color: #e9f3f0; background: #1d2c29; border: 1px solid rgba(255, 255, 255, .08); border-radius: var(--radius-small); box-shadow: var(--shadow-small); font-size: 12px; pointer-events: auto; animation: toast-in .2s ease both; }
.toast.error { color: #f8e7e4; background: #672f2a; }
.toast button { padding: 0; color: inherit; background: transparent; border: 0; opacity: .7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.noscript-message { position: fixed; inset: auto 12px 12px; z-index: 100; padding: 13px; color: #fff; background: var(--danger-dark); border-radius: var(--radius-small); text-align: center; }

/* Login */
.login-body { min-height: 100dvh; background: #eef3f1; }
.login-shell { display: grid; min-height: 100dvh; grid-template-columns: minmax(420px, .94fr) minmax(460px, 1.06fr); }
.login-brand { position: relative; display: grid; min-height: 100dvh; color: #dce8e5; background: var(--sidebar); overflow: hidden; }
.login-brand::before { position: absolute; right: -110px; bottom: -110px; width: 420px; height: 420px; content: ""; border: 1px solid rgba(140, 204, 192, .12); border-radius: 50%; box-shadow: 0 0 0 70px rgba(140, 204, 192, .025), 0 0 0 145px rgba(140, 204, 192, .018); }
.login-brand::after { position: absolute; top: 22%; right: 13%; width: 1px; height: 38%; content: ""; background: linear-gradient(transparent, rgba(137, 195, 184, .2), transparent); }
.login-brand-inner { position: relative; z-index: 1; display: flex; width: min(580px, 100%); min-height: 100dvh; flex-direction: column; margin-left: auto; padding: clamp(28px, 5vw, 62px); }
.login-logo { align-self: flex-start; }
.login-message { margin: auto 0; padding: 80px 0 70px; }
.login-message .section-kicker { color: #75b9ac; }
.login-message h1 { max-width: 590px; margin: 0 0 20px; color: #f3f8f7; font-size: clamp(38px, 4.1vw, 62px); font-weight: 620; letter-spacing: -.045em; line-height: 1.08; }
.login-message > p:last-child { max-width: 520px; color: #91a6a1; font-size: 14px; line-height: 1.8; }
.login-proof { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: rgba(255, 255, 255, .09); }
.login-proof > div { min-width: 0; padding: 13px; background: var(--sidebar); }
.login-proof strong, .login-proof span { display: block; }
.login-proof strong { color: #ccdcd8; font-size: 11px; }
.login-proof span { margin-top: 4px; color: #6f8580; font-size: 9px; line-height: 1.5; }
.login-panel { display: grid; min-height: 100dvh; place-items: center; padding: 40px; background: #f7f9f8; }
.login-form-wrap { width: min(400px, 100%); }
.login-form-head { margin-bottom: 28px; }
.login-form-head h2 { margin-bottom: 8px; font-size: 28px; }
.login-form-head p { color: var(--ink-soft); font-size: 13px; }
.mobile-login-mark { display: none; }
.login-form { display: grid; gap: 18px; }
.login-form .form-message { margin: -3px 0 0; }
.password-field input { padding-right: 59px; }
.password-field button { position: absolute; right: 7px; padding: 5px 7px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 5px; font-size: 11px; }
.password-field button:hover { color: var(--accent-dark); background: var(--accent-pale); }
.login-help { margin-top: 23px; color: var(--ink-faint); font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 228px; }
  .page-wrap, .topbar { padding-right: 24px; padding-left: 24px; }
  .policy-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .simulation-layout { grid-template-columns: minmax(350px, .9fr) minmax(0, 1.1fr); }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 18px 0 54px rgba(12, 21, 19, .22); }
  .main-column { margin-left: 0; }
  .menu-button { display: grid; }
  .sidebar-scrim { display: block; }
  .login-shell { grid-template-columns: minmax(340px, .85fr) minmax(410px, 1.15fr); }
  .login-brand-inner { padding: 40px; }
  .login-message h1 { font-size: 42px; }
  .login-proof { grid-template-columns: 1fr; gap: 0; background: transparent; }
  .login-proof > div { padding: 9px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
  .login-proof span { display: none; }
}

@media (max-width: 820px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 0; }
  .health-strip > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .import-layout, .policy-layout, .simulation-layout { grid-template-columns: 1fr; }
  .policy-aside { position: static; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .55fr); gap: 15px; }
  .formula-card { margin: 0; }
  .simulation-output { min-height: 430px; }
  .alert-card { grid-template-columns: 80px minmax(0, 1fr); }
  .alert-actions { grid-column: 2; }
}

@media (max-width: 720px) {
  :root { --topbar-height: 58px; }
  .topbar { padding: 0 14px; }
  .breadcrumb, .sync-state, #top-refresh-button { display: none; }
  .page-wrap { padding: 24px 14px 48px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 15px; margin-bottom: 20px; }
  .page-heading .button { align-self: flex-start; }
  .heading-actions { width: 100%; }
  .heading-actions > *, .heading-actions .button { flex: 1; }
  .export-menu .button { width: 100%; }
  .popover { right: auto; left: 0; }
  .notice { align-items: flex-start; flex-direction: column; gap: 3px; }
  .health-strip { padding: 13px; }
  .health-strip > div { padding: 0 12px; }
  .panel-heading { align-items: flex-start; flex-direction: column; min-height: auto; padding: 14px; }
  .toolbar { align-items: stretch; flex-direction: column; padding: 12px 14px; }
  .toolbar .search-field { width: 100%; }
  .toolbar select { width: 100%; }
  .table-foot { align-items: flex-start; flex-direction: column; gap: 3px; }
  .catalog-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-2, .simulation-details dl { grid-template-columns: 1fr; }
  .policy-aside { grid-template-columns: 1fr; }
  .comparison-grid { grid-template-columns: 1fr; }
  .detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trace-grid { grid-template-columns: 1fr; }
  .alert-card { grid-template-columns: 1fr; gap: 10px; }
  .alert-actions { grid-column: auto; }
  .alert-meta { display: flex; align-items: center; justify-content: space-between; }
  .login-shell { display: block; }
  .login-brand { display: none; }
  .login-panel { min-height: 100dvh; padding: 28px 20px; }
  .mobile-login-mark { display: grid; width: 42px; height: 42px; place-items: center; margin-bottom: 24px; color: #d7f1eb; background: var(--sidebar); border-radius: 11px; font-size: 15px; font-weight: 750; }
}

@media (max-width: 500px) {
  h1 { font-size: 27px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 108px; padding: 17px; }
  .health-strip { grid-template-columns: 1fr; }
  .health-strip > div { padding: 8px 0; border-top: 1px solid #d0d9d7; border-left: 0; }
  .health-strip > div:first-child { padding-top: 0; border-top: 0; }
  .health-strip > div:last-child { padding-bottom: 0; }
  .catalog-summary, .approval-summary { grid-template-columns: 1fr; }
  .detail-drawer { width: 100vw; }
  .drawer-head, .drawer-body, .drawer-foot { padding-right: 14px; padding-left: 14px; }
  .detail-hero { margin-right: -14px; margin-left: -14px; padding-right: 14px; padding-left: 14px; }
  .drawer-foot .button { flex: 1; }
  .dialog-actions .button { flex: 1; }
  .drop-zone { min-height: 205px; padding: 20px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media print {
  .sidebar, .topbar, .heading-actions, .toolbar, .drawer-scrim, .detail-drawer, .toast-region { display: none !important; }
  .main-column { margin: 0; }
  .page-wrap { width: 100%; padding: 0; }
  .panel, .kpi-grid { break-inside: avoid; box-shadow: none; }
}
