:root{
  --bg:#f4f7fb;
  --panel:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --line:#e5e7eb;
  --primary:#1d4ed8;
  --primary-dark:#1e40af;
  --secondary:#4b5563;
  --ok:#166534;
  --warn:#92400e;
  --err:#b91c1c;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:Inter,Arial,Helvetica,sans-serif;
  background:linear-gradient(180deg,#f8fbff 0%,#f4f7fb 100%);
  color:var(--text);
  min-height:100vh;
}
button,input,select{font:inherit}
button{
  border:0;
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
  background:var(--primary);
  color:#fff;
}
button:hover{background:var(--primary-dark)}
button.secondary{background:var(--secondary)}
button.secondary:hover{filter:brightness(.95)}
button.ghost{background:#fff;color:var(--primary);border:1px solid #bfdbfe}
input,select{
  width:100%;
  border:1px solid var(--line);
  border-radius:12px;
  padding:11px 12px;
  background:#fff;
}
input:focus,select:focus{
  outline:none;
  border-color:#93c5fd;
  box-shadow:0 0 0 4px rgba(147,197,253,.22);
}
.auth-gate{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(15,23,42,.18);
  backdrop-filter:blur(4px);
  z-index:9999;
}
.auth-gate.open{display:flex}
.auth-card{
  width:min(420px,100%);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:20px;
  box-shadow:0 18px 40px rgba(15,23,42,.12);
  padding:24px;
}
.auth-card h1{margin:0 0 8px 0}
.auth-subtitle{margin:0 0 18px 0;color:var(--muted)}
.field-label{display:block;margin:12px 0 6px 0;font-size:13px;color:var(--muted)}
.auth-actions{margin-top:16px}
.status{margin-top:14px;padding:12px 14px;border-radius:12px}
.status.ok{background:#ecfdf5;color:var(--ok)}
.status.warn{background:#fffbeb;color:var(--warn)}
.status.err{background:#fef2f2;color:var(--err)}
.app-shell-hidden{display:none}
.topbar{
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:flex-start;
  padding:20px 24px;
}
.app-title{margin:0}
.app-subtitle{margin:6px 0 0 0;color:var(--muted)}
.version-pill{
  display:inline-block;
  margin-left:8px;
  padding:4px 10px;
  border-radius:999px;
  background:#eff6ff;
  color:var(--primary);
  font-size:13px;
  vertical-align:middle;
}
.session-box{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px 16px;
  min-width:260px;
}
.muted{color:var(--muted)}
.layout{
  display:grid;
  grid-template-columns:240px 1fr;
  gap:18px;
  padding:0 24px 24px 24px;
}
.sidebar{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  height:fit-content;
}
.nav-btn{text-align:left;background:#eef2ff;color:#1f2937}
.nav-btn:hover{background:#dbeafe;color:var(--primary)}
.nav-btn.active{background:var(--primary);color:#fff}
.content{min-width:0}
.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:20px;
  box-shadow:0 10px 28px rgba(15,23,42,.05);
}
.section-view{display:none}
.section-view.active{display:block}
.info-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  margin-top:18px;
}
.info-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
  background:#fafcff;
}
.info-card h3{margin-top:0}
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:flex-end;
}
.control-col{min-width:180px}
.control-col.grow{flex:1}
.table-wrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
}
table{
  width:100%;
  border-collapse:collapse;
}
th,td{
  padding:10px 8px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
}
th{
  background:#f9fafb;
  position:sticky;
  top:0;
}
.badge{
  display:inline-block;
  padding:3px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
}
.badge.active{background:#dcfce7;color:#166534}
.badge.archived{background:#f3f4f6;color:#374151}
.row-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
@media (max-width:980px){
  .layout{grid-template-columns:1fr}
  .topbar{flex-direction:column}
  .info-grid{grid-template-columns:1fr}
}

.grid-two{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}
.days{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:12px;
}
.day-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background:#fff;
}
.lesson-card{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  margin-bottom:10px;
  background:#fafcff;
}
.lesson-actions{
  margin-top:8px;
}
.selected-row{
  background:#e0f2fe !important;
}
.group-editor-box{
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  max-height:520px;
  overflow:auto;
  padding:12px;
}
.group-editor-row{
  display:grid;
  grid-template-columns:1.2fr 1fr 180px;
  gap:10px;
  align-items:center;
  padding:10px 0;
  border-bottom:1px solid var(--line);
}
.small{font-size:12px}
.field-label.compact{
  margin:0 0 4px 0;
  font-size:12px;
}
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
}
.modal-backdrop.open{display:flex}
.modal-card{
  width:min(760px,92vw);
  background:#fff;
  border-radius:18px;
  padding:20px;
  box-shadow:0 18px 42px rgba(0,0,0,.22);
}
.modal-top{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
}
.grid-form{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
  margin-top:16px;
}
.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:18px;
}
@media (max-width:1200px){
  .days{grid-template-columns:repeat(3,1fr)}
}
@media (max-width:980px){
  .grid-two{grid-template-columns:1fr}
  .days{grid-template-columns:repeat(2,1fr)}
  .group-editor-row{grid-template-columns:1fr}
  .grid-form{grid-template-columns:1fr}
}
@media (max-width:640px){
  .days{grid-template-columns:1fr}
}


.group-editor-occurrences{
  margin-top:8px;
  padding-top:8px;
  border-top:1px dashed var(--line);
  line-height:1.5;
}
.group-number-pill{
  display:inline-block;
  padding:3px 9px;
  border-radius:999px;
  background:#dbeafe;
  color:#1d4ed8;
  font-weight:700;
}

.split-panels{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  margin-top:18px;
}
.subhead{
  margin:0 0 10px 0;
  font-size:16px;
}
.mini-list{
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  min-height:120px;
  padding:10px;
}
.mini-item{
  border:1px solid var(--line);
  border-radius:12px;
  background:#fafcff;
  padding:10px;
  margin-bottom:10px;
}
.mini-item:last-child{margin-bottom:0}
.mini-item-actions{
  margin-top:8px;
}
@media (max-width:980px){
  .split-panels{grid-template-columns:1fr}
}

.modal-card-narrow{
  width:min(560px,92vw);
}

.student-days .day-card{
  min-width:0;
}

.student-plan-empty{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:92px;
  border:1px dashed var(--line);
  border-radius:12px;
  background:#fff;
  color:var(--muted);
  margin-bottom:10px;
}

.lesson-card.compact-card,
.student-tile{
  position:relative;
  padding:8px 10px;
  margin-bottom:8px;
}

.lesson-card.compact-card .teacher-add-btn,
.student-tile .tile-delete-btn{
  position:absolute;
  top:8px;
  right:8px;
  z-index:2;
}

.teacher-add-btn,
.tile-delete-btn{
  padding:4px 8px;
  font-size:12px;
  border-radius:999px;
}

.lesson-card.compact-card .tile-top,
.student-tile .tile-top{
  display:flex;
  align-items:center;
  gap:8px;
  padding-right:66px;
  margin-bottom:8px;
}

.student-tile .tile-top{
  margin-bottom:6px;
}

.tile-lesson-no{
  font-weight:700;
}

.badge.fixed-badge{
  background:#dbeafe;
  color:#1d4ed8;
}

.student-tile{
  background:#fafcff;
}

.student-tile .tile-row,
.lesson-card.compact-card .tile-row{
  margin-bottom:4px;
  line-height:1.35;
}

.student-tile .tile-row:last-child,
.lesson-card.compact-card .tile-row:last-child{
  margin-bottom:0;
}

.student-tile .tile-row b,
.lesson-card.compact-card .tile-row b{
  font-weight:700;
}

.student-tile.block-tile{
  background:#fef2f2;
  border-color:#fca5a5;
}

.student-tile.block-tile .tile-top{
  padding-right:66px;
}

.student-tile.block-tile .block-title{
  font-weight:700;
  color:#991b1b;
  margin-bottom:4px;
}

.lesson-card.compact-card.lesson-card-assigned{
  background:#f3f4f6;
  border-color:#d1d5db;
}

.lesson-card.compact-card.lesson-card-assigned .teacher-add-btn[disabled]{
  cursor:not-allowed;
  opacity:.7;
}

@media (max-width:980px){
  .lesson-card.compact-card .teacher-add-btn,
  .student-tile .tile-delete-btn{position:static;margin-bottom:8px;}
  .lesson-card.compact-card .tile-top,
  .student-tile .tile-top{padding-right:0;flex-wrap:wrap;}
}

.planner-block{
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
  background:#fff;
}
.planner-block-top{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
}
.presentation-status-text{
  font-weight:600;
  color:#374151;
}
.presentation-actions-cell{
  white-space:nowrap;
}
.presentation-plan-btn,
.presentation-choose-btn,
.presentation-delete-btn{
  min-width:88px;
}
#section-planner .table-wrap table td,
#section-planner .table-wrap table th{
  white-space:nowrap;
}
#section-planner .table-wrap{
  overflow:auto;
}
@media (max-width:980px){
  #section-planner .table-wrap table td,
  #section-planner .table-wrap table th{
    white-space:normal;
  }
}


