:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #86868b;
  --line: rgba(0, 0, 0, 0.06);
  --accent: #0071e3;
  --accent-dark: #005bb5;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --success: #34c759;
  --warn: #ff3b30;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.006em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

button:active { transform: scale(0.97); }

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

.primary-button:hover {
  background: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.25);
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.secondary-button:hover {
  background: rgba(0, 113, 227, 0.16);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.ghost-button:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.shell {
  width: min(1200px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.eyebrow,
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.017em;
  line-height: 1.2;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  margin-top: 4px;
  letter-spacing: -0.006em;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -0.006em;
}

.login {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

input:focus,
textarea:focus {
  border-color: rgba(0, 113, 227, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

input {
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.intake {
  display: grid;
  gap: 12px;
}

textarea {
  min-height: 126px;
  resize: vertical;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.metric span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.021em;
  color: var(--ink);
}

.reports,
.ledger {
  margin-top: 16px;
}

.emailRow {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.generatedReport {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fafafa;
  margin-bottom: 14px;
  overflow: hidden;
}

.reportMeta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.reportMeta span {
  overflow-wrap: anywhere;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.generatedReport pre {
  margin: 0;
  padding: 14px 16px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.55;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--ink);
}

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

.reportBubble {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  min-height: 120px;
  line-height: 1.5;
  font-size: 14px;
  transition: box-shadow 0.2s ease;
}

.reportBubble:hover {
  box-shadow: var(--shadow);
}

.tableWrap {
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
}

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

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

th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: #fafafa;
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: rgba(0, 113, 227, 0.03); }

td.amount {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty {
  color: var(--warn);
  font-weight: 600;
}

@media (max-width: 860px) {
  .topbar,
  .grid,
  .emailRow {
    grid-template-columns: 1fr;
    display: grid;
    align-items: stretch;
  }

  .login { display: grid; }

  .actions,
  .reportMeta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .reportMeta span { text-align: left; }

  .tableWrap { overflow-x: auto; }
}
