/* Expense Portal — polished, professional finance ops UI. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f0f2f7;
  --border: #e3e6ee;
  --border-strong: #c8cddb;
  --text: #171b28;
  --text-muted: #5b657a;
  --text-subtle: #8992a5;
  --accent: #2f57ff;
  --accent-hover: #1f3fdd;
  --accent-soft: #eef1ff;
  --approve: #058a4f;
  --approve-soft: #e2f6ea;
  --reject: #b0263a;
  --reject-soft: #fce7ea;
  --flag: #a45a00;
  --flag-soft: #fff2df;
  --neutral: #4b5670;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(23, 27, 40, 0.05);
  --shadow-md: 0 4px 14px rgba(23, 27, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(23, 27, 40, 0.08);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
p { margin: 0; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand__logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f57ff, #7c4dff);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
}
.brand__accent { color: var(--accent); }
.app-nav { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--text-muted); font-weight: 500; }
.policy-chip {
  background: var(--surface-muted);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.app-main {
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 32px 80px;
}
.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 32px 48px;
  display: flex;
  justify-content: space-between;
  color: var(--text-subtle);
  font-size: 13px;
}
.footer-chip {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-muted);
}

/* Hero */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 24px;
}
.hero__text h1 { margin-bottom: 6px; }
.hero__text p { color: var(--text-muted); max-width: 620px; }
.policy-badge {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 4px;
  text-align: right;
}
.policy-badge__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); }
.policy-badge__value { font-family: var(--font-mono); font-weight: 600; }

/* Stat cards */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 8px;
}
.stat-card__label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card__value { font-size: 28px; font-weight: 700; }
.stat-card--approve { border-top: 3px solid var(--approve); }
.stat-card--reject { border-top: 3px solid var(--reject); }
.stat-card--flag { border-top: 3px solid var(--flag); }
.stat-card--neutral { border-top: 3px solid var(--neutral); }

/* Tabs */
.tabs {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}
.tabs__nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.tabs__button {
  border: 0;
  background: transparent;
  padding: 18px 22px;
  font: inherit;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tabs__button:hover { color: var(--text); }
.tabs__button.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tabs__icon { font-size: 16px; }
.tabs__panel { padding: 32px; display: none; }
.tabs__panel.is-active { display: block; }

/* Form */
.expense-form.is-hidden { display: none; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.form-grid--compact { gap: 12px; }
.field {
  display: grid;
  gap: 6px;
}
.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.field .optional { color: var(--text-subtle); font-weight: 400; margin-left: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 87, 255, 0.15);
}
.field--wide { grid-column: 1 / -1; }
.field--checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}
.field--checkbox > span { grid-column: 2; }
.field--checkbox .hint { grid-column: 1 / -1; }
.hint {
  color: var(--text-subtle);
  font-size: 12px;
}
.review-notice {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

/* Buttons */
.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}
.button {
  border: 0;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.button--primary {
  background: var(--accent);
  color: #fff;
}
.button--primary:hover { background: var(--accent-hover); }
.button--primary:active { transform: translateY(1px); }
.button--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}
.button--ghost:hover { color: var(--text); border-color: var(--text-muted); }
.link {
  background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0;
}
.link:hover { text-decoration: underline; }
.loading-indicator {
  color: var(--text-muted);
  font-size: 13px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
  background: var(--surface-muted);
  margin-bottom: 20px;
}
.drop-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone__icon { font-size: 28px; margin-bottom: 8px; }
.drop-zone .hint { margin-top: 8px; }

