/* ============================================================
   edu.flow — "Exercise Book" design system
   A Kenyan school exercise book: manila cover, ruled paper,
   red margin rule. Used as real UI structure, not decoration.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Color */
  --paper:      #EFE3BE;  /* manila cover — page background */
  --surface:    #FFFDF6;  /* inside-page paper — cards, panels */
  --surface-2:  #FBF6E8;  /* slightly deeper paper — table stripes, nested panels */
  --ink:        #232B2E;  /* chalkboard charcoal — primary text */
  --ink-soft:   #5B6467;  /* softened ink — secondary text */
  --rule-navy:  #2F4B7C;  /* ruled line blue — links, primary actions, headings */
  --rule-navy-dark: #223a63;
  --margin-red: #B4383F;  /* margin rule — danger, required, alerts */
  --margin-red-dark: #972c32;
  --chalk-green: #2E6B4F; /* blackboard green — success, positive balances */
  --chalk-green-dark: #24543e;
  --sun-gold:   #D9A441;  /* accent — badges, highlights, focus */
  --line-faint: rgba(47, 75, 124, 0.14); /* faint ruled lines */
  --shadow: 0 1px 2px rgba(35, 43, 46, 0.06), 0 4px 14px rgba(35, 43, 46, 0.07);

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Layout */
  --sidebar-width: 232px;
  --radius: 10px;
  --radius-sm: 6px;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

/* Faint ruled-paper texture on the main app background */
body.app {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    var(--line-faint) 28px
  );
  background-attachment: local;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

a { color: var(--rule-navy); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); }

::selection { background: var(--sun-gold); color: var(--ink); }

/* Visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--sun-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Auth screens (login) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 27px, var(--line-faint) 28px
  );
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
  position: relative;
  border-left: 4px solid var(--margin-red);
}

.auth-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rule-navy);
  margin: 0 0 4px;
}
.auth-brand span { color: var(--margin-red); }

.auth-sub {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0 0 24px;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid rgba(47, 75, 124, 0.22);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--rule-navy);
  box-shadow: 0 0 0 3px rgba(47, 75, 124, 0.14);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--rule-navy);
  color: #fff;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover, .btn:hover { background: var(--rule-navy-dark); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }

.btn-block { width: 100%; }
.btn-danger { background: var(--margin-red); }
.btn-danger:hover { background: var(--margin-red-dark); }
.btn-success { background: var(--chalk-green); }
.btn-success:hover { background: var(--chalk-green-dark); }
.btn-ghost { background: transparent; color: var(--rule-navy); border: 1px solid rgba(47, 75, 124, 0.3); }
.btn-ghost:hover { background: rgba(47, 75, 124, 0.06); }

/* ---------- Alerts / flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
  border-left: 4px solid transparent;
}
.flash-success {
  background: rgba(46, 107, 79, 0.1);
  color: var(--chalk-green-dark);
  border-left-color: var(--chalk-green);
}
.flash-error {
  background: rgba(180, 56, 63, 0.09);
  color: var(--margin-red-dark);
  border-left-color: var(--margin-red);
}

/* ---------- App shell: sidebar + topbar ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--rule-navy);
  color: #EFE3BE;
  padding: 24px 0;
  position: relative;
}

/* Ring-binder punch holes down the sidebar edge — signature detail */
.sidebar::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 3px;
  background: repeating-linear-gradient(
    to bottom,
    var(--sun-gold) 0, var(--sun-gold) 6px,
    transparent 6px, transparent 26px
  );
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  padding: 0 24px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}
.sidebar-brand span { color: var(--sun-gold); }

.sidebar h2 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(239, 227, 190, 0.6);
  font-weight: 700;
  margin: 22px 24px 8px;
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block;
  padding: 8px 24px;
  color: #EFE3BE;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar li a:hover {
  background: rgba(255,255,255,0.06);
  text-decoration: none;
  border-left-color: var(--sun-gold);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-faint);
}

.topbar .user {
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.topbar .user strong { color: var(--ink); }

.content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* ---------- Cards (the ruled-paper module) ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 4px solid var(--margin-red);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.card ul { margin: 0; padding-left: 0; list-style: none; }
.card li { padding: 6px 0; border-bottom: 1px dashed var(--line-faint); }
.card li:last-child { border-bottom: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; font-size: 0.9rem; }
th { background: var(--surface-2); font-weight: 700; color: var(--ink-soft); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:hover { background: rgba(217, 164, 65, 0.08); }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-green { background: rgba(46,107,79,0.12); color: var(--chalk-green-dark); }
.badge-red   { background: rgba(180,56,63,0.12); color: var(--margin-red-dark); }
.badge-gold  { background: rgba(217,164,65,0.18); color: #8a651e; }

/* Money figures always in mono, for scannability */
.amount { font-family: var(--font-mono); font-weight: 500; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px 0; }
  .sidebar::before { display: none; }
  .content { padding: 20px; }
  .topbar { padding: 12px 20px; }
}
