:root {
  color-scheme: light;
  --ink: #152033;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f4f6f9;
  --surface: #ffffff;
  --sidebar: #182235;
  --sidebar-2: #222e43;
  --blue: #2168d5;
  --blue-soft: #eaf2ff;
  --green: #16805d;
  --green-soft: #e7f6f0;
  --red: #c53c43;
  --red-soft: #fff0f1;
  --amber: #a46709;
  --amber-soft: #fff6dc;
  --shadow: 0 16px 48px rgba(21, 32, 51, 0.14);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #141d2e;
}
.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  border: 1px solid #34415a;
  border-radius: 8px;
  background: #1d2940;
  color: #f8fafc;
  box-shadow: var(--shadow);
}
.product-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid #4c78bc;
  border-radius: 6px;
  background: #2168d5;
  color: white;
  font-weight: 800;
}
.product-mark.small { width: 36px; height: 36px; margin: 0; font-size: 12px; }
.eyebrow { margin: 0 0 6px; color: #7696c8; font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.login-panel h1 { margin-bottom: 10px; font-size: 25px; }
.muted { color: #aab5c9; line-height: 1.65; }
.login-form { display: grid; gap: 9px; margin-top: 28px; }
.login-form label, .order-dialog label { margin-top: 8px; color: inherit; font-size: 13px; font-weight: 700; }
input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  outline: none;
}
.login-form input { border-color: #43516b; background: #141d2e; color: white; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 104, 213, 0.14); }
.button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}
.button.primary { margin-top: 10px; background: var(--blue); color: white; }
.button.secondary { border-color: var(--line); }
.button.compact { min-height: 32px; padding: 5px 10px; border-color: #b9c6d8; background: #f8fafc; color: #23405f; }
.button.danger { width: 100%; margin-top: 9px; border-color: #ecc6c8; background: var(--red-soft); color: var(--red); }
.button:disabled { cursor: wait; opacity: 0.6; }
.form-error { min-height: 18px; margin: 4px 0 0; color: #ff9b9f; font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--sidebar);
  color: #e7edf7;
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; border-bottom: 1px solid #34415a; }
.brand-row strong, .brand-row span { display: block; }
.brand-row span { margin-top: 3px; color: #9cabbe; font-size: 11px; }
.nav-list { display: grid; gap: 5px; margin-top: 18px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #b8c4d6;
  text-align: left;
}
.nav-item:hover, .nav-item.active { background: var(--sidebar-2); color: white; }
.nav-item.active { box-shadow: inset 3px 0 var(--blue); }
.guardrail-box { margin-top: auto; padding: 13px; border: 1px solid #34415a; border-radius: 6px; background: #141d2e; }
.guardrail-box strong, .guardrail-box small { display: block; margin-left: 18px; }
.guardrail-box small { margin-top: 4px; color: #8fa0b7; }
.status-dot { float: left; width: 9px; height: 9px; margin-top: 3px; border-radius: 50%; background: #28b37e; box-shadow: 0 0 0 3px rgba(40, 179, 126, 0.15); }

.workspace { min-width: 0; }
.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar h1 { margin: 0; font-size: 21px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.safe { background: var(--green-soft); color: var(--green); }
.badge.blocked { background: var(--red-soft); color: var(--red); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); font-size: 18px; }
.view { display: none; padding: 22px 26px 38px; }
.view.active-view { display: block; }
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.metric-strip > div { padding: 17px 20px; border-right: 1px solid var(--line); }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span, .metric-strip strong { display: block; }
.metric-strip span { color: var(--muted); font-size: 12px; }
.metric-strip strong { margin-top: 7px; font-size: 24px; }
.green { color: var(--green); }
.red { color: var(--red); }
.content-section { margin-bottom: 22px; border-top: 2px solid #26364f; background: var(--surface); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 18px; border: 1px solid var(--line); border-top: 0; }
.section-heading h2 { margin-bottom: 4px; font-size: 16px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-top: 0; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e7eaf0; text-align: left; vertical-align: middle; }
th { background: #f7f8fa; color: #5b6575; font-size: 11px; text-transform: uppercase; }
tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: 5px; color: var(--muted); }
.align-right { text-align: right; }
.empty { height: 92px; color: var(--muted); text-align: center; }
.wide-cell { min-width: 260px; max-width: 520px; line-height: 1.55; }
code { padding: 2px 4px; border-radius: 3px; background: #eff2f6; color: #3c4a5f; font-family: Consolas, monospace; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status i { width: 7px; height: 7px; border-radius: 50%; }
.status.online { color: var(--green); }
.status.online i { background: var(--green); }
.status.offline { color: var(--muted); }
.status.offline i { background: #98a2b3; }
.segmented { width: 142px; display: grid; grid-template-columns: 1fr 1fr; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: #f5f7fa; }
.segmented button { min-height: 29px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); }
.segmented button.selected { background: white; color: var(--blue); box-shadow: 0 1px 4px rgba(21, 32, 51, 0.12); font-weight: 800; }
.segmented button.selected.reverse { color: var(--red); }
.choice { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; font-weight: 800; }
.choice.original { background: var(--blue-soft); color: var(--blue); }
.choice.mapped { background: var(--red-soft); color: var(--red); }
.finding-banner { display: flex; justify-content: space-between; gap: 24px; padding: 22px; border: 1px solid #ecc6c8; border-left: 4px solid var(--red); background: var(--red-soft); }
.finding-banner h2 { margin: 9px 0 7px; font-size: 18px; }
.finding-banner p { margin: 0; color: #79474a; }
.finding-count { min-width: 92px; display: grid; place-items: center; align-content: center; border-left: 1px solid #ecc6c8; }
.finding-count strong, .finding-count span { display: block; }
.finding-count strong { font-size: 28px; color: var(--red); }
.finding-count span { color: #79474a; font-size: 11px; }
.finding-banner + .content-section { margin-top: 22px; }
.severity { display: inline-flex; padding: 3px 7px; border-radius: 4px; font-size: 10px; font-weight: 900; }
.severity.critical, .severity.high { background: var(--red-soft); color: var(--red); }
.severity.medium { background: var(--amber-soft); color: var(--amber); }
.severity.info { background: var(--blue-soft); color: var(--blue); }

.order-dialog { width: min(500px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
.order-dialog::backdrop { background: rgba(15, 23, 42, 0.58); }
.order-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.selection-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 9px 0 16px; }
.selection-grid button { min-height: 38px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); }
.selection-grid button.selected { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 900; }
.mapping-preview { display: grid; grid-template-columns: auto 1fr auto auto 1fr; align-items: center; gap: 9px; margin-top: 16px; padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; }
.mapping-preview span { color: var(--muted); }
.mapping-preview strong { font-size: 18px; }
.mapping-preview b { color: var(--red); }
.guardrail-note { margin: 14px 0 4px; padding: 10px 12px; border-left: 3px solid var(--green); background: var(--green-soft); color: #285f4d; font-size: 12px; line-height: 1.55; }
.order-dialog .button.primary { width: 100%; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 380px; padding: 11px 15px; border-radius: 5px; background: #1d2939; color: white; opacity: 0; pointer-events: none; transform: translateY(8px); transition: 160ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding-inline: 9px; }
  .brand-row { justify-content: center; padding-inline: 0; }
  .brand-row > div:last-child, .nav-item:not(.active) { }
  .brand-row strong, .brand-row span, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item span { font-size: 18px; }
  .guardrail-box { padding: 10px; text-align: center; }
  .guardrail-box strong, .guardrail-box small { display: none; }
  .guardrail-box .status-dot { float: none; display: inline-block; margin: 0; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip > div:nth-child(2) { border-right: 0; }
  .metric-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; z-index: 10; width: 100%; height: 60px; flex-direction: row; padding: 6px; border-top: 1px solid #34415a; }
  .brand-row, .guardrail-box { display: none; }
  .nav-list { width: 100%; grid-template-columns: repeat(3, 1fr); margin: 0; }
  .nav-item, .nav-item:not(.active) { display: flex; flex-direction: column; gap: 2px; font-size: 10px; }
  .nav-item span { font-size: 16px; }
  .nav-item.active { box-shadow: inset 0 2px var(--blue); }
  .workspace { padding-bottom: 62px; }
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .top-actions .badge { display: none; }
  .view { padding: 16px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading .button { width: 100%; }
  .finding-banner { flex-direction: column; }
  .finding-count { min-height: 68px; border-top: 1px solid #ecc6c8; border-left: 0; }
  .selection-grid { grid-template-columns: repeat(3, 1fr); }
  .login-panel { padding: 27px 22px; }
}
