:root{
  --ink:#10233f;
  --muted:#64748b;
  --line:#d9e7ee;
  --paper:#ffffff;
  --soft:#f4f8fb;
  --teal:#0b6b5e;
  --teal-dark:#063f39;
  --blue:#2156a5;
  --gold:#c78316;
  --danger:#b42318;
  --shadow:0 18px 45px rgba(16,35,63,.12);
}

*{box-sizing:border-box}

[hidden]{display:none!important}

html{scroll-behavior:smooth}

body{
  margin:0;
  min-height:100vh;
  font-family:Arial,Helvetica,sans-serif;
  background:#e9f1f4;
  color:var(--ink);
}

a{color:inherit}

img{max-width:100%;display:block}

button,input{font:inherit}

.auth-gate{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
  background:
    linear-gradient(90deg,rgba(5,26,35,.78),rgba(6,63,57,.58)),
    url("../../assets/happytutor.PNG") center/cover no-repeat;
}

.login-panel{
  width:min(680px,100%);
  background:rgba(255,255,255,.96);
  border:1px solid rgba(255,255,255,.65);
  border-radius:8px;
  box-shadow:var(--shadow);
  padding:28px;
}

.brand-row{display:flex;gap:16px;align-items:center}
.brand-row img{width:72px;height:72px;object-fit:contain}
.eyebrow{margin:0 0 8px;color:var(--gold);font-weight:800;text-transform:uppercase;font-size:.78rem;letter-spacing:0}
.brand-row h1,.topbar h1,.hero h2,.section-head h2{margin:0;line-height:1.05}
.login-copy{color:#36526a;font-size:1.05rem}

.pin-form label{font-weight:800}
.pin-entry{display:flex;gap:10px;margin-top:8px}
.pin-entry input{
  flex:1;
  min-width:0;
  border:1px solid var(--line);
  border-radius:8px;
  padding:14px 16px;
  background:white;
}
.pin-entry button,.primary-link{
  border:0;
  border-radius:8px;
  padding:14px 18px;
  background:var(--teal);
  color:white;
  font-weight:800;
  text-decoration:none;
  cursor:pointer;
}
.auth-message{min-height:24px;color:var(--muted);font-weight:700}
.auth-message.error{color:var(--danger)}
.auth-message.ok{color:var(--teal)}
.login-actions,.hero-actions,.top-actions{display:flex;gap:10px;flex-wrap:wrap}
.quiet-button,.secondary-link,.icon-button{
  border:1px solid var(--line);
  border-radius:8px;
  padding:12px 14px;
  background:#f8fafc;
  color:var(--ink);
  font-weight:800;
  text-decoration:none;
  cursor:pointer;
}

.app-shell{min-height:100vh;display:grid;grid-template-columns:280px 1fr}
.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  padding:18px;
  background:#092621;
  color:white;
  display:flex;
  flex-direction:column;
  gap:22px;
}
.identity{display:flex;gap:12px;align-items:center;text-decoration:none}
.identity img{width:52px;height:52px;object-fit:contain;background:white;border-radius:8px;padding:4px}
.identity small{display:block;color:#b7ccc8}
.side-nav{display:grid;gap:8px}
.side-nav a{
  text-decoration:none;
  padding:13px 14px;
  border-radius:8px;
  color:#d7eeea;
  font-weight:800;
}
.side-nav a.active,.side-nav a:hover{background:#124d44;color:white}
.sync-card{
  margin-top:auto;
  display:flex;
  gap:10px;
  align-items:center;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.12);
  border-radius:8px;
  padding:14px;
}
.sync-card small{display:block;color:#c5d8d4}
.sync-dot{width:12px;height:12px;border-radius:50%;background:var(--gold);flex:0 0 auto}
.sync-dot.ok{background:#22c55e}
.sync-dot.offline{background:#38bdf8}

.workspace{padding:26px;max-width:1320px;width:100%;margin:0 auto}
.topbar{display:flex;justify-content:space-between;align-items:center;gap:18px;margin-bottom:20px}
.topbar h1{font-size:clamp(1.45rem,3vw,2.6rem)}
.view{display:none}
.active-view{display:block}

.hero{
  display:grid;
  grid-template-columns:minmax(0,1.05fr) minmax(280px,.95fr);
  gap:24px;
  align-items:center;
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:8px;
  padding:26px;
  box-shadow:var(--shadow);
}
.hero h2{font-size:clamp(2rem,4.6vw,4.2rem);max-width:900px}
.hero p{color:#426071;font-size:1.08rem}
.hero img{width:100%;height:360px;object-fit:cover;border-radius:8px;border:1px solid var(--line)}

.metrics,.learning-grid,.test-grid,.tool-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
  gap:16px;
  margin-top:18px;
}
.metrics article,.lesson-card,.module-list a,.tool-grid article,.note-band{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:8px;
  padding:18px;
}
.metrics strong{display:block;font-size:1.65rem;color:var(--teal)}
.metrics span,.lesson-card span{color:var(--muted);font-weight:800}
.lesson-card img,.tool-grid img{width:100%;height:220px;object-fit:contain;background:#f8fafc;border-radius:8px;margin-bottom:12px;border:1px solid var(--line)}
.lesson-card h3,.tool-grid h3{margin:8px 0 12px;font-size:1.2rem}
.lesson-card a,.module-list a{
  display:block;
  color:var(--blue);
  font-weight:800;
  text-decoration:none;
}
.section-head{margin:8px 0 18px}
.section-head h2{font-size:clamp(1.8rem,4vw,3rem)}
.module-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px}
.note-band{margin-top:16px;border-left:6px solid var(--gold);font-weight:800}
.table-wrap{overflow:auto;background:var(--paper);border-radius:8px;border:1px solid var(--line)}
table{border-collapse:collapse;width:100%}
th,td{padding:13px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}
th{background:#eef7f5;color:var(--teal-dark)}

.test-card{background:var(--paper);border:1px solid var(--line);border-radius:8px;padding:18px;display:flex;flex-direction:column;gap:12px}
.test-card strong{font-size:1.12rem}
.test-card a{margin-top:auto;color:var(--blue);font-weight:800;text-decoration:none}
.update-notice{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:50;
  width:min(420px,calc(100vw - 36px));
  background:white;
  border:1px solid var(--line);
  border-left:6px solid var(--teal);
  border-radius:8px;
  box-shadow:var(--shadow);
  padding:16px;
  display:grid;
  gap:10px;
}
.update-notice span{color:var(--muted)}
.update-notice button{
  border:1px solid var(--line);
  border-radius:8px;
  padding:10px 12px;
  font-weight:800;
  cursor:pointer;
  background:#f8fafc;
}
.update-notice #applyUpdate{background:var(--teal);color:white;border-color:var(--teal)}

@media(max-width:900px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:static;height:auto}
  .side-nav{grid-template-columns:repeat(5,minmax(0,1fr));overflow:auto}
  .side-nav a{text-align:center;white-space:nowrap}
  .hero{grid-template-columns:1fr}
  .hero img{height:260px}
}

@media(max-width:620px){
  .auth-gate{padding:14px}
  .login-panel,.hero{padding:18px}
  .brand-row{align-items:flex-start}
  .pin-entry{display:grid}
  .workspace{padding:16px}
  .topbar{align-items:flex-start;flex-direction:column}
  .side-nav{grid-template-columns:repeat(2,minmax(0,1fr))}
}
