:root {
  --ink: #12241C;
  --secondary: #55645C;
  --muted: #8A958D;
  --bg: #F7F7F2;
  --card: #FFFFFF;
  --brand: #0E3B2E;
  --brand-dark: #0A2E24;
  --accent: #C99A3B;
  --border: rgba(18, 36, 28, 0.08);
  --border-strong: rgba(18, 36, 28, 0.16);
  --good-bg: #E9F3EC;
  --good-fg: #0A6B34;
  --warn-bg: #FEF3D9;
  --warn-fg: #8A5A00;
  --bad-bg: #FBEAE8;
  --bad-fg: #B23A3A;
  --neutral-bg: #EDEDE8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--accent); }

.h-font { font-family: 'Space Grotesk', system-ui, sans-serif; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--brand);
  min-height: 100vh;
  box-sizing: border-box;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 28px 8px;
}
.brand-mark .box {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.brand-mark .box span { color: var(--brand); font-weight: 700; font-size: 15px; }
.brand-mark .name { font-weight: 600; font-size: 17px; color: #FAF9F5; }

.navitem {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: rgba(250,249,245,0.72); cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.navitem:hover { color: #FAF9F5; }
.navitem.active { background: rgba(255,255,255,0.12); color: #FAF9F5; font-weight: 600; }
.navitem svg { flex: 0 0 auto; }

.sidebar-spacer { flex: 1; }

.sidebar-profile {
  border-top: 1px solid rgba(255,255,255,0.12); margin-top: 12px; padding-top: 16px;
  display: flex; align-items: center; gap: 10px; padding-left: 8px;
}
.sidebar-profile .avatar {
  width: 30px; height: 30px; border-radius: 999px; background: rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sidebar-profile .avatar span { color: #FAF9F5; font-size: 12px; font-weight: 600; }
.sidebar-profile .who { display: flex; flex-direction: column; }
.sidebar-profile .who .name { color: #FAF9F5; font-size: 13px; font-weight: 500; }
.sidebar-profile .who .role { color: rgba(250,249,245,0.55); font-size: 12px; }

.main { flex: 1; min-height: 100vh; padding: 28px 40px; display: flex; flex-direction: column; gap: 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-good { background: var(--good-bg); color: var(--good-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill-neutral { background: var(--neutral-bg); color: var(--secondary); }

.btn-primary, .btn-ghost {
  border-radius: 8px; padding: 11px 18px; font-family: 'IBM Plex Sans', sans-serif; font-weight: 600;
  font-size: 13px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #FAF9F5; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: #FFFFFF; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--secondary); }
.field input, .field select {
  font-family: 'IBM Plex Sans', sans-serif; font-size: 14px; padding: 11px 13px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #FFFFFF; color: var(--ink);
}

table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 12px 10px 12px; }
td { font-size: 13px; padding: 10px 12px; border-top: 1px solid var(--border); }

.tabbtn {
  border: none; background: none; font-family: 'IBM Plex Sans', sans-serif; font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: 8px; cursor: pointer; color: var(--secondary);
}
.tabbtn.active { background: var(--brand); color: #FAF9F5; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-tile { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.stat-tile .label { font-size: 12px; color: var(--muted); }
.stat-tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

.error-text { color: var(--bad-fg); font-size: 13px; }
.hint-text { color: var(--muted); font-size: 12px; }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg);
}
.login-card { width: 380px; padding: 40px; display: flex; flex-direction: column; gap: 20px; }

/* Shared layout helpers for the app pages */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-title { font-size: 20px; font-weight: 700; margin: 0; }
.section-sub { font-size: 13px; color: var(--secondary); margin: 2px 0 0 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.tabs-row { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.table-wrap { overflow-x: auto; }
.card-pad { padding: 20px 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18,36,28,0.45); display: flex;
  align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal-card { width: 480px; max-width: 100%; max-height: 88vh; overflow: auto; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px; }
.icon-btn:hover { color: var(--ink); }
.breakdown-list { display: flex; flex-direction: column; gap: 0; }
.breakdown-row { display: flex; justify-content: space-between; font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row.total { font-weight: 700; font-size: 14px; padding-top: 12px; }
.net-highlight { font-size: 30px; font-weight: 700; color: var(--brand); font-family: 'Space Grotesk', sans-serif; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner-text { color: var(--muted); font-size: 13px; padding: 20px; }
.link-back { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
