:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f2ef;
  --text: #171a18;
  --muted: #68716b;
  --line: #dfe3df;
  --blue: #1768ac;
  --green: #167252;
  --amber: #a76614;
  --red: #b42318;
  --shadow: 0 20px 60px rgba(30, 38, 34, 0.08);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 54px);
  background: rgba(247, 247, 245, 0.9);
  border-bottom: 1px solid rgba(223, 227, 223, 0.75);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: #171a18;
  border-radius: 8px;
  font-weight: 760;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.role-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.role-tabs a {
  min-width: 88px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.role-tabs a.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(23, 26, 24, 0.08);
}

main {
  padding: clamp(22px, 4vw, 54px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.two-column {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: clamp(24px, 5vw, 64px);
  align-items: start;
}

.two-column.active {
  display: grid;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading p {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 760;
}

.section-heading h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
  font-weight: 760;
}

.section-heading span {
  display: block;
  max-width: 640px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.section-heading.compact h1 {
  font-size: clamp(28px, 3vw, 42px);
}

.submission-panel,
.chart-panel,
.cashflow-panel,
.approval-panel,
.settings-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.submission-panel {
  padding: clamp(18px, 3vw, 32px);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.stepper li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fafafa;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.stepper li.active {
  color: var(--green);
  border-color: rgba(22, 114, 82, 0.3);
  background: rgba(22, 114, 82, 0.08);
}

.submission-form {
  display: grid;
  gap: 16px;
}

.upload-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 170px;
  padding: 22px;
  border: 1.5px dashed #bdc8c0;
  border-radius: 8px;
  background: #fbfcfb;
  text-align: center;
  cursor: pointer;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: var(--blue);
  background: rgba(23, 104, 172, 0.08);
  border-radius: 8px;
}

.upload-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.upload-zone strong {
  font-size: 16px;
}

.upload-zone small {
  max-width: 460px;
  color: var(--muted);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #333936;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 104, 172, 0.12);
}

.form-actions,
.filter-row,
.workspace-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.button.primary {
  color: #fff;
  background: var(--text);
}

.button.secondary {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
}

.button.success {
  color: #fff;
  background: var(--green);
}

.button.warning {
  color: #fff;
  background: var(--amber);
}

.button.danger {
  color: #fff;
  background: var(--red);
}

.phone-preview {
  position: sticky;
  top: 96px;
}

.phone-frame {
  max-width: 340px;
  min-height: 640px;
  margin-inline: auto;
  padding: 18px;
  background: #111412;
  border-radius: 34px;
  box-shadow: 0 28px 70px rgba(17, 20, 18, 0.24);
}

.phone-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px 14px;
  color: #fff;
}

.phone-header span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.phone-header strong {
  font-size: 24px;
}

.status-stack {
  display: grid;
  gap: 10px;
}

.status-item,
.review-card,
.approval-item,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-item {
  padding: 14px;
}

.status-item strong,
.review-card strong,
.approval-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.status-item span,
.review-card span,
.approval-item span,
.metric span,
.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.badge.submitted,
.badge.manager_reviewed {
  color: var(--blue);
  background: rgba(23, 104, 172, 0.1);
}

.badge.owner_approved {
  color: var(--green);
  background: rgba(22, 114, 82, 0.1);
}

.badge.needs_fix,
.badge.rejected {
  color: var(--red);
  background: rgba(180, 35, 24, 0.1);
}

.review-grid,
.approval-list,
.metric-grid {
  display: grid;
  gap: 14px;
}

.review-grid {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.review-card,
.approval-item,
.metric {
  padding: 16px;
}

.review-card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.review-card dt {
  color: var(--muted);
  font-size: 11px;
}

.review-card dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 720;
}

.review-actions,
.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-header {
  margin-bottom: 20px;
}

.inline-filter {
  width: min(260px, 100%);
}

.filter-row label {
  width: 170px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 34px);
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.owner-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.chart-panel,
.cashflow-panel,
.approval-panel {
  padding: 18px;
}

.approval-panel {
  margin-top: 18px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title h2,
.settings-grid h2 {
  margin: 0;
  font-size: 17px;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 720;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #e8ece8;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  background: var(--green);
  border-radius: inherit;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.approval-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

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

.settings-grid article {
  padding: 20px;
}

.settings-grid ul,
.guardrail-list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: #171a18;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .two-column.active,
  .owner-layout,
  .settings-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .phone-preview {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    position: static;
    display: grid;
  }

  .brand {
    min-width: 0;
  }

  .role-tabs {
    overflow-x: auto;
    justify-content: start;
  }

  .role-tabs a {
    min-width: max-content;
  }

  main {
    padding: 18px;
  }

  .form-grid,
  .metric-grid,
  .approval-item {
    grid-template-columns: 1fr;
  }

  .form-actions {
    display: grid;
  }

  .filter-row label,
  .inline-filter {
    width: 100%;
  }

  .section-heading h1 {
    font-size: 34px;
  }

  .phone-frame {
    min-height: auto;
    border-radius: 24px;
  }
}
