:root {
  --green: #0A7866;
  --green-dark: #086354;
  --link: #049AD3;
  --bg: #f0f2f3;
  --border: #d8dcde;
  --text: #333;
  --muted: #777;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header — Sentral portal style */
.header {
  background-color: var(--green);
  border-bottom: 1px solid var(--green-dark);
  color: #fff;
}

.header header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #333;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.titles h1 { font-size: 21px; font-weight: 500; line-height: 1.2; }
.titles .sub-title { font-size: 12px; opacity: 0.85; }

.header-actions { margin-left: auto; display: flex; gap: 8px; }

.hbtn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.hbtn:hover { background: rgba(255, 255, 255, 0.12); }
.hbtn.danger:hover { background: rgba(200, 40, 40, 0.55); border-color: #e88; }

/* Layout */
.main {
  display: flex;
  gap: 20px;
  padding-top: 20px;
  padding-bottom: 40px;
  align-items: flex-start;
}

.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.sidebar h2 {
  font-size: 15px;
  color: var(--green);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--green);
}

.sidebar h3 {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
}

.subject-list { list-style: none; }

.subject-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  background: #fafafa;
  border: 1px solid var(--border);
}

.subject-list .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.subject-list .subj-meta { flex: 1; min-width: 0; }
.subject-list .subj-name { font-weight: 600; font-size: 12px; display: block; }
.subject-list .subj-detail {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.subject-list .del {
  border: none;
  background: none;
  color: #b33;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.subject-list .del:hover { color: #e00; }

.subject-list .empty {
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  justify-content: center;
  font-size: 12px;
}

.subject-form input[type="text"] {
  width: 100%;
  padding: 7px 9px;
  margin-bottom: 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.subject-form input[type="text"]:focus {
  outline: none;
  border-color: var(--green);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.color-row input[type="color"] {
  width: 40px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px;
  cursor: pointer;
  background: #fff;
}

.btn-primary {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.btn-secondary:hover { background: #eaf5f3; }

.btn-plain {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 10px;
}

/* Period editor */
.period-list { list-style: none; margin-bottom: 8px; }
.period-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 6px;
  border-bottom: 1px solid #f0f0f0;
}
.period-list .p-name { flex: 1; }
.period-list .p-break {
  font-size: 10px;
  color: var(--muted);
  background: #eee;
  border-radius: 3px;
  padding: 1px 5px;
}
.period-list .del {
  border: none;
  background: none;
  color: #b33;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.period-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period-add input[type="text"] {
  flex: 1;
  min-width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}
.break-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Content / timetable */
.content { flex: 1; min-width: 0; }

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-title { font-size: 24px; font-weight: 600; color: #222; }

.week-tabs { display: flex; gap: 6px; }

.week-tab {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 22px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
}
.week-tab.active {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
  font-weight: 700;
}

.table-scroll { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; }

.timetable {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
}

.timetable th {
  background: var(--green);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 8px;
  border: 1px solid var(--green-dark);
}

.timetable th.period-col { width: 92px; }

.timetable td {
  border: 1px solid var(--border);
  padding: 0;
  height: 76px;
  vertical-align: top;
}

.timetable td.period-label {
  background: #f7f8f8;
  padding: 8px 6px;
  vertical-align: middle;
  text-align: center;
}

.period-label .pl-name {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: #444;
}

.period-label .pl-time {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
}

.timetable tr.break-row td {
  height: 26px;
  background: #eceeef;
}
.timetable tr.break-row td.period-label { background: #e6e8e9; }
.timetable tr.break-row .pl-name { font-size: 11px; color: #888; }
.timetable tr.break-row .pl-time { display: inline; margin-left: 4px; font-size: 10px; }

/* Cells — white with coloured left bar, like the real portal */
.cell-btn {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 76px;
  border: none;
  border-left: 4px solid transparent;
  background: none;
  cursor: pointer;
  text-align: left;
  padding: 7px 8px;
  font-family: inherit;
  color: var(--text);
}
.cell-btn:hover { outline: 2px solid var(--link); outline-offset: -2px; }

.cell-btn .c-name { font-weight: 700; font-size: 12px; display: block; line-height: 1.25; }
.cell-btn .c-detail {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.cell-btn.empty-cell {
  color: #aaa;
  font-size: 12px;
  text-align: center;
  padding-top: 28px;
}

.hint { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* Picker modal */
.picker[hidden] { display: none; }

.picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.picker-inner {
  background: #fff;
  border-radius: 6px;
  padding: 18px;
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
}

.picker-inner h3 {
  font-size: 14px;
  color: var(--green);
  margin-bottom: 12px;
}

#picker-list { list-style: none; margin-bottom: 12px; }

#picker-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}
#picker-list button:hover { border-color: var(--green); background: #eaf5f3; }
#picker-list .swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* Sticky period column — keeps labels visible when the grid scrolls sideways */
.timetable th.period-col,
.timetable td.period-label {
  position: sticky;
  left: 0;
  z-index: 2;
}

@media (max-width: 860px) {
  .main { flex-direction: column; }
  .content { order: 1; width: 100%; }
  .sidebar { order: 2; width: 100%; }

  .header header {
    flex-wrap: wrap;
    row-gap: 8px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .badge { width: 36px; height: 36px; font-size: 13px; }
  .titles h1 { font-size: 16px; }
  .titles .sub-title { font-size: 11px; }
  .header-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }
  .hbtn { padding: 5px 10px; font-size: 12px; }

  .page-title { font-size: 19px; }
  .week-tab { padding: 7px 16px; flex: 1; }
  .timetable { min-width: 640px; }
  .timetable th.period-col { width: 78px; }
}

@media print {
  .sidebar, .header-actions, .hint, .week-tabs { display: none !important; }
  body { background: #fff; }
  .table-scroll { border: none; }
}
