:root {
  --navy: #1B2A4A;
  --navy-light: #2E4066;
  --paper: #FAF8F3;
  --card: #FFFFFF;
  --ink: #22262E;
  --teal: #2F7A6F;
  --teal-soft: #E4F0EC;
  --amber: #C98A1E;
  --amber-soft: #FBF0DC;
  --coral: #C4515C;
  --coral-soft: #FBE7E9;
  --blue: #5B8FDB;
  --blue-soft: #E7EEFB;
  --line: #E6E1D6;
  --muted: #8A8F98;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; }
.boot { display:flex; align-items:center; justify-content:center; height:100vh; color:var(--muted); font-size:14px; }

/* ---- auth screen ---- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 28px; width: 380px; max-width: 100%;
}
.auth-logo { display:flex; align-items:center; gap:10px; margin-bottom: 22px; font-weight:800; font-size:17px; color: var(--navy); }
.auth-logo .dot { width:34px; height:34px; border-radius:10px; background:var(--navy); color:#fff; display:flex; align-items:center; justify-content:center; font-size:16px; }
.auth-tabs { display:flex; gap:6px; background:var(--paper); padding:4px; border-radius:10px; margin-bottom:20px; }
.auth-tab { flex:1; padding:9px; text-align:center; border-radius:8px; cursor:pointer; font-size:13px; font-weight:700; color: var(--muted); }
.auth-tab.active { background:#fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.role-pick { display:flex; gap:10px; margin-bottom: 4px; }
.role-opt { flex:1; border:1.5px solid var(--line); border-radius:10px; padding:12px; text-align:center; cursor:pointer; font-size:12.5px; font-weight:700; color:var(--muted); }
.role-opt.active { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }

.field { display:flex; flex-direction:column; gap:5px; margin-bottom:14px; }
.field label { font-size:12px; color: var(--muted); font-weight:700; }
.field input, .field select {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); font-size: 13.5px; outline: none; background:#fff;
}
.field input:focus, .field select:focus { border-color: var(--teal); }

.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  font-size: 13.5px; font-weight: 700; padding: 10px 16px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--navy); color: #fff; width: 100%;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn.teal { background: var(--teal); }
.btn.danger { background: var(--coral-soft); color: var(--coral); }
.btn.sm { width:auto; padding:7px 12px; font-size:12.5px; }

.error-box { background: var(--coral-soft); color: var(--coral); font-size:12.5px; padding:9px 12px; border-radius:9px; margin-bottom:14px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 14px; text-align:center; }
.hint a { color: var(--teal); cursor:pointer; font-weight:700; }

/* ---- shell ---- */
.shell { display:flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--navy); color:#fff; flex-shrink:0; padding: 20px 14px;
  display:flex; flex-direction:column; position: sticky; top:0; height:100vh;
}
.sidebar .brand { display:flex; align-items:center; gap:8px; padding: 0 6px 20px; border-bottom:1px solid var(--navy-light); margin-bottom:16px; font-weight:800; font-size:15px; }
.navitem {
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px; cursor:pointer;
  font-size:13px; font-weight:600; color:#D9DEEA; margin-bottom:3px;
}
.navitem.active { background:#fff; color: var(--navy); }
.navitem svg { flex-shrink:0; }
.sidebar .foot { margin-top:auto; font-size:11px; color:#8792AC; padding: 10px 6px 0; border-top:1px solid var(--navy-light); }
.sidebar .foot button { background:none; border:none; color:#D9DEEA; font-size:12px; cursor:pointer; padding: 8px 0; font-weight:700; }

.main { flex:1; padding: 26px 30px; max-width: 1180px; margin: 0 auto; width:100%; }
.pagehead { display:flex; align-items:flex-end; justify-content:space-between; margin-bottom:20px; gap: 12px; flex-wrap: wrap;}
.pagehead h1 { font-size:20px; font-weight:800; margin:0; }
.pagehead p { font-size:12.5px; color:var(--muted); margin: 4px 0 0; }

.card { background: var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; }
.empty { padding: 36px 12px; text-align:center; color: var(--muted); font-size:13px; }

.class-chip { padding:8px 14px; border-radius:20px; border:1px solid var(--line); background:#fff; font-size:12.5px; font-weight:600; cursor:pointer; }
.class-chip.active { background: var(--navy); color:#fff; border-color: var(--navy); }
.chiprow { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:18px; align-items:center; }

.row { display:flex; align-items:center; gap:12px; padding:9px 12px; background: var(--paper); border-radius:10px; margin-bottom:6px; }
.avatar { width:32px; height:32px; border-radius:50%; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex-shrink:0; }

table.timetable { width:100%; border-collapse: collapse; min-width: 680px; }
table.timetable th { padding:8px; font-size:12.5px; font-weight:700; color:var(--navy); border-bottom:2px solid var(--line); }
table.timetable td { border:1px solid var(--line); padding:6px; vertical-align:top; height:58px; }
.tcell { width:100%; height:100%; min-height:46px; border-radius:8px; border:none; cursor:pointer; padding:6px; text-align:right; background:transparent; }
.tcell.filled { background: var(--teal-soft); }
.tcell .sub { font-size:12.5px; font-weight:700; color: var(--teal); }
.tcell .meta { font-size:10.5px; color:var(--muted); }

.modal-overlay { position:fixed; inset:0; background: rgba(27,42,74,.35); display:flex; align-items:center; justify-content:center; z-index:50; padding:16px; }
.modal { background:#fff; border-radius:16px; padding:22px; width:400px; max-width:94vw; max-height:88vh; overflow-y:auto; }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.modal-head h3 { font-size:15px; font-weight:800; margin:0; }
.modal-close { border:none; background: var(--paper); border-radius:8px; padding:6px; cursor:pointer; }

.status-btn { font-size:11.5px; font-weight:700; padding:6px 11px; border-radius:8px; cursor:pointer; border:1px solid var(--line); background:#fff; color: var(--muted); }
.status-btn.on { border-width: 1.5px; }

.chatwrap { display:grid; grid-template-columns: 220px 1fr; gap:16px; height: 540px; }
.chatlist { overflow-y:auto; padding:10px !important; }
.chatlist .row { cursor:pointer; }
.chatlist .row.active { background: var(--teal-soft); }
.chatmain { display:flex; flex-direction:column; }
.bubbles { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:8px; padding: 4px 2px; }
.bubble { max-width:70%; padding:8px 12px; border-radius:12px; font-size:12.5px; }
.bubble.me { align-self:flex-start; background: var(--navy); color:#fff; }
.bubble.them { align-self:flex-end; background: var(--teal-soft); }
.chat-inputrow { display:flex; gap:8px; margin-top:10px; }
.chat-inputrow input { flex:1; }

.join-code { font-family: monospace; font-size: 18px; font-weight:800; letter-spacing: 3px; background: var(--amber-soft); color: var(--amber); padding: 8px 14px; border-radius: 10px; display:inline-block; }

.stat-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap:14px; margin-bottom:22px; }
.stat-card { padding: 16px 18px !important; }
.stat-val { font-size:26px; font-weight:800; }
.stat-lbl { font-size:12.5px; color: var(--muted); margin-top:4px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width:100%; height:auto; position:relative; flex-direction:row; overflow-x:auto; padding:10px; gap:4px;}
  .sidebar .brand, .sidebar .foot { display:none; }
  .navitem { flex-direction:column; gap:3px; font-size:10.5px; padding:8px 10px; white-space:nowrap; }
  .main { padding: 16px; }
  .chatwrap { grid-template-columns: 1fr; height:auto; }
  .chatlist { display:flex; overflow-x:auto; gap:6px; }
}
