:root{
  --bg:#f4f1eb;
  --surface:#fbfaf7;
  --surface-2:#ece8e1;
  --text:#262626;
  --muted:#74716b;
  --line:#d7d2ca;
  --accent:#3b3a36;
  --accent-soft:#e1ddd5;
  --success:#dfe9df;
  --success-text:#36513a;
  --busy:#e8dddd;
  --busy-text:#7a4a4a;
  --danger:#9e3f3f;
  --shadow:0 12px 35px rgba(37,34,29,.07);
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
  background:var(--bg);
  color:var(--text);
}

body{
  font-family:Inter,Arial,Helvetica,sans-serif;
  letter-spacing:-.015em;
  line-height:1.5;
}

button,
input,
select{
  font:inherit;
}

button{
  cursor:pointer;
}

.hidden{
  display:none!important;
}

.muted{
  color:var(--muted);
}

.eyebrow{
  font-size:11px;
  letter-spacing:.14em;
  font-weight:700;
  color:var(--muted);
  text-transform:uppercase;
}

.error{
  color:var(--danger);
  min-height:20px;
  font-size:13px;
  margin:14px 0;
}

.toast{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:100;
  max-width:420px;
  padding:14px 18px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--accent);
  color:#fff;
  box-shadow:var(--shadow);
  font-size:13px;
}

/* AUTH */

.auth-layout{
  min-height:100vh;
  display:grid;
  grid-template-columns:1fr 1fr;
  background:var(--bg);
}

.auth-poster{
  position:relative;
  min-height:100vh;
  overflow:hidden;
  padding:34px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.04), transparent 38%),
    #2d2c29;
  color:#f6f3ed;
}

.auth-poster:before,
.auth-poster:after{
  content:"";
  position:absolute;
  background:#dad5cc;
  opacity:.88;
  border-radius:3px;
}

.auth-poster:before{
  width:44%;
  height:68%;
  left:10%;
  top:14%;
}

.auth-poster:after{
  width:28%;
  height:52%;
  right:9%;
  bottom:12%;
}

.poster-mark{
  position:relative;
  z-index:2;
  font-size:30px;
  font-weight:800;
  letter-spacing:-.06em;
}

.poster-copy{
  position:absolute;
  z-index:3;
  left:12%;
  top:27%;
  color:#fff;
}

.poster-copy span{
  font-size:10px;
  letter-spacing:.18em;
}

.poster-copy h1{
  margin:20px 0;
  font-size:clamp(54px,7vw,108px);
  line-height:.86;
  font-weight:800;
  letter-spacing:-.065em;
}

.poster-copy p{
  font-size:11px;
  letter-spacing:.13em;
  text-transform:uppercase;
}

.poster-index{
  position:absolute;
  right:30px;
  bottom:28px;
  z-index:3;
  font-size:10px;
  letter-spacing:.13em;
  color:#d5d0c7;
}

.auth-panel{
  display:grid;
  place-items:center;
  padding:40px;
  background:var(--bg);
}

.auth-box{
  width:min(460px,100%);
  padding:34px;
  border:1px solid var(--line);
  border-radius:22px;
  background:var(--surface);
  box-shadow:var(--shadow);
}

.auth-box h2{
  margin:14px 0 34px;
  font-size:52px;
  line-height:.95;
  font-weight:700;
  letter-spacing:-.045em;
}

label{
  display:block;
  margin:18px 0;
  font-size:11px;
  font-weight:700;
  letter-spacing:.11em;
  color:var(--muted);
  text-transform:uppercase;
}

input,
select{
  width:100%;
  margin-top:7px;
  padding:12px 13px;
  border:1px solid var(--line);
  border-radius:11px;
  outline:none;
  background:#fff;
  color:var(--text);
  transition:border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus{
  border-color:#9c978f;
  box-shadow:0 0 0 3px rgba(84,80,72,.08);
}

.primary-btn,
.outline-btn{
  border:1px solid var(--accent);
  border-radius:11px;
  padding:13px 16px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.1em;
  transition:.2s ease;
}

.primary-btn{
  width:100%;
  margin-top:18px;
  background:var(--accent);
  color:#fff;
}

.outline-btn{
  background:transparent;
  color:var(--accent);
}

.primary-btn:hover,
.outline-btn:hover{
  transform:translateY(-1px);
  box-shadow:0 8px 18px rgba(37,34,29,.08);
}

.outline-btn:hover{
  background:var(--accent-soft);
}

.auth-switch{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:24px;
}

.auth-switch button,
.text-btn{
  border:0;
  padding:0;
  background:transparent;
  color:var(--muted);
  font-size:11px;
  letter-spacing:.08em;
  text-decoration:none;
}

.auth-switch button:hover,
.text-btn:hover{
  color:var(--text);
}

/* APP */

.app-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns:240px 1fr;
}

