/* ==========================================================================
   Tel-Hai design system (adapted from the softreq hand-off).
   Green brand, dark default + light theme via :root[data-theme="light"].
   ========================================================================== */

:root {
  --th-green:#2fae6f; --th-green-deep:#1c8a54; --th-green-bright:#7ae994; --th-lime:#9fe06a;
  --th-glow:rgba(122,233,148,.13);

  --canvas:#1e1e1e; --canvas-2:#252526; --surface:#2d2d2d; --surface-2:#333333; --surface-3:#3c3c3c;
  --line:#535353; --line-soft:#3e3e3e; --line-bright:#6e6e6e;
  --ink:#e2e2e2; --ink-soft:#b8b8b8; --ink-faint:#8e8e8e;

  --blue:#4fc1ff;   --blue-bg:rgba(79,193,255,.13);
  --amber:#e5c07b;  --amber-bg:rgba(229,192,123,.10);
  --purple:#c586c0; --purple-bg:rgba(197,134,192,.13);
  --danger:#f44747; --danger-bg:rgba(244,71,71,.13);

  --radius:14px; --radius-sm:10px;
  --shadow:0 1px 3px rgba(0,0,0,.5),0 10px 30px rgba(0,0,0,.42);
}

:root[data-theme="light"] {
  --canvas:#f4faf6; --canvas-2:#edf5f0; --surface:#ffffff; --surface-2:#f8fcfa; --surface-3:#eff8f3;
  --line:#9bbfad; --line-soft:#b0cfc0; --line-bright:#7fa896;
  --ink:#0d1f16; --ink-soft:#2a4a38; --ink-faint:#5b7a6a;
  --th-glow:rgba(47,174,111,.12);
  --shadow:0 1px 2px rgba(0,0,0,.08),0 8px 24px rgba(0,0,0,.10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Assistant', system-ui, 'Segoe UI', Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
}
h1, h2, h3 { font-family: 'Heebo', sans-serif; font-weight: 800; margin: 0; }
a { color: var(--th-green-bright); }

/* ---- Topbar ---- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line-soft);
  padding: .75rem 1.4rem; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; }
.topbar .brand img { height: 32px; }
/* telhai-logo.png's text is a dark gray, too low-contrast on the dark theme's
   near-black background — telhai-logo-dark.png is the same file with just the
   text lightened (the green icon is untouched). Both sit in the DOM; CSS
   picks the one with contrast for the active theme. !important because this
   is a theme switch, not a layout rule, and must win over the img's own
   display value. */
.logo-light { display: none !important; }
:root[data-theme="light"] .logo-dark { display: none !important; }
:root[data-theme="light"] .logo-light { display: inline-block !important; }
.topbar .brand .title { font-family: 'Heebo', sans-serif; font-weight: 700; font-size: 1rem; }
.topbar .right { display: flex; align-items: center; gap: .7rem; }
.topbar .user { color: var(--ink-soft); font-size: .85rem; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.center-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6rem; padding: 1rem; }

/* ---- Buttons ---- */
.btn {
  font-family: 'Heebo', sans-serif; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: var(--radius-sm); padding: .6rem 1.1rem; cursor: pointer;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { border: 0; color: #06120c; background: linear-gradient(180deg, var(--th-green-bright), var(--th-green-deep)); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px var(--th-glow); transform: translateY(-1px); }
.btn-danger { border-color: transparent; background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-block { width: 100%; }

/* ---- Cards / stats ---- */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
        padding: 1.4rem; box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-inline-start: 3px solid var(--th-green);
        border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.stat .num { font-family: 'Heebo', sans-serif; font-weight: 800; font-size: 2rem; color: var(--th-green-bright); }
.stat .lbl { color: var(--ink-faint); font-size: .85rem; margin-top: .2rem; }

/* ---- Sections ---- */
.section { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
           padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.section h2 { font-size: 1rem; margin-bottom: 1rem; font-weight: 700; }

/* ---- Tables ---- */
.table-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { text-align: right; padding: .55rem .7rem; border-bottom: 1px solid var(--line-soft); }
.tbl th { color: var(--ink-faint); font-weight: 600; position: sticky; top: 0; background: var(--canvas-2); z-index: 1; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.dim td { opacity: .5; }
.tbl.sortable th:not([data-nosort]) { cursor: pointer; user-select: none; }
.tbl.sortable th:not([data-nosort]):hover { color: var(--th-green-bright); }
.sort-ind { color: var(--th-green-bright); font-size: .7rem; }

/* ---- Pills ---- */
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill-green { background: var(--th-glow); color: var(--th-green-bright); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-muted { background: var(--surface-3); color: var(--ink-faint); }

/* ---- Forms ---- */
.fld { margin-bottom: 1rem; }
.fld label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .4rem; }
.fld input, .fld select {
  width: 100%; padding: .7rem; background: var(--canvas-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 1rem; font-family: inherit;
}
.fld input:focus { outline: none; border-color: var(--th-green); box-shadow: 0 0 0 3px var(--th-glow); }
input[type="file"] { color: var(--ink-soft); font-size: .9rem; }
/* The native calendar icon renders dark-on-transparent by default, invisible
   against this app's dark input background — invert it to match; the light
   theme already has a dark icon on a light input, so it stays uninverted. */
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }
:root[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }

/* ---- Notes / banners / empty ---- */
.banner { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger);
          border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1.4rem; }
.note { border-radius: var(--radius-sm); padding: .7rem 1rem; font-size: .9rem; margin-top: .5rem; }
.note-ok { background: var(--th-glow); color: var(--th-green-bright); }
.note-err { background: var(--danger-bg); color: var(--danger); }
.note-wait { background: var(--amber-bg); color: var(--amber); }
.empty { color: var(--ink-faint); font-size: .9rem; padding: .6rem 0; }
.muted { color: var(--ink-faint); font-size: .9rem; }

/* ---- Auth (login / student) ---- */
.auth-card { width: 100%; max-width: 440px; }
.auth-brand { text-align: center; }
.auth-brand img { display: block; height: 44px; margin: 0 auto; }
.auth-brand .sub { color: var(--ink-faint); font-size: .9rem; margin-top: .5rem; }
.brand-title-plain { display: block; margin-top: 1rem; color: var(--ink); font-weight: 700; font-size: 1.05rem; }

/* ---- License code display ---- */
.code { font-family: 'Heebo', sans-serif; font-size: 1.5rem; font-weight: 800; letter-spacing: 1px;
        direction: ltr; color: var(--th-green-bright); margin: .5rem 0; }

/* ---- Modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal-bg.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.4rem; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .18s ease both;
}
#adminsModalBg .modal { max-width: 560px; }
.modal h3 { font-size: 1.05rem; margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 768px) {
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal, #adminsModalBg .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; animation: sheetIn .2s ease both; }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
}

/* ---- Theme / text-size toggles ---- */
.theme-toggle, .text-size-toggle {
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 999px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.text-size-toggle { font-family: 'Heebo', sans-serif; font-weight: 700; font-size: .8rem; }
.theme-toggle:hover, .text-size-toggle:hover { border-color: var(--th-green); color: var(--th-green-bright); }

/* Floating stack (login pages) — two circular buttons, one above the other. */
.corner-toggles { position: fixed; bottom: 1rem; left: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 10; }

/* Text-size scaling — applied to the root, so every rem-based size scales. */
html[data-text-size="large"] { font-size: 112.5%; }
html[data-text-size="larger"] { font-size: 125%; }

/* ---- Utilities ---- */
.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.hidden { display: none; }
.scroll-x { overflow-x: auto; }

/* ---- Motion ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.section, .card, .stat { animation: fadeUp .25s ease both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .topbar { padding: .7rem 1rem; }
  .stat .num { font-size: 1.6rem; }
}
