:root {
  --navy-950: #071322;
  --navy-900: #0b1f35;
  --navy-800: #123152;
  --navy-700: #16436d;
  --gold-500: #d7a843;
  --gold-400: #f0c35b;
  --teal-500: #2fb8a6;
  --green-500: #3aa66d;
  --red-500: #d45656;
  --orange-500: #df8a39;
  --ink-900: #172234;
  --ink-700: #405066;
  --ink-500: #6c7890;
  --line: #dbe2ec;
  --line-soft: #edf1f6;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --surface-tint: #eef4f7;
  --shadow: 0 18px 50px rgba(7, 19, 34, 0.14);
  --radius: 8px;
  font-family: "Inter", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface-soft);
  color: var(--ink-900);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  background: var(--navy-950);
  color: #f8fbff;
}

.brand {
  display: grid;
  place-items: center;
  min-height: 96px;
  padding: 12px;
  border: 1px solid rgba(215, 168, 67, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.brand-logo {
  width: 170px;
  height: 76px;
  display: block;
  object-fit: contain;
  object-position: center;
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab,
.ghost-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  min-height: 38px;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab {
  justify-content: flex-start;
  width: 100%;
  padding: 10px 12px;
  color: #d7e1f0;
  background: transparent;
  text-align: left;
}

.tab:hover,
.tab.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.tab.active {
  box-shadow: inset 3px 0 0 var(--gold-500);
}

[data-icon],
.tab-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
}

.sidebar-summary {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-summary span,
.sidebar-summary small {
  display: block;
  color: #b8c5d7;
}

.sidebar-summary strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 26px;
  color: var(--gold-400);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 800;
  color: var(--navy-700);
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

h3 {
  margin-bottom: 14px;
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 46vw);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-900);
}

.ghost-button,
.primary-button,
.icon-button {
  padding: 0 13px;
  white-space: nowrap;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-700);
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-tint);
}

.primary-button {
  background: var(--gold-500);
  color: var(--navy-950);
  font-weight: 800;
}

.primary-button:hover {
  background: var(--gold-400);
}

.icon-button {
  width: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-700);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-strip article,
.table-region,
.detail-panel,
.report-panel,
.settings-section,
.ledger-agent,
.milestone-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(7, 19, 34, 0.03);
}

.metric-strip article {
  padding: 15px;
}

.metric-strip span,
.metric-strip small {
  display: block;
  color: var(--ink-500);
}

.metric-strip strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 27px;
  line-height: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.section-header p {
  margin-bottom: 0;
  color: var(--ink-500);
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink-900);
}

select {
  min-height: 38px;
  padding: 0 32px 0 10px;
}

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

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  font-size: 12px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fafbfd;
}

td {
  font-size: 14px;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f8fbff;
}

.customer-cell strong,
.ledger-title strong,
.commission-deal strong {
  display: block;
  margin-bottom: 3px;
}

.muted {
  color: var(--ink-500);
}

.status-pill,
.small-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.paid,
.small-pill.ready {
  color: #15613f;
  background: #e3f5eb;
}

.status-pill.approved,
.small-pill.connected {
  color: #6b4a00;
  background: #fff1c9;
}

.status-pill.pending,
.small-pill.pending {
  color: #8b4b0f;
  background: #ffe8d0;
}

.status-pill.failed,
.small-pill.issue {
  color: #962d2d;
  background: #ffe1e1;
}

.detail-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.detail-hero {
  padding: 18px;
  color: #ffffff;
  background: linear-gradient(145deg, var(--navy-900), var(--navy-700));
  border-radius: 7px 7px 0 0;
}

.detail-hero h2 {
  margin-bottom: 7px;
  color: #ffffff;
}

.detail-hero p {
  margin-bottom: 0;
  color: #d7e1f0;
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.detail-body {
  display: grid;
  gap: 18px;
  padding: 18px;
}

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

.field,
.editable-field {
  display: grid;
  gap: 5px;
}

.field span,
.editable-field span,
.settings-grid label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-500);
}

