/* ============================================================
   VIVEKAM SUBSTITUTION SYSTEM — styles.css
   Aesthetic: Institutional-Refined | Navy + Amber + Ivory
   ============================================================ */

/* -- Custom Properties ---------------------------------------- */
:root {
  --navy:       #0f2044;
  --navy-mid:   #1a3460;
  --navy-light: #2a4a80;
  --amber:      #e8a020;
  --amber-light:#f5c060;
  --amber-dim:  #7a4e00;
  --ivory:      #faf8f4;
  --ivory-dark: #f0ece4;
  --white:      #ffffff;
  --text:       #1a1a2e;
  --text-mid:   #4a5568;
  --text-light: #8896a8;
  --success:    #1a7a4a;
  --success-bg: #e8f7ef;
  --warning:    #b45309;
  --warning-bg: #fef3c7;
  --danger:     #c0392b;
  --danger-bg:  #fdecea;
  --border:     #d8d0c4;
  --border-light: #e8e4dc;
  --shadow-sm:  0 1px 4px rgba(15,32,68,0.08);
  --shadow-md:  0 4px 16px rgba(15,32,68,0.12);
  --shadow-lg:  0 8px 32px rgba(15,32,68,0.18);
  --radius:     10px;
  --radius-lg:  16px;
  --sidebar-w:  260px;
  --topbar-h:   56px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;
  --transition:   0.2s ease;
}

/* -- Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--ivory);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font-body); border: none; background: none; }
input, select, textarea { font-family: var(--font-body); }
ul { list-style: none; }
img { display: block; max-width: 100%; }

/* -- Layout: Sidebar + Main ----------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 2rem;
  max-width: 1400px;
}

.topbar { display: none; }

/* -- Sidebar Header ------------------------------------------- */
.sidebar-header {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.school-emblem { flex-shrink: 0; }
.emblem-ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--amber);
  display: flex; align-items: center; justify-content: center;
}
.emblem-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--amber);
}
.school-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}
.school-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  font-weight: 400;
}
.school-affn {
  font-size: 0.65rem;
  color: var(--amber-light);
  font-family: var(--font-mono);
  margin-top: 0.15rem;
}

/* -- Sidebar Nav --------------------------------------------- */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}
.nav-item.active {
  background: rgba(232,160,32,0.15);
  color: var(--amber-light);
  border-left: 3px solid var(--amber);
}

/* -- Sidebar Footer ------------------------------------------ */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.today-badge {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.today-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.4); }
.today-date { font-size: 0.8rem; color: rgba(255,255,255,0.75); font-family: var(--font-mono); }

/* -- Content Sections ---------------------------------------- */
.content-section { display: none; }
.content-section.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.2;
}
.section-desc { font-size: 0.875rem; color: var(--text-mid); margin-top: 0.3rem; }

/* -- Upload Grid --------------------------------------------- */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.upload-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.upload-card:hover { box-shadow: var(--shadow-md); }

.upload-card-label { padding: 1rem 1.25rem 0; }
.upload-pill {
  display: inline-block;
  background: var(--navy);
  color: var(--amber-light);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

.drop-zone {
  margin: 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.drop-zone.dragover {
  border-color: var(--amber);
  background: rgba(232,160,32,0.04);
}
.drop-zone.has-file {
  border-color: var(--success);
  background: var(--success-bg);
  border-style: solid;
}
.drop-icon { display: flex; justify-content: center; margin-bottom: 0.875rem; }
.drop-icon svg { width: 48px; height: 48px; color: var(--text-light); }
.drop-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
.drop-sub { font-size: 0.8rem; color: var(--text-light); margin-bottom: 1.25rem; }

.btn-upload {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--navy);
  color: var(--white);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-upload:hover { background: var(--navy-light); }

.file-status {
  padding: 0 1.25rem 1rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 500;
}

/* -- Extraction Progress ------------------------------------- */
.extraction-progress {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.progress-bar-wrap {
  height: 6px;
  background: var(--ivory-dark);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-mid), var(--amber));
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}
.progress-label { font-size: 0.8rem; color: var(--text-mid); text-align: center; }

/* -- Extracted Section --------------------------------------- */
.extracted-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.extracted-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.extracted-title { font-size: 1rem; font-weight: 600; color: var(--navy); }
.extracted-note {
  font-size: 0.8rem;
  color: var(--warning);
  background: var(--warning-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}
.extracted-actions { display: flex; gap: 0.5rem; }

/* -- Tables -------------------------------------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(15,32,68,0.02); }
.data-table td input, .data-table td select {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  background: var(--ivory);
}
.data-table td input:focus, .data-table td select:focus {
  outline: none;
  border-color: var(--navy-light);
}
.empty-td { text-align: center; color: var(--text-light); padding: 2rem; }

/* -- Manual Entry -------------------------------------------- */
.manual-entry-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.manual-entry-header h3 { font-size: 1rem; font-weight: 600; color: var(--navy); margin-bottom: 0.25rem; }
.manual-entry-header p { font-size: 0.8rem; color: var(--text-mid); margin-bottom: 1rem; }
.manual-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  align-items: flex-end;
}
.form-group { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; min-width: 120px; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--text-mid); }
.form-group input, .form-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--ivory);
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--navy-light);
  background: var(--white);
}
.form-group-btn { flex: 0 0 auto; }

