:root {
  --ink: #1d2522;
  --muted: #66706c;
  --faint: #8a9490;
  --line: #dfe5e2;
  --line-strong: #cbd4d0;
  --surface: #ffffff;
  --surface-subtle: #f5f7f6;
  --canvas: #eef2f0;
  --sidebar: #202724;
  --sidebar-muted: #a9b4af;
  --green: #167a57;
  --green-dark: #105f43;
  --green-soft: #e2f3eb;
  --amber: #a66108;
  --amber-soft: #fff1d7;
  --red: #b13b3b;
  --red-soft: #fde8e7;
  --blue: #276b8f;
  --blue-soft: #e4f1f7;
  --shadow: 0 10px 30px rgba(25, 40, 34, 0.08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
a { color: inherit; }
svg { width: 18px; height: 18px; flex: 0 0 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: #f7faf8;
  background: var(--sidebar);
  border-right: 1px solid #303936;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 24px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; color: #fff; background: var(--green); border-radius: 6px; }
.brand-mark svg { width: 21px; height: 21px; }
.brand strong { display: block; font-size: 15px; line-height: 1.25; }
.brand small { display: block; margin-top: 3px; color: var(--sidebar-muted); font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px; color: #cbd4d0; text-decoration: none; border-radius: 6px; }
.nav a:hover { color: #fff; background: #2a332f; }
.nav a.active { color: #fff; background: #34433d; box-shadow: inset 3px 0 var(--green); }
.nav svg { color: #95a39d; }
.nav a.active svg { color: #61c89d; }
.scope-note { display: flex; gap: 10px; margin-top: auto; padding: 13px; color: var(--sidebar-muted); background: #29312e; border: 1px solid #36413c; border-radius: 6px; }
.scope-note svg { color: #61c89d; margin-top: 1px; }
.scope-note strong, .scope-note span { display: block; }
.scope-note strong { color: #e9eeec; font-size: 12px; }
.scope-note span { margin-top: 3px; font-size: 11px; line-height: 1.4; }

.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; height: 68px; padding: 0 30px; background: rgba(255,255,255,0.96); border-bottom: 1px solid var(--line); }
.topbar-title span, .topbar-title strong { display: block; }
.topbar-title span { color: var(--faint); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.topbar-title strong { margin-top: 1px; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection > span, .health-state > span { width: 7px; height: 7px; background: #21a36e; border-radius: 50%; box-shadow: 0 0 0 3px #daf1e8; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; text-decoration: none; }
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-subtle); }
.icon-button.small { width: 30px; height: 30px; }
.icon-button.small svg { width: 16px; height: 16px; }
.mobile-menu, .sidebar-backdrop { display: none; }

.main-content { width: min(1240px, 100%); margin: 0 auto; padding: 32px 34px 64px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 1px 0 5px; font-size: 30px; line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--green) !important; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 6px; font-weight: 700; font-size: 13px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:disabled { opacity: 0.65; cursor: wait; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover, .button-quiet:hover { background: var(--surface-subtle); }
.button-quiet { color: var(--muted); background: transparent; border-color: transparent; }
.button-danger-quiet { color: var(--red); background: var(--red-soft); border-color: #f1c8c5; }
.button-full { width: 100%; }
.text-link { display: inline-flex; align-items: center; gap: 5px; color: var(--green-dark); font-weight: 700; font-size: 12px; text-decoration: none; }
.text-link svg { width: 15px; height: 15px; }

.alert { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 20px; padding: 10px 13px; border: 1px solid; border-radius: 6px; }
.alert-success { color: var(--green-dark); background: var(--green-soft); border-color: #b9dfcd; }
.alert-error { color: #8f2727; background: var(--red-soft); border-color: #efc2bf; }
.alert-info { color: #245e7d; background: var(--blue-soft); border-color: #bfdbe8; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 36px; }
.metric-card, .health-item { display: flex; align-items: flex-start; gap: 13px; min-width: 0; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.metric-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 6px; }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.gray { color: #66706c; background: #e9edeb; }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.red { color: var(--red); background: var(--red-soft); }
.metric-card small, .metric-card strong, .metric-card span, .health-item small, .health-item strong, .health-item span { display: block; }
.metric-card small, .health-item small { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.metric-card strong { margin-top: 3px; font-size: 25px; line-height: 1.1; }
.metric-card div > span, .health-item div > span { margin-top: 4px; color: var(--faint); font-size: 11px; }

.section-block { padding: 27px 0 31px; border-top: 1px solid var(--line-strong); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th { height: 40px; padding: 0 14px; color: var(--faint); background: var(--surface-subtle); border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 800; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
td small { display: block; margin-top: 2px; color: var(--faint); font-size: 11px; }
.product-name { color: var(--ink); font-weight: 750; text-decoration: none; }
.product-name:hover { color: var(--green-dark); text-decoration: underline; }
.table-actions, .heading-actions { display: flex; align-items: center; gap: 7px; }
.table-actions { justify-content: flex-end; min-width: 67px; }
.heading-actions { justify-content: flex-end; flex-wrap: wrap; }
.score-cell { display: grid; grid-template-columns: 42px 78px; align-items: center; gap: 8px; }
progress { width: 100%; height: 6px; overflow: hidden; background: #e2e8e5; border: 0; border-radius: 6px; }
progress::-webkit-progress-bar { background: #e2e8e5; }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 2px 8px; border-radius: 5px; font-size: 10px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge-low, .badge-completed, .badge-approved, .badge-active, .badge-digital { color: var(--green-dark); background: var(--green-soft); }
.badge-medium, .badge-pending, .badge-retry, .badge-running { color: #895008; background: var(--amber-soft); }
.badge-high, .badge-dead_letter, .badge-failed, .badge-rejected { color: #962f2f; background: var(--red-soft); }
.badge-unknown, .badge-neutral, .badge-expired, .badge-consumed, .badge-cancelled { color: #59635f; background: #e9edeb; }

.activity-list { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.activity-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; min-height: 62px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; }
.activity-row strong, .activity-row span { display: block; }
.activity-row div span { margin-top: 2px; color: var(--faint); font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8e9994; }
.status-completed { background: #28a873; }
.status-running, .status-pending, .status-retry { background: #d68a20; }
.status-dead_letter, .status-failed { background: #c94b4b; }
.empty-state { display: grid; place-items: center; min-height: 220px; padding: 30px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 6px; }
.empty-state svg { width: 30px; height: 30px; color: var(--faint); }
.empty-state h3, .empty-state h1 { margin: 10px 0 2px; color: var(--ink); }
.empty-state p { margin: 0; }
.empty-state .button { margin-top: 18px; }
.empty-state.compact { min-height: 90px; }
.page-empty { min-height: 420px; }

.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 180px auto auto; gap: 10px; margin-bottom: 28px; }
.search-field, .password-field { position: relative; }
.search-field svg, .password-field svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; color: var(--faint); transform: translateY(-50%); }
input, select { width: 100%; height: 40px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; outline: none; }
input { padding: 0 12px; }
.search-field input, .password-field input { padding-left: 39px; }
select { padding: 0 34px 0 11px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,122,87,0.12); }

.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; color: var(--faint); font-size: 12px; }
.breadcrumb a { color: var(--green-dark); text-decoration: none; }
.breadcrumb svg { width: 13px; height: 13px; }
.product-heading { align-items: center; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.product-summary { display: grid; grid-template-columns: 260px 1fr; gap: 26px; padding: 22px 0 32px; }
.score-panel { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.score-panel small, .score-panel strong, .score-panel span { display: block; }
.score-panel small { color: var(--muted); font-weight: 700; }
.score-panel strong { margin: 5px 0 10px; font-size: 34px; }
.score-panel span { margin-top: 10px; color: var(--faint); font-size: 11px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.detail-list div { padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--faint); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.detail-list dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.evidence-column { min-width: 0; }
.evidence-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.evidence-title h3 { margin: 0; font-size: 13px; }
.evidence-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 5px; }
.evidence-icon.fact { color: var(--green); background: var(--green-soft); }
.evidence-icon.claim { color: var(--amber); background: var(--amber-soft); }
.evidence-icon.inference { color: var(--blue); background: var(--blue-soft); }
.evidence-icon svg { width: 15px; height: 15px; }
.evidence-card { margin-bottom: 9px; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.evidence-card p { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.evidence-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; padding-top: 9px; color: var(--faint); border-top: 1px solid var(--line); font-size: 10px; }
.evidence-card footer a { display: grid; place-items: center; color: var(--green); }
.evidence-card footer svg { width: 14px; height: 14px; }
.empty-evidence { padding: 18px; color: var(--faint); background: var(--surface-subtle); border: 1px dashed var(--line); border-radius: 6px; font-size: 11px; text-align: center; }
.error-text { max-width: 380px; color: var(--red); white-space: normal; overflow-wrap: anywhere; }

.approval-list { border-top: 1px solid var(--line); }
.approval-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.approval-main { display: flex; align-items: flex-start; gap: 12px; }
.approval-main h3 { margin: 0; font-size: 14px; }
.approval-main p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.approval-main small, .decision span { color: var(--faint); font-size: 10px; }
.approval-actions { display: flex; gap: 8px; }
.decision { text-align: right; }
.decision span, .decision strong { display: block; }
.decision strong { margin-top: 2px; font-size: 12px; }

.health-state { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 11px; color: var(--green-dark); background: var(--green-soft); border-radius: 5px; font-size: 12px; font-weight: 800; }
.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 36px; }
.health-item strong { margin-top: 3px; font-size: 16px; }
.boundary-list { border-top: 1px solid var(--line); }
.boundary-list > div { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.boundary-list > div > svg { color: var(--green); }
.boundary-list strong, .boundary-list small { display: block; }
.boundary-list small { margin-top: 2px; color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: var(--canvas); }
.login-panel { width: min(410px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 7px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 15px; }
.login-brand div > span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.login-copy { padding: 25px 0 18px; }
.login-copy h1 { margin: 2px 0 5px; font-size: 28px; }
.login-copy p { margin: 0; color: var(--muted); }
.login-form label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 750; }
.login-form .button { margin-top: 14px; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 20px; color: var(--faint); font-size: 10px; }
.login-foot svg { width: 14px; height: 14px; }

@media (max-width: 1020px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evidence-grid { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; box-shadow: var(--shadow); }
  .menu-open .sidebar { transform: translateX(0); }
  .workspace { min-width: 0; }
  .mobile-menu { display: inline-grid; margin-right: 12px; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; width: 100%; height: 100%; padding: 0; background: rgba(20,27,24,0.45); border: 0; }
  .menu-open .sidebar-backdrop { display: block; }
  .topbar { padding: 0 16px; }
  .main-content { padding: 24px 16px 50px; }
  .connection { display: none; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 26px; }
  .filter-bar { grid-template-columns: 1fr 150px; }
  .product-summary { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-heading { flex-direction: column; }
  .page-heading > form, .page-heading > form .button { width: 100%; }
  .heading-actions, .heading-actions .button { width: 100%; }
  .heading-actions { display: grid; grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .button { width: 100%; }
  .table-wrap { overflow: visible; background: transparent; border: 0; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 11px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
  tbody tr:hover { background: var(--surface); }
  td { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; min-height: 34px; padding: 5px 0; border: 0; text-align: right; }
  td::before { content: attr(data-label); color: var(--faint); font-size: 9px; font-weight: 800; text-align: left; text-transform: uppercase; }
  td:not([data-label]) { display: none; }
  td small { text-align: right; }
  .table-actions { justify-content: flex-end; }
  .score-cell { grid-template-columns: 42px 80px; justify-content: end; }
  .detail-list { grid-template-columns: 1fr; }
  .approval-row { align-items: flex-start; flex-direction: column; }
  .approval-actions, .approval-actions form, .approval-actions .button { width: 100%; }
  .approval-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .decision { text-align: left; }
  .section-heading { align-items: flex-start; }
  .login-page { padding: 14px; }
  .login-panel { padding: 22px; }
}
