:root {
  --ink: #171512;
  --muted: #6d665e;
  --line: #ded8cf;
  --surface: #f7f4ef;
  --panel: #fffdf9;
  --accent: #d96b2b;
  --accent-dark: #8c3814;
  --good: #167247;
  --bad: #b8422d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface);
  color: var(--ink);
}
button, input, select {
  font: inherit;
}
button {
  border: 0;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost, .ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.hidden { display: none !important; }
.shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.rail {
  border-right: 1px solid var(--line);
  padding: 22px;
  background: #ede6dc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand small, .eyebrow, label, .muted {
  color: var(--muted);
}
.mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0;
}
nav {
  display: grid;
  gap: 8px;
}
.nav {
  text-align: left;
  background: transparent;
  color: var(--ink);
}
.nav.active {
  background: var(--panel);
  box-shadow: inset 3px 0 0 var(--accent);
}
.login {
  grid-column: 1 / -1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(23,21,18,.78), rgba(23,21,18,.18)),
    url("https://images.unsplash.com/photo-1518005020951-eccb494ad742?auto=format&fit=crop&w=1800&q=80") center/cover;
}
.login-panel {
  width: min(420px, 100%);
  background: rgba(255,253,249,.94);
  border: 1px solid rgba(255,255,255,.55);
  padding: 28px;
  border-radius: 8px;
  display: grid;
  gap: 16px;
  animation: rise .35s ease-out both;
}
.login-panel h1 { margin: 4px 0 0; line-height: 1.05; }
.login-panel p { margin: 0; color: var(--muted); }
label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: var(--panel);
  color: var(--ink);
}
.workspace {
  min-width: 0;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1, .section-head h2 {
  margin: 0;
}
.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
}
.panel {
  animation: fade .22s ease-out both;
}
.balance-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.balance-strip div {
  padding: 22px 20px;
  border-right: 1px solid var(--line);
}
.balance-strip div:last-child { border-right: 0; }
.balance-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.balance-strip strong {
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ledger-list {
  border-top: 1px solid var(--line);
}
.tx {
  display: grid;
  grid-template-columns: 150px 1fr 140px 120px;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.tx strong { overflow-wrap: anywhere; }
.tx .amount {
  text-align: right;
  font-weight: 750;
}
.amount.in { color: var(--good); }
.amount.out { color: var(--bad); }
.tx-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.tx-actions button {
  padding: 7px 9px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.entry-form {
  display: grid;
  grid-template-columns: 180px 150px minmax(220px, 1fr) 130px minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.filters select { max-width: 260px; }
.report-controls {
  display: grid;
  grid-template-columns: 150px 150px 150px minmax(220px, 1fr) 190px auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
}
.checkline input { width: auto; }
.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.report-summary div {
  padding: 18px 16px;
  border-right: 1px solid var(--line);
}
.report-summary div:last-child { border-right: 0; }
.report-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.report-summary strong { font-size: clamp(22px, 2.4vw, 34px); }
.import-layout {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}
.import-layout h2 { margin: 0 0 8px; }
.import-layout p { margin: 0; color: var(--muted); max-width: 620px; }
pre {
  margin-top: 18px;
  background: var(--ink);
  color: white;
  padding: 16px;
  border-radius: 6px;
  overflow: auto;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }
  nav { display: flex; }
  .workspace { padding: 18px; }
  .balance-strip { grid-template-columns: 1fr; }
  .balance-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .entry-form, .report-controls { grid-template-columns: 1fr; }
  .report-summary { grid-template-columns: 1fr; }
  .report-summary div { border-right: 0; border-bottom: 1px solid var(--line); }
  .tx { grid-template-columns: 1fr; gap: 6px; }
  .tx .amount { text-align: left; }
  .tx-actions { justify-content: flex-start; }
}
