:root {
  --ink: #151c23;
  --muted: #66717d;
  --line: #dce2e7;
  --soft: #f3f5f6;
  --paper: #ffffff;
  --orange: #f58220;
  --orange-dark: #c85c00;
  --orange-soft: #fff0e3;
  --green: #157f64;
  --green-soft: #e8f6f1;
  --red: #b33b35;
  --red-soft: #fff0ee;
  --blue: #2d5b88;
  --shadow: 0 12px 34px rgba(21, 28, 35, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
}

.signin-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #111820 0%, #27313a 52%, #f3f5f6 52%); }
.signin-card { width: min(560px, 100%); padding: 34px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 28px 70px rgba(0,0,0,.22); }
.signin-card h1 { margin: 24px 0 12px; font-size: clamp(1.8rem, 5vw, 2.65rem); line-height: 1.08; letter-spacing: -.04em; }
.signin-card p { color: var(--muted); line-height: 1.55; }
.signin-card small { display: block; margin-top: 18px; color: var(--muted); line-height: 1.45; }
.signin-brand { margin-bottom: 28px; }
.signin-brand .brand-title { color: var(--ink); }
.signin-brand .brand-sub { color: var(--muted); }
.signin-button { width: 100%; margin-top: 10px; padding: 13px 16px; }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; }

