:root {
  --blue: #1454a3;
  --blue-dark: #082849;
  --red: #d33b2d;
  --green: #167b52;
  --amber: #c98511;
  --purple: #6f42c1;
  --cyan: #148fa2;
  --bg: #edf2f7;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --ink: #15263c;
  --muted: #5d7187;
  --line: #d8e2ec;
  --line-soft: #e9eff5;
  --shadow: 0 10px 28px -24px rgba(10, 43, 80, .45);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Archivo, system-ui, sans-serif;
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  display: flex;
}

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

button {
  border: none;
}

.rail {
  width: 248px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--blue-dark), #0b3d78);
  color: #dbe9f8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #fff;
  font-family: Sora, sans-serif;
  font-weight: 700;
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 13px;
}

.brand span,
.rail-foot {
  display: block;
  color: #8fb5df;
  font-size: 10px;
  margin-top: 4px;
}

.rail-nav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.nav-btn,
.subnav-btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: inherit;
  padding: 0 12px;
  cursor: pointer;
}

.nav-btn svg {
  width: 16px;
  height: 16px;
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(61, 139, 212, .22);
  border-color: rgba(180, 215, 247, .18);
  color: #fff;
}

.rail-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-family: Sora, sans-serif;
  font-weight: 700;
}

.shell {
  min-width: 0;
  flex: 1;
  height: 100vh;
  overflow: auto;
}

