:root {
  --ink: #18201e;
  --ink-soft: #56605d;
  --paper: #f1f0e8;
  --card: #fbfbf7;
  --line: #d8d9cf;
  --acid: #caff4a;
  --acid-dark: #93c41f;
  --green: #16704e;
  --mint: #dff3e7;
  --amber: #b86c21;
  --amber-bg: #f8ead7;
  --white: #ffffff;
  --danger: #bd3f31;
  --shadow: 0 18px 60px rgba(18, 29, 25, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

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

main { padding: 30px 0 72px; }

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(147, 196, 31, 0.45);
  outline-offset: 2px;
}

.page-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.23;
  z-index: 10;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(24, 32, 30, .025) 3px 4px),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(24, 32, 30, .018) 5px 6px);
}

.shell { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }

.utility-bar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(24, 32, 30, 0.12);
}
.utility-title { font-size: 14px; font-weight: 780; letter-spacing: -.02em; }

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(24, 32, 30, 0.14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.brand-dot, .footer-brand span { color: var(--acid-dark); }
.brand-mark { width: 25px; height: 25px; display: flex; align-items: end; gap: 3px; }
.brand-mark i { display: block; width: 5px; border-radius: 4px; background: var(--ink); transform: skew(-9deg); }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 18px; background: var(--acid-dark); }
.brand-mark i:nth-child(3) { height: 24px; }

.topbar-actions, .period-actions { display: flex; align-items: center; gap: 18px; }
.sync-state { color: var(--ink-soft); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.sync-state i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(22, 112, 78, .10); }