/* Result cards */
.result-region { margin-top: 24px; }
.decision-card {
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: grid;
  gap: 12px;
  border: 1px solid transparent;
}
.decision-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.decision-card h2 { font-size: 18px; }
.decision-card--approve {
  background: var(--approve-soft);
  border-color: rgba(5, 138, 79, 0.2);
  color: #0e5a34;
}
.decision-card--reject {
  background: var(--reject-soft);
  border-color: rgba(176, 38, 58, 0.2);
  color: #6b1524;
}
.decision-card--flag {
  background: var(--flag-soft);
  border-color: rgba(164, 90, 0, 0.2);
  color: #6a3d00;
}
.decision-reason { font-size: 15px; }
.follow-up-question {
  background: rgba(255, 255, 255, 0.65);
  border-left: 4px solid var(--flag);
  padding: 12px 16px;
  border-radius: 8px;
  font-style: italic;
  margin: 0;
}
.follow-up-updates {
  border: 1px solid rgba(164, 90, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 0;
}
.follow-up-updates legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.reason-code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(23, 27, 40, 0.08);
  color: currentColor;
  font-weight: 500;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill--approve { background: var(--approve-soft); color: var(--approve); }
.pill--reject { background: var(--reject-soft); color: var(--reject); }
.pill--flag { background: var(--flag-soft); color: var(--flag); }
.pill--neutral { background: var(--surface-muted); color: var(--neutral); }
.pill--large { font-size: 14px; padding: 6px 14px; }
.pill--approve::before { content: "✓"; }
.pill--reject::before { content: "✕"; }
.pill--flag::before { content: "!"; font-weight: 700; }

/* LLM invocation chips */
.llm-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 260px;
}
.llm-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: linear-gradient(135deg, #eef2ff, #f3edff);
  color: #4a3bcf;
  border: 1px solid rgba(74, 59, 207, 0.15);
  cursor: help;
}
.llm-chip::before { content: "◉"; font-size: 9px; color: #6f5cff; }

.success-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--approve-soft);
  border: 1px solid rgba(5, 138, 79, 0.2);
  color: #0e5a34;
  font-weight: 500;
  margin-bottom: 16px;
}
.success-banner__icon { font-size: 22px; line-height: 1; }
.success-banner__title { font-weight: 600; margin-bottom: 4px; }
.success-banner__body { color: #216d43; font-weight: 400; font-size: 14px; }

/* Tables */
.section { margin-bottom: 40px; }
.section__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.section__subtitle { color: var(--text-subtle); font-size: 13px; }
.table-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th {
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(47, 87, 255, 0.04); }
.expense-link { font-family: var(--font-mono); font-weight: 500; }
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.mono.small { font-size: 12px; white-space: pre-wrap; }
.empty { text-align: center; color: var(--text-subtle); padding: 32px; }

/* Detail page */
.back-link { font-size: 13px; color: var(--text-muted); }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin: 12px 0 28px;
}
.detail-title { font-family: var(--font-mono); font-size: 24px; }
.detail-meta { color: var(--text-muted); font-size: 14px; }
.dot { margin: 0 6px; color: var(--text-subtle); }

/* Timeline */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}
.timeline__item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.timeline__marker {
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--neutral);
}
.timeline__item--approve .timeline__marker { background: var(--approve); }
.timeline__item--reject .timeline__marker { background: var(--reject); }
.timeline__item--flag .timeline__marker { background: var(--flag); }
.timeline__body {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.timeline__title { font-weight: 600; display: flex; gap: 10px; align-items: center; }
.timeline__meta { color: var(--text-subtle); font-size: 12px; margin-top: 2px; }
.timeline__reason { margin-top: 8px; }
.timeline__question { margin-top: 4px; color: var(--text-muted); font-style: italic; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.card__header { display: flex; justify-content: space-between; font-weight: 500; margin-bottom: 8px; }

/* Batch progress */
.batch-progress {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  margin-bottom: 20px;
  font-size: 14px;
}

/* Receipt-vs-form match panel */
.match-card {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 14px;
}
.match-header { margin: 0 0 10px; font-weight: 600; }
.match-header--ok { color: #256d3f; }
.match-header--warn { color: #a3411a; }
.match-table { width: 100%; border-collapse: collapse; }
.match-table th, .match-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.match-table th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.match-row--ok td:first-child { color: #256d3f; font-weight: 700; }
.match-row--mismatch { background: #fff5ec; }
.match-row--mismatch td:first-child { color: #a3411a; font-weight: 700; }
.match-row--neutral td:first-child { color: var(--text-muted); }

/* Responsive */
@media (max-width: 900px) {
  .app-main { padding: 0 20px 60px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .tabs__panel { padding: 20px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .detail-header { flex-direction: column; align-items: flex-start; }
}
