:root {
  --brand-900: #1b3a2b;
  --brand-800: #204a34;
  --brand-700: #2a5c40;
  --brand-600: #35714f;
  --brand-500: #4c8f68;
  --brand-100: #e7f2ea;
  --coffee-800: #3c2a21;
  --coffee-600: #6f4e37;
  --gold-500: #c9972c;
  --ink-900: #1f2530;
  --ink-600: #5b6472;
  --ink-400: #94a0ae;
  --line: #e6e9ee;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --danger: #c0392b;
  --warning: #b8860b;
  --success: #2f7d4f;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink-900);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14.5px;
}

a { text-decoration: none; }

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

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
  color: #eef5f0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  color: #fff; font-weight: 700; font-size: 1.05rem;
}
.sidebar-brand .bi { color: var(--gold-500); font-size: 1.4rem; }

.sidebar-section {
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .08em;
  color: rgba(238,245,240,.55);
  padding: 1rem 1.2rem .35rem;
}

.sidebar .nav-link {
  color: rgba(238,245,240,.85);
  padding: .5rem 1.2rem;
  font-size: .875rem;
  display: flex; align-items: center; gap: .6rem;
  border-left: 3px solid transparent;
}
.sidebar .nav-link .bi { width: 18px; text-align: center; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--gold-500);
  font-weight: 600;
}
.sidebar .nav-sub .nav-link { padding-left: 2.4rem; font-size: .82rem; }

.main-content { margin-left: 260px; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .7rem 1.4rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1020;
}
.topbar .page-title { font-weight: 700; font-size: 1.05rem; color: var(--ink-900); }
.topbar .page-subtitle { font-size: .78rem; color: var(--ink-600); }

.content { padding: 1.4rem; flex: 1; }

.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-overlay.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1030;
  }
}

/* ---------- Cards & KPIs ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20,30,25,.04); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); font-weight: 600; }

.kpi-card { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); padding: 1rem 1.1rem; display: flex; gap: .85rem; align-items: flex-start; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
}
.kpi-icon.bg-brand { background: var(--brand-100); color: var(--brand-700); }
.kpi-icon.bg-gold { background: #fbf0da; color: var(--gold-500); }
.kpi-icon.bg-danger { background: #fbe6e2; color: var(--danger); }
.kpi-icon.bg-info { background: #e3f1fb; color: #2a72a8; }
.kpi-label { font-size: .74rem; color: var(--ink-600); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.32rem; font-weight: 700; color: var(--ink-900); line-height: 1.25; }
.kpi-hint { font-size: .72rem; color: var(--ink-400); }

.section-title { font-weight: 700; font-size: .95rem; margin: 1.6rem 0 .7rem; color: var(--ink-900); }
.section-title:first-child { margin-top: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table.data-table { width: 100%; margin-bottom: 0; font-size: .86rem; }
table.data-table thead th {
  background: #fafbfa; color: var(--ink-600); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; white-space: nowrap; border-bottom: 1px solid var(--line); padding: .65rem .85rem;
}
table.data-table td { padding: .6rem .85rem; vertical-align: middle; border-bottom: 1px solid var(--line); }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #fafcfa; }

.badge-status-active { background: var(--brand-100); color: var(--brand-700); }
.badge-status-inactive { background: #f1f1f1; color: var(--ink-600); }
.badge-status-pending { background: #fdf1da; color: var(--warning); }
.badge-status-paid { background: var(--brand-100); color: var(--success); }
.badge-status-cancelled { background: #fbe6e2; color: var(--danger); }

/* ---------- Forms ---------- */
.form-label { font-size: .82rem; font-weight: 600; color: var(--ink-900); }
.form-control, .form-select { font-size: .88rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .18rem rgba(76,143,104,.18); }

.btn-brand { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-brand:hover { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.btn-outline-brand { border-color: var(--brand-700); color: var(--brand-700); }
.btn-outline-brand:hover { background: var(--brand-700); color: #fff; }

.filter-bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, var(--brand-700), var(--brand-900) 60%);
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 2.2rem 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.6rem; }
.auth-logo .bi { font-size: 1.8rem; color: var(--gold-500); }
.auth-logo span { font-weight: 700; font-size: 1.1rem; color: var(--brand-900); }

/* ---------- Misc ---------- */
.stock-alert-row td { background: #fdf5e8 !important; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ink-400); }
.empty-state .bi { font-size: 2.2rem; margin-bottom: .5rem; display: block; }
.demo-badge { background: var(--gold-500); color: #402d00; font-size: .68rem; padding: .15rem .5rem; border-radius: 6px; font-weight: 700; }