/* -- Upload Actions Bar -------------------------------------- */
.upload-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* -- Daily Config Grid --------------------------------------- */
.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.config-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.config-card-full { grid-column: 1 / -1; }
.config-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.config-card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.config-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}
.config-badge.required { background: var(--danger-bg); color: var(--danger); }
.config-hint { font-size: 0.78rem; color: var(--text-mid); margin-bottom: 0.875rem; }
.config-hint-inline { font-size: 0.78rem; color: var(--text-mid); }

/* Day Order */
.day-order-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.radio-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-mid);
  transition: all var(--transition);
  user-select: none;
}
.radio-pill input[type="radio"] { display: none; }
.radio-pill:hover { border-color: var(--navy-light); color: var(--navy); }
.radio-pill.selected {
  border-color: var(--amber);
  background: rgba(232,160,32,0.1);
  color: var(--amber-dim);
}

/* Grades */
.grades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}
.grade-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-mid);
  transition: all var(--transition);
  user-select: none;
}
.grade-check input { display: none; }
.grade-check.active {
  border-color: var(--navy-mid);
  background: rgba(15,32,68,0.05);
  color: var(--navy);
}
.grade-check .check-box {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.grade-check.active .check-box {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
  font-size: 10px;
}

/* Teacher list items */
.teacher-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}
.teacher-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  background: var(--ivory);
  flex-wrap: wrap;
}
.teacher-item.selected { border-color: var(--navy-mid); background: rgba(15,32,68,0.04); }
.teacher-item-check { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 160px; cursor: pointer; }
.teacher-item-check input { accent-color: var(--navy); width: 15px; height: 15px; }
.teacher-item-name { font-size: 0.875rem; font-weight: 500; }
.teacher-group-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  margin-left: auto;
}
.group-a { background: #dbeafe; color: #1e40af; }
.group-b { background: #dcfce7; color: #166534; }
.group-c { background: #fef9c3; color: #854d0e; }
.group-d { background: #fce7f3; color: #9d174d; }

.btn-config {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  background: var(--navy);
  color: var(--white);
  border-radius: 4px;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-config:hover { background: var(--navy-light); }

.period-config-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
  flex: 0 0 100%;
}
.period-tag {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  background: var(--navy-mid);
  color: white;
  border-radius: 20px;
  font-family: var(--font-mono);
}

/* -- Engine -------------------------------------------------- */
.engine-controls { flex-shrink: 0; }
.btn-generate {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--white);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.btn-generate:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-generate svg { width: 16px; height: 16px; }

.engine-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.summary-stat {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 110px;
  flex: 1;
  box-shadow: var(--shadow-sm);
}
.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.stat-label { font-size: 0.72rem; color: var(--text-mid); text-transform: uppercase; letter-spacing: 0.05em; }
.summary-stat.success .stat-num { color: var(--success); }
.summary-stat.warning .stat-num { color: var(--warning); }

/* Conflicts */
.conflicts-panel {
  background: var(--warning-bg);
  border: 1px solid rgba(180,83,9,0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.conflicts-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--warning);
  margin-bottom: 0.75rem;
}
.conflicts-header svg { width: 18px; height: 18px; }
.conflicts-list { display: flex; flex-direction: column; gap: 0.35rem; }
.conflicts-list li {
  font-size: 0.82rem;
  color: var(--warning);
  padding-left: 1rem;
  position: relative;
}
.conflicts-list li::before {
  content: '•';
  position: absolute; left: 0;
}

/* Subs Table */
.subs-table-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.subs-table-header {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}
.subs-table-header h3 { font-size: 1rem; font-weight: 600; color: var(--navy); }
.subs-table-actions { display: flex; gap: 0.5rem; }

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-assigned { background: var(--success-bg); color: var(--success); }
.status-unavailable { background: var(--danger-bg); color: var(--danger); }
.status-locked { background: rgba(15,32,68,0.08); color: var(--navy); }

.priority-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(15,32,68,0.06);
  color: var(--navy);
  font-family: var(--font-mono);
}

.lock-icon { color: var(--amber-dim); }

/* Empty state */
.empty-engine {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.empty-icon svg { width: 56px; height: 56px; color: var(--text-light); }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-mid); margin-bottom: 0.25rem; }
.empty-sub { font-size: 0.8rem; color: var(--text-light); }
.empty-state-sm {
  font-size: 0.82rem;
  color: var(--text-light);
  padding: 1rem;
  text-align: center;
}

/* -- Report -------------------------------------------------- */
.report-preview {
  background: var(--ivory-dark);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.report-doc {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  max-width: 900px;
  margin: 0 auto;
}
.report-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px solid var(--navy);
}
.report-logo-area { display: flex; align-items: center; gap: 1rem; }
.report-emblem {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--amber-light);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.report-school-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}
.report-affn { font-size: 0.8rem; color: var(--text-mid); font-family: var(--font-mono); }
.report-meta { font-size: 0.85rem; color: var(--text-mid); line-height: 1.8; }
.report-subtitle {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}
.report-table th { background: var(--navy); }
.report-table th:last-child { min-width: 80px; }
.report-footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}
.signature-block { text-align: center; flex: 1; }
.sig-line {
  border-bottom: 1px solid var(--text);
  height: 40px;
  margin-bottom: 0.5rem;
}
.signature-block p { font-size: 0.8rem; color: var(--text-mid); }

