:root {
  --bg: #F1E4C4;
  --surface: #FFFCF6;
  --wood: #B98449;
  --wood-dark: #8C5E2E;
  --wood-light: #E3C08B;
  --ink: #3A2E20;
  --ink-soft: #7A6A54;
  --sidebar-bg: #DEC28C;
  --sidebar-active: #C7A468;
  --sidebar-text: #33260F;
  --success: #4C7A52;
  --success-bg: #E7F0EA;
  --warning: #B9792B;
  --warning-bg: #FBF0DF;
  --danger: #A93A2E;
  --danger-bg: #F8E7E4;
  --border: #DCC79C;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
}

/* Neutral typography — one family throughout, weight/spacing does the work */
.font-display { font-family: 'Inter', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
.font-mono { font-family: 'Inter', sans-serif; font-variant-numeric: tabular-nums; }

/* ---------- Layout shell ---------- */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--ink);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 60;
  border-right: 1px solid var(--border);
  transition: transform .25s ease;
}
.sidebar .brand { padding: 1.15rem 1.25rem 1rem; border-bottom: 1px solid rgba(51,38,15,.18); }
.sidebar .brand span { color: var(--sidebar-text) !important; }
.sidebar nav { padding-top: .5rem; }
.sidebar nav a {
  color: var(--sidebar-text);
  opacity: .8;
  padding: .65rem 1.25rem;
  display: flex;
  gap: .7rem;
  align-items: center;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: .92rem;
  font-weight: 600;
  transition: background .15s, color .15s, opacity .15s;
}
.sidebar nav a i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar nav a:hover { background: var(--sidebar-active); opacity: 1; }
.sidebar nav a.active { background: var(--sidebar-active); opacity: 1; border-left-color: var(--wood-dark); font-weight: 700; }
.sidebar .plan-tag { padding: .9rem 1.25rem; border-top: 1px solid rgba(51,38,15,.18); font-size: .78rem; color: var(--sidebar-text); opacity: .75; font-weight: 500; }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(58,46,32,.45); z-index: 55; display: none;
}
.sidebar-backdrop.show { display: block; }

.btn-menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  color: var(--ink);
}

.main { margin-left: 240px; min-height: 100vh; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .95rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 40;
}
.content { padding: 1.75rem; max-width: 1200px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main { margin-left: 0; }
  .btn-menu-toggle { display: inline-flex; }
  .topbar { padding: .85rem 1rem; }
  .content { padding: 1rem; }
}

/* ---------- Cards & ledger motif ---------- */
.card-ledger {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.kpi-card { padding: 1.1rem 1.2rem; }
.kpi-card .kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.kpi-card .kpi-value { font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 700; margin-top: .2rem; }

.ledger-row { display: flex; align-items: baseline; gap: .5rem; padding: .32rem 0; }
.ledger-row .label { white-space: nowrap; color: var(--ink-soft); font-size: .9rem; }
.ledger-row .leader { flex: 1; border-bottom: 1px dashed var(--border); margin-bottom: 5px; min-width: 20px; }
.ledger-row .value { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

table.table-ledger { margin-bottom: 0; }
table.table-ledger thead th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  background: #F8F0DE;
}
table.table-ledger td { vertical-align: middle; border-color: var(--border); }
table.table-ledger .num { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }

/* ---------- Mobile row-cards (table replacement) ---------- */
.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: .75rem;
}
.row-card .row-card-title { font-weight: 700; font-size: .98rem; margin-bottom: .35rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.row-card .row-card-actions { margin-top: .6rem; display: flex; gap: .5rem; }

/* ---------- Badges ---------- */
.badge-status { font-size: .74rem; font-weight: 700; padding: .32rem .6rem; border-radius: 20px; }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-review { background: #EDE3F5; color: #6E4E9C; }
.badge-blocked { background: var(--danger-bg); color: var(--danger); }
.badge-owner { background: #EDE3F5; color: #6E4E9C; }
.badge-staff { background: #DDE9F5; color: #2D6FA8; }

/* ---------- Buttons ---------- */
.btn-walnut { background: var(--wood-dark); border-color: var(--wood-dark); color: #fff; }
.btn-walnut:hover { background: #714A24; border-color: #714A24; color: #fff; }
.btn-outline-walnut { border-color: var(--wood-dark); color: var(--wood-dark); }
.btn-outline-walnut:hover { background: var(--wood-dark); color: #fff; }

/* ---------- Forms ---------- */
.form-label { font-size: .85rem; font-weight: 600; color: var(--ink); }
.form-control:focus, .form-select:focus { border-color: var(--wood); box-shadow: 0 0 0 .2rem rgba(140,94,46,.15); }
.section-eyebrow { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--wood-dark); font-weight: 700; }

/* ---------- Pending invoice banner ---------- */
.alert-ledger {
  background: var(--warning-bg);
  border: 1px solid #E6C58E;
  color: #7A5117;
  border-radius: var(--radius);
}

/* ---------- Block overlay (demo) ---------- */
.block-overlay {
  position: fixed; inset: 0; background: rgba(58,46,32,.72);
  z-index: 999; display: none; align-items: center; justify-content: center;
}
.block-overlay.show { display: flex; }
.block-card { background: #fff; border-radius: var(--radius); max-width: 420px; padding: 2rem; text-align: center; margin: 1rem; }

.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff; background: var(--wood);
}

/* ---------- Toasts (replaces bootstrap modals for feedback) ---------- */
.toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 1080;
  display: flex; flex-direction: column; gap: .5rem; max-width: 320px;
}
.toast-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--wood-dark);
  border-radius: 8px; padding: .75rem 1rem; box-shadow: 0 4px 14px rgba(58,46,32,.12);
  font-size: .9rem; animation: toast-in .2s ease-out;
}
.toast-item.success { border-left-color: var(--success); }
.toast-item.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* jQuery Validate error styling */
label.error { color: var(--danger); font-size: .8rem; display: block; margin-top: .25rem; font-weight: 500; }
input.error, select.error, textarea.error { border-color: var(--danger) !important; }

/* Infinite scroll sentinel */
.scroll-sentinel { height: 40px; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: .85rem; opacity: 0; }
.scroll-sentinel.loading-visible { opacity: 1; }
