:root {
  --ink: #14201a;
  --ink-soft: #3d4a43;
  --muted: #6b756f;
  --line: #d2dbd5;
  --paper: #eef2ef;
  --panel: #f7faf8;
  --accent: #0f5c4c;
  --accent-soft: #d5ebe4;
  --danger: #8b2e2e;
  --ok: #1f6b45;
  --warn: #8a5a2b;
  --shadow: 0 14px 36px rgba(20, 32, 26, 0.08);
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Libre Baskerville", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(15, 92, 76, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(138, 90, 43, 0.07), transparent 50%),
    linear-gradient(165deg, #e8eeea 0%, var(--paper) 50%, #e6efe9 100%);
  background-attachment: fixed;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.brand-link {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-sep {
  color: var(--muted);
}

.quiet-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}

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

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

.card {
  background: rgba(247, 250, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.2rem;
}

.setup {
  margin-bottom: 1rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.setup-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.setup-grid input,
.accounts-table input,
.accounts-table select {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  width: 100%;
}

.setup-grid input:focus,
.accounts-table input:focus,
.accounts-table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.setup-actions,
.accounts-actions,
.stmt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover {
  border-color: #b7c7bc;
  color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f4faf8;
}

.btn-primary:hover {
  background: #0c4a3d;
  color: #fff;
}

.btn-danger {
  color: var(--danger);
  border-color: #e2c4c4;
  background: #fff8f8;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.card-head h2 {
  margin: 0 0 0.3rem;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.table-wrap {
  overflow-x: auto;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.accounts-table th,
.accounts-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.3rem;
  text-align: left;
  vertical-align: middle;
}

.accounts-table th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.accounts-table .num,
.accounts-table th.num,
.stmt-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.accounts-table tfoot td {
  font-weight: 700;
  border-bottom: 0;
  padding-top: 0.65rem;
}

.balance-status {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.balance-status.ok {
  color: var(--ok);
}

.balance-status.bad {
  color: var(--danger);
}

.empty-state h2 {
  margin: 0 0 0.4rem;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.empty-state p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stmt-card h2 {
  margin: 0 0 0.15rem;
  font-family: var(--serif);
  font-size: 1.15rem;
}

.stmt-meta {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.stmt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stmt-table td {
  padding: 0.28rem 0.2rem;
  border-bottom: 1px solid #e4ebe6;
  vertical-align: top;
}

.stmt-table tr.section td {
  padding-top: 0.7rem;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: transparent;
}

.stmt-table tr.total td {
  font-weight: 700;
  border-top: 2px solid var(--ink);
  border-bottom: 3px double var(--ink);
  padding-top: 0.45rem;
}

.stmt-table tr.subtotal td {
  font-weight: 600;
  border-top: 1px solid var(--line);
}

.stmt-table .indent {
  padding-left: 1rem;
}

.alert {
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.alert.warn {
  background: #f8efe4;
  border: 1px solid #e5d0b4;
  color: #6a4520;
}

.alert.ok {
  background: var(--accent-soft);
  border: 1px solid #b9d9cd;
  color: #184a37;
}

.alert.bad {
  background: #f8eaea;
  border: 1px solid #e2c4c4;
  color: var(--danger);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.kpi span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.kpi strong {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
}

@media (max-width: 960px) {
  .workspace,
  .setup-grid,
  .kpi-row {
    grid-template-columns: 1fr;
  }
}