/* Report actions */
.report-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* -- Audit Trail --------------------------------------------- */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.audit-entry {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.audit-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--navy-light);
  margin-top: 4px;
  flex-shrink: 0;
}
.audit-content {}
.audit-action { font-size: 0.875rem; font-weight: 600; color: var(--navy); }
.audit-detail { font-size: 0.78rem; color: var(--text-mid); margin-top: 0.15rem; }
.audit-time { font-size: 0.72rem; color: var(--text-light); font-family: var(--font-mono); white-space: nowrap; }

/* -- Buttons ------------------------------------------------- */
.btn-primary {
  padding: 0.6rem 1.25rem;
  background: var(--navy);
  color: var(--white);
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--navy-light); transform: translateY(-1px); }

.btn-secondary {
  padding: 0.6rem 1.25rem;
  background: var(--ivory-dark);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--navy-light); color: var(--navy); }
.btn-secondary svg { width: 15px; height: 15px; }

.btn-ghost {
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--text-mid);
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: color var(--transition);
}
.btn-ghost:hover { color: var(--navy); }

.btn-tiny {
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--ivory);
  color: var(--text-mid);
  transition: all var(--transition);
}
.btn-tiny:hover { border-color: var(--navy-light); color: var(--navy); }

.header-actions { display: flex; gap: 0.35rem; }

.btn-delete {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.btn-edit {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  background: rgba(15,32,68,0.08);
  color: var(--navy);
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.section-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* -- Modal --------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--navy); }
.modal-close {
  font-size: 1rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-hint { font-size: 0.82rem; color: var(--text-mid); margin-bottom: 0.875rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

.period-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.period-btn {
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
  background: var(--ivory);
  transition: all var(--transition);
  user-select: none;
}
.period-btn.selected {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}

.full-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--ivory);
}
.modal-check-row { margin-top: 0.875rem; }
.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* -- Toast --------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--navy);
  color: var(--white);
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* -- Hamburger & Mobile Sidebar ------------------------------ */
.hamburger { display: none; flex-direction: column; gap: 5px; padding: 0.5rem; cursor: pointer; }
.hamburger span { width: 22px; height: 2px; background: var(--white); border-radius: 2px; display: block; transition: all 0.3s; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; }

/* -- Print Styles -------------------------------------------- */
@media print {
  .sidebar, .topbar, .report-actions, .section-header .report-actions,
  .subs-table-actions, .engine-controls { display: none !important; }
  body { background: white; }
  .main-content { margin-left: 0; padding: 0; }
  .content-section { display: none !important; }
  #section-report { display: block !important; }
  .report-preview { background: white; padding: 0; }
  .report-doc { box-shadow: none; padding: 1cm; }
  .data-table th { background: #333 !important; color: white !important; -webkit-print-color-adjust: exact; }
}

/* -- Responsive Breakpoints ---------------------------------- */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: all; }

  .topbar {
    display: flex;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--navy);
    padding: 0 1rem;
    z-index: 100;
    gap: 0.75rem;
  }
  .hamburger { display: flex; }
  .topbar-title { display: flex; flex-direction: column; flex: 1; }
  .topbar-school { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; color: var(--white); }
  .topbar-sub { font-size: 0.65rem; color: rgba(255,255,255,0.5); }
  .topbar-right { font-size: 0.72rem; color: rgba(255,255,255,0.6); font-family: var(--font-mono); }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(var(--topbar-h) + 1rem);
  }

  .section-title { font-size: 1.4rem; }
  .upload-grid { grid-template-columns: 1fr; }
  .daily-grid { grid-template-columns: 1fr; }
  .config-card-full { grid-column: auto; }
  .report-head { flex-direction: column; }
  .report-footer { flex-direction: column; gap: 1.5rem; }
  .engine-summary { gap: 0.5rem; }
  .summary-stat { min-width: 80px; padding: 0.75rem 0.875rem; }
}

@media (max-width: 480px) {
  .section-title { font-size: 1.2rem; }
  .report-doc { padding: 1.25rem; }
  .period-grid { grid-template-columns: repeat(5, 1fr); }
  .report-actions { flex-wrap: wrap; }
  .grades-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