.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:26px 22px;
  border-right:1px solid var(--line);
  background:#2f2e2b;
  color:#f5f2ec;
}

.logo-block{
  padding-bottom:24px;
  border-bottom:1px solid rgba(255,255,255,.12);
}

.logo-main{
  font-size:48px;
  line-height:.9;
  font-weight:800;
  letter-spacing:-.07em;
}

.logo-sub{
  margin-top:12px;
  font-size:9px;
  line-height:1.5;
  letter-spacing:.14em;
  color:#c9c4bb;
}

.side-nav{
  display:grid;
  gap:6px;
  margin-top:36px;
}

.side-nav button{
  width:100%;
  border:0;
  border-radius:10px;
  padding:13px 12px;
  background:transparent;
  color:#d9d5cf;
  text-align:left;
  font-size:11px;
  letter-spacing:.08em;
  transition:.2s ease;
}

.side-nav button span{
  display:inline-block;
  width:30px;
  color:#8d8982;
}

.side-nav button:hover{
  background:rgba(255,255,255,.06);
  color:#fff;
}

.side-nav button.active{
  background:#f0ede7;
  color:#2f2e2b;
}

.side-nav button.active span{
  color:#8b877f;
}

.user-caption{
  margin-bottom:12px;
  font-size:11px;
  line-height:1.55;
  letter-spacing:.04em;
  color:#c9c4bb;
}

.sidebar .text-btn{
  color:#f5f2ec;
}

.main{
  min-width:0;
  padding:34px 34px 64px;
}

.page-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:24px;
  padding-bottom:24px;
  border-bottom:1px solid var(--line);
}

.page-header h1{
  margin:16px 0 0;
  font-size:clamp(42px,6vw,78px);
  line-height:.92;
  font-weight:700;
  letter-spacing:-.055em;
}

.lesson-counter{
  min-width:190px;
  padding:18px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
  box-shadow:var(--shadow);
  text-align:right;
}

.lesson-counter span{
  display:block;
  font-size:10px;
  letter-spacing:.11em;
  color:var(--muted);
}

.lesson-counter strong{
  display:block;
  margin-top:4px;
  font-size:52px;
  line-height:1;
  font-weight:700;
}

.page-section{
  padding-top:30px;
}

.section-bar{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:20px;
  padding-bottom:14px;
  border-bottom:1px solid var(--line);
}

.section-bar>div{
  display:flex;
  align-items:flex-end;
  gap:12px;
}

.section-num{
  font-size:11px;
  color:var(--muted);
}

.section-bar h2{
  margin:0;
  font-size:25px;
  font-weight:700;
  letter-spacing:-.035em;
}

.date-field{
  width:190px;
  margin:0;
}

.intro{
  margin:18px 0 24px;
  font-size:13px;
  color:var(--muted);
}

/* TABLES */

.table-wrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
  box-shadow:var(--shadow);
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

th,
td{
  padding:13px 14px;
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
  text-align:left;
  font-size:12px;
  white-space:nowrap;
}

th:last-child,
td:last-child{
  border-right:0;
}

tr:last-child td{
  border-bottom:0;
}

th{
  background:var(--surface-2);
  color:var(--muted);
  font-size:10px;
  font-weight:700;
  letter-spacing:.1em;
}

.schedule-table th:first-child,
.schedule-table td:first-child{
  position:sticky;
  left:0;
  z-index:3;
}

.schedule-table th:first-child{
  background:var(--surface-2);
}

.schedule-table td:first-child{
  background:var(--surface);
  font-weight:700;
}

.slot{
  min-width:96px;
  text-align:center;
  font-weight:700;
  letter-spacing:.03em;
  transition:.18s ease;
}

