@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --ink: #1A2421;
  --ink-soft: #46524C;
  --paper: #FBF9F4;
  --paper-deep: #F1ECE0;
  --line: #E2DCCD;
  --amber: #B8722E;
  --amber-soft: rgba(184,114,46,0.12);
  --teal: #2D6E63;
  --teal-soft: rgba(45,110,99,0.12);
  --rust: #B23B3B;
  --rust-soft: rgba(178,59,59,0.10);
  --gray: #6B6458;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); }
body { font-family: 'IBM Plex Sans', sans-serif; color: var(--ink); }
.font-display { font-family: 'Space Grotesk', sans-serif; }
.font-mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
button, input, select { font-family: inherit; font-size: 14px; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 500; }
a { color: inherit; }

/* layout */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
@media (min-width: 768px) { .layout { flex-direction: row; } }
.sidebar { display: flex; flex-direction: row; overflow-x: auto; gap: 4px; padding: 12px; background: var(--ink); }
@media (min-width: 768px) { .sidebar { flex-direction: column; width: 224px; flex-shrink: 0; padding: 20px 12px; overflow-x: visible; } }
.sidebar__brand { display: none; padding: 8px; margin-bottom: 16px; }
@media (min-width: 768px) { .sidebar__brand { display: block; } }
.sidebar__title { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; color: var(--paper); }
.sidebar__sub { font-size: 12px; color: #9CA89F; margin-top: 2px; }
.nav-btn { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; white-space: nowrap; flex-shrink: 0; background: transparent; color: #A9B2A7; border: none; cursor: pointer; font-size: 14px; }
.nav-btn.active { background: rgba(255,255,255,0.10); color: var(--paper); }
.sidebar__footer { display: none; margin-top: auto; padding: 16px 8px 0; }
@media (min-width: 768px) { .sidebar__footer { display: block; } }
.main { flex: 1; padding: 16px; min-width: 0; }
@media (min-width: 768px) { .main { padding: 32px; } }

/* atoms */
.section-title { margin-bottom: 16px; }
.section-title h2 { font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 600; margin: 0; color: var(--ink); }
.section-title p { font-size: 14px; color: var(--gray); margin: 2px 0 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; display: inline-block; }
.chip--outsourcing { background: var(--amber-soft); color: var(--amber); }
.chip--merchandise { background: var(--teal-soft); color: var(--teal); }
.chip--overhead { background: rgba(107,100,88,0.10); color: var(--gray); }
.btn { font-size: 14px; font-weight: 500; padding: 7px 14px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid transparent; }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--danger { background: var(--rust); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.field__label { font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.input, select.input { font-family: 'IBM Plex Mono', monospace; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 14px; background: #fff; color: var(--ink); width: 100%; }
select.input { font-family: 'IBM Plex Sans', sans-serif; }
.empty { font-size: 14px; text-align: center; padding: 28px; border: 1px dashed var(--line); border-radius: 6px; color: var(--gray); }
.toast { position: fixed; bottom: 20px; right: 20px; font-size: 14px; padding: 10px 16px; border-radius: 6px; color: #fff; background: var(--ink); box-shadow: 0 4px 14px rgba(0,0,0,0.18); z-index: 50; }
.toast.error { background: var(--rust); }

/* grids */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } .grid-2 { grid-template-columns: repeat(2, 1fr); } }
.grid-3 { grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* stat cards */
.stat-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.stat-card__top { display: flex; align-items: center; justify-content: space-between; }
.stat-card__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray); }
.stat-card__value { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 600; }
.stat-card__sub { font-size: 12px; color: var(--gray); }

/* ledger hero */
.ledger-hero { overflow: hidden; margin-bottom: 24px; }
.ledger-hero__label { text-align: center; padding: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray); border-bottom: 1px solid var(--line); }
.ledger-hero__grid { display: grid; grid-template-columns: 1fr; position: relative; }
@media (min-width: 768px) { .ledger-hero__grid { grid-template-columns: 1fr 1fr; } }
.ledger-hero__divider { display: none; }
@media (min-width: 768px) { .ledger-hero__divider { display: block; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); } }
.ledger-hero__divider-mobile { height: 1px; width: 100%; background: var(--line); }
@media (min-width: 768px) { .ledger-hero__divider-mobile { display: none; } }
.ledger-half { padding: 20px; }
.ledger-half__title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }

/* generic LR row */
.lr-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.lr-row .label { font-size: 14px; color: var(--gray); }
.lr-row.bold .label { color: var(--ink); font-weight: 600; }
.lr-row .value { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 500; }
.lr-row.bold .value { font-weight: 700; }
.lr-row.large .label { font-size: 15px; }
.lr-row.large .value { font-size: 16px; }
.hr { height: 1px; background: var(--ink); margin: 8px 0; }
.hr-light { height: 1px; background: var(--line); margin: 4px 0; }

/* tables */
.table-wrap { border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
table th, table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table thead th { font-size: 12px; color: var(--gray); padding: 10px 12px; }
table tfoot td { border-top: 2px solid var(--ink); border-bottom: none; font-weight: 600; }
.text-right { text-align: right; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn { font-size: 14px; padding: 6px 12px; border-radius: 6px; background: transparent; border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer; }
.tab-btn.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* account rows (COA) */
.acc-row { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.acc-row__left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.acc-row__code { font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: var(--gray); flex-shrink: 0; }
.acc-row__name { font-size: 14px; }
.acc-row__right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.acc-group-label { font-size: 12px; padding: 8px 12px 4px; color: var(--gray); background: var(--paper-deep); }
.type-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray); }

.banner { border-radius: 6px; padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.banner--error { background: var(--rust-soft); color: var(--rust); }
.banner--ok { background: var(--teal-soft); color: var(--teal); }

.muted { color: var(--gray); }
.small { font-size: 12px; }
.italic { font-style: italic; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* login / setup screens */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--paper); padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 32px; }
.auth-card h1 { font-family: 'Space Grotesk', sans-serif; font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--gray); font-size: 14px; margin: 0 0 24px; }