.presentation-modal-row-fixed td{
  background:#dbeafe;
  color:#1e3a8a;
}
.presentation-modal-row-block td{
  background:#fef2f2;
  color:#991b1b;
}
.presentation-modal-row-presentation td{
  background:#dcfce7;
  color:#166534;
}
.presentation-modal-row-available td{
  background:#fff;
}
.presentation-modal-term-cell{
  min-width:280px;
}
.presentation-modal-term-main{
  font-weight:600;
}
.presentation-modal-term-sub{
  font-size:12px;
  margin-top:3px;
  opacity:.95;
}
.presentation-plan-modal-table .presentation-choose-btn[disabled],
.presentation-choose-btn[disabled]{
  opacity:.65;
  cursor:not-allowed;
}


.presentation-status-completed{color:#b91c1c;font-weight:700;}
.presentation-status-planned{color:#15803d;font-weight:700;}
.presentation-modal-student{margin-top:6px;font-size:13px;color:#374151;}
#plannedPresentationsTableBody tr.presentation-row-planned td{background:#dcfce7;}
#plannedPresentationsTableBody tr.presentation-row-other td{background:#fff;}

#completedPresentationStatusBox{margin-top:14px;}

.auth-actions-split{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.linkish-btn{
  background:transparent;
  color:var(--primary);
  padding:0;
  border:0;
}
.linkish-btn:hover{
  background:transparent;
  text-decoration:underline;
}
body[data-role="reader"] .presentation-plan-btn,
body[data-role="reader"] .presentation-choose-btn,
body[data-role="reader"] .presentation-delete-btn,
body[data-role="reader"] #addCompletedPresentationBtn,
body[data-role="reader"] .teacher-add-btn,
body[data-role="reader"] .tile-delete-btn,
body[data-role="reader"] .deleteFixedLessonBtn,
body[data-role="reader"] .deleteBlockBtn,
body[data-role="reader"] .deleteStudentBtn,
body[data-role="reader"] .toggleStudentBtn,
body[data-role="reader"] #addStudentBtn,
body[data-role="reader"] #addFixedLessonBtn,
body[data-role="reader"] #addBlockBtn,
body[data-role="reader"] #saveGroupEditorBtn,
body[data-role="reader"] #importZipBtn,
body[data-role="reader"] #inviteUserBtn,
body[data-role="editor"] #importZipBtn{
  display:none !important;
}
.users-active-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
}
.users-active-toggle input{
  width:auto;
}

.version-debug-card{background:#f8fbff}
.version-debug-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(220px,1fr));
  gap:10px 18px;
}
.version-debug-grid div{
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
  font-size:14px;
}
@media (max-width:980px){
  .version-debug-grid{grid-template-columns:1fr;}
}


.subject-translations-card{background:#fbfdff}
.subject-translations-card strong{font-size:14px}


.student-access-card{background:#fbfdff}
.student-access-link-cell{display:flex;gap:8px;align-items:center;min-width:320px}
.student-access-url{min-width:240px;background:#f9fafb}
@media (max-width:980px){
  .student-access-link-cell{min-width:0;flex-direction:column;align-items:stretch}
}

.guardian-students-box {
  max-height: 220px;
  overflow: auto;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}
.guardian-student-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.guardian-student-item:last-child { border-bottom: 0; }
.student-access-link-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}
.student-access-link-cell .student-access-url {
  min-width: 280px;
}
button.danger {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.22);
}