.button {
  min-height: 43px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 750;
  font-size: 14px;
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-ghost { background: transparent; color: var(--ink); border-color: rgba(24,32,30,.28); }
.button-ghost:hover { background: rgba(255,255,255,.65); }
.button-primary { background: var(--acid); color: #172018; box-shadow: 0 8px 24px rgba(147, 196, 31, .20); }
.button-primary:hover { background: #d5ff6c; }
.button-dark { background: var(--ink); color: white; }
.button-dark:hover { background: #2d3835; }
.button.full { width: 100%; }

.hero {
  min-height: 430px;
  padding: 74px 0 70px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
}
.hero-copy { max-width: 820px; }
.eyebrow, .section-kicker {
  margin: 0 0 16px;
  color: var(--green);
  font-size: 11px;
  line-height: 1;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .16em;
}
.hero h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(54px, 7.7vw, 104px);
  line-height: .89;
  letter-spacing: -.07em;
  font-weight: 760;
}
.hero h1 em { font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.065em; }
.hero-note { max-width: 660px; margin: 28px 0 0; color: var(--ink-soft); font-size: 17px; line-height: 1.55; }
.hero-stamp {
  width: 150px;
  height: 150px;
  padding: 28px;
  border: 1px solid rgba(24, 32, 30, .26);
  border-radius: 50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  gap: 6px;
  transform: rotate(7deg);
  flex: 0 0 auto;
  position: relative;
}
.hero-stamp::after { content: ""; position: absolute; inset: 8px; border: 1px dashed rgba(24, 32, 30, .20); border-radius: 50%; }
.hero-stamp span { font-size: 10px; font-weight: 800; text-align: center; }
.hero-stamp small { grid-column: 1 / -1; text-align: center; margin-top: 4px; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: 9px; color: var(--ink-soft); }

.workspace {
  background: rgba(251, 251, 247, .58);
  border: 1px solid rgba(24, 32, 30, .12);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 36px;
}
.period-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.section-kicker { margin-bottom: 11px; color: #77807d; }
.month-control { display: flex; align-items: center; gap: 10px; }
.month-control select {
  appearance: none;
  min-width: 220px;
  border: 0;
  padding: 0 30px 2px 0;
  color: var(--ink);
  background: transparent;
  font-size: 27px;
  font-weight: 730;
  letter-spacing: -.04em;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 8px) 48%, calc(100% - 2px) 48%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--card);
  font-size: 18px;
  line-height: 1;
  transition: background .18s ease, transform .18s ease;
}
.icon-button:hover:not(:disabled) { transform: translateX(-1px); background: white; }
.icon-button:last-child:hover:not(:disabled) { transform: translateX(1px); }
.icon-button:disabled { opacity: .3; cursor: default; }
.updated-at { margin: 0; font-size: 12px; color: #7b8481; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.14fr;
  gap: 12px;
  margin: 36px 0 54px;
}
.summary-card {
  min-height: 166px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  position: relative;
  overflow: hidden;
}
.summary-card::before { content: ""; position: absolute; width: 74px; height: 74px; border-radius: 50%; background: rgba(202,255,74,.18); right: -24px; top: -30px; }
.summary-card.bank-total { background: var(--acid); border-color: #b5e83d; }
.summary-card.bank-total::before { background: rgba(24, 32, 30, .08); }
.summary-card.bank-total .currency-tag, .summary-card.bank-total .summary-caption { color: #4e6426; }
.currency-tag { color: #747d7a; font-size: 10px; font-weight: 850; letter-spacing: .15em; }
.summary-value { margin: 31px 0 6px; font-size: clamp(26px, 3vw, 38px); line-height: 1; font-weight: 760; letter-spacing: -.055em; white-space: nowrap; }
.summary-value.zero { color: #a7aca9; }
.summary-caption { margin: 0; color: #7a8380; font-size: 12px; }
.summary-live-rate { margin: 8px 0 0; color: var(--green); font-size: 10px; font-weight: 750; }
.progress-card { background: var(--ink); color: white; border-color: var(--ink); display: flex; align-items: center; gap: 18px; }
.progress-card::before { background: rgba(202,255,74,.09); width: 110px; height: 110px; }
.progress-ring {
  --progress: 0deg;
  width: 85px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: conic-gradient(var(--acid) var(--progress), rgba(255,255,255,.12) 0);
  position: relative;
}
.progress-ring::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--ink); }
.progress-ring strong { position: relative; z-index: 1; font-size: 18px; letter-spacing: -.04em; }
.progress-copy span { color: var(--acid); font-size: 10px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.progress-copy strong { display: block; margin: 8px 0 5px; font-size: 18px; }
.progress-copy small { color: #aeb7b4; font-size: 12px; line-height: 1.4; }

.ledger-head { display: flex; justify-content: space-between; align-items: end; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.ledger-head h2 { margin: 0; font-size: 27px; letter-spacing: -.045em; }
.ledger-legend { display: flex; gap: 18px; color: #707a76; font-size: 12px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.legend-dot.pending { background: #dc8b35; }
.legend-dot.paid { background: var(--green); }

.expense-list { min-height: 150px; }
.month-group + .month-group { margin-top: 34px; }
.group-title { margin: 28px 0 10px; font-size: 12px; color: #79827f; text-transform: uppercase; letter-spacing: .14em; }
.expense-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(180px, 1fr) 150px 170px 48px;
  align-items: center;
  gap: 18px;
  padding: 20px 2px;
  border-bottom: 1px solid var(--line);
}
.expense-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.service-avatar {
  width: 45px;
  height: 45px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--ink);
  color: var(--acid);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -.02em;
}
.expense-main strong, .expense-amount strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-main small, .expense-period small, .expense-amount small { display: block; margin-top: 5px; color: #78817e; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-main .expense-plan { color: var(--green); font-weight: 750; }
.expense-main .expense-note { margin-top: 3px; color: #8a928f; }
.expense-amount .expense-rate { margin-top: 4px; color: var(--green); font-size: 10px; }
.expense-period span { font-size: 13px; color: #4f5956; }
.expense-amount { text-align: right; }
.invoice-link { color: var(--ink); font-size: 12px; font-weight: 750; text-decoration: none; border-bottom: 1px solid rgba(24,32,30,.35); }
.invoice-link:hover { border-color: var(--green); color: var(--green); }
.status-button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.status-button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-button.pending { color: var(--amber); background: var(--amber-bg); }
.status-button.reimbursed { color: var(--green); background: var(--mint); }
.delete-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: #8a928f; font-size: 20px; }
.delete-button:hover { background: #f8ded9; color: var(--danger); }
.empty-state { padding: 70px 20px; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--green); font-size: 24px; }
.empty-state h3 { margin: 0 0 8px; font-size: 20px; }
.empty-state p { margin: 0; color: #7a8380; font-size: 14px; }
.loading-row { height: 86px; margin-top: 10px; border-radius: 16px; background: linear-gradient(90deg, rgba(24,32,30,.04), rgba(255,255,255,.65), rgba(24,32,30,.04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.footer { min-height: 180px; display: flex; align-items: center; justify-content: space-between; color: #6e7774; }
.footer-brand { color: var(--ink); font-size: 18px; font-weight: 850; letter-spacing: -.04em; }
.footer p { margin: 7px 0 0; font-size: 12px; }
.footer-secure { padding-left: 19px; position: relative; }
.footer-secure::before { content: ""; position: absolute; left: 0; top: 2px; width: 10px; height: 11px; border: 1.5px solid var(--green); border-radius: 3px; }

.modal {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(8,15,13,.30);
}
.modal::backdrop { background: rgba(15, 22, 20, .58); backdrop-filter: blur(5px); }
.modal-card { padding: 38px; }
.modal-card.compact { max-width: 470px; margin: auto; }
.modal-close { position: absolute; right: 19px; top: 16px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #e9e9e2; color: var(--ink); font-size: 25px; font-weight: 300; }
.modal-close:hover { background: #dedfd6; }
.modal h2 { margin: 0; font-size: 30px; letter-spacing: -.05em; }
.modal-note { margin: 12px 0 25px; color: #737d79; font-size: 14px; line-height: 1.5; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.step-badge { margin-right: 38px; padding: 8px 11px; border-radius: 999px; background: var(--mint); color: var(--green); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field.wide, .upload-field.wide { grid-column: 1 / -1; }
.field > span { color: #4d5753; font-size: 12px; font-weight: 750; }
.field > span small { color: #909793; font-weight: 500; }
.field input, .field select {
  width: 100%;
  height: 48px;
  border: 1px solid #d5d7cf;
  border-radius: 13px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
}
.field input::placeholder { color: #a4aaa7; }
.field input:hover, .field select:hover { border-color: #b4b9b4; }
.field.autofilled input, .field.autofilled select {
  border-color: rgba(22, 112, 78, .42);
  background: rgba(223, 243, 231, .42);
}
.amount-field { display: grid; grid-template-columns: 1.25fr .95fr; gap: 9px; }
.upload-field {
  min-height: 79px;
  padding: 14px 15px;
  border: 1.5px dashed #bdc2ba;
  border-radius: 15px;
  display: flex;
  align-items: center;
  gap: 13px;
  background: rgba(255,255,255,.54);
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.upload-field:hover, .upload-field.has-file { border-color: var(--green); background: rgba(223,243,231,.52); }
.upload-field.dragging { border-color: var(--green); border-style: solid; background: var(--mint); box-shadow: 0 0 0 5px rgba(22,112,78,.10); }
.upload-field input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { width: 41px; height: 41px; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: var(--acid); font-size: 21px; flex: 0 0 auto; }
.upload-copy { min-width: 0; flex: 1; }
.upload-copy strong, .upload-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-copy strong { font-size: 13px; }
.upload-copy small { margin-top: 5px; color: #7b8481; font-size: 11px; }
.upload-action { color: var(--green); font-size: 11px; font-weight: 800; }
.form-divider { display: flex; align-items: center; gap: 12px; margin: 2px 0 1px; color: #8a928f; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.form-divider::before, .form-divider::after { content: ""; height: 1px; background: #dedfd8; flex: 1; }
.parse-result {
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff0ea;
  color: #68716e;
  font-size: 12px;
}
.parse-result.success { background: var(--mint); color: var(--green); }
.parse-result.partial { background: var(--amber-bg); color: #8b571e; }
.parse-result.error { background: #f8ded9; color: var(--danger); }
.parse-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto; }
.parse-result.success .parse-spinner, .parse-result.partial .parse-spinner, .parse-result.error .parse-spinner { animation: none; border: 0; display: grid; place-items: center; width: 16px; height: 16px; }
.parse-result.success .parse-spinner::after { content: "✓"; font-weight: 900; }
.parse-result.partial .parse-spinner::after { content: "!"; font-weight: 900; }
.parse-result.error .parse-spinner::after { content: "×"; font-weight: 900; }
@keyframes spin { to { transform: rotate(360deg); } }
.conversion-preview {
  padding: 13px 15px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #edf1e7;
  color: var(--ink);
  font-size: 12px;
}
.conversion-preview strong { font-size: 14px; }
.conversion-preview span { color: #6f7975; }
.settings-hint { margin: 11px 0 0; color: #838b88; font-size: 11px; line-height: 1.45; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { min-height: 18px; margin: 13px 0 0; color: var(--danger); font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 30;
  transform: translate(-50%, 25px);
  padding: 13px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 13px;
  box-shadow: 0 12px 35px rgba(10,19,16,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (max-width: 960px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expense-row { grid-template-columns: minmax(180px, 1.4fr) 1fr 140px; }
  .expense-amount { text-align: left; }
  .expense-status { justify-self: start; }
  .delete-button { position: absolute; right: 0; top: 17px; }
  .expense-row { position: relative; padding-right: 45px; }
}

@media (max-width: 700px) {
  .shell { width: min(100% - 28px, 1180px); }
  main { padding-top: 16px; }
  .utility-bar { height: 68px; }
  .utility-title { font-size: 13px; }
  .utility-bar .button { min-height: 38px; padding: 0 13px; font-size: 12px; }
  .topbar { height: 76px; }
  .sync-state { display: none; }
  .topbar .button { min-height: 38px; padding: 0 13px; font-size: 12px; }
  .hero { min-height: 390px; padding: 56px 0 46px; align-items: flex-start; }
  .hero h1 { font-size: clamp(49px, 15.5vw, 74px); }
  .hero-note { font-size: 15px; margin-top: 23px; }
  .hero-stamp { display: none; }
  .workspace { width: 100%; border-radius: 28px 28px 0 0; padding: 26px 14px 30px; }
  .period-bar { align-items: flex-start; }
  .period-actions { align-items: flex-end; flex-direction: column; gap: 8px; }
  .period-actions .button { min-height: 36px; padding-inline: 12px; font-size: 11px; }
  .updated-at { display: none; }
  .month-control { gap: 6px; }
  .month-control select { min-width: 165px; font-size: 22px; }
  .icon-button { width: 34px; height: 34px; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 28px 0 43px; gap: 7px; }
  .summary-card { min-height: 115px; padding: 14px 11px; border-radius: 16px; }
  .summary-value { margin: 25px 0 5px; font-size: clamp(18px, 5.3vw, 26px); }
  .summary-caption { font-size: 10px; }
  .progress-card { grid-column: 1 / -1; min-height: 120px; padding: 17px; }
  .progress-ring { width: 74px; }
  .ledger-head { align-items: flex-start; }
  .ledger-head h2 { font-size: 23px; }
  .ledger-legend { display: none; }
  .expense-row { grid-template-columns: 1fr auto; gap: 15px 10px; padding: 18px 2px; }
  .expense-main { grid-column: 1 / -1; }
  .expense-period { padding-left: 59px; }
  .expense-amount { text-align: right; }
  .expense-status { grid-column: 1; padding-left: 59px; }
  .expense-actions { grid-column: 2; }
  .delete-button { top: 19px; }
  .footer { min-height: 150px; }
  .footer-secure { display: none; }
  .modal-card { padding: 32px 20px 23px; }
  .modal-heading { margin-bottom: 23px; }
  .step-badge { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .field.wide, .upload-field.wide { grid-column: auto; }
  .amount-field { grid-template-columns: 1.15fr .85fr; }
  .modal-actions .button { flex: 1; }
  .conversion-preview { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
