:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --ink: #000000;
  --muted: #1f2933;
  --soft: #eef1ed;
  --line: rgba(21, 31, 25, 0.1);
  --line-strong: rgba(21, 31, 25, 0.16);
  --green: #176b47;
  --green-dark: #0f4f34;
  --mint: #e8f5ed;
  --gold: #a9781e;
  --gold-soft: #fff7e6;
  --red: #b43d3d;
  --blue: #275f93;
  --shadow: 0 22px 65px rgba(23, 36, 29, 0.11);
  --shadow-soft: 0 10px 28px rgba(23, 36, 29, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 0%, rgba(23, 107, 71, 0.12), transparent 28rem),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 42%, #f2f4f1 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

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

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  max-width: 100%;
}

.brand-title img {
  display: block;
  width: clamp(72px, 9vw, 118px);
  height: auto;
  object-fit: contain;
  transform: translateY(2px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.15rem, 5vw, 4.15rem);
  line-height: 0.92;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.13rem;
  line-height: 1.2;
}

.tagline {
  max-width: 610px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.year-picker {
  display: grid;
  gap: 7px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex: 0 0 auto;
}

.top-receipt,
.top-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid rgba(23, 107, 71, 0.18);
  border-radius: 16px;
  padding: 0 16px;
  white-space: nowrap;
  font-weight: 800;
  text-decoration: none;
}

.top-receipt {
  background: linear-gradient(180deg, #1f7b52, var(--green-dark));
  color: #fff;
  box-shadow: 0 14px 26px rgba(23, 107, 71, 0.18);
}

.top-receipt:hover {
  background: linear-gradient(180deg, #22855a, #0e4a31);
}

.top-link {
  background: rgba(255, 255, 255, 0.74);
  color: var(--green-dark);
  box-shadow: var(--shadow-soft);
}

.top-link:hover {
  background: #fff;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 720;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 12px 12px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9aa39d;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 107, 71, 0.62);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(23, 107, 71, 0.11);
}

.shell {
  display: grid;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 0 0 42px;
}

.agent-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
  grid-template-areas:
    "total stats"
    "recent recent";
  gap: 16px;
}

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

.report-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  backdrop-filter: blur(18px);
}

.report-controls strong {
  display: block;
  font-size: 1.08rem;
}

.period-controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(88px, 1fr));
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 4px;
}

