/* Koinia SIS shared design tokens + base elements (Batch 1 modernization).
 * Linked by every portal BEFORE its inline <style>; pages keep only
 * page-specific rules. Brand colors live here as defaults and are overridden
 * per school at runtime by theme.js (same --brand* names). Cache-busted via
 * ?v=20260922220449 like page scripts (see build-web.sh). */
:root {
  --brand: #146f99;
  --brand-primary: #146f99;
  --brand-bg: #FFFFFF;
  --brand-text: #1A202C;
  --brand-head: 'Poppins', sans-serif;
  --brand-body: 'Lato', sans-serif;
  --bg: #F7FAFC;
  --text: #1A202C;
  --border: #E2E8F0;
  --border-soft: #EDF2F7;
  --muted: #4A5568;
  --input-border: #CBD5E0;
  --ghost-bg: #EDF2F7;
  --success: #276749;
  --warning: #B7791F;
  --warning-bg: #FFFAF0;
  --danger: #9B2C2C;
  --info: #2B6CB0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --font-h1: clamp(1.4rem, 1.1rem + 1.5vw, 1.8rem);
  --font-h2: clamp(1.15rem, 1rem + 1vw, 1.4rem);
  --font-h3: 1.05rem;
  --font-body: 1rem;
  --font-small: .82rem;
}
body {
  font-family: var(--brand-body);
  color: var(--text);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
}
h1 { font-size: var(--font-h1); }
h2 { font-size: var(--font-h2); }
h3 { font-size: var(--font-h3); }
header { background: var(--brand-primary); color: #fff; padding: 14px 20px; }
header h1 { font-family: var(--brand-head); margin: 0; font-size: 1.2rem; }
header a { color: #fff; }
main { max-width: 1080px; margin: 0 auto; padding: var(--space-4); }
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: var(--space-3) 0;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-family: var(--brand-head); margin: 0 0 var(--space-2); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); }
button, a.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--font-body);
  font-family: inherit;
  cursor: pointer;
}
button.primary, a.btn.primary, a.btn:not(.ghost) {
  background: var(--brand-primary);
  color: #fff;
  border: 0;
}
button.ghost {
  background: var(--ghost-bg);
  color: var(--text);
  border: 0;
}
input, select, textarea {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font: inherit;
  box-sizing: border-box;
}
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1.1rem; height: 1.1rem; }
.grid { display: grid; gap: var(--space-2); }
.small { font-size: var(--font-small); color: var(--muted); }
pre {
  background: #1A202C;
  color: var(--border);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: .75rem;
}
/* Visible keyboard focus everywhere (a11y foundation). */
:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}
/* Portal tab navigation (shared by office/gradebook/lunch/care). */
nav.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
nav.tabs button { border: 1px solid var(--input-border); background: #fff; }
nav.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
section.tab { display: none; }
section.tab.active { display: block; }
/* Mobile: tables scroll instead of crushing; weekday calendars keep 5
   aligned columns with room to scroll (stacking would break Mon–Fri). */
.table-wrap { overflow-x: auto; }
@media (max-width: 600px) {
  main { padding: var(--space-3) var(--space-2); }
  .card { padding: var(--space-3); }
  .cal-grid, .print-cal { grid-template-columns: repeat(5, minmax(68px, 1fr)); overflow-x: auto; }
  .cal-day { min-height: 72px; }
}
#koinia-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
#koinia-toast .toast {
  pointer-events: auto;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .85rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
#koinia-toast .toast.error { background: var(--danger); }
#koinia-toast .toast.ok { background: var(--success); }
/* Accessible modal (Batch 5). */
.modal-ov {
  position: fixed;
  inset: 0;
  background: rgba(26, 32, 44, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10000;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
/* Dismissible app banner (error net + toasts share the pattern). */
#koinia-err {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--danger);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .85rem;
  z-index: 9999;
  cursor: pointer;
}
@media (max-width: 600px) {
  main { padding: var(--space-3) var(--space-2); }
  .card { padding: var(--space-3); }
}
