:root{
  --navy:#1D2B53;
  --navy-dark:#141D3B;
  --gold:#F4A300;
  --teal:#2EC4B6;
  --bg:#F7F8FA;
  --ink:#1F2933;
  --ink-soft:#6B7684;
  --line:#E4E7EC;
}

*{box-sizing:border-box;}
html,body{margin:0; padding:0;}
body{
  font-family:'Inter', sans-serif;
  color:var(--ink);
  background:var(--bg);
  min-height:100vh;
}
h1,h2,h3,.brand-mark{font-family:'Poppins', sans-serif;}

.layout{
  display:flex;
  min-height:100vh;
}

/* SIDEBAR - 1/3 */
.sidebar{
  flex:0 0 33.333%;
  max-width:33.333%;
  background:linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color:#EDEFF7;
  display:flex;
  flex-direction:column;
}

.brand{
  padding:28px 26px 20px 26px;
  border-bottom:1px solid rgba(237,239,247,0.12);
}
.brand-mark{
  font-size:22px;
  font-weight:700;
  color:#fff;
  letter-spacing:.01em;
}
.brand-mark em{
  font-style:normal;
  color:var(--gold);
}

.user-box{
  padding:16px 26px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.user-box .auth-role-badge{color:var(--teal);}
.user-name{
  font-size:14px;
  font-weight:600;
  color:#fff;
  margin-top:2px;
}

.sidebar-foot .logout-link{
  display:block;
  color:#C7CDE0;
  text-decoration:none;
  font-size:13px;
  font-weight:600;
}
.sidebar-foot .logout-link:hover{color:#fff;}

/* Manage Users - inline reset password row */
.reset-row{display:none;}
.reset-row.open{display:table-row;}
.reset-row td{background:#FAFAFC; padding:14px 16px !important;}
.reset-form{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.reset-form input{
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:7px;
  font-family:'Inter', sans-serif;
  font-size:13.5px;
  min-width:180px;
}

/* Checkbox grids (assign-instructor / assign-parent) */
.checkgrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  max-height:260px;
  overflow-y:auto;
  border:1px solid var(--line);
  border-radius:8px;
  padding:12px;
  background:#FBFBFD;
}
.checkgrid label{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13.5px;
  font-weight:400;
  color:var(--ink);
  margin:0;
}
@media (max-width:600px){
  .checkgrid{grid-template-columns:1fr;}
}

.menu{padding:14px 0; flex:1;}
.menu ul{list-style:none; margin:0; padding:0;}
.menu li{margin:0;}
.menu-item{
  display:block;
  padding:13px 26px;
  color:#C7CDE0;
  text-decoration:none;
  font-size:14.5px;
  font-weight:500;
  border-left:3px solid transparent;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}
.menu-item:hover{
  background:rgba(255,255,255,0.06);
  color:#fff;
}
.menu-item.active{
  background:rgba(0,0,0,0.18);
  border-left:3px solid var(--gold);
  color:#fff;
}

/* Submenu (View group) */
.submenu-toggle{
  width:100%;
  background:none;
  border:none;
  border-left:3px solid transparent;
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-family:'Inter', sans-serif;
  cursor:pointer;
  text-align:left;
}
.submenu-toggle .chevron{
  transition:transform .18s ease;
  flex-shrink:0;
}
.submenu-toggle[aria-expanded="true"] .chevron{
  transform:rotate(180deg);
}
.submenu{
  list-style:none;
  margin:0;
  padding:0;
  max-height:0;
  overflow:hidden;
  transition:max-height .22s ease;
  background:rgba(0,0,0,0.14);
}
.submenu.open{
  max-height:400px;
}
.submenu-item{
  display:block;
  padding:10px 26px 10px 44px;
  color:#BCC6D4;
  text-decoration:none;
  font-size:13.5px;
  font-weight:500;
  border-left:3px solid transparent;
  transition:background .15s ease, color .15s ease;
}
.submenu-item:hover{
  background:rgba(255,255,255,0.05);
  color:#fff;
}
.submenu-item.active{
  color:#fff;
  border-left:3px solid var(--gold);
  background:rgba(0,0,0,0.16);
}

/* CONTENT - 2/3 */
.content{
  flex:0 0 66.667%;
  max-width:66.667%;
  padding:48px 52px;
}
.content h3{
  font-size:30px;
  font-weight:700;
  margin:0 0 8px 0;
  color:var(--navy);
}
.content-sub{
  font-size:15px;
  color:var(--ink-soft);
  margin:0;
}

/* MOBILE TOGGLE */
.menu-toggle{
  display:none;
  position:fixed;
  top:16px;
  right:16px;
  z-index:20;
  width:42px;
  height:42px;
  border:none;
  border-radius:8px;
  background:var(--navy);
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  cursor:pointer;
}
.menu-toggle span{
  width:20px;
  height:2px;
  background:#fff;
  border-radius:2px;
}

/* RESPONSIVE */
@media (max-width: 860px){
  .layout{flex-direction:column;}
  .menu-toggle{display:flex;}

  .sidebar{
    max-width:100%;
    flex:0 0 auto;
    position:fixed;
    top:0; left:0; bottom:0;
    width:78%;
    max-width:320px;
    transform:translateX(-100%);
    transition:transform .25s ease;
    z-index:15;
    box-shadow:6px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.open{transform:translateX(0);}

  .content{
    max-width:100%;
    flex:1;
    padding:80px 22px 40px 22px;
  }
  .content h3{font-size:24px;}
}

:focus-visible{outline:2px solid var(--teal); outline-offset:2px;}

/* ===== FORMS ===== */
.form-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  padding:28px 30px;
  margin-top:26px;
  max-width:720px;
  box-shadow:0 1px 2px rgba(29,43,83,0.05), 0 8px 24px rgba(29,43,83,0.05);
}

.form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px 20px;
}

.field{margin-bottom:18px;}
.field label{
  display:block;
  font-size:13px;
  font-weight:600;
  color:var(--ink);
  margin-bottom:7px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="date"],
.field select,
.field textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:8px;
  font-family:'Inter', sans-serif;
  font-size:14.5px;
  color:var(--ink);
  background:#FBFBFD;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus{
  outline:none;
  border-color:var(--teal);
  box-shadow:0 0 0 3px rgba(46,196,182,0.15);
  background:#fff;
}
.field textarea{resize:vertical;}
.field-hint{
  font-size:12px;
  color:var(--ink-soft);
  margin:6px 0 0 0;
}

/* Photo upload */
.photo-field{margin-bottom:24px;}
.photo-upload{
  display:flex;
  align-items:center;
  gap:18px;
  flex-wrap:wrap;
}
.photo-preview{
  width:76px;
  height:76px;
  border-radius:50%;
  background:#EEF0F5;
  border:2px dashed var(--line);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex-shrink:0;
}
.photo-preview span{
  font-size:10.5px;
  color:var(--ink-soft);
  text-align:center;
  padding:0 6px;
}
.photo-preview img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.form-actions{
  display:flex;
  justify-content:flex-end;
  gap:12px;
  margin-top:6px;
  padding-top:18px;
  border-top:1px solid var(--line);
}
.btn{
  font-family:'Inter', sans-serif;
  font-weight:600;
  font-size:14px;
  border:none;
  border-radius:8px;
  padding:10px 20px;
  cursor:pointer;
  transition:transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--navy); color:#fff;}
.btn-primary:hover{background:var(--navy-dark);}
.btn-ghost{background:transparent; color:var(--ink-soft); border:1px solid var(--line);}
.btn-ghost:hover{border-color:var(--ink-soft); color:var(--ink);}

@media (max-width:600px){
  .form-grid{grid-template-columns:1fr;}
  .form-card{padding:22px 18px;}
}

/* Validation + alerts */
.req{color:var(--gold); margin-left:2px;}
.field.has-error input,
.field.has-error select,
.photo-field.has-error .photo-preview{
  border-color:#D0483C;
}
.field-error{
  font-size:12.5px;
  color:#D0483C;
  margin:6px 0 0 0;
}
.alert{
  padding:13px 16px;
  border-radius:9px;
  font-size:14px;
  font-weight:500;
  margin-top:20px;
  max-width:720px;
}
.alert-success{
  background:rgba(46,196,182,0.12);
  color:#1B7A70;
  border:1px solid rgba(46,196,182,0.35);
}
.alert-error{
  background:rgba(208,72,60,0.1);
  color:#B03B30;
  border:1px solid rgba(208,72,60,0.3);
}

/* Attendance list */
.attendance-list{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:22px;
  max-width:820px;
}
.attendance-row{
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  padding:16px 18px;
  display:flex;
  align-items:center;
  gap:18px;
  flex-wrap:wrap;
  box-shadow:0 1px 2px rgba(29,43,83,0.04);
}
.attendance-info{flex:1 1 260px; min-width:220px;}
.attendance-student{font-weight:600; font-size:15px; color:var(--ink);}
.attendance-meta{font-size:12.5px; color:var(--ink-soft); margin-top:3px;}
.attendance-remark{flex:1 1 200px; min-width:180px;}
.attendance-remark label{
  display:block;
  font-size:11.5px;
  font-weight:600;
  color:var(--ink-soft);
  margin-bottom:4px;
}
.attendance-remark input{
  width:100%;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:7px;
  font-family:'Inter', sans-serif;
  font-size:13.5px;
  background:#FBFBFD;
}
.attendance-remark input:focus{
  outline:none;
  border-color:var(--teal);
  box-shadow:0 0 0 3px rgba(46,196,182,0.15);
  background:#fff;
}
@media (max-width:600px){
  .attendance-row{flex-direction:column; align-items:stretch;}
}

/* ===== VIEW / LIST TABLES ===== */
.list-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  margin-top:22px;
  overflow-x:auto;
  box-shadow:0 1px 2px rgba(29,43,83,0.05), 0 8px 24px rgba(29,43,83,0.05);
}
.list-table{width:100%; border-collapse:collapse; min-width:640px;}
.list-table thead th{
  text-align:left;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:var(--ink-soft);
  font-weight:600;
  padding:13px 16px;
  border-bottom:1px solid var(--line);
  white-space:nowrap;
}
.list-table tbody td{
  padding:12px 16px;
  font-size:13.5px;
  color:var(--ink);
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.list-table tbody tr:last-child td{border-bottom:none;}
.list-table tbody tr:hover{background:rgba(29,43,83,0.02);}
.list-table td.actions{white-space:nowrap; text-align:right;}

.avatar{
  width:36px; height:36px; border-radius:50%;
  object-fit:cover; background:#EEF0F5;
  border:1px solid var(--line);
  display:block;
}
.avatar-placeholder{
  width:36px; height:36px; border-radius:50%;
  background:#EEF0F5; border:1px solid var(--line);
  display:flex; align-items:center; justify-content:center;
  font-size:10px; color:var(--ink-soft);
}

.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:20px;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.03em;
}
.badge-open{background:rgba(244,163,0,0.15); color:#A5730A;}
.badge-done{background:rgba(46,196,182,0.16); color:#1B7A70;}

.action-btn{
  border:none;
  background:none;
  cursor:pointer;
  font-family:'Inter', sans-serif;
  font-size:12.5px;
  font-weight:600;
  padding:6px 10px;
  border-radius:6px;
}
.action-edit{color:var(--navy);}
.action-edit:hover{background:rgba(29,43,83,0.08);}
.action-delete{color:#D0483C;}
.action-delete:hover{background:rgba(208,72,60,0.08);}

.link-cell{
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:inline-block;
  color:var(--navy);
}

.empty-list{
  padding:50px 20px;
  text-align:center;
  color:var(--ink-soft);
  font-size:14px;
}

.form-back{
  display:inline-block;
  font-size:13px;
  font-weight:600;
  color:var(--ink-soft);
  text-decoration:none;
  margin-bottom:14px;
}
.form-back:hover{color:var(--ink);}

/* ===== AUTH PAGES (login / setup) ===== */
.auth-body{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
  padding:20px;
  background:linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 60%);
}
.auth-card{
  background:#fff;
  border-radius:16px;
  padding:36px 34px;
  width:100%;
  max-width:400px;
  box-shadow:0 20px 60px rgba(0,0,0,0.25);
}
.auth-card h3{margin:0 0 6px 0; font-size:22px; color:var(--navy);}
.auth-card code{
  background:#F1F2F6; padding:2px 6px; border-radius:4px; font-size:12.5px;
}
.auth-role-badge{
  display:inline-block;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.05em;
  color:var(--teal);
  margin-bottom:4px;
}
