/* ======================================================
   SIMRS – CBC School Management System
   Design System · main.css
   ====================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --sidebar-bg:       #0c1a2e;
  --sidebar-hover:    rgba(16,185,129,.1);
  --sidebar-active:   rgba(16,185,129,.15);
  --sidebar-text:     #94a3b8;
  --sidebar-border:   rgba(255,255,255,.06);
  --primary:          #10b981;
  --primary-dk:       #059669;
  --primary-lt:       #d1fae5;
  --danger:           #ef4444;
  --danger-lt:        #fee2e2;
  --warning:          #f59e0b;
  --warning-lt:       #fef3c7;
  --info:             #3b82f6;
  --info-lt:          #dbeafe;
  --purple:           #8b5cf6;
  --purple-lt:        #ede9fe;
  --bg:               #f0f4f8;
  --card:             #ffffff;
  --border:           #e2e8f0;
  --text:             #0f172a;
  --text-2:           #475569;
  --text-muted:       #94a3b8;
  /* Aliases used by page templates; undefined names made some states invisible */
  --text-1:           #0f172a;
  --success:          #10b981;
  --success-lt:       #d1fae5;
  --primary-light:    #d1fae5;
  --bg-1:             #f0f4f8;
  --bg-2:             #f8fafc;
  --border-color:     #e2e8f0;
  --sidebar-w:        260px;
  --topbar-h:         64px;
  --radius:           12px;
  --radius-sm:        8px;
  --shadow-sm:        0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --shadow:           0 4px 6px -1px rgba(0,0,0,.08),0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg:        0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);
  --transition:       all .2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.6}
a{color:inherit;text-decoration:none}
img{max-width:100%}
input,select,textarea,button{font-family:inherit}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar{width:5px;height:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}

