/* Timetable Maker - dark red + gray, calendar-app design language. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --maroon: #7a1f2b;
  --maroon-dark: #611722;
  --maroon-light: #a3242f;
  --ink: #232326;
  --muted: #6b6b72;
  --line: #d7d2d4;
  --bg: #f2f0f1;
  --panel: #ffffff;
  --chip: #f5f3f4;
}
body { font-family: Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 13px; }
button { font-family: inherit; }
a { color: var(--maroon); }

/* topbar */
.topbar {
  background: var(--maroon); color: #fff; padding: 9px 20px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.topbar .brand { font-size: 16px; font-weight: 800; letter-spacing: .3px; }
.topbar .school { font-size: 11px; opacity: .8; }
.topbar .spacer { flex: 1; }
.save-state { font-size: 11px; opacity: .85; min-width: 54px; text-align: right; }
.btn {
  border: none; padding: 8px 15px; border-radius: 5px; font-size: 12.5px;
  font-weight: 700; cursor: pointer; color: #fff; background: rgba(255,255,255,.16);
  transition: background .14s;
}
.btn:hover { background: rgba(255,255,255,.3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: #1668c5; }
.btn.primary:hover { background: #1257a8; }
.btn.go { background: #1f9d57; }
.btn.go:hover { background: #178047; }
.btn.danger { background: #b23; }

/* tabs */
.tabs {
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; gap: 2px; padding: 0 14px; position: sticky; top: 42px; z-index: 90;
  overflow-x: auto;
}
.tab {
  border: none; background: none; padding: 11px 15px; font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--maroon); border-bottom-color: var(--maroon); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 18px 60px; }
.panel { display: none; }
.panel.active { display: block; }
.panel h2 { font-size: 17px; margin-bottom: 3px; }
.panel .sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; max-width: 720px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; background: var(--chip);
  border: 1.5px solid var(--line); border-radius: 7px; padding: 6px 10px;
  font-size: 12.5px; font-weight: 600;
}
.chip .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); flex-shrink: 0; }
.chip .tag { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.chip .gear { display: inline-flex; cursor: pointer; opacity: .5; }
.chip .gear:hover { opacity: 1; }
.chip .gear svg { width: 13px; height: 13px; }
.chip.add { color: #1f7a44; border-style: dashed; border-color: #9dcbae; background: #f2f9f4; cursor: pointer; }

/* inline add form */
.addform {
  display: inline-flex; align-items: center; gap: 6px; background: #f0f6f1;
  border: 1.5px solid #bfe0c8; border-radius: 7px; padding: 5px 8px; flex-wrap: wrap;
}
.addform input[type=text], .addform select {
  border: 1px solid #cdd4e0; border-radius: 5px; padding: 6px 8px; font-size: 12px; font-family: inherit;
}
.addform input[type=color] { width: 30px; height: 30px; border: none; background: none; cursor: pointer; padding: 0; }
.mini { border: none; border-radius: 5px; padding: 7px 12px; font-size: 12px; font-weight: 700; cursor: pointer; color: #fff; }
.mini.green { background: #1f9d57; } .mini.grey { background: #7a8598; } .mini.blue { background: #1668c5; }

/* popover */
.pop {
  position: absolute; z-index: 400; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 38px rgba(0,0,0,.24); padding: 14px; width: 280px;
  display: flex; flex-direction: column; gap: 10px;
}
.pop label { font-size: 10px; font-weight: 800; color: #667085; text-transform: uppercase; letter-spacing: .3px; display:block; margin-bottom:4px; }
.pop input[type=text], .pop select, .pop input[type=number] {
  border: 1px solid #cdd4e0; border-radius: 6px; padding: 8px; font-size: 12.5px; font-family: inherit; width: 100%;
}
.pop .row { display: flex; align-items: center; gap: 10px; }
.pop input[type=color] { width: 42px; height: 34px; border: none; padding: 0; background: none; cursor: pointer; }
.pop .actions { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.pop .del { background: #fbe3df; color: #b23; border: none; border-radius: 6px; padding: 8px 12px; font-size: 12px; cursor: pointer; font-weight: 700; }
.pop .done { background: #1668c5; color: #fff; border: none; border-radius: 6px; padding: 8px 15px; font-size: 12px; cursor: pointer; font-weight: 700; }
.checkgrid { display: flex; flex-wrap: wrap; gap: 5px; max-height: 160px; overflow-y: auto; }
.checkgrid .opt {
  border: 1.5px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 11.5px; cursor: pointer; user-select: none;
}
.checkgrid .opt.on { border-color: var(--maroon); background: #f7ecee; color: var(--maroon); font-weight: 700; }

/* rows (teachers, students, groups) */
.rows { display: flex; flex-direction: column; gap: 7px; }
.rowitem {
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
}
.rowitem .grow { flex: 1; }
.rowitem .name { font-weight: 700; }
.rowitem .meta { color: var(--muted); font-size: 11.5px; }
.pill { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; padding: 2px 7px; border-radius: 20px; }
.pill.full { background: #e7f3ec; color: #1f7a44; }
.pill.part { background: #fdefe0; color: #b5701a; }
.pill.seed { background: #eef1f6; color: #667085; }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 9px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); }
.iconbtn:hover { border-color: var(--maroon-light); color: var(--maroon); }

.section-head { display: flex; align-items: center; gap: 10px; margin: 20px 0 9px; }
.section-head h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.section-head .line { flex: 1; height: 1px; background: var(--line); }

/* controls bar */
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.controls select { border: 1.5px solid #c4ccda; border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: inherit; }
.ctl-label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.badge { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 6px; }
.badge.ok { background: #e7f3ec; color: #1f7a44; }
.badge.warn { background: #fde8e6; color: #b23; }

/* timetable grid */
.tt { border-collapse: collapse; width: 100%; background: #fff; border: 1px solid var(--line); }
.tt th, .tt td { border: 1px solid var(--line); text-align: center; }
.tt thead th { background: #efe7e8; font-size: 12px; padding: 7px 4px; }
.tt .timecol { background: #f3eef0; width: 88px; font-size: 10px; color: var(--muted); padding: 4px 6px; text-align: left; }
.tt .timecol b { display: block; font-size: 13px; color: var(--ink); }
.tt .brkrow td { background: #ece6e8; color: var(--muted); font-style: italic; font-size: 11px; height: 16px; }
.tt td.cell { height: 46px; cursor: pointer; position: relative; padding: 0; vertical-align: middle; }
.tt td.cell .lesson { height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 3px; line-height: 1.15; }
.tt td.cell .lesson .s { font-weight: 800; font-size: 12px; }
.tt td.cell .lesson .m { font-size: 9px; opacity: .85; }
.tt td.cell.empty:hover { background: #f7f3f4; }
.tt td.cell.clash { outline: 3px solid #e11; outline-offset: -3px; }
.tt td.cell .lock { position: absolute; top: 1px; right: 3px; font-size: 9px; font-weight: 800; color: rgba(0,0,0,.55); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; font-size: 11.5px; align-items: center; }
.legend .item { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }

/* place-picker (inline, under grid, not a modal) */
.picker { margin-top: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: none; }
.picker.open { display: block; }
.picker h4 { font-size: 12px; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.picker .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.picker .opt { border: 1.5px solid var(--line); border-radius: 6px; padding: 6px 9px; cursor: pointer; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.picker .opt:hover { border-color: var(--maroon); }

/* login gate */
.gate { max-width: 340px; margin: 60px auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 26px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.gate h2 { margin-bottom: 4px; }
.gate p { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.gate input { width: 100%; border: 1.5px solid #c4ccda; border-radius: 7px; padding: 10px; font-size: 13px; margin-bottom: 10px; font-family: inherit; }
.gate .err { color: #b23; font-size: 12px; margin-bottom: 10px; min-height: 16px; }
.readonly-banner { background: #fff6e5; border-bottom: 1px solid #f0dca8; color: #8a6d1f; font-size: 12px; padding: 8px 20px; text-align: center; }

/* availability grid (teacher popover) */
.availgrid table { border-collapse: collapse; }
.availgrid th { font-size: 9px; color: var(--muted); padding: 2px 4px; font-weight: 700; }
.availgrid td { width: 22px; height: 18px; border: 1px solid var(--line); cursor: pointer; }
.availgrid td.on { background: #e7f3ec; }
.availgrid td.off { background: #f3b6b0; }
.availgrid td.on:hover { background: #d3ecdd; }

/* room availability chips */
.freerooms { display: flex; flex-wrap: wrap; gap: 3px; }
.freerooms .rm { font-size: 10px; background: #eef2f5; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: #556; }
.tt td.ybcell { height: 30px; cursor: pointer; }
.tt td.ybcell.ybon { background: #f3b6b0; }

input.wide { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-top: 4px; font-family: inherit; font-size: 13px; }
input.narrow { border: 1px solid var(--line); border-radius: 6px; padding: 7px; font-family: inherit; font-size: 13px; }

/* conflicts */
.conflicts { background: #fde8e6; border: 1px solid #f3b6b0; border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 12.5px; color: #922; display: none; }
.conflicts.show { display: block; }
.conflicts ul { margin: 6px 0 0 18px; }
.empty-hint { color: var(--muted); font-size: 12.5px; padding: 10px 0; }
