:root {
  --bg: #f8f9fa;
  --surface-low: #f3f4f5;
  --panel: #ffffff;
  --text: #191c1d;
  --muted: #434656;
  --primary: #003ec7;
  --primary-dark: #0033a6;
  --secondary: #006c49;
  --border: rgba(67, 70, 86, 0.16);
  --danger: #ba1a1a;
  --anchor-offset: 84px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--anchor-offset);
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 62, 199, 0.06) 0, transparent 30%),
    var(--bg);
}

#upload-section,
#review-section,
#download-section {
  scroll-margin-top: var(--anchor-offset);
}

.page {
  width: min(1320px, calc(100% - 2rem));
  margin: 1.35rem auto 4rem;
  display: grid;
  gap: 1.1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: rgba(247, 248, 248, 0.85);
  box-shadow: 0 10px 30px -26px rgba(0, 0, 0, 0.55);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 78px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: "Manrope", "Source Sans 3", sans-serif;
  text-decoration: none;
  color: #1c1f22;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 1.34rem;
}

.top-links {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.top-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.top-links a:hover {
  color: var(--primary);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-plain {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.menu-toggle {
  display: none;
}

.topbar-btn {
  border-radius: 999px;
  padding: 11px 18px;
  min-height: auto;
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: none;
}

.top-actions .btn-primary {
  color: #ffffff;
  background: linear-gradient(130deg, var(--primary) 0%, #2a69f6 100%);
}

.top-actions .btn-primary:hover:not(:disabled) {
  background: linear-gradient(130deg, var(--primary-dark) 0%, #1f58d9 100%);
}

.hero {
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 0;
  padding: 0.15rem 0.05rem 0.55rem;
  text-align: center;
}

.hero h1 {
  font-family: "Manrope", "Inter", "Segoe UI", sans-serif;
  margin: 0.35rem 0;
  font-size: clamp(1.7rem, 3.2vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.hero .lead {
  margin: 0 auto;
  color: var(--muted);
  max-width: 680px;
}
.hero-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.btn-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 62, 199, 0.03), 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.panel-head h2 {
  margin: 0;
  font-family: "Manrope", "Inter", "Segoe UI", sans-serif;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  letter-spacing: -0.015em;
}
.panel-head p { margin: 0.3rem 0 0.8rem; color: var(--muted); }

.review-headline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.dropzone {
  border: 2px dashed rgba(0, 62, 199, 0.25);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(50vw, 640px);
  max-width: 100%;
  margin: 0 auto;
  min-height: 140px;
  cursor: pointer;
  padding: 1rem;
  background: var(--surface-low);
}

.dropzone.is-dragover {
  border-color: var(--primary);
  background: #edf2ff;
}

.dropzone.is-filled {
  border-style: solid;
  border-color: #0d7661;
  background: #edf8f3;
}

.dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
}

.pdf-placeholder-icon {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(0, 62, 199, 0.1);
  border: 1px solid rgba(0, 62, 199, 0.18);
  border-radius: 999px;
  padding: 0.22rem 0.72rem;
  margin-bottom: 0.35rem;
}

.dropzone-loaded {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.loaded-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d7661;
  color: #fff;
  font-weight: 900;
  font-size: 1rem;
}

.loaded-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 180px;
}

.loaded-text strong {
  font-size: 0.95rem;
}

.loaded-text span {
  color: var(--muted);
  font-size: 0.85rem;
}

.clear-file-btn {
  border: 1px solid #bfd8cf;
  background: #fff;
  color: #0b5f4f;
  border-radius: 0.55rem;
  padding: 0.45rem 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.clear-file-btn:hover {
  background: #f1fbf7;
}

.upload-meta {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.45rem;
  justify-items: center;
}

#selected-file { color: var(--muted); font-size: 0.9rem; }

.hidden-label {
  display: none;
}

.btn {
  border: 0;
  border-radius: 0.65rem;
  padding: 0.65rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #003ec7 0%, #0052ff 100%);
  color: #fff;
  border-radius: 0.85rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 18px -10px rgba(0, 62, 199, 0.65);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0035ad 0%, #0047e2 100%);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.status {
  margin: 0.85rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
}

.support-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.support-hint a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.support-hint a:hover {
  text-decoration: underline;
}
.status.error {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  background: #f8dddf;
  color: #8d181e;
  font-weight: 700;
}

.status.error a {
  color: #8d181e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.status.error a:hover {
  color: #6f1116;
}

.status.success {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  background: #d2f0e5;
  color: #0d6f4a;
  font-weight: 700;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 0.3rem 0 1.1rem;
}

.kpi {
  border: none;
  border-radius: 0.9rem;
  padding: 0.2rem 0.15rem;
  background: transparent;
}
.kpi-label { margin: 0 0 0.32rem; font-size: 0.78rem; color: #7b808d; text-transform: uppercase; letter-spacing: 0.1em; }
.kpi-value {
  margin: 0;
  font-family: "Manrope", "Inter", "Segoe UI", sans-serif;
  font-size: clamp(1.5rem, 2vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(67, 70, 86, 0.1);
  border-radius: 1.05rem;
  background: #fff;
  box-shadow: 0 2px 8px rgba(25, 28, 29, 0.03);
}

table { width: 100%; border-collapse: collapse; min-width: 980px; table-layout: auto; }
th, td { padding: 1rem 0.85rem; border-bottom: 1px solid rgba(67, 70, 86, 0.07); text-align: left; font-size: 0.94rem; white-space: nowrap; }
th { background: #f6f7f8; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: #7c8190; }
td { color: #2a3140; }

tbody tr:hover td {
  background: #f7f8f9;
}

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

td:first-child {
  font-weight: 500;
  color: #141920;
}

td:nth-child(2) {
  color: #2e3443;
}

.amount-credit {
  color: #0b6b45;
  font-weight: 800;
}

.amount-debit {
  color: #9b1f14;
  font-weight: 800;
}

.amount-empty {
  color: #98a0ae;
}

th:nth-child(2), td:nth-child(2) {
  min-width: 520px;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
}

th:last-child, td:last-child {
  width: 230px;
}

tr.row-changed td {
  background: #fff3d4;
}

tr.row-new td {
  background: #dff7e6;
}

tr.row-deleted td {
  background: #f7d8de;
}

tr.row-deleted td:not(.actions-cell) {
  text-decoration: line-through;
  color: #7a2b39;
}

.actions-cell {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-start;
}

.btn-inline {
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  line-height: 1;
}

.btn-icon {
  font-size: 0.82rem;
  line-height: 1;
}

#add-row-btn {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-dark);
  min-height: 42px;
  padding: 0.5rem 0.9rem;
  font-size: 0.84rem;
  border-radius: 0.68rem;
}

#add-row-btn:hover {
  background: var(--primary-dark);
}

#convert-btn {
  min-height: 50px;
  min-width: 148px;
  padding: 0.8rem 1.25rem;
  font-size: 1rem;
  border-radius: 0.9rem;
  justify-self: center;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.btn-ghost:hover {
  background: #f7f9fd;
}

.cell-input {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
}

.cell-input-date {
  min-width: 150px;
}

.cell-input-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.cell-input-description {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.cell-input-money {
  min-width: 120px;
  text-align: right;
}

.download-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.3rem;
  align-items: start;
}
.download-row p {
  margin: 0.35rem 0;
  color: #585e6d;
}

.download-row strong {
  color: #767d8d;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.73rem;
}

.download-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  align-self: center;
}

#download-ofx-btn,
#download-excel-btn,
#download-report-btn {
  background: linear-gradient(135deg, #003ec7 0%, #0052ff 100%);
  color: #fff;
  border: 0;
  border-radius: 0.95rem;
  min-height: 52px;
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 14px 22px -16px rgba(0, 62, 199, 0.8);
}

#download-ofx-btn:hover:not(:disabled),
#download-excel-btn:hover:not(:disabled),
#download-report-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #0035ad 0%, #0047e2 100%);
}

.hidden { display: none !important; }

body.quota-locked {
  overflow: hidden;
}

.quota-lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  pointer-events: none;
  place-items: center;
  z-index: 140;
  padding: 1rem;
}

.quota-lock-overlay.is-open {
  display: grid;
  pointer-events: auto;
}

.quota-lock-modal {
  width: min(560px, 100%);
  background: #ffffff;
  border-radius: 1.1rem;
  border: 1px solid rgba(67, 70, 86, 0.18);
  box-shadow: 0 24px 46px -24px rgba(17, 24, 39, 0.55);
  padding: 1.1rem;
}

.quota-lock-badge {
  margin: 0 0 0.42rem;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: #fdeaea;
  color: #9b1f14;
  font-weight: 800;
  font-size: 0.8rem;
}

.quota-lock-modal h2 {
  margin: 0;
  font-family: "Manrope", "Inter", "Segoe UI", sans-serif;
  font-size: clamp(1.2rem, 2.3vw, 1.5rem);
}

.quota-lock-message {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.quota-lock-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

@media (max-width: 820px) {
  :root {
    --anchor-offset: 76px;
  }

  .topbar-inner {
    grid-template-columns: auto auto;
    grid-template-areas:
      "brand menu"
      "links links"
      "actions actions";
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brand {
    grid-area: brand;
  }

  .menu-toggle {
    grid-area: menu;
    justify-self: end;
    display: inline-flex;
    border: 0;
    border-radius: 999px;
    background: var(--surface-low);
    color: var(--text);
    font-weight: 700;
    padding: 9px 14px;
  }

  .top-links {
    grid-area: links;
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
  }

  .top-links.is-open {
    display: flex;
  }

  .top-actions {
    grid-area: actions;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  :root {
    --anchor-offset: 76px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions .btn,
  .top-actions .link-plain {
    text-align: center;
    justify-content: center;
  }

  .page {
    width: calc(100% - 1rem);
  }

  .dropzone {
    width: 100%;
  }

  .panel { padding: 0.8rem; }

  .download-row {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }
}