.field strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.editable-field input,
.editable-field select,
.settings-grid input,
.modal-form input,
.modal-form select {
  min-height: 38px;
  width: 100%;
  padding: 0 10px;
}

.commission-input {
  width: 94px;
  min-height: 34px;
  padding: 0 8px;
}

.commission-rate {
  width: 72px;
}

.commission-actions {
  display: flex;
  gap: 6px;
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.ledger-agent {
  overflow: hidden;
}

.ledger-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--line-soft);
}

.ledger-list {
  display: grid;
}

.ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.ledger-item:last-child {
  border-bottom: 0;
}

.ledger-item small {
  display: block;
  margin-top: 3px;
  color: var(--ink-500);
}

.milestone-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow: auto;
  padding-bottom: 4px;
}

.milestone-column {
  min-width: 220px;
  overflow: hidden;
}

.milestone-column h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.milestone-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.milestone-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.milestone-card strong {
  font-size: 14px;
}

.milestone-card span {
  color: var(--ink-500);
  font-size: 12px;
}

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

.report-panel {
  padding: 16px;
}

.report-panel.wide {
  grid-column: 1 / -1;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) 88px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track,
.month-track {
  height: 12px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar-fill,
.month-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-500), var(--teal-500));
}

.month-chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  min-height: 190px;
  align-items: end;
}

.month-bar {
  display: grid;
  gap: 8px;
  align-items: end;
  text-align: center;
  font-size: 12px;
  color: var(--ink-500);
}

.month-track {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: end;
  border-radius: var(--radius);
}

.month-fill {
  width: 100%;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.settings-section {
  padding: 18px;
}

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

.settings-grid label {
  display: grid;
  gap: 6px;
}

.payout-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.payout-account span {
  display: block;
  margin-top: 4px;
  color: var(--ink-500);
}

.settings-note {
  margin-top: 14px;
  padding: 13px;
  border-left: 3px solid var(--gold-500);
  background: #fff9eb;
  color: #675229;
  font-size: 13px;
  line-height: 1.45;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(7, 19, 34, 0.42);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(520px, 100vw);
  padding: 22px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transform: translateX(104%);
  transition: transform 180ms ease;
  overflow: auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.calc-list {
  display: grid;
  gap: 10px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.calc-row.total {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy-900);
}

.payment-panel {
  margin-top: 18px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.payment-panel h3 {
  margin-bottom: 10px;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 31;
  width: min(740px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 20px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.modal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

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

.modal-form label {
  display: grid;
  gap: 5px;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 700;
}

.modal-form .full {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  min-width: min(420px, calc(100vw - 28px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--navy-950);
  color: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
  transform: translate(-50%, 140%);
  transition: transform 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .sidebar {
    padding: 14px 10px;
  }

  .brand {
    justify-content: center;
    min-height: 78px;
    padding: 12px;
  }

  .brand-logo {
    width: 62px;
    height: 54px;
  }

  .tab {
    justify-content: center;
    padding: 12px;
    font-size: 0;
  }

  .tab [data-icon] {
    width: 20px;
    height: 20px;
  }

  .sidebar-summary {
    display: none;
  }

  .split-view {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .brand {
    display: none;
  }

  .tabs {
    grid-template-columns: repeat(6, 1fr);
  }

  .tab {
    min-height: 44px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .search {
    width: 100%;
  }

  .ghost-button,
  .primary-button {
    flex: 1;
  }

  .metric-strip,
  .report-grid,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row select {
    flex: 1;
  }

  .milestone-board {
    grid-template-columns: repeat(5, 260px);
  }
}

@media (max-width: 560px) {
  .tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-strip article {
    padding: 13px;
  }

  .field-grid,
  .settings-grid,
  .modal-form {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .month-chart {
    grid-template-columns: repeat(3, 1fr);
  }
}