/* ══════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════ */
.app{display:flex;min-height:100vh}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar{
  width:var(--sidebar-w);background:var(--sidebar-bg);
  height:100vh;height:100dvh;position:fixed;left:0;top:0;
  display:flex;flex-direction:column;z-index:100;
  border-right:1px solid rgba(255,255,255,.04);
}
.sidebar-brand{
  padding:20px 20px 16px;border-bottom:1px solid var(--sidebar-border);
  flex-shrink:0;
}
.brand-link{display:flex;align-items:center;gap:11px}
.brand-icon{
  width:40px;height:40px;border-radius:11px;flex-shrink:0;
  background:linear-gradient(135deg,#10b981,#059669);
  display:flex;align-items:center;justify-content:center;font-size:20px;
}
.brand-text h1{font-size:14.5px;font-weight:800;color:#fff;line-height:1.15;letter-spacing:-.2px}
.brand-text span{font-size:10.5px;color:#64748b;font-weight:400}

.sidebar-nav{flex:1;overflow-y:auto;padding:12px 0}

.nav-section-label{
  font-size:10px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:#475569;padding:10px 20px 4px;
}
.nav-item{
  display:flex;align-items:center;gap:9px;
  padding:8px 20px;margin:1px 10px;border-radius:8px;
  color:var(--sidebar-text);font-size:13px;font-weight:500;
  transition:var(--transition);cursor:pointer;position:relative;
}
.nav-item:hover{background:var(--sidebar-hover);color:#e2e8f0}
.nav-item.active{background:var(--sidebar-active);color:var(--primary)}
.nav-item.active::before{
  content:'';position:absolute;left:-10px;top:50%;transform:translateY(-50%);
  width:3px;height:16px;background:var(--primary);border-radius:0 2px 2px 0;
}
.nav-item .ni{font-size:16px;width:20px;text-align:center;flex-shrink:0}
.nav-item .nav-badge{
  margin-left:auto;background:rgba(16,185,129,.15);color:var(--primary);
  font-size:10px;padding:1px 7px;border-radius:10px;font-weight:700;
}

/* Collapsible nav group */
.nav-group-toggle{
  display:flex;align-items:center;gap:9px;
  padding:8px 20px;margin:1px 10px;border-radius:8px;
  color:var(--sidebar-text);font-size:13px;font-weight:500;
  cursor:pointer;transition:var(--transition);user-select:none;
}
.nav-group-toggle:hover{background:var(--sidebar-hover);color:#e2e8f0}
.nav-group-toggle .chevron{margin-left:auto;order:2;font-size:11px;transition:var(--transition)}
.nav-group-toggle.open .chevron{transform:rotate(90deg)}

.nav-sub{display:none;padding:2px 0 2px 14px}
.nav-sub.open{display:block}
.nav-sub .nav-item{font-size:12.5px;color:#64748b;padding:7px 20px}
.nav-sub .nav-item::after{
  content:'';display:inline-block;width:5px;height:5px;
  border-radius:50%;background:#334155;flex-shrink:0;order:-1;
  transition:var(--transition);
}
.nav-sub .nav-item.active::after,.nav-sub .nav-item:hover::after{background:var(--primary)}

.sidebar-footer{padding:14px 20px;border-top:1px solid var(--sidebar-border);flex-shrink:0}
.user-card{display:flex;align-items:center;gap:10px}
.user-avatar{
  width:34px;height:34px;border-radius:50%;flex-shrink:0;
  background:linear-gradient(135deg,#10b981,#059669);
  display:flex;align-items:center;justify-content:center;
  font-size:12px;font-weight:800;color:#fff;
}
.user-name{font-size:12.5px;font-weight:700;color:#e2e8f0;line-height:1.2}
.user-role{font-size:10.5px;color:#64748b;text-transform:capitalize}
.logout-btn{
  margin-left:auto;width:28px;height:28px;border:none;background:transparent;
  color:#64748b;cursor:pointer;border-radius:6px;display:flex;align-items:center;
  justify-content:center;transition:var(--transition);font-size:14px;
}
.logout-btn:hover{background:rgba(239,68,68,.15);color:#ef4444}

/* ── Main / Topbar ─────────────────────────────────────── */
.main{margin-left:var(--sidebar-w);flex:1;min-width:0;display:flex;flex-direction:column;min-height:100vh}

.topbar{
  height:var(--topbar-h);background:var(--card);border-bottom:1px solid var(--border);
  display:flex;align-items:center;padding:0 28px;position:sticky;top:0;z-index:50;gap:14px;
}
.topbar-left{flex:1}
.page-title{font-size:17px;font-weight:800;color:var(--text);line-height:1.2}
.breadcrumb{display:flex;align-items:center;gap:5px;font-size:11.5px;color:var(--text-muted);margin-top:1px}
.breadcrumb a{color:var(--text-muted)}
.breadcrumb a:hover{color:var(--primary)}
.bc-sep{color:#cbd5e1}
.topbar-right{display:flex;align-items:center;gap:6px}
.topbar-icon-btn{
  width:34px;height:34px;border-radius:8px;border:1px solid var(--border);
  background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;
  color:var(--text-2);transition:var(--transition);font-size:15px;
}
.topbar-icon-btn:hover{background:var(--bg);color:var(--text)}
.term-pill{
  display:flex;align-items:center;gap:5px;background:var(--primary-lt);
  color:var(--primary-dk);padding:5px 11px;border-radius:8px;font-size:11.5px;font-weight:700;
}

.page-content{padding:24px 28px;flex:1;min-width:0}
.flash-area{padding:0 28px;padding-top:16px}
canvas{max-width:100%}

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */
.card{background:var(--card);border-radius:var(--radius);border:1px solid var(--border);box-shadow:var(--shadow-sm)}
.card-header{padding:16px 22px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}
.card-title{font-size:14.5px;font-weight:700;color:var(--text)}
.card-subtitle{font-size:11.5px;color:var(--text-muted);font-weight:400;margin-top:1px}
.card-body{padding:22px}

/* ── Stat Cards ────────────────────────────────────────── */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:18px;margin-bottom:24px}
.stat-card{
  background:var(--card);border-radius:var(--radius);padding:20px 22px;
  border:1px solid var(--border);box-shadow:var(--shadow-sm);
  display:flex;align-items:center;gap:14px;position:relative;overflow:hidden;
  transition:var(--transition);
}
.stat-card:hover{transform:translateY(-2px);box-shadow:var(--shadow)}
.stat-card::before{content:'';position:absolute;top:0;left:0;right:0;height:3px}
.stat-card.green::before{background:linear-gradient(90deg,#10b981,#059669)}
.stat-card.blue::before{background:linear-gradient(90deg,#3b82f6,#1d4ed8)}
.stat-card.amber::before{background:linear-gradient(90deg,#f59e0b,#d97706)}
.stat-card.purple::before{background:linear-gradient(90deg,#8b5cf6,#6d28d9)}
.stat-card.teal::before{background:linear-gradient(90deg,#06b6d4,#0284c7)}

.stat-icon{width:48px;height:48px;border-radius:13px;display:flex;align-items:center;justify-content:center;font-size:22px;flex-shrink:0}
.stat-icon.green{background:#d1fae5}
.stat-icon.blue{background:#dbeafe}
.stat-icon.amber{background:#fef3c7}
.stat-icon.purple{background:#ede9fe}
.stat-icon.teal{background:#cffafe}

.stat-val{font-size:28px;font-weight:800;color:var(--text);line-height:1;margin-bottom:3px}
.stat-lbl{font-size:11.5px;color:var(--text-muted);font-weight:500}

/* ── Chart Grid ────────────────────────────────────────── */
.charts-row{display:grid;grid-template-columns:2fr 1fr;gap:18px;margin-bottom:24px}
.chart-box{position:relative;height:240px}

/* ══════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════ */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
table{width:100%;border-collapse:collapse}
thead tr{background:#f8fafc;border-bottom:1px solid var(--border)}
thead th{padding:10px 16px;text-align:left;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-muted);white-space:nowrap}
tbody tr{border-bottom:1px solid #f1f5f9;transition:var(--transition)}
tbody tr:hover{background:#f8fafc}
tbody tr:last-child{border-bottom:none}
tbody td{padding:12px 16px;font-size:13.5px;color:var(--text);vertical-align:middle}

/* ── Table Actions ─────────────────────────────────────── */
.row-actions{display:flex;gap:3px;opacity:0;transition:var(--transition)}
tbody tr:hover .row-actions{opacity:1}

/* ── Toolbar ───────────────────────────────────────────── */
.toolbar{display:flex;align-items:center;gap:10px;margin-bottom:18px;flex-wrap:wrap}
.toolbar-l{flex:1;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.toolbar-r{display:flex;align-items:center;gap:8px}

.search-box{
  display:flex;align-items:center;gap:7px;background:#fff;
  border:1.5px solid var(--border);border-radius:8px;padding:7px 13px;min-width:230px;
  transition:var(--transition);
}
.search-box:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px rgba(16,185,129,.1)}
.search-box input{border:none;outline:none;font-size:13px;background:transparent;flex:1;color:var(--text)}
.search-box .si{color:var(--text-muted);font-size:13px}

.filter-sel{
  padding:7px 11px;border:1.5px solid var(--border);border-radius:8px;
  font-size:12.5px;background:#fff;color:var(--text);cursor:pointer;outline:none;
}
.filter-sel:focus{border-color:var(--primary)}

/* ── Pagination ────────────────────────────────────────── */
.pagination{display:flex;align-items:center;justify-content:space-between;padding:13px 22px;border-top:1px solid var(--border)}
.pg-info{font-size:12px;color:var(--text-muted)}
.pg-controls{display:flex;gap:3px}
.pg-btn{
  min-width:30px;height:30px;border-radius:6px;border:1px solid var(--border);
  background:#fff;cursor:pointer;font-size:12px;font-weight:600;
  color:var(--text-2);display:flex;align-items:center;justify-content:center;
  padding:0 7px;transition:var(--transition);
}
.pg-btn:hover,.pg-btn.active{background:var(--primary);color:#fff;border-color:var(--primary)}

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.btn{
  display:inline-flex;align-items:center;gap:6px;padding:8px 15px;
  border-radius:8px;border:none;cursor:pointer;font-size:13px;font-weight:600;
  transition:var(--transition);white-space:nowrap;
}
.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px}
.btn-lg{padding:10px 20px;font-size:14px}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-dk);transform:translateY(-1px);box-shadow:0 4px 12px rgba(16,185,129,.3)}
.btn-danger{background:#ef4444;color:#fff}
.btn-danger:hover{background:#dc2626}
.btn-outline{background:transparent;color:var(--text-2);border:1.5px solid var(--border)}
.btn-outline:hover{background:var(--bg);color:var(--text)}
.btn-ghost{background:transparent;color:var(--text-2);padding:6px 8px}
.btn-ghost:hover{background:var(--bg);color:var(--text)}
.btn-icon{width:32px;height:32px;padding:0;justify-content:center}
.btn-warning{background:#f59e0b;color:#fff}
.btn-warning:hover{background:#d97706}

/* ══════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════ */
.badge{display:inline-flex;align-items:center;gap:3px;padding:2px 9px;border-radius:20px;font-size:11px;font-weight:700}
.badge-success{background:#d1fae5;color:#065f46}
.badge-danger{background:#fee2e2;color:#991b1b}
.badge-warning{background:#fef3c7;color:#92400e}
.badge-info{background:#dbeafe;color:#1e40af}
.badge-purple{background:#ede9fe;color:#5b21b6}
.badge-gray{background:#f1f5f9;color:#475569}
.badge-teal{background:#cffafe;color:#164e63}

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */
.form-group{margin-bottom:16px}
.form-label{display:block;font-size:12.5px;font-weight:700;color:var(--text);margin-bottom:5px}
.form-label .req{color:#ef4444;margin-left:2px}
.form-control{
  width:100%;padding:8px 13px;border:1.5px solid var(--border);border-radius:8px;
  font-size:13.5px;color:var(--text);background:#fff;transition:var(--transition);outline:none;
}
.form-control:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(16,185,129,.1)}
.form-control::placeholder{color:#94a3b8}
select.form-control{cursor:pointer}
textarea.form-control{resize:vertical;min-height:80px}
.form-hint{font-size:11px;color:var(--text-muted);margin-top:3px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-row-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px}

/* ── Toggle ────────────────────────────────────────────── */
.switch{position:relative;display:inline-block;width:42px;height:22px}
.switch input{opacity:0;width:0;height:0}
.slider{position:absolute;cursor:pointer;inset:0;background:#cbd5e1;border-radius:22px;transition:var(--transition)}
.slider::before{content:'';position:absolute;height:16px;width:16px;left:3px;top:3px;background:#fff;border-radius:50%;transition:var(--transition);box-shadow:0 1px 3px rgba(0,0,0,.2)}
input:checked+.slider{background:var(--primary)}
input:checked+.slider::before{transform:translateX(20px)}

/* ══════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════ */
.modal-overlay{
  display:none;position:fixed;inset:0;
  background:rgba(0,0,0,.45);backdrop-filter:blur(4px);
  z-index:1000;align-items:center;justify-content:center;padding:18px;
}
.modal-overlay.show{display:flex;animation:fadeIn .2s ease}
.modal{
  background:#fff;border-radius:16px;width:100%;max-width:540px;
  box-shadow:0 25px 60px rgba(0,0,0,.2);max-height:92vh;
  display:flex;flex-direction:column;animation:slideUp .2s ease;
}
.modal-lg{max-width:720px}
.modal-xl{max-width:920px}
.modal-header{
  padding:18px 22px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:10px;flex-shrink:0;
}
.modal-header h3{font-size:15px;font-weight:800;flex:1;color:var(--text)}
.modal-close{
  width:30px;height:30px;border-radius:8px;border:none;background:var(--bg);
  cursor:pointer;display:flex;align-items:center;justify-content:center;
  color:var(--text-muted);transition:var(--transition);font-size:16px;
}
.modal-close:hover{background:var(--danger-lt);color:var(--danger)}
.modal-body{padding:22px;overflow-y:auto;flex:1 1 auto;min-height:0}
/* A form inside a dialog must share its height, so its footer (Save) stays on screen */
.modal{overflow:hidden}
.modal > form{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
.modal-footer{
  padding:14px 22px;border-top:1px solid var(--border);
  display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-shrink:0;
}

/* ══════════════════════════════════════════════════════
   ALERTS & FLASH
   ══════════════════════════════════════════════════════ */
.alert{
  padding:11px 15px;border-radius:8px;font-size:13px;font-weight:500;
  display:flex;align-items:center;gap:8px;margin-bottom:14px;
}
.alert-success{background:#d1fae5;color:#065f46;border:1px solid #a7f3d0}
.alert-danger {background:#fee2e2;color:#991b1b;border:1px solid #fca5a5}
.alert-warning{background:#fef3c7;color:#92400e;border:1px solid #fcd34d}
.alert-info   {background:#dbeafe;color:#1e40af;border:1px solid #93c5fd}

/* ══════════════════════════════════════════════════════
   AVATAR / PERSON DISPLAY
   ══════════════════════════════════════════════════════ */
.avatar{
  width:36px;height:36px;border-radius:50%;flex-shrink:0;
  background:linear-gradient(135deg,#10b981,#059669);
  display:flex;align-items:center;justify-content:center;
  font-size:12px;font-weight:800;color:#fff;
}
.avatar-lg{width:64px;height:64px;font-size:22px;border-radius:16px}
.avatar-xl{width:96px;height:96px;font-size:32px;border-radius:20px}
.avatar img{width:100%;height:100%;object-fit:cover;border-radius:inherit}

.av-row{display:flex;align-items:center;gap:10px}
.av-name{font-weight:700;font-size:13.5px;line-height:1.2}
.av-sub{font-size:11.5px;color:var(--text-muted)}

/* ══════════════════════════════════════════════════════
   INFO GRID (profile view)
   ══════════════════════════════════════════════════════ */
.info-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:14px}
.info-item{}
.info-lbl{font-size:10.5px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);font-weight:700;margin-bottom:3px}
.info-val{font-size:14px;font-weight:600;color:var(--text)}

/* ══════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════ */
.empty-state{text-align:center;padding:50px 20px;color:var(--text-muted)}
.empty-state .ei{font-size:46px;margin-bottom:12px}
.empty-state h3{font-size:15px;font-weight:700;color:var(--text-2);margin-bottom:6px}
.empty-state p{font-size:13px}

/* ══════════════════════════════════════════════════════
   PHOTO UPLOAD
   ══════════════════════════════════════════════════════ */
.photo-drop{
  display:flex;flex-direction:column;align-items:center;gap:10px;
  padding:20px;border:2px dashed var(--border);border-radius:12px;
  cursor:pointer;transition:var(--transition);text-align:center;
}
.photo-drop:hover{border-color:var(--primary);background:var(--primary-lt)}
.photo-drop input[type=file]{display:none}
.photo-preview{width:80px;height:80px;border-radius:50%;object-fit:cover;border:3px solid var(--primary-lt)}

/* ══════════════════════════════════════════════════════
   WEIGHT INDICATOR
   ══════════════════════════════════════════════════════ */
.weight-bar{height:6px;background:#e2e8f0;border-radius:3px;overflow:hidden}
.weight-fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--primary-dk));border-radius:3px;transition:width .4s ease}

/* Level badge */
.level-badge{
  display:inline-flex;align-items:center;justify-content:center;
  width:32px;height:32px;border-radius:8px;font-size:14px;font-weight:800;
}
.level-4{background:#d1fae5;color:#065f46}
.level-3{background:#dbeafe;color:#1e40af}
.level-2{background:#fef3c7;color:#92400e}
.level-1{background:#fee2e2;color:#991b1b}

/* ══════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════ */
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes slideUp{from{transform:translateY(18px);opacity:0}to{transform:translateY(0);opacity:1}}
@keyframes spin{to{transform:rotate(360deg)}}

.spinner{
  width:18px;height:18px;border:2px solid rgba(255,255,255,.3);
  border-top-color:#fff;border-radius:50%;animation:spin .6s linear infinite;
}

/* ══════════════════════════════════════════════════════
   DROPDOWN
   ══════════════════════════════════════════════════════ */
.dropdown{position:relative}
.dropdown-menu{
  display:none;position:absolute;right:0;top:calc(100% + 6px);
  background:#fff;border:1px solid var(--border);border-radius:10px;
  box-shadow:var(--shadow-lg);min-width:170px;z-index:200;
  padding:5px;animation:fadeIn .15s ease;
}
.dropdown-menu.show{display:block}
.dd-item{
  display:flex;align-items:center;gap:7px;padding:7px 11px;
  font-size:13px;color:var(--text);border-radius:6px;cursor:pointer;
  transition:var(--transition);
}
.dd-item:hover{background:var(--bg)}
.dd-item.danger{color:#ef4444}
.dd-item.danger:hover{background:var(--danger-lt)}
.dd-divider{border:none;border-top:1px solid var(--border);margin:4px 0}

/* ══════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════ */
.toast-container{position:fixed;bottom:22px;right:22px;z-index:9999;display:flex;flex-direction:column;gap:8px}
.toast{
  background:#1e293b;color:#fff;padding:11px 16px;border-radius:10px;
  font-size:12.5px;font-weight:500;box-shadow:0 10px 30px rgba(0,0,0,.2);
  display:flex;align-items:center;gap:9px;min-width:260px;
  animation:slideUp .3s ease;
}
.toast.t-success{border-left:4px solid #10b981}
.toast.t-danger {border-left:4px solid #ef4444}
.toast.t-warning{border-left:4px solid #f59e0b}
.toast.t-info   {border-left:4px solid #3b82f6}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */
/* Menu button and backdrop are hidden on desktop; the phone rules below show them */
.nav-toggle{display:none}
.sidebar-backdrop{display:none}

/* Touch screens have no hover, so hover-only actions must always be visible */
@media (hover:none){
  .row-actions{opacity:1}
}

/* Tablets and small laptops */
@media(max-width:1024px){
  .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .charts-row{grid-template-columns:minmax(0,1fr)}
}

/* Phones and small tablets: navigation becomes a drawer */
@media(max-width:768px){
  :root{--topbar-h:56px}

  /* Sidebar drawer */
  .sidebar{
    width:min(84vw,300px);transform:translateX(-102%);
    transition:transform .25s ease;box-shadow:none;
    padding-bottom:env(safe-area-inset-bottom);
  }
  .sidebar.open{transform:translateX(0);box-shadow:0 0 40px rgba(0,0,0,.35)}
  .sidebar-nav{-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
  .nav-item,.nav-group-toggle{padding-top:11px;padding-bottom:11px}
  .nav-sub .nav-item{padding-top:9px;padding-bottom:9px}
  .sidebar-backdrop{
    display:block;position:fixed;inset:0;background:rgba(15,23,42,.5);
    z-index:90;opacity:0;pointer-events:none;transition:opacity .25s ease;
  }
  .sidebar-backdrop.show{opacity:1;pointer-events:auto}
  body.nav-open{overflow:hidden}

  .nav-toggle{display:inline-flex;flex-shrink:0;width:42px;height:42px;font-size:19px}

  /* Content fills the screen */
  .main{margin-left:0;width:100%}
  .topbar{padding:0 12px 0 10px;gap:8px;height:var(--topbar-h)}
  .topbar-left{min-width:0;flex:1}
  .page-title{font-size:15.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .breadcrumb{display:none}
  .topbar-right{flex-shrink:0;gap:6px}
  .help-btn{display:none}
  .term-pill{max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;padding:5px 8px}
  .flash-area{padding:12px 12px 0}
  .page-content{padding:14px 12px 32px}
  .card-header{padding:14px 16px;gap:10px}
  .card-body{padding:16px}
  .card-title{font-size:14px}

  /* Inputs: 16px stops iOS Safari zooming in when a field is tapped */
  input,select,textarea,.form-control,.search-box input,.filter-sel{font-size:16px !important}
  .form-control,.filter-sel{min-height:42px}
  .form-group{margin-bottom:14px}
  .form-row,.form-row-3{grid-template-columns:minmax(0,1fr)}

  /* Inline two- and three-column layouts stack on phones */
  [style*="grid-template-columns"]{grid-template-columns:minmax(0,1fr) !important}

  /* Buttons are easy to tap */
  .btn{min-height:42px;padding:9px 15px}
  .btn-sm{min-height:36px;padding:6px 11px}
  .btn-icon{min-width:36px;min-height:36px}
  /* !important: some pages declare their own grids, which would otherwise win on phones */
  .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr)) !important;gap:12px;margin-bottom:18px}
  .charts-row,.dashboard-grid-2{grid-template-columns:minmax(0,1fr) !important;gap:14px}
  .stat-card{padding:14px 14px}
  .stat-val{font-size:22px !important}
  .card{min-width:0}
  .chart-box{height:220px}

  /* Toolbars and search wrap onto full-width rows */
  .toolbar{gap:8px}
  .toolbar-l,.toolbar-r{width:100%;flex-wrap:wrap}
  .search-box{min-width:0;width:100%}
  .pagination{flex-wrap:wrap;gap:10px;padding:12px 14px}

  /* Tables scroll sideways inside their card; the first column stays visible */
  .table-wrap table{width:max-content;min-width:100%}
  .table-wrap th,.table-wrap td{white-space:nowrap}
  .table-wrap th:first-child,.table-wrap td:first-child{
    position:sticky;left:0;z-index:1;background:#fff;box-shadow:2px 0 4px -2px rgba(0,0,0,.08);
  }
  .table-wrap thead th:first-child{background:#f8fafc}
  .table-wrap thead th{padding:9px 12px}
  .table-wrap tbody td{padding:10px 12px}

  /* Dialogs become bottom sheets */
  .modal-overlay{padding:0;align-items:flex-end}
  .modal,.modal-lg,.modal-xl{
    max-width:100%;width:100%;max-height:92dvh;
    border-radius:18px 18px 0 0;padding-bottom:env(safe-area-inset-bottom);
  }
  .modal-header,.modal-footer{padding:14px 16px}
  .modal-body{padding:16px}
  .modal-footer{flex-wrap:wrap}
  .modal-footer .btn{flex:1 1 140px;justify-content:center}

  /* Notifications sit above the bottom edge and fill the width */
  .toast-container{left:12px;right:12px;bottom:calc(12px + env(safe-area-inset-bottom));align-items:stretch}
  .toast{min-width:0;width:100%}

  .dropdown-menu{max-width:calc(100vw - 24px)}
  .photo-drop{padding:16px}
}

/* Small phones */
@media(max-width:360px){
  .stats-grid{grid-template-columns:minmax(0,1fr) !important}
  .page-title{font-size:14.5px}
  .card-header{flex-direction:column;align-items:flex-start}
}

/* ══════════════════════════════════════════════════════
   LIST PAGES: live toolbar, phone cards, pickers
   ══════════════════════════════════════════════════════ */
.only-mobile{display:none}
.only-desktop{display:block}
.hide-sm{display:inline}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.section-label{font-size:12px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px}

.list-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:18px}
.lt-search{position:relative;flex:1 1 280px;min-width:0;display:flex;align-items:center}
.lt-search .si{position:absolute;left:12px;font-size:14px;pointer-events:none}
.lt-search input{
  width:100%;padding:10px 14px 10px 36px;border:1.5px solid var(--border);border-radius:10px;
  background:#fff;font-size:14px;color:var(--text);outline:none;transition:var(--transition);
}
.lt-search input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(16,185,129,.12)}
.lt-search input::-webkit-search-cancel-button{cursor:pointer}
.lt-filters{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end;width:100%}
.lt-field{display:flex;flex-direction:column;gap:4px;min-width:150px}
.lt-field span{font-size:11.5px;font-weight:700;color:var(--text-2)}
.lt-field select{min-width:150px}
.lt-filter-toggle{display:none;position:relative}
.lt-count{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;border-radius:10px;background:var(--primary);color:#fff;font-size:11px;font-weight:800;padding:0 6px;margin-left:4px}
.lt-actions{display:flex;gap:8px;flex-wrap:wrap}
.is-loading{opacity:.55;transition:opacity .15s ease;pointer-events:none}

.person-list{display:block}
.person-card{
  display:flex;align-items:center;gap:12px;padding:14px 18px;border-top:1px solid #f1f5f9;
  color:inherit;min-height:72px;transition:background .15s ease;
}
.person-card:first-child{border-top:none}
.person-card:active{background:#f8fafc}
.person-card .avatar{width:44px;height:44px;font-size:14px;flex-shrink:0}
.pc-main{min-width:0;flex:1}
.pc-name{font-size:15px;font-weight:700;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pc-sub{font-size:12.5px;color:var(--text-muted);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pc-tags{display:flex;flex-wrap:wrap;gap:5px;margin-top:6px}
.pc-chev{font-size:22px;color:#cbd5e1;flex-shrink:0;line-height:1}

/* Pickers: search the server and choose records */
.picker{position:relative}
.picker-results{
  margin-top:6px;border:1px solid var(--border);border-radius:10px;background:#fff;
  box-shadow:var(--shadow);max-height:260px;overflow-y:auto;empty:none;
}
.picker-results:empty{display:none}
.picker-option{
  display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;
  padding:10px 12px;border:none;background:transparent;text-align:left;cursor:pointer;
  border-top:1px solid #f1f5f9;min-height:52px;font-size:13px;color:var(--text);
}
.picker-option:first-child{border-top:none}
.picker-option:hover,.picker-option:focus-visible{background:#f0fdf4;outline:none}
.picker-option span{font-size:12px;color:var(--text-muted)}
.picker-empty{padding:12px;font-size:13px;color:var(--text-muted)}
.picker-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.picker-chip{
  display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:6px 8px 6px 12px;
  border-radius:999px;background:var(--primary-lt);color:var(--primary-dk);font-size:12.5px;font-weight:600;
}
.picker-chip-x{
  width:24px;height:24px;border-radius:50%;border:none;background:rgba(255,255,255,.7);
  color:var(--primary-dk);font-size:15px;line-height:1;cursor:pointer;flex-shrink:0;
}
.picker-chip-x:hover{background:#fff}

/* Forms: page layout */
.form-page{max-width:820px;margin:0 auto;display:flex;flex-direction:column;gap:18px}
.form-section{margin:0}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px}
.form-span-2{grid-column:1/-1}
.form-check{display:flex;align-items:flex-start;gap:10px;font-size:13px;color:var(--text-2);cursor:pointer;margin-bottom:6px}
.form-check input{margin-top:3px;width:18px;height:18px;accent-color:var(--primary)}
.form-actions{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}
.form-inline-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.danger-zone{border-color:#fecaca}
.danger-zone .card-header{border-bottom-color:#fee2e2}

/* Linked students (parent page) */
.link-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,190px) auto;gap:12px;align-items:center;padding:12px 0;border-top:1px solid #f1f5f9}
.link-row:first-of-type{border-top:none;padding-top:0}
.link-main{min-width:0}
.link-name{font-size:14px;font-weight:700;color:var(--text)}
.link-name:hover{color:var(--primary-dk)}
.link-sub{font-size:12px;color:var(--text-muted);margin-top:2px}
.link-rel select{padding:7px 10px;min-height:38px}
.link-add{display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap}

/* Parents on the student profile */
.profile-layout{display:grid;grid-template-columns:300px minmax(0,1fr);gap:20px;align-items:start}
.profile-main{display:flex;flex-direction:column;gap:18px;min-width:0}
.parent-row{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;padding:14px 0;border-top:1px solid #f1f5f9}
.parent-row:first-of-type{border-top:none;padding-top:0}
.parent-main{min-width:0;flex:1 1 220px}
.parent-name{font-size:14.5px;font-weight:700;color:var(--text);display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.parent-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.parent-actions form{margin:0}

/* Phones */
@media(max-width:768px){
  .only-mobile{display:block}
  .only-desktop{display:none !important}
  .hide-sm{display:none}

  .list-toolbar{gap:8px;margin-bottom:14px}
  .lt-search{flex:1 1 100%}
  .lt-filter-toggle{display:inline-flex;flex:0 0 auto;min-height:42px}
  .lt-actions{flex:1 1 auto;display:flex;justify-content:flex-end}
  .lt-actions .btn{flex:1 1 0;justify-content:center;min-width:0}
  .lt-filters{display:none;flex-direction:column;align-items:stretch;background:#fff;border:1px solid var(--border);border-radius:12px;padding:12px;gap:10px}
  .lt-filters.open{display:flex}
  .lt-field{min-width:0}
  .lt-field select{min-width:0;width:100%}
  .lt-reset{align-self:flex-start}

  .person-card{padding:12px 14px}

  .form-grid{grid-template-columns:minmax(0,1fr)}
  .form-page{gap:14px}
  .link-row{grid-template-columns:minmax(0,1fr) auto;}
  .link-rel{grid-column:1/-1}
  .link-rel select{width:100%}
  .link-add>*{flex:1 1 100% !important}
  .link-add .btn{width:100%;justify-content:center}
  .profile-layout{grid-template-columns:minmax(0,1fr)}
  .parent-actions{width:100%}
  .parent-actions .btn{flex:1 1 auto;justify-content:center}
  .parent-actions form{flex:1 1 auto;display:flex}
  .parent-actions form .btn{width:100%}
  .form-actions .btn{flex:1 1 auto;justify-content:center}
  .danger-zone .btn{width:100%;justify-content:center}
}

/* ══════════════════════════════════════════════════════
   ACCESS RIGHTS (teacher profile)
   ══════════════════════════════════════════════════════ */
.access-now{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:18px}
.access-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.access-item{
  display:flex;align-items:flex-start;gap:10px;padding:12px 14px;border:1px solid var(--border);
  border-radius:10px;background:#fff;cursor:pointer;min-width:0;
}
.access-item:hover{border-color:#a7f3d0}
.access-item input{margin-top:3px;width:18px;height:18px;flex-shrink:0;accent-color:var(--primary)}
.access-item span{display:flex;flex-direction:column;gap:2px;min-width:0}
.access-item strong{font-size:13.5px;color:var(--text)}
.access-item small{font-size:12px;color:var(--text-muted);line-height:1.4}
.access-item input:disabled{opacity:.4}
.access-item input:disabled ~ span{opacity:.5}
.access-full{background:#f0fdf4;border-color:#bbf7d0}
.parent-detail{margin-bottom:12px}
.parent-detail-actions{margin-bottom:18px}

@media(max-width:768px){
  .access-grid{grid-template-columns:minmax(0,1fr)}
  .access-form .form-actions .btn{width:100%;justify-content:center}
}

/* Stream list on the teacher profile */
.stream-list{display:flex;flex-direction:column}
.stream-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid #f1f5f9}
.stream-row:first-child{border-top:none;padding-top:0}
.stream-row form{margin:0;flex-shrink:0}

/* Promotion review table: a table on desktop, one card per student on phones */
.promo-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.how-steps{padding-left:20px;display:flex;flex-direction:column;gap:8px;font-size:13.5px;color:var(--text-2)}
.promo-bar{
  position:fixed;left:var(--sidebar-w);right:0;bottom:0;z-index:60;display:flex;align-items:center;justify-content:space-between;
  gap:14px;padding:12px 24px calc(12px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--border);
  box-shadow:0 -6px 20px rgba(15,23,42,.08);flex-wrap:wrap;
}
.promo-bar-text{font-size:13.5px;color:var(--text-2)}
.promo-bar .btn:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}
@media(max-width:768px){
  .promo-summary{grid-template-columns:repeat(2,minmax(0,1fr))}
  .promo-table thead{display:none}
  .promo-table tr{display:block;padding:12px 14px;border-bottom:1px solid #f1f5f9}
  .promo-table td{display:block;padding:4px 0;border:0;white-space:normal}
  .promo-table td[data-label]::before{content:attr(data-label);display:block;font-size:11.5px;font-weight:700;color:var(--text-muted);margin-bottom:3px;text-transform:uppercase;letter-spacing:.04em}
  .promo-bar{left:0;padding:10px 12px calc(10px + env(safe-area-inset-bottom))}
  .promo-bar-text{display:none}
  .promo-bar .btn{width:100%;justify-content:center}
}

/* ══════════════════════════════════════════════════════
   CLASS LIST (screen and print)
   ══════════════════════════════════════════════════════ */
.class-controls{display:flex;gap:14px;align-items:flex-end;flex-wrap:wrap}
.class-cols-form{display:flex;gap:10px;align-items:flex-end;flex:1 1 420px;flex-wrap:wrap}
.class-sheet{background:#fff;border:1px solid var(--border);border-radius:12px;padding:28px 30px;box-shadow:var(--shadow-sm)}
.sheet-head{text-align:center;margin-bottom:18px}
.sheet-school{font-size:20px;font-weight:800;color:var(--text);letter-spacing:-.2px}
.sheet-title{font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--text-2);margin-top:4px}
.sheet-meta{display:flex;justify-content:center;gap:24px;flex-wrap:wrap;margin-top:14px;padding-top:12px;border-top:1px solid var(--border)}
.sheet-meta div{display:flex;flex-direction:column;gap:2px;min-width:120px}
.sheet-meta span{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);font-weight:700}
.sheet-meta strong{font-size:14px;color:var(--text)}
.sheet-table{width:100%;border-collapse:collapse;font-size:13px}
.sheet-table th,.sheet-table td{border:1px solid #94a3b8;padding:6px 8px;text-align:left;vertical-align:middle}
.sheet-table thead th{background:#f1f5f9;font-size:11.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--text)}
.sheet-table tbody td{height:30px}
.sheet-table .c-no{width:44px;text-align:center}
.sheet-table .c-adm{width:150px;font-family:ui-monospace,Consolas,monospace;font-weight:600}
.sheet-table .c-extra{min-width:110px}
.sheet-table tbody tr:nth-child(even) td{background:#fafbfc}
.sheet-empty{text-align:center;color:var(--text-muted);padding:18px !important}
.sheet-foot{margin-top:14px;font-size:11px;color:var(--text-muted);text-align:right}

@media(max-width:768px){
  .class-sheet{padding:18px 12px;overflow-x:auto}
  .sheet-table{min-width:560px}
  .sheet-meta{gap:14px}
}

@media print{
  @page{size:A4;margin:14mm}
  html,body{background:#fff !important}
  .sidebar,.topbar,.no-print,.flash-area,.sidebar-backdrop,.toast-container,.nav-toggle{display:none !important}
  .main{margin:0 !important;width:100% !important}
  .page-content{padding:0 !important}
  .class-sheet{border:none;box-shadow:none;padding:0;border-radius:0;overflow:visible}
  .sheet-table{min-width:0 !important}
  .sheet-table th,.sheet-table td{border-color:#000}
  .sheet-table tbody td{height:24px}
  .sheet-table tbody tr:nth-child(even) td{background:none}
  .sheet-table thead th{background:#e5e7eb !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .sheet-head,.sheet-table tr{break-inside:avoid}
  .sheet-meta{border-top-color:#000}
}

/* Promotion controls on the student profile */
.promo-inline{display:flex;gap:12px;flex-wrap:wrap;align-items:flex-end}
@media(max-width:768px){.promo-inline .btn{width:100%;justify-content:center}}

/* Print: the whole sheet must fit the page. Scroll wrappers are switched off for printing. */
@media print{
  .class-sheet,.class-sheet .table-wrap,.table-wrap,.card,.card-body,.page-content,.main,.app{overflow:visible !important;max-width:none !important}
  .class-sheet .sheet-table{width:100% !important;min-width:0 !important;table-layout:fixed;font-size:10.5pt}
  .sheet-table .c-no{width:36px}
  .sheet-table .c-adm{width:110px}
  .sheet-table .c-extra{min-width:0 !important;width:auto}
  .sheet-table th,.sheet-table td{word-wrap:break-word;overflow-wrap:anywhere}
  .sheet-table thead th{font-size:9.5pt}
  .sheet-title{font-size:11pt}
  .sheet-school{font-size:16pt}
  .sheet-meta{gap:14px}
}

/* Class list headers wrap onto several lines; admission numbers use a plain, unbolded face */
.sheet-table thead th{white-space:normal;vertical-align:bottom}
.sheet-table .c-adm{font-family:'Courier New',Courier,monospace;font-weight:400}
@media print{
  .sheet-table thead th{white-space:normal;word-wrap:break-word}
  .sheet-table .c-adm{font-family:'Courier New',Courier,monospace;font-weight:400}
}
@media print{ .sheet-table .c-no{width:46px;white-space:nowrap} }

/* Class list pages: each page holds --n rows. Printing sizes the rows to fit one A4 portrait page. */
.sheet-page{margin-bottom:22px}
.sheet-running{display:none;font-size:11px;color:var(--text-2);margin-bottom:8px}
@media print{
  @page{size:A4 portrait;margin:10mm}
  .sheet-page{margin:0;padding:0;border:none;box-shadow:none;break-after:page;page-break-after:always}
  .sheet-page:last-of-type{break-after:auto;page-break-after:auto}
  .sheet-running{display:block;margin:0 0 3mm}
  .sheet-page .sheet-table{font-size:9pt;line-height:1.1}
  .sheet-page .sheet-table th,.sheet-page .sheet-table td{padding:0 4px}
  /* 269mm usable height; the first page's heading takes about 58mm; the rest is shared by --n rows */
  .sheet-page .sheet-table tbody tr{height:calc((269mm - 60mm) / var(--n))}
  .sheet-page .sheet-table thead th{padding:2px 4px}
  .sheet-page .sheet-foot{margin-top:2mm}
}

/* Class list printing. Placed last so it overrides the screen and phone rules. Phone rules also
   apply in a narrow print window, so every one that changes table size or position is reset here. */
@media print{
  .sheet-page,.sheet-page *{box-sizing:border-box}
  .sheet-page{width:100% !important;min-width:0 !important;max-width:none !important;overflow:visible !important;padding:0 !important;margin:0 !important;border:none !important;box-shadow:none !important;background:#fff !important}
  .sheet-page .sheet-table{display:table !important;width:100% !important;min-width:0 !important;max-width:none !important;table-layout:fixed !important;font-size:9pt !important;line-height:1.1 !important;margin:0 !important}
  .sheet-page .sheet-table th,.sheet-page .sheet-table td{position:static !important;box-shadow:none !important;white-space:normal !important;overflow-wrap:anywhere !important;padding:0 4px !important;background:transparent !important;height:auto !important;vertical-align:middle !important}
  .sheet-page .sheet-table thead th{background:#e5e7eb !important;padding:2px 4px !important;vertical-align:bottom !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .sheet-page .sheet-table tbody tr{height:calc((269mm - 60mm) / var(--n)) !important;display:table-row !important}
  .sheet-page .sheet-table tbody tr:nth-child(even) td{background:transparent !important}
  .sheet-page .sheet-table .c-no{width:46px !important;white-space:nowrap !important;text-align:center}
  .sheet-page .sheet-table .c-adm{width:110px !important}
  .sheet-page .sheet-table .c-extra{width:auto !important;min-width:0 !important}
  .sheet-page .sheet-head{margin-bottom:4mm}
  .sheet-page .sheet-foot{margin-top:2mm;font-size:8pt}
  .sheet-running{display:block !important}
  .table-wrap{overflow:visible !important;max-width:none !important}
}

/* Print column widths: the name keeps its width and stays on one line; the added columns take the rest */
@media print{
  .sheet-page .sheet-table .c-no{width:11mm !important}
  .sheet-page .sheet-table .c-adm{width:28mm !important;white-space:nowrap !important}
  .sheet-page .sheet-table .c-name{width:62mm !important;white-space:nowrap !important;overflow:hidden !important;text-overflow:clip}
  .sheet-page .sheet-table .c-extra{width:auto !important;white-space:normal !important}
  .sheet-page .sheet-table tbody td{font-size:8pt !important;line-height:3mm !important}
  .sheet-page .sheet-table tbody tr{height:calc((269mm - 66mm) / var(--n)) !important}
}
@media print{
  .sheet-page .sheet-table thead th{overflow-wrap:normal !important;word-break:normal !important;font-size:7.5pt !important;line-height:2.6mm !important}
  .sheet-page .sheet-table .c-adm{width:31mm !important}
}
@media print{
  .sheet-page .sheet-table .c-name{width:52mm !important}
  .sheet-page .sheet-table .c-no{width:10mm !important}
  .sheet-page .sheet-table thead th{font-size:6.5pt !important;line-height:2.4mm !important;padding:2px 2px !important;letter-spacing:0 !important}
  .sheet-page .sheet-table .c-extra{padding:0 2px !important}
}

/* All class lists: each class starts on a new printed page */
@media print{
  .class-group{break-after:page;page-break-after:always}
  .class-group:last-child{break-after:auto;page-break-after:auto}
  .class-group .sheet-page:last-child{break-after:auto;page-break-after:auto}
}

/* Subjects and teaching assignments */
.subject-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-height:260px;overflow-y:auto;padding:4px}
.subject-pick{display:flex;align-items:center;gap:8px;padding:8px 10px;border:1px solid var(--border);border-radius:8px;font-size:13px;cursor:pointer;min-width:0}
.subject-pick input{accent-color:var(--primary);width:16px;height:16px;flex-shrink:0}
.load-bar{height:8px;background:var(--bg-2);border-radius:999px;overflow:hidden;margin:6px 0 4px}
.load-bar>span{display:block;height:100%;background:var(--primary);border-radius:999px}
.load-bar.over>span{background:var(--danger)}
.load-bar.under>span{background:var(--warning)}
@media(max-width:768px){.subject-grid{grid-template-columns:minmax(0,1fr)}}

/* Timetables */
.break-row{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr);gap:10px;align-items:end;margin-bottom:10px}
.break-row label{display:flex;flex-direction:column;gap:4px}
.tt-grid{width:100%;border-collapse:collapse;font-size:12.5px;table-layout:fixed}
.tt-grid th,.tt-grid td{border:1px solid var(--border);padding:6px 6px;text-align:center;vertical-align:middle;min-width:0;overflow-wrap:anywhere}
.tt-grid thead th{background:#f8fafc;font-weight:700}
.tt-grid .tt-time{width:110px;color:var(--text-2);font-size:11.5px;text-align:left;white-space:nowrap}
.tt-grid .tt-period{width:90px;text-align:left;font-weight:700}
.tt-grid .tt-break td{background:#fef9e7;color:#92400e;font-style:italic}
.tt-cell{display:flex;flex-direction:column;gap:2px;align-items:center}
.tt-cell strong{font-size:12.5px}
.tt-cell span{font-size:11px;color:var(--text-muted)}
.tt-cell.empty{color:#cbd5e1}
.tt-edit{margin-top:4px;display:flex;flex-direction:column;gap:4px;width:100%}
.tt-edit select{font-size:11.5px;padding:3px}
@media(max-width:768px){.break-row{grid-template-columns:minmax(0,1fr)}.tt-wrap{overflow-x:auto}.tt-grid{min-width:720px}}
.tt-room{color:var(--text-2);font-size:11px}
.tt-jump{display:flex;flex-wrap:wrap;gap:6px}.tt-class-block{margin-bottom:22px;scroll-margin-top:80px}@media print{.tt-class-block{break-after:page;page-break-after:always;box-shadow:none}.tt-class-block:last-of-type{break-after:auto}}

.tt-dragging{opacity:.4}
.tt-over{outline:2px dashed var(--primary);outline-offset:-4px;background:#f0fdf4}
[draggable=true]{cursor:grab}
[draggable=true]:active{cursor:grabbing}

/* Timetable with times across the top and days down the side */
.tt-by-time th.tt-dayhead,.tt-by-time th.tt-dayname{width:96px;text-align:left;white-space:nowrap}
.tt-by-time thead th{vertical-align:top;font-size:11.5px}
.tt-by-time .tt-time-head{font-weight:700;color:var(--text);font-size:11px}
.tt-by-time .tt-period-head{font-weight:600;color:var(--text-2);font-size:10.5px;margin-top:2px}
.tt-by-time th.tt-breakhead{width:58px;background:#fef9e7;color:#92400e}
.tt-by-time .tt-break-cell{background:#fef9e7;color:#92400e;font-style:italic;text-align:center;vertical-align:middle;width:58px}
.tt-by-time .tt-break-cell span{writing-mode:vertical-rl;transform:rotate(180deg);font-size:10.5px;white-space:nowrap;display:inline-block}
.tt-by-time td{height:72px}
@media(max-width:768px){.tt-by-time{min-width:900px}}

.tt-by-time th.tt-breakhead{height:120px;padding:4px 2px}
.tt-by-time th.tt-breakhead .tt-time-head,.tt-by-time th.tt-breakhead .tt-period-head{writing-mode:vertical-rl;transform:rotate(180deg);white-space:nowrap;display:inline-block;margin:0 auto;font-size:10px}
.tt-by-time th.tt-breakhead .tt-period-head{margin-top:0;margin-right:2px}
.tt-by-time th.tt-breakhead > div{display:flex;justify-content:center;gap:4px;height:100%}
.tt-code{font-weight:700;letter-spacing:.3px}

/* Searchable dropdowns */
.combo { position: relative; min-width: 0; width: 100%; }
.combo select.combo-hidden { display: none !important; }
.combo-input { width: 100%; }
.combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; max-height: 260px; overflow-y: auto;
  background: var(--bg-1, #fff); border: 1px solid var(--border, #d6dde6); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); margin-top: 4px; }
.combo-item { display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 12px; border: 0;
  background: transparent; color: var(--text-1, #111); font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.combo-item:hover, .combo-item:focus { background: var(--bg-2, #f1f5f9); outline: none; }
.combo-item.is-on { font-weight: 700; color: var(--primary, #059669); }
.combo-empty { padding: 12px; color: var(--text-muted, #64748b); font-size: 14px; }
.tt-time-txt{display:block;font-size:10px;color:var(--text-muted);font-weight:400}
