/* ============================================================
   Design tokens
   A school-ledger palette: deep slate-navy for structure, a brass/amber
   accent standing in for the institution's seal, and a legible workhorse
   sans for dense tabular data. Deliberately not the generic
   cream+terracotta or SaaS rounded-card look.
   ============================================================ */
:root {
  --ink:        #16233F;   /* primary text / sidebar base */
  --ink-2:      #29385C;   /* sidebar hover */
  --paper:      #F6F5F1;   /* app background — warm paper, not stark white */
  --card:       #FFFFFF;
  --line:       #E3E0D6;
  --brass:      #B8863C;   /* accent — institutional brass, not terracotta */
  --brass-deep: #8F6526;
  --ok:         #2F6D48;
  --warn:       #B8863C;
  --danger:     #A23B3B;
  --muted:      #6B7280;
  --radius:     6px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  margin: 0;
}

/* ---- Topbar ---- */
.topbar {
  background: var(--ink);
  color: #fff;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-brand { font-weight: 600; letter-spacing: .2px; display: flex; align-items: center; gap: .5rem; }
.topbar-logo { height: 26px; width: auto; border-radius: 3px; }
.btn-icon { color: #fff; background: transparent; border: 0; font-size: 1.1rem; }

/* ---- Shell / Sidebar ---- */
.app-shell { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--ink);
  color: #cfd6e6;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-scroll { padding: .75rem .5rem 2rem; }
.nav-section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8592ac;
  margin: 1.1rem .75rem .35rem;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: .6rem;
  color: #cfd6e6;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .92rem;
}
.sidebar .nav-link i { width: 18px; text-align: center; color: #8592ac; }
.sidebar .nav-link:hover { background: var(--ink-2); color: #fff; }
.sidebar .nav-link.active { background: var(--brass); color: #1a1408; font-weight: 600; }
.sidebar .nav-link.active i { color: #1a1408; }

.sidebar-backdrop { display: none; }

.main-content { flex: 1; padding: 1.25rem 1.25rem 3rem; min-width: 0; }

@media (max-width: 991px) {
  .sidebar {
    position: fixed; left: -260px; top: 56px; z-index: 1040;
    transition: left .2s ease; box-shadow: 4px 0 18px rgba(0,0,0,.25);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 56px 0 0 0;
    background: rgba(0,0,0,.35); z-index: 1035;
  }
}

/* ---- Cards ---- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.card-header { background: var(--card); border-bottom: 1px solid var(--line); font-weight: 600; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brass);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-card .stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
.stat-card.accent-ok { border-left-color: var(--ok); }
.stat-card.accent-danger { border-left-color: var(--danger); }
.stat-card.accent-warn { border-left-color: var(--warn); }

/* ---- Buttons ---- */
.btn-primary { background: var(--ink); border-color: var(--ink); }
.btn-primary:hover, .btn-primary:focus { background: var(--ink-2); border-color: var(--ink-2); }
.btn-brass { background: var(--brass); border-color: var(--brass); color: #1a1408; font-weight: 600; }
.btn-brass:hover { background: var(--brass-deep); border-color: var(--brass-deep); color: #fff; }

/* ---- Tables ---- */
table.dataTable { font-size: .9rem; }
.table thead th { background: #FAF9F5; border-bottom: 2px solid var(--line); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* ---- Invoice (screenshot / print friendly) ---- */
.invoice-wrap { max-width: 440px; margin: 0 auto; }
.invoice-card {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 1.25rem; font-size: .92rem;
}
.invoice-card .inv-logo { height: 44px; margin-bottom: .35rem; }
.invoice-card .inv-title { font-weight: 700; font-size: 1.05rem; }
.invoice-card hr { border-top: 1px dashed var(--line); }
.invoice-row { display: flex; justify-content: space-between; padding: .18rem 0; font-size: .9rem; }
.invoice-row .lbl { color: var(--muted); }
.invoice-total-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.05rem; padding-top: .4rem; }
.invoice-signature { margin-top: 2rem; text-align: right; font-size: .85rem; color: var(--muted); }

@media print {
  .no-print { display: none !important; }
  .topbar, .sidebar, .sidebar-backdrop { display: none !important; }
  .main-content { padding: 0; }
  .invoice-wrap { max-width: 100%; }
  body { background: #fff; }
}

/* ---- Import preview ---- */
.row-invalid   { background: #FBEAEA !important; }
.row-duplicate { background: #FDF3E3 !important; }
