/* ============================================================
   Excel Gene Academy — app styles
   A calm, legible internal tool. One accent (deep teal), plenty
   of whitespace, no decoration that doesn't earn its place.
   ============================================================ */

:root {
  --ink:        #1c2a2a;   /* near-black with a green cast */
  --ink-soft:   #52605e;
  --ink-faint:  #8a9694;
  --line:       #e2e6e4;
  --paper:      #f7f8f7;
  --surface:    #ffffff;
  --teal:       #0f6e56;   /* the single accent */
  --teal-dark:  #0a4f3e;
  --teal-tint:  #e4efeb;
  --amber:      #ba7517;   /* used sparingly for the brand mark */
  --danger:     #a32d2d;
  --danger-tint:#f7e9e9;
  --ok:         #27500a;
  --ok-tint:    #eaf3de;
  --radius:     10px;
  --shadow:     0 1px 2px rgba(28, 42, 42, 0.05), 0 4px 16px rgba(28, 42, 42, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Top bar (only when logged in) ------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 0.6rem; }
.topbar__mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: var(--teal); color: #fff;
  border-radius: 8px;
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.02em;
}
.topbar__name { font-weight: 600; font-size: 0.98rem; }
.topbar__nav { display: flex; align-items: center; gap: 1rem; }
.topbar__user { font-size: 0.9rem; color: var(--ink-soft); display: flex; align-items: center; gap: 0.5rem; }
.topbar__role {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--teal-tint); color: var(--teal-dark);
  padding: 0.15rem 0.5rem; border-radius: 20px; font-weight: 600;
}
.topbar__logout { margin: 0; }

/* --- Layout ------------------------------------------------ */
.main { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
.page__head { margin-bottom: 2rem; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 0.72rem; font-weight: 600; color: var(--teal);
  margin-bottom: 0.4rem;
}
.page__title { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; }
.page__lead { color: var(--ink-soft); margin-top: 0.4rem; max-width: 60ch; }
.page__note { margin-top: 2rem; color: var(--ink-faint); font-size: 0.85rem; }

/* --- Flash messages ---------------------------------------- */
.flash {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1.5rem; font-size: 0.92rem;
  border: 1px solid transparent;
}
.flash--error   { background: var(--danger-tint); color: var(--danger); border-color: #eccaca; }
.flash--success { background: var(--ok-tint);     color: var(--ok);     border-color: #d3e5b8; }

/* --- Cards grid -------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--teal); transform: translateY(-2px); }
.card__title { font-weight: 600; font-size: 1.02rem; }
.card__desc { color: var(--ink-soft); font-size: 0.88rem; }

/* --- Buttons ----------------------------------------------- */
.btn {
  font: inherit; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px;
  padding: 0.55rem 1rem; font-size: 0.92rem; font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-dark); }
.btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink-faint); color: var(--ink); }
.btn--block { width: 100%; }

/* --- Forms ------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.field__input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field__input:focus {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.1rem;
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-tint);
}

/* --- Auth (login) page ------------------------------------- */
.auth {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
}
.auth__card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2.25rem;
  box-shadow: var(--shadow);
}
.auth__brand { text-align: center; margin-bottom: 1.75rem; }
.auth__mark {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; margin-bottom: 0.75rem;
  background: var(--teal); color: #fff;
  border-radius: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.auth__title { font-size: 1.25rem; font-weight: 700; }
.auth__subtitle { color: var(--ink-faint); font-size: 0.9rem; margin-top: 0.15rem; }
.auth__foot { margin-top: 1.5rem; color: var(--ink-faint); font-size: 0.8rem; }
/* --- Toolbar (actions above a list) ------------------------ */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; }

/* --- Table (list views) ------------------------------------ */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table thead th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.table__row { cursor: pointer; transition: background 0.12s ease; }
.table__row:hover { background: var(--teal-tint); }
.table__row:last-child td { border-bottom: none; }
.table__link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table__row:hover .table__link { color: var(--teal-dark); }

/* --- Empty state ------------------------------------------- */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.empty__hint { font-size: 0.88rem; color: var(--ink-faint); margin-top: 0.25rem; }
/* --- Section (grouping within a page) ---------------------- */
.section { margin-top: 2rem; }
.section__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  color: var(--ink);
}

