:root {
  --white: #fff;
  --canvas: #f8f9fb;
  --text: #12151a;
  --muted: #667085;
  --line: #dfe3e8;
  --line-soft: #edf0f3;
  --blue: #0656d8;
  --blue-soft: #eaf2ff;
  --red: #e32219;
  --amber: #f08b18;
  --green: #22a447;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--white);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--white); }
body { margin: 0; background: var(--white); font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, .button {
  min-height: 40px;
  border: 1px solid #bdc4ce;
  border-radius: 7px;
  padding: 9px 15px;
  color: var(--text);
  background: var(--white);
  font-size: 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
button:hover, .button:hover { border-color: #8c96a4; }
button.primary, .button.primary { color: var(--white); background: var(--blue); border-color: var(--blue); }
button.primary:hover, .button.primary:hover { background: #004bc2; }
button:disabled { cursor: not-allowed; background: #aeb7c5; border-color: #aeb7c5; opacity: .72; }
.full { width: 100%; }
.icon { flex: 0 0 auto; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(28px, 2.25vw, 38px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 14px; font-size: 20px; letter-spacing: -.015em; }
h3 { margin-bottom: 7px; font-size: 16px; }
p { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--white);
  padding: 24px 13px 18px;
}
.brand { display: inline-flex; align-items: baseline; gap: 6px; padding: 0 13px; font-size: 23px; letter-spacing: -.04em; }
.brand strong { color: var(--blue); }
.brand span { font-weight: 500; }
.sidebar nav { display: grid; gap: 7px; margin-top: 45px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 47px; border-radius: 8px; padding: 0 13px; color: #303641; font-weight: 560; }
.nav-link:hover { background: #f4f6f8; }
.nav-link.is-active { color: var(--blue); background: var(--blue-soft); font-weight: 680; }
.sidebar-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 18px 10px 0; }
.sidebar-foot > span:last-child { display: grid; min-width: 0; }
.sidebar-foot strong, .sidebar-foot small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot small { color: var(--muted); }
.avatar { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #e9eff8; color: #24415f; font-size: 12px; }
.workspace { min-width: 0; }
.topbar { height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding: 0 28px; background: rgba(255,255,255,.98); }
.global-search { width: min(420px, 45vw); height: 40px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 7px; padding: 0 12px; color: var(--muted); }
.global-search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 13px; }
.kill-switch { display: flex; align-items: center; gap: 9px; min-height: 40px; border: 1px solid var(--line); border-radius: 7px; padding: 0 7px 0 12px; white-space: nowrap; font-size: 13px; }
.kill-switch button { min-height: 28px; width: 44px; border: 0; border-radius: 999px; padding: 3px; background: #d3d8df; justify-content: flex-start; }
.kill-switch button span { width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.16); }
.status-square { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 2px; background: #a4acb8; }
.status-square.red, .status-square.danger { background: var(--red); }
.status-square.amber { background: var(--amber); }
.status-square.green { background: var(--green); }

.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: calc(100vh - 70px); }
.primary-column { min-width: 0; padding: 32px 28px 48px; }
.decision-rail { border-left: 1px solid var(--line); padding: 31px 20px; background: #fcfcfd; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading p { margin-bottom: 0; }
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(145px, 220px)); margin: 31px 0 32px; }
.summary-strip a { min-height: 86px; border-left: 1px solid var(--line); padding: 3px 18px; display: grid; align-content: start; }
.summary-strip a:first-child { border-left: 2px solid #9bc0ff; }
.summary-strip span { color: #4f5661; font-size: 13px; }
.summary-strip strong { color: var(--blue); margin-top: 2px; font-size: 34px; font-weight: 620; letter-spacing: -.04em; }
.summary-strip .danger-text strong, .danger-text { color: var(--red) !important; }
.case-table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
table { width: 100%; border-collapse: collapse; }
th { height: 48px; padding: 10px 13px; border-bottom: 1px solid var(--line); color: #4d5561; font-size: 12px; font-weight: 590; text-align: left; white-space: nowrap; }
td { min-height: 76px; padding: 15px 13px; border-bottom: 1px solid var(--line); color: #333942; vertical-align: top; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
td + td, th + th { border-left: 1px solid var(--line-soft); }
.case-table { min-width: 930px; table-layout: fixed; }
.case-table th:nth-child(1) { width: 112px; }
.case-table th:nth-child(2) { width: 140px; }
.case-table th:nth-child(3) { width: 135px; }
.case-table th:nth-child(4) { width: 150px; }
.case-table th:nth-child(5) { width: 145px; }
.case-table th:nth-child(6) { width: 165px; }
.case-table th:nth-child(7) { width: 100px; }
.case-table td { line-height: 1.45; overflow-wrap: anywhere; }
.case-table td strong { color: #171b21; }
.case-table td small, .case-link small { display: block; color: var(--muted); margin-top: 4px; }
.case-link strong { color: var(--blue) !important; font-size: 14px; }
.status-cell, .risk-line { display: flex; align-items: flex-start; gap: 9px; }
.status-cell .status-square, .risk-line .status-square { margin-top: 5px; }
.empty-state { padding: 42px !important; color: var(--muted); text-align: center; }
.rail-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.rail-heading h2 { margin: 0; font-size: 21px; }
.rail-heading > span { min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; background: #edf0f3; font-weight: 700; font-size: 12px; }
.approval-card, .bridge-card { margin-bottom: 15px; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--white); }
.approval-card > small { color: var(--muted); text-transform: uppercase; letter-spacing: .025em; font-size: 10px; font-weight: 700; }
.approval-card h3 { margin: 7px 0; color: var(--blue); font-size: 18px; }
.approval-card p { font-size: 12px; }
.approval-card code { font-size: 11px; }
.approval-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.approval-actions form, .approval-actions button { width: 100%; }
.quiet-empty { border: 1px dashed #cfd5dc; border-radius: 8px; padding: 24px 16px; color: var(--muted); text-align: center; }
.bridge-card { margin-top: 28px; }
.bridge-card > div:first-child { display: flex; justify-content: space-between; gap: 12px; }
.connection { color: var(--muted); font-size: 12px; }
.connection::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #9ca4ae; }
.connection.online::before { background: var(--green); }
.bridge-card dl { display: grid; grid-template-columns: 1fr 1fr; margin: 10px -16px -16px; }
.bridge-card dt, .bridge-card dd { margin: 0; padding: 9px 13px; border-top: 1px solid var(--line-soft); font-size: 11px; }
.bridge-card dt { color: var(--muted); }
.bridge-card dd { text-align: right; }

.case-page { padding: 20px 28px 60px; }
.case-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.back-link { display: inline-flex; gap: 6px; align-items: center; color: var(--blue); margin-bottom: 12px; font-size: 12px; }
.title-line { display: flex; align-items: center; gap: 14px; }
.title-line h1 { margin: 0; font-size: 38px; }
.title-line code { border-radius: 5px; padding: 5px 8px; background: #f0f2f5; font-size: 12px; }
.state-control { display: grid; grid-template-columns: auto 250px; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.state-control select { height: 40px; border: 1px solid var(--line); border-radius: 7px; padding: 0 12px; color: var(--green); background: var(--white); font-weight: 650; }
.case-tabs { display: flex; gap: 28px; margin-top: 18px; border-bottom: 1px solid var(--line); }
.case-tabs a { padding: 13px 4px 11px; color: #3f4650; font-size: 13px; }
.case-tabs a.is-active { color: var(--blue); border-bottom: 2px solid var(--blue); font-weight: 650; }
.case-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 14px; margin-top: 13px; }
.identity-strip, .fact-strip { border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.identity-strip { display: grid; grid-template-columns: 1.15fr 1.25fr .55fr .9fr; }
.identity-strip > div { min-height: 86px; padding: 18px; border-left: 1px solid var(--line-soft); }
.identity-strip > div:first-child { border-left: 0; }
.identity-strip span, .fact-strip span { display: block; color: var(--muted); font-size: 11px; }
.identity-strip strong { display: block; margin-top: 6px; font-size: 14px; }
.identity-strip small { display: block; margin-top: 2px; color: #4f5661; }
.fact-strip { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 13px; }
.fact-strip > div { position: relative; min-height: 138px; border-left: 1px solid var(--line-soft); padding: 22px 14px 16px 48px; }
.fact-strip > div:first-child { border-left: 0; }
.fact-strip .icon { position: absolute; left: 17px; top: 22px; color: var(--blue); }
.fact-strip .warn .icon { color: var(--amber); }
.fact-strip .danger .icon { color: var(--red); }
.fact-strip strong { display: block; margin-top: 8px; font-size: 13px; line-height: 1.45; }
.case-lower-grid { display: grid; grid-template-columns: 32% minmax(0, 1fr); gap: 13px; margin-top: 13px; }
.timeline, .supplier-table, .pricing-panel, .audit-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.timeline, .supplier-table { min-height: 315px; padding: 17px; }
.timeline h2, .supplier-table h2, .pricing-panel h2, .audit-panel h2 { font-size: 14px; }
.timeline article { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; padding: 0 0 20px 22px; }
.timeline article::before { content: ""; position: absolute; left: 4px; top: 9px; bottom: -5px; border-left: 1px solid #d0d5dd; }
.timeline article:last-of-type::before { display: none; }
.timeline article > i { position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.timeline article strong { font-size: 12px; }
.timeline article p, .timeline article time { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.supplier-table .case-table-wrap { margin: 0 -17px -17px; border-width: 1px 0 0; border-radius: 0; }
.supplier-table th, .supplier-table td { font-size: 11px; padding: 10px; }
mark { border-radius: 4px; padding: 2px 5px; color: #bd4e00; background: #fff0e3; }
.pricing-panel, .audit-panel { padding: 16px; }
.pricing-panel dl { display: grid; grid-template-columns: 1fr auto; margin: 0; }
.pricing-panel dt, .pricing-panel dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.pricing-panel dd { text-align: right; font-weight: 630; }
.pricing-panel .total { margin-top: 6px; border-bottom: 0; font-weight: 700; }
.pricing-warning { color: #ce5c00; font-size: 11px; }
.audit-panel { margin-top: 13px; }
.audit-panel > div { display: grid; gap: 3px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 11px; }
.audit-panel small { color: var(--muted); }
.mobile-nav, .mobile-primary { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.login-panel { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 12px; padding: 34px; background: var(--white); box-shadow: 0 20px 60px rgba(26, 35, 48, .08); }
.login-panel .brand { padding: 0; margin-bottom: 38px; }
.login-panel h1 { font-size: 29px; }
.login-error { color: var(--red); }
.login-form { display: grid; gap: 9px; margin: 22px 0 12px; }
.login-form label { color: #4d5561; font-size: 12px; font-weight: 650; }
.login-form input { height: 44px; border: 1px solid var(--line); border-radius: 7px; padding: 0 12px; outline: 0; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .sidebar .brand span, .nav-link span, .sidebar-foot > span:last-child { display: none; }
  .sidebar .brand { padding: 0; justify-content: center; }
  .nav-link { justify-content: center; padding: 0; }
  .dashboard-layout { grid-template-columns: minmax(0,1fr) 280px; }
  .fact-strip { grid-template-columns: repeat(3, 1fr); }
  .fact-strip > div:nth-child(4) { border-left: 0; border-top: 1px solid var(--line-soft); }
  .fact-strip > div:nth-child(5) { border-top: 1px solid var(--line-soft); }
}

@media (max-width: 900px) {
  .dashboard-layout { display: block; }
  .decision-rail { border: 0; border-top: 1px solid var(--line); }
  .decision-rail .approval-card, .decision-rail .bridge-card { max-width: 560px; }
  .case-detail-layout { display: block; }
  .case-rail { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 13px; }
  .audit-panel { margin-top: 0; }
}

@media (max-width: 700px) {
  body { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { height: 56px; padding: 0 14px; }
  .global-search { width: 100%; }
  .kill-switch { display: none; }
  .primary-column, .decision-rail { padding: 22px 16px 28px; }
  .page-heading { align-items: center; }
  .page-heading p { display: none; }
  .page-heading .button { min-width: 40px; padding: 9px 11px; font-size: 0; }
  .page-heading .button .icon { margin: 0; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); margin: 23px 0; }
  .summary-strip a { min-width: 0; min-height: 68px; padding: 2px 10px; }
  .summary-strip span { font-size: 10px; }
  .summary-strip strong { font-size: 26px; }
  .case-table-wrap { border-radius: 0; border-width: 1px 0; margin-inline: -16px; }
  .case-table, .case-table tbody, .case-table tr, .case-table td { display: block; min-width: 0; width: 100%; }
  .case-table thead { display: none; }
  .case-table tr { padding: 13px 16px; border-bottom: 1px solid var(--line); }
  .case-table td { display: grid; grid-template-columns: 100px minmax(0,1fr); min-height: 0; border: 0 !important; padding: 6px 0; }
  .case-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; }
  .decision-rail { background: var(--canvas); }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(4,1fr); min-height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.98); }
  .mobile-nav a { display: grid; justify-items: center; align-content: center; gap: 2px; color: #687180; font-size: 10px; }
  .mobile-nav a.is-active { color: var(--blue); }
  .case-page { padding: 17px 16px 152px; }
  .case-titlebar { display: block; }
  .back-link { font-size: 0; }
  .title-line { display: block; }
  .title-line h1 { margin-bottom: 5px; font-size: 30px; }
  .state-control { display: grid; grid-template-columns: 1fr; gap: 5px; margin-top: 18px; }
  .state-control select { width: 100%; }
  .case-tabs { display: none; }
  .case-main { display: flex; flex-direction: column; }
  .fact-strip { order: 1; }
  .identity-strip { order: 2; margin-top: 13px; }
  .case-lower-grid { order: 3; }
  .identity-strip { grid-template-columns: 1fr 1fr; }
  .identity-strip > div { min-height: 76px; border-top: 1px solid var(--line-soft); }
  .identity-strip > div:nth-child(odd) { border-left: 0; }
  .identity-strip > div:nth-child(-n+2) { border-top: 0; }
  .fact-strip { display: block; }
  .fact-strip > div { min-height: 78px; border: 0 !important; border-top: 1px solid var(--line-soft) !important; padding: 15px 40px 14px 48px; }
  .fact-strip > div:first-child { border-top: 0 !important; }
  .fact-strip .icon { top: 17px; }
  .fact-strip strong { margin-top: 3px; }
  .case-lower-grid, .case-rail { display: block; }
  .supplier-table, .pricing-panel, .audit-panel { margin-top: 13px; }
  .case-rail .pricing-panel .primary { display: none; }
  .mobile-primary { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 40; display: block; padding: 10px 16px; border-top: 1px solid var(--line); background: rgba(255,255,255,.98); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
