:root {
  --bg: #f5f2ed;
  --panel: #ffffff;
  --panel-2: #fbfaf7;
  --text: #1d1c1a;
  --muted: #6d6861;
  --line: #ded8cf;
  --accent: #2f4a3b;
  --accent-2: #d3c2aa;
  --danger: #9d2b2b;
  --shadow: 0 18px 45px rgba(28, 25, 22, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 285px;
  background: #211f1c;
  color: #f8f3ea;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  width: 42px; height: 42px; border: 1px solid #d8c4a7;
  display: grid; place-items: center; font-weight: 700; letter-spacing: 0.08em;
}
.brand-title { font-weight: 700; font-size: 18px; }
.brand-subtitle { color: #bfb5a9; font-size: 12px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  width: 100%; border: 0; border-radius: 10px; padding: 12px 14px;
  background: transparent; color: #f8f3ea; text-align: left; cursor: pointer; font-size: 15px;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.09); }
.sidebar-footer { margin-top: auto; }
.small-label { text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.sidebar .small-label { color: #bfb5a9; }
.pill { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.read-only { background: rgba(211,194,170,0.18); color: #f1dfc6; }

.main { flex: 1; padding: 28px; overflow: auto; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  margin-bottom: 24px;
}
h1 { margin: 0; font-size: 31px; }
h2 { margin: 0 0 10px; font-size: 20px; }
h3 { margin: 24px 0 10px; }
p { color: var(--muted); line-height: 1.5; }
.auth-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
button {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  cursor: pointer; font-weight: 650; background: #fff; color: var(--text);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.secondary { background: var(--panel); }
.ghost { background: transparent; }

.panel { display: none; }
.panel.active { display: block; }
.grid { display: grid; gap: 18px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow);
}
.card.wide { margin-top: 18px; }
.card-label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.metric { font-size: 24px; font-weight: 750; overflow-wrap: anywhere; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
label { display: flex; flex-direction: column; gap: 7px; font-weight: 650; color: #35302a; }
select, input {
  min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  background: #fff; color: var(--text); font-size: 14px;
}
.result-card { min-height: 120px; }
.muted-state { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; }
.money { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.breakdown .line { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.breakdown .total { font-size: 18px; font-weight: 800; color: var(--accent); }
.config-grid { display: grid; gap: 16px; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: block; overflow-wrap: anywhere; color: #3f3324; }
.error { color: var(--danger); }

@media (max-width: 1050px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .cards, .two, .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}
