:root {
  --primary: #1e6b42;
  --primary-hover: #175433;
  --brand-text: #1e6b42;
  --bg-main: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warn: #ea580c;
  --ok: #16a34a;
  --radius: 10px;
  --sidebar-w: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* Base form controls (outside modals) */
input, select, textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.9rem;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.brand-crest {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-crest.large {
  width: 96px;
  height: 96px;
  margin: 0 auto 0.75rem auto;
  display: block;
}

.brand div {
  display: flex;
  flex-direction: column;
}

.brand div strong {
  font-size: 0.95rem;
  line-height: 1.2;
}

.brand div span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.school-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  background: var(--surface-alt);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
}

.online-dot {
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 50%;
}

.online-dot.cloud { background: #22c55e; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.nav-item:hover, .nav-item.active {
  background: #ecfdf5;
  color: var(--primary);
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  color: inherit;
  flex-shrink: 0;
}

.top-avatar {
  background: var(--primary);
  color: white;
}

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

.user-info strong {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.icon-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
  color: var(--text-muted);
}

.icon-button:hover {
  color: var(--text-main);
}

/* Topbar */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.mobile-menu {
  display: none;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.crumb-sep {
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.today-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Main Content Area */
.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.muted {
  color: var(--text-muted);
}

.brand-text { color: var(--brand-text); }

/* Reusable layout helpers */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 8px;
}

.filter-bar label {
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.search-input { flex: 1; min-width: 200px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: 8px;
}

.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--brand-text); margin-top: 0.25rem; }
.stat-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table thead tr {
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
}

.data-table th, .data-table td { padding: 0.75rem; }
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table .right { text-align: right; white-space: nowrap; }
.data-table .center { text-align: center; }
.data-table .empty { padding: 2rem; text-align: center; color: var(--text-muted); }

.chip {
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

.pill.ok { background: #dcfce7; color: #15803d; border-color: #86efac; }
.pill.warn { background: #ffedd5; color: #c2410c; border-color: #fdba74; }
.pill.bad { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

.alert {
  padding: 0.85rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.alert.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.link-danger { color: var(--danger) !important; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1.25rem;
}

/* Footer */
.footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.creator-credit {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.creator-credit a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.creator-mark {
  background: var(--primary);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
}

/* Auth + modal shell */
.auth-screen {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.auth-screen.hidden {
  display: none !important;
}

/* The sign-in screen sits on the page background; modals keep the dim overlay */
#authScreen { background: var(--bg-main); }

.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.auth-card.modal-card {
  max-width: 860px;
  text-align: left;
  position: relative;
  padding: 1.75rem 1.5rem;
}

.modal-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
  z-index: 10;
}

.auth-card .eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
  text-align: left;
}

.auth-card label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-card input,
.auth-card select,
.auth-card textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.auth-card input:focus,
.auth-card select:focus,
.auth-card textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.auth-forgot-row { text-align: right; margin-top: -0.25rem; }
.auth-forgot-row .text-button { font-size: 0.8rem; padding: 0; }

.auth-message {
  margin-top: 0.5rem;
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 500;
}

.auth-message.ok { color: #15803d; }

.btn {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.15s ease;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn.secondary:hover { background: var(--surface-alt); }

.btn.success { background: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.78rem; }

.btn:disabled {
  background: #94a3b8;
  color: #fff;
  cursor: not-allowed;
}

.btn.full {
  width: 100%;
  margin-top: 0.5rem;
}

.text-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0;
}

.tiny {
  font-size: 0.75rem;
  margin-top: 1rem;
}

.auth-brand-credit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.auth-brand-credit a {
  color: var(--primary);
  text-decoration: none;
}

/* Mobile Drawer Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-in-out;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Form Controls & Disabled Profile State */
input:disabled,
input[readonly] {
  background-color: var(--surface-alt) !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
  cursor: not-allowed;
}

#forgotPasswordView, #setupView {
  animation: fadeInAuth 0.2s ease-in-out;
}

@keyframes fadeInAuth {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bell schedule editor rows */
.bs-head, .bs-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 0.8fr 1.1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.bs-head {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
}

.bs-row {
  background: var(--surface-alt);
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.bs-row input, .bs-row select { padding: 0.4rem !important; font-size: 0.85rem !important; }

/* Mobile Responsiveness (Screen <= 768px) */
@media (max-width: 768px) {
  .app-shell {
    display: block;
    width: 100vw;
    overflow-x: hidden;
  }

  .mobile-menu {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    padding: 0.25rem 0.5rem;
    color: inherit;
    cursor: pointer;
  }

  .sidebar {
    background-color: var(--surface) !important;
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    z-index: 999;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 0 1rem;
  }

  .page-content {
    padding: 1rem;
  }

  .auth-card { padding: 1.5rem 1.1rem; }

  .bs-head { display: none; }
  .bs-row { grid-template-columns: 1fr 1fr 1fr; }
  .bs-row .bs-type { grid-column: span 2; }
  .bs-tool, .bs-chain { width: 100%; }
  .bs-row .bs-label { grid-column: 1 / -1; }
}

/* ===================================================
   MASTER SCHOOL TIMETABLE MATRIX
   =================================================== */
.timetable-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.timetable-day-tabs {
  display: none;
  gap: 0.35rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.day-tab-btn {
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.day-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.timetable-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  font-size: 0.85rem;
}

.timetable-matrix th,
.timetable-matrix td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: middle;
}

.timetable-matrix th:last-child,
.timetable-matrix td:last-child {
  border-right: none;
}

.timetable-matrix tr:last-child td {
  border-bottom: none;
}

.timetable-matrix thead th {
  background: var(--surface-alt);
  color: var(--text-main);
  font-weight: 700;
  text-align: center;
  padding: 10px;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
}

.period-header-col {
  width: 140px;
  min-width: 130px;
  background: var(--surface-alt);
  text-align: center;
}

.period-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-main);
}

.period-hours {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.timetable-break-row td {
  background: var(--surface-alt);
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 6px;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.slot-tile {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3px solid #16a34a;
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 58px;
  justify-content: center;
}

.slot-subject {
  font-weight: 700;
  font-size: 0.82rem;
  color: #14532d;
  line-height: 1.2;
}

.slot-teacher {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.slot-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 2px;
  border-top: 1px dashed #bbf7d0;
  padding-top: 3px;
}

.slot-actions .text-button { font-size: 0.62rem; }

.slot-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.4;
  font-style: italic;
}

@media (max-width: 768px) {
  .timetable-day-tabs {
    display: flex;
  }

  .timetable-matrix thead th:not(.period-header-col),
  .timetable-matrix tbody td:not(.period-header-col) {
    display: none;
  }

  .timetable-matrix thead th.active-day-col,
  .timetable-matrix tbody td.active-day-col {
    display: table-cell !important;
  }

  .timetable-break-row td {
    display: table-cell !important;
  }
}

/* ===================================================
   TERMINAL REPORT CARD MODAL & PRINT MEDIA LAYOUT
   =================================================== */
.report-modal-body {
  max-height: 72vh;
  overflow-y: auto;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
}

.report-card-container {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 2px solid #1e6b42;
  padding: 24px;
  border-radius: 8px;
  max-width: 820px;
  margin: 0 auto 2rem auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.report-header {
  text-align: center;
  border-bottom: 2px solid #1e6b42;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.report-header img {
  width: 150px;
  height: 120px;
  object-fit: contain;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 14px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  background: #f8fafc !important;
  color: #0f172a !important;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

.report-meta-grid strong {
  color: #0f172a !important;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 10px;
}

.report-table th { white-space: nowrap;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  padding: 8px !important;
  border: 1px solid #cbd5e1 !important;
  text-align: center;
}

.report-table td {
  padding: 7px 8px !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

.report-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 14px;
  background: #f8fafc !important;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid #e2e8f0;
  color: #0f172a !important;
}

.report-traits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  background: #f8fafc !important;
  color: #0f172a !important;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  margin-top: 14px;
  font-size: 0.85rem;
}

.report-remarks-box {
  margin-top: 14px;
  padding: 10px 14px;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
  font-size: 0.85rem;
  color: #0f172a !important;
}

.sig-line { margin-top: 28px; border-bottom: 1px solid #94a3b8; width: 85%; }

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .report-card-container {
    page-break-after: always;
    break-after: page;
    box-shadow: none !important;
    border: 2px solid #1e6b42 !important;
    margin: 0 0 20px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ===================================================
   HIGH-CONTRAST DARK THEME OVERRIDES
   =================================================== */
body.dark-mode {
  --primary: #22c55e;
  --primary-hover: #16a34a;
  --brand-text: #4ade80;
  --bg-main: #0a0f1d;
  --surface: #131b2e;
  --surface-alt: #1a253c;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --border: #2e3d5b;

  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
}

body.dark-mode .btn.primary { color: #052e16; }

body.dark-mode .app-shell,
body.dark-mode .main-area {
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
}

body.dark-mode .sidebar,
body.dark-mode .topbar,
body.dark-mode .card,
body.dark-mode .footer {
  background-color: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-main) !important;
}

body.dark-mode .school-chip {
  background-color: var(--surface-alt) !important;
  color: #f1f5f9 !important;
  border: 1px solid var(--border);
}

body.dark-mode .nav-item {
  color: #cbd5e1 !important;
}

body.dark-mode .nav-item:hover,
body.dark-mode .nav-item.active {
  background-color: #064e3b !important;
  color: #4ade80 !important;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

body.dark-mode input:disabled,
body.dark-mode input[readonly] {
  background-color: #1e293b !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #94a3b8 !important;
}

body.dark-mode .data-table th {
  color: #f1f5f9 !important;
  border-bottom: 2px solid var(--border) !important;
  background-color: var(--surface) !important;
}

body.dark-mode .data-table td {
  color: #f8fafc !important;
}

body.dark-mode .pill.ok { background: #064e3b; color: #86efac; border-color: #065f46; }
body.dark-mode .pill.warn { background: #431407; color: #fdba74; border-color: #7c2d12; }
body.dark-mode .pill.bad { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
body.dark-mode .alert.bad { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
body.dark-mode .alert.warn { background: #422006; color: #fde68a; border-color: #713f12; }

body.dark-mode .timetable-matrix thead th {
  background: var(--surface-alt) !important;
  color: #f8fafc !important;
}

body.dark-mode .period-header-col {
  background: var(--surface-alt) !important;
}

body.dark-mode .timetable-break-row td {
  background: #111a2e !important;
  color: #94a3b8 !important;
}

body.dark-mode .slot-tile {
  background: #064e3b33 !important;
  border-color: #065f46 !important;
  border-left-color: #22c55e !important;
}

body.dark-mode .slot-subject {
  color: #86efac !important;
}

body.dark-mode .slot-actions {
  border-top-color: #065f46 !important;
}

body.dark-mode .report-modal-body {
  background: var(--surface-alt) !important;
}

body.dark-mode .muted {
  color: #cbd5e1 !important;
}

body.dark-mode .text-button {
  color: #4ade80 !important;
}

body.dark-mode .text-button.link-danger {
  color: #f87171 !important;
}

body.dark-mode #authScreen { background: var(--bg-main); }

body.dark-mode .auth-card {
  background-color: var(--surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border);
}

body.dark-mode .auth-message { color: #f87171; }
body.dark-mode .auth-message.ok { color: #86efac; }

/* ===================================================
   v2.0 additions
   =================================================== */
.demo-banner {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 0.55rem 1.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

body.dark-mode .demo-banner { background: #422006; color: #fde68a; border-color: #713f12; }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden { display: none !important; }

.loading-box {
  background: var(--surface);
  color: var(--text-main);
  padding: 1.5rem 2rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: gs-spin 0.8s linear infinite;
}

@keyframes gs-spin { to { transform: rotate(360deg); } }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.4rem 0.75rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}

.check-grid label,
.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem !important;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
}

.check-grid input[type="checkbox"],
.check-row input[type="checkbox"] {
  width: auto !important;
  padding: 0 !important;
}

.pill.muted-pill { background: var(--surface-alt); color: var(--text-muted); }
body.dark-mode .pill.muted-pill { background: #1e293b; color: #cbd5e1; border-color: #334155; }

.bulk-table input[type="number"] {
  width: 90px;
  padding: 0.35rem 0.45rem;
  font-size: 0.9rem;
}

.bulk-wrap {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.bulk-wrap thead th { position: sticky; top: 0; background: var(--surface-alt); z-index: 1; }

.warn-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

body.dark-mode .warn-box { background: #422006; color: #fde68a; border-color: #713f12; }

.info-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.info-box ol { margin: 0.35rem 0 0 1.2rem; }
.info-box li { margin: 0.15rem 0; }

.log-list { max-height: 280px; overflow-y: auto; font-size: 0.82rem; border: 1px solid var(--border); border-radius: 6px; }
.log-list div { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border); }
.log-list div:last-child { border-bottom: none; }

.hide-print { }
@media print { .hide-print { display: none !important; } }

/* Large sign-out button */
.signout-btn {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  background: #b91c1c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.signout-btn:hover { background: #991b1b; }
body.dark-mode .signout-btn { background: #dc2626; }

/* Sign-in screen: no inner scrollbar */
#authScreen { overflow-y: auto; scrollbar-width: none; align-items: flex-start; }
#authScreen::-webkit-scrollbar { display: none; }
#authScreen .auth-card { max-height: none; overflow: visible; margin: auto; padding: 1.5rem 1.75rem; }
#authScreen .brand-crest.large { margin-bottom: 0.4rem; }
#authScreen h1 { font-size: 1.5rem; }

/* Attendance tick boxes */
#attTable input[type="radio"] {
  -webkit-appearance: none; appearance: none;
  width: 32px; height: 32px; margin: 0;
  border: 2px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer;
  display: inline-grid; place-content: center; vertical-align: middle;
}
#attTable input[type="radio"]::after { content: ''; font-size: 1.2rem; font-weight: 800; line-height: 1; }
#attTable input[value="Present"]:checked { background: #16a34a; border-color: #16a34a; }
#attTable input[value="Present"]:checked::after { content: '\2713'; color: #fff; }
#attTable input[value="Absent"]:checked { background: #dc2626; border-color: #dc2626; }
#attTable input[value="Absent"]:checked::after { content: '\2715'; color: #fff; }
#attTable input[value="Late"]:checked { background: #f59e0b; border-color: #f59e0b; }
#attTable input[value="Late"]:checked::after { content: 'L'; color: #fff; font-size: 1rem; }
#attTable input[type="radio"]:disabled { opacity: 0.65; cursor: not-allowed; }
#attTable td.center, #attTable th.center { text-align: center; }

/* Password show/hide */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 2.8rem; }
.pw-eye { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1.15rem; padding: 0.3rem 0.45rem; line-height: 1; color: var(--text-muted); }

/* Greeting & clock */
.greet-card h2 { font-size: 1.45rem; }
.clock-line { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; align-items: baseline; }
.clock-line strong { font-size: 1.35rem; color: var(--primary); font-variant-numeric: tabular-nums; }
.period-now { margin-top: 0.35rem; font-size: 0.88rem; color: var(--text-muted); }
.period-now b { color: var(--text-main); }

/* Period alarm banner */
.bell-banner { position: fixed; top: 0.75rem; left: 50%; transform: translateX(-50%); z-index: 3000; background: #1e6b42; color: #fff; padding: 0.85rem 1rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); display: flex; gap: 0.9rem; align-items: center; max-width: calc(100vw - 1.5rem); font-weight: 600; }
.bell-banner button { background: #fff; color: #1e6b42; border: none; border-radius: 8px; padding: 0.4rem 0.8rem; font-weight: 700; cursor: pointer; }

/* Draggable divider between the menu and the page */
.sidebar-resizer {
  width: 7px; flex-shrink: 0; cursor: col-resize; touch-action: none;
  position: sticky; top: 0; height: 100vh;
  background: var(--border); opacity: 0.55; transition: opacity 0.15s, background 0.15s;
}
.sidebar-resizer:hover, .sidebar-resizer.dragging, .sidebar-resizer:focus-visible { opacity: 1; background: var(--primary); outline: none; }
body.resizing-sidebar { user-select: none; cursor: col-resize; }
.sidebar { overflow-x: hidden; border-right: none; }
.nav-item, .user-info strong, .user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 768px) { .sidebar-resizer { display: none; } }

/* Quick actions (Install / Sign out) sit near the top of the menu so they are never cut off on phones */
.quick-row { display: flex; gap: 0.5rem; margin: -0.5rem 0 1rem; }
.mini-btn { flex: 1; padding: 0.45rem 0.5rem; font-size: 0.8rem; font-weight: 700; border: none; border-radius: 8px; cursor: pointer; color: #fff; white-space: nowrap; }
.mini-btn.signout { background: #b91c1c; }
.mini-btn.signout:hover { background: #991b1b; }
.mini-btn.install { background: #1e6b42; }
.mini-btn.install:hover { background: #17573a; }
.mini-btn.hidden { display: none; }
body.dark-mode .mini-btn.signout { background: #dc2626; }
/* Mobile browsers: 100vh is taller than the visible screen, which hid the bottom of the menu */
.sidebar { height: 100vh; height: 100dvh; }
.nav-list { overflow-y: auto; min-height: 0; }
@media (max-width: 768px) { .sidebar { height: 100dvh; padding-bottom: 1.25rem; } }

.sba-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.75rem; }
.sba-live { background: #e8f2ec; color: #1e6b42; border-radius: 6px; padding: 0.5rem 0.75rem; font-weight: 600; font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }
.bulk-table th small { font-weight: 400; color: var(--muted, #64748b); }
.bulk-table input[type="number"] { width: 4.2rem; }
.bulk-table td.calc { text-align: center; font-weight: 600; color: #1e6b42; white-space: nowrap; }
.bulk-wrap { overflow-x: auto; }

.bs-tools { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.bs-tool { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.bs-tool input { width: 5rem; }
.bs-chain { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.bs-actions { display: inline-flex; gap: 0.2rem; }
.bs-actions .text-button { font-size: 1.05rem; padding: 0 0.35rem; }
#bellScheduleForm .bs-tools { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; }
#bellScheduleForm label.bs-tool, #bellScheduleForm label.bs-chain { flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: flex-start; text-align: left; gap: 0.4rem; width: auto; }
#bellScheduleForm label.bs-chain { flex-basis: 100%; }
#bellScheduleForm .bs-tool input, #bellScheduleForm .bs-chain input { width: 4.5rem; margin: 0; }
#bellScheduleForm .bs-chain input { width: auto; }
#bellScheduleForm .bs-tool .btn { padding: 0.35rem 0.8rem; width: auto; }

#authScreen label.keep-row { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.5rem; font-size: 0.85rem; font-weight: 400; text-align: left; color: var(--text-muted); }
#authScreen label.keep-row input { width: auto; margin: 0; }

.privacy-text { max-height: 65vh; overflow-y: auto; font-size: 0.9rem; line-height: 1.55; }
.privacy-text h3 { font-size: 0.95rem; margin: 0.9rem 0 0.25rem; }
.privacy-text ul { margin: 0.25rem 0 0.5rem 1.1rem; padding: 0; }
.privacy-text p { margin: 0.25rem 0; }