.topbar {
  min-height: 70px;
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(237, 242, 247, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.top-title {
  min-width: 0;
  flex: 1;
}

.top-title span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.top-title h1,
.section-head h2 {
  margin: 4px 0 0;
  font-family: Sora, sans-serif;
  font-size: 20px;
  letter-spacing: 0;
}

.project-switch select,
.date-pill {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.project-switch select {
  min-width: 220px;
  padding: 0 32px 0 12px;
  font-weight: 700;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.date-pill svg {
  width: 15px;
  height: 15px;
  color: var(--blue);
}

.screen {
  display: none;
  padding: 20px 24px 48px;
}

.screen.active {
  display: block;
}

.section-head,
.panel-head,
.band-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-head h3,
.band-head h3,
.form-panel h3,
.child-band h4 {
  margin: 0;
  font-family: Sora, sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

.band-head {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.band-head svg {
  width: 17px;
  height: 17px;
  color: var(--blue);
}

.kpi-band,
.panel,
.form-panel,
.inline-form,
.config-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.kpi-band,
.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

.kpi-card {
  min-height: 120px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  padding: 12px;
  background: var(--panel-soft);
}

.kpi-card.good { border-left-color: var(--green); }
.kpi-card.warn { border-left-color: var(--amber); }
.kpi-card.bad { border-left-color: var(--red); }

.kpi-label,
.kpi-sub {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 10px 0 8px;
  font-family: Sora, sans-serif;
  font-size: 27px;
  font-weight: 700;
}

.kpi-value small {
  font-size: 12px;
  color: var(--muted);
}

.mini-track {
  height: 6px;
  margin-top: 12px;
  border-radius: 99px;
  background: #dce7f2;
  overflow: hidden;
}

.mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th {
  text-align: left;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 10px;
  white-space: nowrap;
  vertical-align: top;
}

tbody tr:hover {
  background: #f9fbfd;
}

.matrix-wrap {
  max-height: 480px;
}

.matrix {
  min-width: 1580px;
}

.matrix th {
  vertical-align: bottom;
  border-top: 3px solid var(--stage-color, var(--blue));
}

.matrix .stage-group-head {
  text-align: center;
  background: #eef4fb;
}

.matrix th span {
  display: block;
  color: var(--stage-color, var(--blue));
  font-size: 9px;
  margin-bottom: 4px;
}

.matrix th strong {
  display: block;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.25;
  white-space: normal;
  min-width: 88px;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
}

thead .sticky-col {
  background: var(--panel-soft);
  z-index: 4;
}

.lob-name {
  font-weight: 800;
}

.lob-name span,
.process-drill-row strong,
.activity-drill-table strong {
  vertical-align: middle;
}

.vendor-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.drill-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.drill-title span {
  font-weight: 700;
}

.drill-title em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.compact .drill-title em,
.drill-title.compact em {
  font-size: 9px;
}

.open-ticket {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecf4ff;
  color: var(--blue);
  text-decoration: none;
  font-size: 10px;
  font-weight: 800;
}

.open-ticket:hover {
  background: #dcecff;
}

.outcome-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.outcome-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: var(--panel-soft);
}

.outcome-card > div:first-child span,
.ticket span,
.compact-list span,
td span {
  color: var(--muted);
  font-size: 10px;
}

.outcome-card h4 {
  margin: 4px 0 8px;
  font-family: Sora, sans-serif;
  font-size: 13px;
}

.outcome-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.outcome-metrics div {
  min-height: 52px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line-soft);
}

.outcome-metrics b {
  font-family: Sora, sans-serif;
  font-size: 16px;
}

.outcome-metrics span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.config-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.subnav-btn {
  min-height: 34px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0 11px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.subnav-btn:hover,
.subnav-btn.active {
  border-color: rgba(20, 84, 163, .24);
  background: #edf4ff;
  color: var(--blue);
}

.config-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.config-card {
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 6px;
  color: var(--ink);
  cursor: pointer;
}

.config-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.config-card small {
  color: var(--muted);
  line-height: 1.5;
}

.erp-note-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.erp-note-grid > div {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--panel-soft);
}

.erp-note-grid p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.erp-page-grid {
  display: grid;
  grid-template-columns: minmax(340px, .95fr) minmax(0, 1.35fr);
  gap: 14px;
}

.erp-panel {
  padding: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.form-panel {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 72px;
  padding: 9px 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20, 84, 163, .10);
}

.two-col,
.three-col {
  display: grid;
  gap: 10px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 34px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}

.check input {
  width: 15px;
  height: 15px;
  padding: 0;
}

.toggle-line {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

.toggle-line.compact {
  justify-content: flex-start;
}

.toggle-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.toggle-line span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.action {
  min-height: 36px;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.action svg {
  width: 15px;
  height: 15px;
}

.action.save {
  margin-top: 14px;
  background: var(--green);
}

.erp-table td strong {
  display: block;
  font-size: 11px;
}

.erp-table .wrap,
.wrap {
  white-space: normal;
  line-height: 1.45;
}

.small-table {
  max-height: 540px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.status-chip {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e9f2ff;
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
}

.activity-layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.activity-list {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.ticket {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: inherit;
  text-decoration: none;
  background: #fff;
  margin-bottom: 8px;
}

.ticket:hover,
.ticket.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20, 84, 163, .08);
}

.ticket-top,
.ticket-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.ticket em {
  font-style: normal;
  color: var(--amber);
  font-size: 9px;
  font-weight: 800;
}

.ticket b {
  color: var(--blue);
  font-size: 10px;
}

.activity-detail {
  min-width: 0;
}

.status-select {
  max-width: 260px;
  margin-bottom: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.field-control {
  min-width: 0;
}

.child-band {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compact-list {
  display: grid;
  gap: 8px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--panel-soft);
}

.expandable-row {
  cursor: pointer;
}

.matrix-lob-row.open,
.matrix-lob-row:hover,
.process-drill-row.open,
.process-drill-row:hover {
  background: #f7fbff;
}

.matrix-expander {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  margin-right: 8px;
  background: #fff;
  color: var(--blue);
  vertical-align: middle;
  cursor: pointer;
}

.matrix-expander.sm {
  width: 22px;
  height: 22px;
}

.matrix-expander svg {
  width: 14px;
  height: 14px;
  transition: transform .16s ease;
}

.open > td .matrix-expander svg {
  transform: rotate(90deg);
}

.lob-name small,
.activity-drill-table small {
  display: inline-flex;
  margin-left: 8px;
  color: var(--muted);
  font-size: 9px;
}

.matrix-detail-row,
.activity-drill-row {
  display: none;
}

.matrix-detail-row.open,
.activity-drill-row.open {
  display: table-row;
}

.process-drill-wrap,
.activity-drill-wrap {
  padding: 10px;
  background: #fcfdff;
}

.empty-drill {
  color: var(--muted);
  text-align: center;
  padding: 18px 10px;
}

.workflow-grid {
  display: grid;
  gap: 14px;
}

.workflow-board {
  padding: 14px;
}

.workflow-lane {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.workflow-step-card {
  min-width: 220px;
  max-width: 220px;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.workflow-step-card strong {
  font-size: 12px;
}

.workflow-step-card span,
.workflow-step-card small {
  color: var(--muted);
  font-size: 10px;
}

.workflow-step-card p {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.45;
  white-space: normal;
}

.workflow-step-count {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dbeaff;
  color: var(--blue);
  font-weight: 800;
}

.workflow-step-meta {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.workflow-arrow {
  min-width: 28px;
  display: grid;
  place-items: center;
  color: var(--blue);
}

.workflow-arrow svg {
  width: 16px;
  height: 16px;
}

.studio-rules {
  margin-top: 6px;
}

.studio-empty {
  margin-bottom: 10px;
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 7px;
}

@media (max-width: 1440px) {
  .config-card-grid,
  .kpi-grid,
  .outcome-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .erp-page-grid,
  .activity-layout {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  body {
    display: block;
  }

  .rail {
    width: 100%;
    min-height: auto;
    position: static;
  }

  .shell {
    height: auto;
  }

  .inline-form,
  .three-col,
  .two-col,
  .form-grid.two,
  .field-grid,
  .erp-note-grid {
    grid-template-columns: 1fr;
  }

  .screen {
    padding: 18px;
  }

  .topbar {
    position: static;
    flex-wrap: wrap;
    padding: 14px 18px;
  }
}