/* Muted inline text + a neutral tag variant */
.muted { color: var(--ink-faint); font-weight: 400; }
.tag--muted { background: var(--line); color: var(--ink-soft); }
/* --- Invoice sub-rows under an enrolment ------------------- */
.subrow td { background: var(--paper); padding: 0.75rem 1rem 1rem; }
.subrow__bill { display: flex; align-items: center; gap: 0.75rem; }
.subrow__summary { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 0.6rem; }
.btn--sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* Nested invoice table sits lighter than the main one */
.table--nested { box-shadow: none; border: 1px solid var(--line); }
.table--nested thead th { background: var(--surface); font-size: 0.72rem; }
.table--nested td { font-size: 0.86rem; padding: 0.5rem 1rem; }
/* --- Stat row (summary cards) ------------------------------ */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat__label {
  display: block;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-faint); margin-bottom: 0.3rem;
}
.stat__value { font-size: 1.5rem; font-weight: 700; }
.stat__value--warn { color: var(--danger); }
.stat__value--ok { color: var(--ok); }
/* --- Tutor assignment control ------------------------------ */
.assign {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding-bottom: 0.9rem; margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.assign__label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.assign__form { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; }
.assign__select { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
/* --- Reports ----------------------------------------------- */
.report__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.report__actions { display: flex; gap: 0.6rem; }
.card--soon { opacity: 0.6; cursor: default; }
.arrears__learner { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.arrears__total { font-weight: 700; color: var(--danger); }

/* --- Print-only elements: hidden on screen ----------------- */
.print-only { display: none; }

/* --- Print letterhead -------------------------------------- */
.print-letterhead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.print-letterhead__brand { font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.print-letterhead__title { font-size: 1.1rem; font-weight: 600; margin-top: 0.15rem; }
.print-letterhead__meta { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.1rem; }

/* Print: strip the app chrome so a clean report sheet prints. */
@media print {
  /* Force backgrounds/colours to render (tags, headline, etc.) */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .topbar, .footer, .no-print { display: none !important; }
  .print-only { display: block !important; }

  body { background: #fff; }
  .main { max-width: none; padding: 0; margin: 0; }
  .report__head { margin-bottom: 0.5rem; }

  /* Keep tables and sections from splitting awkwardly across pages. */
  .table, .section, .stat-row, .pl-headline { page-break-inside: avoid; }
  .section__title { page-break-after: avoid; }

  /* Flatten shadows for clean print. */
  .table, .stat, .card, .record, .pl-headline { box-shadow: none; }

  /* Stat rows sit tighter on paper. */
  .stat-row { gap: 0.5rem; }
}
/* --- Top nav links ----------------------------------------- */
.topbar__links { display: flex; gap: 1.25rem; align-items: center; margin-right: auto; padding-left: 2rem; }
.topbar__links a { color: var(--ink-soft); font-size: 0.92rem; font-weight: 500; text-decoration: none; }
.topbar__links a:hover { color: var(--teal); }
/* --- P&L headline ------------------------------------------ */
.pl-headline {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1.25rem 1.5rem; border-radius: var(--radius);
  margin-bottom: 1.5rem; border: 1px solid var(--line);
}
.pl-headline--profit { background: var(--ok-tint); border-color: #d3e5b8; }
.pl-headline--loss { background: var(--danger-tint); border-color: #eccaca; }
.pl-headline__label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.pl-headline__value { font-size: 2rem; font-weight: 700; }
.pl-headline--profit .pl-headline__value { color: var(--ok); }
.pl-headline--loss .pl-headline__value { color: var(--danger); }

/* --- Responsive -------------------------------------------- */
@media (max-width: 560px) {
  .topbar { padding: 0.75rem 1rem; }
  .topbar__name { display: none; }
  .main { padding: 1.5rem 1rem; }
  .page__title { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
/* --- Record (read-only detail list) ------------------------ */
.record {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.record__row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.record__row:last-child { border-bottom: none; }
.record__key {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.record__val { color: var(--ink); }
.record__actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

/* --- Status tags ------------------------------------------- */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
}
.tag--ok   { background: var(--ok-tint);     color: var(--ok); }
.tag--warn { background: var(--danger-tint); color: var(--danger); }

/* Record rows stack on narrow screens */
@media (max-width: 560px) {
  .record__row { grid-template-columns: 1fr; gap: 0.2rem; }
}