.slot.free{
  background:var(--success);
  color:var(--success-text);
  cursor:pointer;
}

.slot.free:hover{
  background:#cfdccf;
}

.slot.busy{
  background:var(--busy);
  color:var(--busy-text);
}

.slot.closed{
  background:#eceae5;
  color:#a19d96;
}

.badge{
  display:inline-block;
  padding:5px 8px;
  border-radius:999px;
  background:var(--accent-soft);
  color:var(--accent);
  font-size:10px;
  font-weight:700;
  letter-spacing:.05em;
}

.badge.cancelled{
  background:#ece9e4;
  color:#858078;
}

.danger-btn,
.mini-btn{
  border:1px solid var(--line);
  border-radius:8px;
  padding:7px 10px;
  background:#fff;
  color:var(--text);
  font-size:10px;
  font-weight:700;
  letter-spacing:.05em;
}

.danger-btn:hover,
.mini-btn:hover{
  background:var(--surface-2);
}

.admin-actions{
  display:flex;
  gap:10px;
  margin:22px 0;
  flex-wrap:wrap;
}

.editorial-grid.two{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}

.panel{
  min-width:0;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
  box-shadow:var(--shadow);
}

.panel-head{
  display:flex;
  justify-content:space-between;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  background:var(--surface-2);
  color:var(--muted);
  font-size:10px;
  letter-spacing:.1em;
}

.inline-input{
  width:90px;
  margin:0;
  padding:7px 8px;
}

/* MODAL */

.modal-shell{
  position:fixed;
  inset:0;
  z-index:50;
  display:grid;
  place-items:center;
  padding:20px;
  background:rgba(30,28,25,.52);
  backdrop-filter:blur(3px);
}

.modal{
  width:min(560px,100%);
  padding:28px;
  border:1px solid var(--line);
  border-radius:20px;
  background:var(--surface);
  box-shadow:0 28px 70px rgba(34,31,27,.18);
}

.modal h3{
  margin:0 0 22px;
  font-size:38px;
  line-height:.95;
  font-weight:700;
  letter-spacing:-.045em;
}

.modal-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:24px;
}

@media(max-width:980px){
  .auth-layout{
    grid-template-columns:1fr;
  }

  .auth-poster{
    display:none;
  }

  .app-shell{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:relative;
    height:auto;
    display:block;
  }

  .side-nav{
    display:flex;
    overflow:auto;
    gap:8px;
    margin-top:20px;
  }

  .side-nav button{
    width:auto;
    white-space:nowrap;
    border:1px solid rgba(255,255,255,.1);
  }

  .sidebar-bottom{
    margin-top:18px;
  }

  .editorial-grid.two{
    grid-template-columns:1fr;
  }
}

@media(max-width:680px){
  .main{
    padding:20px 12px 44px;
  }

  .page-header{
    display:block;
  }

  .lesson-counter{
    width:100%;
    margin-top:18px;
  }

  .section-bar{
    display:block;
  }

  .date-field{
    width:100%;
    margin-top:18px;
  }

  .modal-grid{
    grid-template-columns:1fr;
  }

  .auth-box{
    padding:24px;
  }

  .auth-box h2{
    font-size:42px;
  }
}


/* =========================================================
   MOBILE / TABLET ADAPTATION
   ========================================================= */