.segmented button {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.segmented button.active {
  background: var(--green-dark);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.month-picker {
  min-width: 170px;
}

.dashboard-total,
.dash-stat,
.recent-card,
.metric,
.panel,
.privacy-strip {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.dashboard-total {
  grid-area: total;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 190px;
  padding: 24px;
}

.dashboard-total span,
.dash-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.dashboard-total strong {
  display: block;
  margin: 10px 0 6px;
  color: var(--green);
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.95;
}

.dashboard-total small,
.dash-stat small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.donut {
  position: relative;
  flex: 0 0 auto;
  width: clamp(108px, 14vw, 156px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 35%, #0c315b 35% 68%, #aab7c7 68% 84%, #e3e8ee 84% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), var(--shadow-soft);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 25%;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 20, 0.08);
}

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

.dash-stat {
  display: grid;
  min-height: 88px;
  gap: 6px;
  padding: 18px;
}

.dash-stat strong {
  color: var(--ink);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1;
}

.recent-card {
  grid-area: recent;
  padding: 20px;
}

.panel-header.compact {
  margin-bottom: 10px;
}

.panel-header.compact > span {
  color: var(--green-dark);
  font-size: 0.9rem;
  font-weight: 850;
}

.recent-list {
  display: grid;
}

.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid rgba(21, 31, 25, 0.08);
  padding: 11px 0;
}

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

.recent-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item span,
.recent-empty {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.recent-amount {
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.metric {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  color: var(--ink);
  font-size: clamp(1.35rem, 2.8vw, 2.15rem);
  line-height: 1;
}

.privacy-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 17px;
  box-shadow: var(--shadow-soft);
}

.privacy-strip div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  align-items: baseline;
}

.privacy-strip strong {
  color: var(--green-dark);
}

.privacy-strip span {
  color: var(--muted);
}

.privacy-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(23, 107, 71, 0.16);
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark) !important;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(340px, 1.08fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

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

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

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

form {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.hint,
.note,
.ocr-status,
.attached-file {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.attached-file {
  margin: -2px 0 0;
  border: 1px solid rgba(23, 107, 71, 0.12);
  border-radius: 12px;
  background: rgba(232, 245, 237, 0.48);
  padding: 10px 12px;
}

.ocr-status {
  min-height: 20px;
  margin: -4px 0 0;
}

.ocr-status.working {
  color: var(--green-dark);
  font-weight: 760;
}

.ocr-status.warning {
  color: var(--gold);
  font-weight: 760;
}

.ocr-status.success {
  color: var(--green-dark);
  font-weight: 760;
}

.hint {
  min-height: 20px;
  margin: 0;
}

.primary {
  min-height: 48px;
  background: linear-gradient(180deg, #1f7b52, var(--green-dark));
  color: #fff;
  box-shadow: 0 14px 26px rgba(23, 107, 71, 0.2);
}

.primary:hover {
  background: linear-gradient(180deg, #22855a, #0e4a31);
  box-shadow: 0 17px 32px rgba(23, 107, 71, 0.25);
}

.ghost,
.danger {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0 12px;
}

.ghost:hover {
  border-color: rgba(23, 107, 71, 0.34);
  background: #fff;
}

.danger {
  color: var(--red);
}

.danger:hover {
  border-color: rgba(180, 61, 61, 0.28);
  background: #fff8f8;
}

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

.category-list {
  display: grid;
  gap: 8px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(21, 31, 25, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
  padding: 13px 14px;
}

.category-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
  line-height: 1.35;
}

.category-row strong {
  color: var(--green-dark);
}

.category-row > strong {
  font-size: 1rem;
  white-space: nowrap;
}

.note {
  margin-top: 18px;
  border: 1px solid rgba(169, 120, 30, 0.16);
  border-left: 4px solid var(--gold);
  border-radius: 14px;
  background: var(--gold-soft);
  padding: 11px 13px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(21, 31, 25, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
}

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

th,
td {
  border-bottom: 1px solid rgba(21, 31, 25, 0.08);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

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

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  color: #253029;
  font-size: 0.92rem;
}

td small {
  display: block;
  max-width: 360px;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.receipt-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

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

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 0 0 34px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.site-footer div,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.site-footer strong {
  color: var(--ink);
}

.site-footer a {
  color: var(--green-dark);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.legal-topbar {
  padding-bottom: 10px;
}

.legal-shell {
  max-width: 920px;
}

.legal-panel {
  display: grid;
  gap: 12px;
  line-height: 1.65;
}

.legal-panel h2 {
  margin-top: 10px;
}

.legal-panel p {
  margin: 0;
  color: var(--muted);
}

.legal-note {
  border: 1px solid rgba(169, 120, 30, 0.16);
  border-left: 4px solid var(--gold);
  border-radius: 14px;
  background: var(--gold-soft);
  padding: 11px 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(10, 18, 14, 0.42);
  padding: 18px;
}

.modal-card {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.22);
  padding: 22px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.delete {
  color: var(--red);
  background: transparent;
  padding: 4px 6px;
}

.delete:hover {
  background: #fff0f0;
}

@media (max-width: 960px) {
  .agent-dashboard,
  .summary-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .agent-dashboard {
    grid-template-areas:
      "total"
      "stats"
      "recent";
  }
}

@media (max-width: 720px) {
  .topbar,
  .top-actions,
  .report-controls,
  .period-controls,
  .panel-header,
  .field-grid,
  .site-footer,
  .privacy-strip {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    padding-top: 24px;
  }

  h1 {
    font-size: clamp(2.1rem, 13vw, 3.15rem);
  }

  .tagline {
    font-size: 0.94rem;
  }

  .brand-title {
    align-items: center;
    gap: 9px;
  }

  .brand-title img {
    width: 62px;
  }

  .dashboard-total {
    align-items: start;
    min-height: 0;
  }

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

  .segmented {
    width: 100%;
  }

  .month-picker {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .dashboard-total {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .button-row {
    justify-content: start;
  }

  .button-row button {
    flex: 1 1 140px;
  }

  .top-receipt,
  .top-link {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .brand {
    display: grid;
  }

  .brand-title {
    align-items: center;
    gap: 7px;
  }

  .brand-title img {
    width: 52px;
  }

  h1 {
    font-size: clamp(1.95rem, 11vw, 2.65rem);
  }

  .shell,
  .topbar {
    width: min(100% - 26px, 1180px);
  }

  .panel,
  .dashboard-total,
  .dash-stat,
  .recent-card,
  .privacy-strip {
    border-radius: 18px;
  }
}

@media print {
  .topbar,
  form,
  .danger,
  #expenseRows button,
  .button-row {
    display: none;
  }

  body {
    background: #fff;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .panel,
  .dashboard-total,
  .dash-stat,
  .recent-card,
  .privacy-strip {
    box-shadow: none;
    backdrop-filter: none;
  }
}
