:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #62716b;
  --line: #dfe5e0;
  --page: #f3f5f2;
  --surface: #ffffff;
  --soft: #f8f7f2;
  --green: #4fa98f;
  --green-strong: #257c68;
  --red: #be5b55;
  --gold: #c29445;
  --nav: #13211d;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--page);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 22px;
  width: min(1384px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
}

.sidebar {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 20px 70px rgba(19, 33, 29, .08);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--nav);
  color: #fff;
}

.brand-name {
  font-size: 23px;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}

.brand-name span {
  color: var(--green);
}

.brand-subtitle,
.signed-in span,
.company-card span,
.eyebrow,
.sync-text,
.meta {
  color: var(--muted);
  font-size: 12px;
}

.company-card {
  display: grid;
  gap: 8px;
  padding: 14px 12px;
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .02em;
}

.company-card select {
  width: 100%;
  min-width: 0;
  border: 1px solid #ddd4c5;
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fffdf8;
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 47px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 8px 10px;
}

.nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f0f2ef;
  color: var(--nav);
  font-size: 12px;
}

.nav-item.active {
  background: #eaf6f2;
  color: var(--green-strong);
  outline: 1px solid #c9e7df;
}

.nav-item.active .nav-icon {
  background: var(--green);
  color: #fff;
}

.signed-in {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.signed-in strong {
  font-size: 13px;
}

.workspace {
  min-width: 0;
  display: grid;
}

.view {
  display: none;
  min-width: 0;
}

.active-view {
  display: grid;
  gap: 18px;
  align-content: start;
}

.hero-panel,
.forecast-panel,
.chat-panel,
.snapshot-panel,
.reporting-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 20px 70px rgba(19, 33, 29, .08);
}

.hero-panel {
  min-height: 136px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 7px 13px;
  border-radius: 999px;
  background: #f4ebdc;
  color: #784d18;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: .08em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 33px;
}

h2 {
  font-size: 19px;
}

.hero-panel p,
.panel-heading p {
  margin: 10px 0 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 300px;
}

.primary-action {
  min-height: 42px;
  border: 1px solid #bfe0d8;
  border-radius: 16px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  padding: 0 22px;
}

.primary-action:disabled {
  opacity: .62;
  cursor: wait;
}

.forecast-panel {
  padding: 22px;
  min-width: 0;
}

.snapshot-panel {
  padding: 22px;
  min-width: 0;
}

.reporting-panel {
  padding: 22px;
  min-width: 0;
}

.reporting-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.reporting-detail {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
}

.reporting-detail span,
.reporting-file span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.reporting-detail strong {
  line-height: 1.35;
}

.reporting-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
  cursor: pointer;
}

.reporting-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

.reporting-option span {
  display: grid;
  gap: 4px;
}

.reporting-option small {
  color: var(--muted);
  line-height: 1.45;
}

.reporting-file {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, .7fr);
  gap: 20px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
}

.reporting-file > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.reporting-file small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.reporting-link {
  color: var(--green-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.reporting-link:hover {
  text-decoration: underline;
}

.reporting-last-run {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.snapshot-form-grid {
  display: grid;
  grid-template-columns: 1.35fr .8fr .7fr 1.35fr;
  gap: 12px;
  margin-top: 18px;
}

.form-field,
.toggle-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.form-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.form-field input,
.form-field select {
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.form-field small,
.toggle-field small,
.company-check small {
  color: var(--muted);
}

.toggle-field,
.company-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.toggle-field input,
.company-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--green-strong);
}

.toggle-field span,
.company-check span {
  display: grid;
  gap: 3px;
}

.snapshot-recipients {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.recipient-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.recipient-entry .secondary-action {
  min-height: 44px;
  border-radius: 12px;
}

.recipient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 11px;
  border: 1px solid #c9e7df;
  border-radius: 999px;
  background: #edf7f3;
  color: var(--green-strong);
  font-size: 13px;
  font-weight: 800;
}

.recipient-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d3ebe4;
  color: var(--green-strong);
  font-size: 17px;
  line-height: 1;
}

.recipient-empty {
  color: var(--muted);
  font-size: 13px;
}

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

.snapshot-notice {
  margin-top: 16px;
  padding: 11px 13px;
  border: 1px solid #bfe0d8;
  border-radius: 12px;
  background: #edf7f3;
  color: var(--green-strong);
  font-weight: 700;
}

.snapshot-notice.warning,
.snapshot-notice.working {
  border-color: #ead3a6;
  background: #fff7e8;
  color: #815b19;
}

.snapshot-notice.error {
  border-color: #e6b8b4;
  background: #fff0ef;
  color: #963e38;
}

.snapshot-history {
  display: grid;
}

.snapshot-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--line);
}