body{
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

button,
input,
select{
  min-height:44px;
}

.table-wrap{
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-inline:contain;
}

.schedule-table{
  min-width:max-content;
}

.schedule-table th,
.schedule-table td{
  scroll-snap-align:start;
}

.slot{
  user-select:none;
  -webkit-tap-highlight-color:transparent;
}

@media(max-width:980px){
  .app-shell{
    display:block;
    min-height:100vh;
  }

  .sidebar{
    position:fixed;
    left:0;
    right:0;
    bottom:0;
    top:auto;
    z-index:40;
    height:auto;
    padding:8px max(10px, env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    border-top:1px solid rgba(255,255,255,.12);
    border-right:0;
    background:rgba(47,46,43,.96);
    backdrop-filter:blur(14px);
  }

  .sidebar>div:first-child{
    width:100%;
  }

  .logo-block,
  .sidebar-bottom{
    display:none;
  }

  .side-nav{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:6px;
    margin:0;
    overflow:visible;
  }

  .side-nav button{
    width:100%;
    min-width:0;
    min-height:54px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:3px;
    padding:7px 5px;
    border:0;
    border-radius:12px;
    text-align:center;
    white-space:normal;
    font-size:9px;
    line-height:1.15;
    letter-spacing:.04em;
  }

  .side-nav button span{
    width:auto;
    font-size:9px;
  }

  .side-nav button.active{
    padding-left:5px;
  }

  .main{
    padding:24px 18px calc(92px + env(safe-area-inset-bottom));
  }

  .page-header{
    align-items:stretch;
  }

  .page-header h1{
    font-size:clamp(40px,8vw,66px);
  }

  .lesson-counter{
    min-width:165px;
  }

  .editorial-grid.two{
    grid-template-columns:1fr;
  }
}

@media(max-width:680px){
  .auth-panel{
    padding:16px;
    min-height:100dvh;
  }

  .auth-box{
    width:100%;
    padding:24px 18px;
    border-radius:18px;
  }

  .auth-box h2{
    margin-bottom:28px;
    font-size:40px;
  }

  .auth-switch{
    display:grid;
    grid-template-columns:1fr;
    gap:6px;
  }

  .auth-switch button{
    min-height:36px;
    text-align:left;
  }

  .main{
    padding:18px 12px calc(90px + env(safe-area-inset-bottom));
  }

  .page-header{
    display:grid;
    grid-template-columns:1fr auto;
    align-items:end;
    gap:10px;
    padding-bottom:18px;
  }

  .page-header .eyebrow{
    display:none;
  }

  .page-header h1{
    margin:0;
    font-size:34px;
    line-height:1;
    letter-spacing:-.045em;
  }

  .lesson-counter{
    min-width:112px;
    padding:11px 12px;
    border-radius:13px;
  }

  .lesson-counter span{
    max-width:86px;
    margin-left:auto;
    font-size:8px;
    line-height:1.25;
  }

  .lesson-counter strong{
    font-size:36px;
  }

  .page-section{
    padding-top:22px;
  }

  .section-bar{
    display:grid;
    gap:12px;
  }

  .section-bar>div{
    align-items:center;
  }

  .section-bar h2{
    font-size:20px;
  }

  .date-field{
    width:100%;
    margin:0;
  }

  .intro{
    margin:14px 0 18px;
    font-size:12px;
  }

  .table-wrap{
    width:calc(100vw - 24px);
    max-width:100%;
    border-radius:14px;
  }

  .schedule-table th,
  .schedule-table td{
    padding:11px 10px;
  }

  .schedule-table th:first-child,
  .schedule-table td:first-child{
    min-width:118px;
    box-shadow:8px 0 14px rgba(37,34,29,.05);
  }

  .slot{
    min-width:84px;
    height:54px;
    font-size:10px;
  }

  th,
  td{
    padding:11px 10px;
    font-size:11px;
  }

  .admin-actions{
    display:grid;
    grid-template-columns:1fr;
  }

  .admin-actions .outline-btn{
    width:100%;
  }

  .panel{
    border-radius:14px;
  }

  .modal-shell{
    align-items:end;
    padding:0;
  }

  .modal{
    width:100%;
    max-height:92dvh;
    overflow:auto;
    padding:24px 18px calc(22px + env(safe-area-inset-bottom));
    border:0;
    border-radius:22px 22px 0 0;
  }

  .modal h3{
    font-size:32px;
  }

  .modal-grid{
    grid-template-columns:1fr;
    gap:2px;
  }

  .modal-actions{
    position:sticky;
    bottom:0;
    display:grid;
    grid-template-columns:1fr 1fr;
    padding-top:14px;
    background:linear-gradient(transparent,var(--surface) 18%);
  }

  .modal-actions .primary-btn,
  .modal-actions .outline-btn{
    width:100%;
    margin:0;
  }

  .toast{
    left:12px;
    right:12px;
    bottom:calc(76px + env(safe-area-inset-bottom));
    max-width:none;
  }
}

@media(max-width:390px){
  .page-header{
    grid-template-columns:1fr 104px;
  }

  .page-header h1{
    font-size:29px;
  }

  .lesson-counter{
    min-width:104px;
  }

  .side-nav button{
    font-size:8px;
  }

  .slot{
    min-width:78px;
  }
}

/* Landscape phones: leave more room for the schedule */
@media(max-height:500px) and (orientation:landscape){
  .sidebar{
    padding-top:5px;
    padding-bottom:calc(5px + env(safe-area-inset-bottom));
  }

  .side-nav button{
    min-height:44px;
  }

  .main{
    padding-bottom:70px;
  }

  .modal{
    max-height:96dvh;
  }
}


/* Delete actions */
.delete-btn{
  border:1px solid #d8bcbc;
  border-radius:8px;
  padding:7px 10px;
  background:#fff7f7;
  color:#8d3333;
  font-size:10px;
  font-weight:700;
  letter-spacing:.05em;
}
.delete-btn:hover{
  background:#f2dddd;
}
.action-stack{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}
.history-note{
  margin:14px 0;
  color:var(--muted);
  font-size:12px;
}
@media(max-width:680px){
  .action-stack{
    min-width:150px;
  }
}


/* MOBILE: hide History from bottom navigation */
@media (max-width: 980px){
  .side-nav button[data-page="history"]{
    display:none!important;
  }

  .side-nav{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
}

.student-star{font-size:28px;line-height:1.3}.student-star.green{color:#16803d}.student-star.red{color:#ce2424}.student-filters{display:flex;gap:16px;flex-wrap:wrap;margin-bottom:20px}.student-filters label{flex:1;min-width:160px}#adminUsers td input[type=date]{min-width:145px}#adminUsers td select{min-width:145px}#adminUsers tr[hidden]{display:none}.editorial-grid.two{grid-template-columns:minmax(0,1fr)}

/* Responsive student editor */
.app-shell{grid-template-columns:240px minmax(0,1fr)}
.user-caption{overflow-wrap:anywhere}
.student-star{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;flex:0 0 28px;font-size:24px;line-height:1;vertical-align:middle}
.star-editor{display:flex;align-items:center;gap:8px;min-width:0}
.star-editor select{flex:1;min-width:0!important}
#adminUsers td{vertical-align:middle}
#adminUsers td input,#adminUsers td select{margin-top:0}
.student-filters{padding:0 14px;gap:12px;margin-bottom:14px}
.student-filters label{margin:14px 0 0;min-width:0}
.mobile-profile{display:none}
.page-header>div:first-child{min-width:0}
.page-header h1{overflow-wrap:anywhere}
@media(max-width:980px){
 .mobile-profile{display:block;margin-top:16px;padding:14px 16px;background:var(--surface);border:1px solid var(--line);border-radius:14px;font-size:13px;overflow-wrap:anywhere}
 #adminUsers .table-wrap{border:0;border-radius:0;box-shadow:none;width:100%;overflow:visible;background:transparent}
 #adminUsers table,#adminUsers tbody{display:block;width:100%}
 #adminUsers thead{display:none}
 #adminUsers tbody{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:0 12px 12px}
 #adminUsers tbody tr{display:block;min-width:0;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:12px}
 #adminUsers tbody tr[hidden]{display:none}
 #adminUsers td{display:block;border:0!important;white-space:normal;overflow-wrap:anywhere;padding:6px 0;font-size:14px}
 #adminUsers td:before{content:attr(data-label);display:block;margin-bottom:4px;font-size:10px;color:var(--muted);letter-spacing:.05em}
 #adminUsers td input,#adminUsers td select{width:100%;max-width:100%;min-width:0!important;font-size:16px}
 #adminUsers .action-stack{min-width:0;display:grid;grid-template-columns:1fr 1fr}
 .page-header h1{font-size:clamp(28px,5vw,52px)}
}
@media(max-width:600px){
 #adminUsers tbody{grid-template-columns:minmax(0,1fr)}
 .student-filters{flex-direction:column;gap:0}
 .student-filters label{width:100%}
 .page-header{grid-template-columns:minmax(0,1fr);align-items:start}
 .page-header h1{font-size:clamp(26px,7vw,38px)}
 .lesson-counter{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-width:0;margin-top:0;text-align:left}
 .lesson-counter span{margin:0;max-width:none;font-size:10px}
 .lesson-counter strong{margin:0;font-size:32px}
 .section-bar>div{min-width:0}.section-bar h2{overflow-wrap:anywhere}
 input,select{min-width:0;font-size:16px}
}