.topbar {
  min-height: 72px;
  background: var(--ink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 6px 20px rgba(0,0,0,.16);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border: 3px solid var(--orange);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--orange);
}
.brand-title { font-weight: 800; letter-spacing: .01em; }
.brand-sub { color: #aeb7bf; font-size: .78rem; margin-top: 2px; }
.private-pill { border: 1px solid #47515b; border-radius: 999px; padding: 8px 12px; color: #d9dfe4; font-size: .78rem; }
.topbar-account { display: flex; align-items: center; gap: 12px; }
.signout-link { color: #d9dfe4; font-size: .76rem; text-decoration: none; }
.signout-link:hover { color: white; text-decoration: underline; }

.page { max-width: 1440px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 42px) 64px; }

.hero {
  display: grid;
  grid-template-columns: 1.5fr .5fr;
  gap: 22px;
  padding: 30px;
  color: white;
  border-radius: 18px;
  background:
    linear-gradient(120deg, rgba(21,28,35,.98), rgba(21,28,35,.83)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(255,255,255,.05) 18px 19px);
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(1.65rem, 3vw, 2.7rem); letter-spacing: -.035em; max-width: 850px; }
.hero p { margin: 0; color: #c9d0d6; max-width: 820px; line-height: 1.55; }
.hero-stat { display: flex; align-items: center; justify-content: flex-end; }
.hero-stat strong { font-size: 2.4rem; color: var(--orange); display: block; }
.hero-stat span { color: #b9c1c8; font-size: .85rem; }

.tabs {
  display: flex;
  gap: 6px;
  margin: 22px 0;
  padding: 5px;
  background: #e7ebee;
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 17px;
  border-radius: 9px;
  font-weight: 700;
  white-space: nowrap;
}
.tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 2px 9px rgba(0,0,0,.07); }

.grid { display: grid; gap: 18px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.metric, .card { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 3px 14px rgba(21,28,35,.035); }
.metric { padding: 20px; }
.metric-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.metric-value { font-size: 1.9rem; font-weight: 850; margin: 6px 0 2px; }
.metric-note { color: var(--muted); font-size: .82rem; }

.card { padding: 22px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.card h2, .card h3 { margin: 0; letter-spacing: -.02em; }
.card h2 { font-size: 1.25rem; }
.card h3 { font-size: 1.02rem; }
.eyebrow { color: var(--orange-dark); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; margin-bottom: 5px; }
.subtle { color: var(--muted); font-size: .86rem; line-height: 1.5; }

.two-col { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); }
.process-list { display: grid; gap: 10px; }
.process-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(130px,.6fr) 110px 120px;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.process-row:hover { border-color: #bbc4cc; background: #fbfcfc; }
.process-name { font-weight: 800; }
.process-meta { color: var(--muted); font-size: .8rem; margin-top: 3px; }

.status, .tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .72rem;
  font-weight: 800;
  width: fit-content;
}
.status.complete { background: var(--green-soft); color: var(--green); }
.status.draft { background: var(--orange-soft); color: var(--orange-dark); }
.status.review { background: #eaf1f9; color: var(--blue); }
.status.approved { background: var(--green-soft); color: var(--green); }
.tag { background: #edf0f2; color: #46515b; }
.tag.orange { background: var(--orange-soft); color: var(--orange-dark); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.green { background: var(--green-soft); color: var(--green); }

.progress { height: 8px; background: #e8ecef; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--orange); border-radius: inherit; }
.progress-label { display: flex; justify-content: space-between; font-size: .77rem; color: var(--muted); margin-bottom: 6px; }

.alert { padding: 13px 14px; border-radius: 10px; font-size: .84rem; line-height: 1.45; margin-bottom: 12px; }
.alert.warn { background: var(--orange-soft); color: #7a3e0c; border-left: 4px solid var(--orange); }
.alert.good { background: var(--green-soft); color: #0f604c; border-left: 4px solid var(--green); }
.alert.bad { background: var(--red-soft); color: #7d2b27; border-left: 4px solid var(--red); }

.button {
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 9px;
  font-weight: 800;
  background: var(--ink);
  color: white;
}
.button:hover { filter: brightness(1.08); }
.button.primary { background: var(--orange); color: #23180e; }
.button.secondary { background: white; color: var(--ink); border-color: var(--line); }
.button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.button.danger { background: white; color: var(--red); border-color: #efc4c0; }
.button.small { padding: 7px 10px; font-size: .78rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.form-layout { grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.form-nav { position: sticky; top: 96px; padding: 10px; }
.form-nav button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}
.form-nav button.active { background: var(--orange-soft); color: var(--orange-dark); }
.form-nav small { display: block; font-size: .68rem; margin-top: 2px; font-weight: 600; opacity: .8; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .79rem; font-weight: 800; }
.required::after { content: " *"; color: var(--red); }
.required-guide { margin-top: 7px; color: var(--muted); font-size: .74rem; }
.required-guide span { color: var(--red); font-weight: 900; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cfd6dc;
  background: white;
  border-radius: 9px;
  padding: 10px 11px;
  color: var(--ink);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.13); }
input:disabled, textarea:disabled, select:disabled { background: #f0f2f3; color: #4f5962; cursor: not-allowed; }
textarea { min-height: 88px; resize: vertical; }

.approval-history { display: grid; gap: 9px; margin-top: 14px; }
.approval-history > div { display: flex; justify-content: space-between; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfc; }
.approval-history span { color: var(--muted); font-size: .78rem; }
.invalid { border-color: var(--red) !important; background: #fffafa; }
.validation-link { width: 100%; text-align: left; }
.field-note { color: var(--muted); font-size: .73rem; }

.repeat-list { display: grid; gap: 12px; }
.repeat-item { border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: #fbfcfc; }
.repeat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.repeat-index { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: white; font-size: .75rem; font-weight: 900; }

.sticky-save {
  position: sticky;
  bottom: 14px;
  margin-top: 18px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 28px rgba(21,28,35,.12);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .82rem; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .055em; font-size: .7rem; }
tr:last-child td { border-bottom: 0; }

.score { font-weight: 900; }
.score.high { color: var(--green); }
.score.mid { color: var(--orange-dark); }
.score.low { color: var(--red); }
.opp-stack { display: flex; gap: 5px; flex-wrap: wrap; }

.review-toolbar { display: grid; grid-template-columns: minmax(240px,1fr) 190px 180px auto; gap: 10px; margin-bottom: 16px; }
.insight-grid { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 18px; }
.insight { border-top: 4px solid var(--orange); }
.insight strong { display: block; font-size: 1.5rem; margin: 4px 0; }
.insight p { margin: 0; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: white; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; }
.hidden { display: none !important; }

.viz-page { display: grid; gap: 18px; }
.viz-intro, .viz-lane-head, .viz-record-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.viz-intro h2, .viz-lane-head h2 { margin-bottom: 5px; }
.viz-intro p { margin: 0; max-width: 820px; }
.viz-boundary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1.15fr) 34px minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
}
.viz-terminal { display: grid; gap: 6px; align-content: center; min-height: 135px; padding: 18px; border-radius: 15px; border: 1px solid var(--line); background: white; box-shadow: 0 3px 14px rgba(21,28,35,.035); }
.viz-terminal.start { border-left: 5px solid var(--orange); }
.viz-terminal.center { background: var(--ink); color: white; border-color: var(--ink); }
.viz-terminal.end { border-right: 5px solid var(--green); }
.viz-terminal span, .viz-step-system span, .viz-step-rule span, .viz-control span, .viz-handoff > span, .viz-text > span, .viz-record-note > span { color: var(--muted); font-size: .68rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.viz-terminal.center span, .viz-terminal.center small { color: #bdc6ce; }
.viz-terminal strong { font-size: .93rem; line-height: 1.45; }
.viz-terminal small { font-size: .75rem; line-height: 1.45; }
.viz-boundary-arrow { display: grid; place-items: center; color: var(--orange-dark); font-size: 1.5rem; font-weight: 900; }
.viz-flow { display: grid; gap: 0; margin-top: 18px; }
.viz-step { border: 1px solid var(--line); border-radius: 13px; padding: 18px; background: #fbfcfc; }
.viz-step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.viz-number { width: 31px; height: 31px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 9px; font-size: .78rem; font-weight: 900; }
.viz-step h3 { font-size: 1.08rem; margin: 0; }
.viz-step-owner { display: inline-flex; width: fit-content; margin: 7px 0 14px; padding: 5px 9px; border-radius: 999px; background: var(--orange-soft); color: var(--orange-dark); font-size: .74rem; font-weight: 800; }
.viz-io { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.viz-io > div { display: grid; gap: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.viz-io span { color: var(--muted); font-size: .68rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.viz-io strong { font-size: .8rem; line-height: 1.4; }
.viz-step-system, .viz-step-rule, .viz-control, .viz-handoff, .viz-text, .viz-record-note { display: grid; gap: 4px; font-size: .8rem; line-height: 1.45; margin-top: 10px; }
.viz-step-system { padding: 10px 11px; background: #edf3f8; border-radius: 9px; }
.viz-step-rule { padding: 10px 11px; border-left: 4px solid var(--orange); background: var(--orange-soft); border-radius: 8px; }
.viz-control { padding: 10px 11px; border-left: 4px solid var(--green); background: var(--green-soft); border-radius: 8px; }
.viz-step-meta, .viz-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.viz-fact { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); background: white; border-radius: 8px; min-width: 0; }
.viz-fact span { color: var(--muted); font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.viz-fact strong { font-size: .77rem; line-height: 1.35; overflow-wrap: anywhere; }
.viz-handoff { padding: 10px 11px; background: var(--ink); color: white; border-radius: 9px; }
.viz-handoff > span, .viz-handoff small { color: #bdc6ce; }
.viz-connector { height: 38px; display: grid; place-items: center; position: relative; }
.viz-connector::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange); }
.viz-connector span { position: relative; z-index: 1; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 999px; color: white; background: var(--orange); font-size: .85rem; }
.viz-support-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.viz-support-grid .card > h2 { margin-bottom: 14px; }
.viz-records { display: grid; gap: 11px; }
.viz-record { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfc; }
.viz-record h3 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 0 0 8px; font-size: .9rem; line-height: 1.4; }
.viz-record .viz-fact { padding: 6px 8px; margin-top: 6px; }
.viz-record-title h3 { flex: 1; }
.viz-record-note { padding: 8px 9px; background: white; border-radius: 8px; border: 1px solid var(--line); }
.viz-text { padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfc; }
.viz-empty { padding: 18px; border: 1px dashed #bdc6ce; border-radius: 10px; color: var(--muted); text-align: center; font-size: .82rem; }
.viz-empty.large { padding: 38px 18px; }
.viz-opportunities .alert:last-child { margin-bottom: 0; }
.viz-summary { overflow: hidden; }
.viz-summary .subtle { margin: 5px 0 0; }
.viz-summary-scroll { margin-top: 18px; overflow-x: auto; padding: 3px 2px 12px; scrollbar-color: var(--orange) #e8ecef; }
.viz-summary-track { display: flex; align-items: stretch; width: max-content; min-width: 100%; }
.viz-summary-part { display: flex; align-items: stretch; }
.viz-summary-step { width: 190px; min-height: 112px; display: grid; align-content: start; gap: 7px; padding: 14px; border: 1px solid #aebbc7; border-top: 4px solid var(--orange); background: #fbfcfc; }
.viz-summary-step span { color: var(--orange-dark); font-size: .68rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.viz-summary-step strong { font-size: .86rem; line-height: 1.35; }
.viz-summary-step small { color: var(--muted); font-size: .72rem; line-height: 1.35; }
.viz-summary-arrow { width: 34px; display: grid; place-items: center; color: var(--green); font-size: 1.35rem; font-weight: 900; }

@media (max-width: 980px) {
  .metrics, .insight-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col, .form-layout { grid-template-columns: 1fr; }
  .form-nav { position: static; display: flex; overflow-x: auto; }
  .form-nav button { min-width: 180px; }
  .process-row { grid-template-columns: 1fr 110px; }
  .process-row > :nth-child(2) { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-stat { justify-content: flex-start; }
  .review-toolbar { grid-template-columns: 1fr 1fr; }
  .viz-boundary { grid-template-columns: 1fr; }
  .viz-boundary-arrow { transform: rotate(90deg); min-height: 26px; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 15px; }
  .private-pill { display: none; }
  .signin-card { padding: 25px 21px; }
  .page { padding: 15px 12px 54px; }
  .hero { padding: 22px 18px; border-radius: 13px; }
  .metrics, .insight-grid, .form-grid { grid-template-columns: 1fr; }
  .card { padding: 17px; border-radius: 12px; }
  .process-row { grid-template-columns: 1fr; }
  .process-row > :nth-child(2) { display: block; }
  .review-toolbar { grid-template-columns: 1fr; }
  .sticky-save { align-items: flex-start; flex-direction: column; }
  .viz-support-grid, .viz-io, .viz-step-meta, .viz-facts { grid-template-columns: 1fr; }
  .viz-intro, .viz-lane-head, .viz-record-title { flex-direction: column; }
  .viz-summary-scroll { overflow-x: visible; }
  .viz-summary-track, .viz-summary-part { width: 100%; flex-direction: column; }
  .viz-summary-step { width: 100%; min-height: 0; }
  .viz-summary-arrow { width: 100%; height: 30px; transform: rotate(90deg); }
}