.snapshot-run:last-child {
  border-bottom: 0;
}

.snapshot-run > div:first-child {
  display: grid;
  gap: 5px;
}

.snapshot-run > div:first-child span {
  color: var(--muted);
  font-size: 13px;
}

.snapshot-run-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.run-status {
  padding: 6px 9px;
  border-radius: 999px;
  background: #edf5f2;
  color: var(--green-strong);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.run-status.completed_with_warnings {
  background: #fff3df;
  color: #815b19;
}

.run-status.failed {
  background: #fff0ef;
  color: #963e38;
}

.report-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #edf5f2;
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.secondary-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 900;
  padding: 0 14px;
  white-space: nowrap;
}

.action-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.secondary-action[aria-pressed="true"] {
  background: #edf5f2;
  border-color: #c9e7df;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.metric {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.forecast-matrix-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cashflow-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.cashflow-table th,
.cashflow-table td {
  height: 44px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.cashflow-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f8f5;
  color: var(--muted);
  text-align: right;
  font-size: 11px;
  text-transform: uppercase;
}

.cashflow-table .row-label {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background: #fff;
  text-align: left;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 1px 0 0 var(--line);
}

.cashflow-table thead .row-label {
  z-index: 3;
  background: #f7f8f5;
  color: var(--muted);
}

.amount-cell {
  min-width: 116px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.section-row td,
.section-row .row-label {
  background: #edf5f2;
  color: var(--green-strong);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.section-row.input-section td,
.section-row.input-section .row-label {
  background: #edf5f2;
  color: var(--green-strong);
}

.section-row.output-section td,
.section-row.output-section .row-label {
  background: #faeeed;
  color: var(--red);
}

.cash-in-row .row-label,
.cash-in-row .amount-cell {
  color: var(--green-strong);
}

.cash-out-row .row-label,
.cash-out-row .amount-cell,
.cash-out-row .negative {
  color: var(--red);
}

.total-row td,
.total-row .row-label {
  background: #fbfaf6;
  font-weight: 900;
}

.net-movement-row .amount-cell.positive {
  color: var(--green-strong);
}

.net-movement-row .amount-cell.negative {
  color: var(--red);
}

.closing-row .amount-cell.positive {
  color: var(--green-strong);
}

.closing-row .amount-cell.negative {
  color: var(--red);
}

.detail-row td,
.detail-row .row-label {
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.detail-row .row-label {
  padding-left: 34px;
  font-weight: 600;
}

.expand-button {
  width: 22px;
  height: 22px;
  margin-right: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  line-height: 1;
}

.negative {
  color: inherit;
}

.cash-in-row .row-label,
.cash-in-row .amount-cell {
  color: var(--green-strong);
}

.cash-out-row .row-label,
.cash-out-row .amount-cell,
.cash-out-row .negative {
  color: var(--red);
}

.empty-state {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.chat-panel {
  min-height: calc(100vh - 210px);
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.messages {
  padding: 22px;
  overflow: auto;
}

.message {
  display: flex;
  margin: 0 0 12px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(760px, 92%);
  padding: 13px 15px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant .bubble {
  background: #fbfcfa;
  border: 1px solid var(--line);
}

.user .bubble {
  background: var(--nav);
  color: #fff;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
}

.composer textarea {
  min-height: 44px;
  max-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--ink);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--green-strong);
  font-size: 22px;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.result-table th,
.result-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.result-table th {
  background: #f7f8f5;
  color: var(--muted);
  font-weight: 800;
}

.result-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.result-table .strong {
  font-weight: 800;
  color: var(--ink);
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment-card {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-strong);
  text-decoration: none;
  font-weight: 800;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 760px);
    padding: 12px 0;
  }

  .sidebar {
    min-height: auto;
  }

  .hero-panel,
  .panel-heading {
    display: grid;
  }

  .hero-actions,
  .metric-strip {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .snapshot-form-grid,
  .recipient-entry,
  .reporting-details,
  .reporting-file {
    grid-template-columns: 1fr;
  }

  .reporting-last-run {
    padding: 16px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .snapshot-run {
    align-items: start;
    display: grid;
  }
}
