/* plan.css — Plan-area view styles (ported from ala-scheduler/css/layout.css).
 *
 * Every rule that targets content living inside #area-plan is scoped under
 * `.area-plan` so the planning grids never leak into the Day area's unscoped
 * grid.css (a `.area-plan`-scoped rule at specificity ≥0,1,1 beats Day's 0,1,0).
 *
 * Three families are intentionally UNSCOPED because their markup mounts outside
 * #area-plan:
 *   • the conflict modal (slotpanel appends it to document.body)
 *   • the setup modal (#setup-modal sits in #screen-app, not #area-plan)
 *   • the week-zoom slider (lives in #chrome-plan header chrome)
 *
 * Shared chrome already lives in layout.css (#term-select, #breadcrumb/.bc-*,
 * .session-stats), base.css (.filter-chip) and students.css (.modal-* base,
 * .plan-modal-dialog, .plan-quill, .form-group, .status-badge) — not redefined.
 */

/* ── Session-state color tokens (missing from base.css) ──────────────────── */

.area-plan {
  --color-booked-ip:      #94A3B8;
  --color-booked-online:  #4ADE80;
  --color-meeting:        #93C5FD;
  --color-admin:          #C4B5FD;
  --color-not-available:  #D1D5DB;
  --color-booked-partial: #DBEAFE;
}

/* ── Plan-area shell — re-implement the scheduler's header/filter/main/panel
 *    grid inside the suite's flex area container. ─────────────────────────── */

body.area-plan #area-plan {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "filter filter"
    "banner banner"
    "main   panel";
}

.area-plan #filter-bar           { grid-area: filter; }
.area-plan #booking-mode-banner  { grid-area: banner; }
.area-plan #plan-main {
  grid-area: main;
  position: relative;
  overflow: auto;
  min-width: 0;
  min-height: 0;
}

.area-plan .view-container { min-height: 100%; }

/* ── Teacher filter bar ──────────────────────────────────────────────────── */

.area-plan #filter-bar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  /* overflow stays visible so the teachers dropdown can escape this bar */
  overflow: visible;
}

.area-plan #student-search {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  width: 170px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
.area-plan #student-search:focus {
  border-color: var(--color-primary, #3b82f6);
  width: 220px;
}
.area-plan #student-search.hidden { display: none; }

.area-plan .filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.area-plan #teacher-filter-list {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.area-plan #teacher-filter-list::-webkit-scrollbar { height: 4px; }
.area-plan #teacher-filter-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* ── Teachers dropdown (in the filter bar) ───────────────────────────────── */

.area-plan .teachers-dropdown {
  position: relative;
  flex-shrink: 0;
}

.area-plan .teachers-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.area-plan .teachers-dropdown-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.area-plan .teachers-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px var(--color-shadow);
  min-width: 200px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 0;
}
.area-plan .teachers-dropdown-menu.hidden { display: none; }

.area-plan .teachers-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.area-plan .teachers-menu-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.area-plan .teachers-menu-empty {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
}

.area-plan .teacher-menu-avail {
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
}

/* ── Week-zoom slider (lives in #chrome-plan header chrome) ───────────────── */

#chrome-plan .zoom-control {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
#chrome-plan .zoom-icon {
  font-size: 13px;
  opacity: 0.7;
  user-select: none;
}
#chrome-plan #week-zoom {
  width: 80px;
  accent-color: rgba(255,255,255,0.8);
  cursor: pointer;
  opacity: 0.85;
}
#chrome-plan #week-zoom:hover { opacity: 1; }

/* ── Booking-mode banner ─────────────────────────────────────────────────── */

.area-plan .booking-mode-banner {
  background: #FEF9C3;
  border-bottom: 2px solid #FDE68A;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #78350F;
  flex-shrink: 0;
}
.area-plan .booking-mode-banner.hidden { display: none; }
.area-plan #booking-mode-text { flex: 1; }

/* ── Week View ───────────────────────────────────────────────────────────── */

.area-plan .week-grid {
  display: grid;
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  /* grid-template-columns set inline per teacher count */
}

.area-plan .week-corner {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
}

.area-plan .week-timeline-header {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.area-plan .week-timeline-cell {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  overflow: hidden;
}

.area-plan .week-tl-slot {
  flex: 0 0 var(--week-slot-height, 7px);
  height: var(--week-slot-height, 7px);
  font-size: 9px;
  line-height: var(--week-slot-height, 7px);
  color: var(--color-text-muted);
  padding: 0 2px;
  overflow: hidden;
  white-space: nowrap;
}
.area-plan .week-tl-hour { border-top: 1px solid var(--color-border); }
.area-plan .week-tl-half { border-top: 1px solid rgba(200,213,236,0.4); }

.area-plan .week-teacher-header {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.area-plan .week-teacher-header:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.area-plan .week-day-label {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.area-plan .week-day-label:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.area-plan .week-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
  background: var(--color-bg);
  transition: opacity var(--transition);
  min-width: 64px;
}
.area-plan .week-cell:hover { opacity: 0.75; }

.area-plan .mini-block {
  height: var(--week-slot-height, 7px);
  border-radius: 1px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.area-plan .mini-block-label {
  display: none;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: rgba(0,0,0,0.65);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 1px 3px 0;
  pointer-events: none;
}
.area-plan #view-week.week-zoomed .mini-block-label { display: block; }

.area-plan .mini-block-venue {
  display: none;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  color: rgba(0,0,0,0.45);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 3px;
  pointer-events: none;
}
.area-plan #view-week.week-zoomed-detail .mini-block-venue { display: block; }

.area-plan .mini-block-scope {
  display: none;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  color: rgba(0,0,0,0.35);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 3px;
  pointer-events: none;
}
.area-plan #view-week.week-zoomed-detail .mini-block-scope { display: block; }

.area-plan .mini-block-time {
  display: none;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  color: rgba(0,0,0,0.35);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 3px;
  pointer-events: none;
}
.area-plan #view-week.week-zoomed-detail .mini-block-time { display: block; }

.area-plan .mini-block.unavailable   { background: var(--color-unavailable); }
.area-plan .mini-block.avail-ip      { background: var(--color-avail-ip); box-shadow: inset 0 0 0 1px var(--color-border); }
.area-plan .mini-block.avail-online  { background: var(--color-avail-online); }
.area-plan .mini-block.booked-ip     { background: var(--color-booked-ip); }
.area-plan .mini-block.booked-online { background: var(--color-booked-online); }
.area-plan .mini-block.meeting       { background: var(--color-meeting); }
.area-plan .mini-block.admin         { background: var(--color-admin); }
.area-plan .mini-block.not-available { background: var(--color-not-available); }
.area-plan .mini-block.hold          { background: var(--color-hold); }

.area-plan #view-week.week-search-active .mini-block { opacity: 0.15; }
.area-plan #view-week.week-search-active .mini-block.mini-block-match { opacity: 1; }

.area-plan .week-empty {
  padding: 60px 40px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ── Day View ────────────────────────────────────────────────────────────── */

.area-plan .day-grid {
  display: grid;
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
}

.area-plan .day-corner {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  gap: 1px;
}

.area-plan .day-corner-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.area-plan .day-corner-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  flex: 1;
  white-space: nowrap;
}

.area-plan .day-nav-btn {
  background: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.area-plan .day-nav-btn:disabled { opacity: 0.25; cursor: default; }
.area-plan .day-nav-btn:not(:disabled):hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.area-plan .day-teacher-header {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}
.area-plan .day-teacher-header:hover { background: var(--color-primary-light); }
.area-plan .day-teacher-header:hover .day-teacher-name { color: var(--color-primary); }

.area-plan .day-teacher-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.area-plan .day-format-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.area-plan .day-format-badge.fmt-ip     { background: var(--color-primary-light); color: var(--color-primary); }
.area-plan .day-format-badge.fmt-online { background: #DCFCE7; color: #15803D; }
.area-plan .day-format-badge.fmt-both   { background: #FEF9C3; color: #92400E; }

.area-plan .day-time-label {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  left: 0;
  z-index: 5;
  height: 36px;
  padding: 3px 8px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
.area-plan .day-time-half {
  border-bottom: 1px dashed var(--color-border);
  font-size: 9px;
  color: var(--color-text-muted);
  justify-content: flex-end;
  padding-right: 4px;
}
.area-plan .day-time-quarter { border-bottom: 1px dotted rgba(0,0,0,0.1); }

.area-plan .day-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  height: 36px;
  padding: 2px 6px;
  font-size: 11px;
  overflow: hidden;
}
.area-plan .day-cell-half      { border-bottom: 1px dashed var(--color-border); }
.area-plan .day-cell-quarter   { border-bottom: 1px dotted rgba(0,0,0,0.1); }
.area-plan .day-cell-clickable { cursor: pointer; }
.area-plan .day-cell-clickable:hover { filter: brightness(0.93); }

.area-plan .day-cell.unavailable   { background: var(--color-unavailable); }
.area-plan .day-cell.avail-ip      { background: var(--color-avail-ip); }
.area-plan .day-cell.avail-online  { background: var(--color-avail-online); }
.area-plan .day-cell.booked-ip     { background: var(--color-booked-ip); }
.area-plan .day-cell.booked-online { background: var(--color-booked-online); }
.area-plan .day-cell.meeting       { background: var(--color-meeting); }
.area-plan .day-cell.admin         { background: var(--color-admin); }
.area-plan .day-cell.not-available { background: var(--color-not-available); }
.area-plan .day-cell.hold          { background: var(--color-hold); }
.area-plan .day-cell.booked-meeting       { background: var(--color-meeting); }
.area-plan .day-cell.booked-admin         { background: var(--color-admin); }
.area-plan .day-cell.booked-not-available { background: var(--color-not-available); }

/* Spanning session cell — height comes from the grid rows it spans */
.area-plan .day-cell.day-cell-span {
  height: auto;
  align-self: stretch;
  border-bottom: 2px solid rgba(0,0,0,0.15);
  z-index: 2;
}

/* Session label inside a booked cell */
.area-plan .session-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.area-plan .session-block-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.75);
}
.area-plan .session-block-venue {
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.50);
}
.area-plan .session-block-scope {
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.40);
}
.area-plan .session-block-time {
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(0,0,0,0.40);
}

/* ── Slot panel (right-docked grid column) ───────────────────────────────── */

.area-plan #slot-panel {
  grid-area: panel;
  width: 360px;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.area-plan #slot-panel.open   { transform: translateX(0); }
.area-plan #slot-panel.hidden { display: none; }

.area-plan .slot-panel-header {
  background: var(--color-primary-dark);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.area-plan .slot-panel-header button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.area-plan .slot-panel-header button:hover { background: rgba(255,255,255,0.25); }

.area-plan #slot-panel-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.area-plan #slot-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Slot panel content ──────────────────────────────────────────────────── */

.area-plan .panel-loading {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 8px 0;
}
.area-plan .panel-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 4px 0 12px;
}
.area-plan .panel-session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.area-plan .panel-session-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.area-plan .panel-session-info {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 2px;
  align-items: start;
  flex: 1;
  min-width: 0;
}
.area-plan .panel-session-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.area-plan .panel-session-item:hover .panel-session-actions { opacity: 1; }
.area-plan .panel-session-tag {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.area-plan .tag-student        { background: var(--color-avail-ip);      color: var(--color-text); border: 1px solid var(--color-border); }
.area-plan .tag-meeting        { background: var(--color-meeting);       color: #1e40af; }
.area-plan .tag-admin          { background: var(--color-admin);         color: #5b21b6; }
.area-plan .tag-not-available  { background: var(--color-not-available); color: #374151; }
.area-plan .panel-session-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.area-plan .panel-session-meta { font-size: 11px; color: var(--color-text-muted); }
.area-plan .panel-session-venue {
  grid-column: 2;
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}
.area-plan .panel-session-exported {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  margin-top: 2px;
  width: fit-content;
}
.area-plan .panel-add-btn { width: 100%; margin-top: 4px; }
.area-plan .panel-add-form {
  margin-top: 12px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}
.area-plan .panel-edit-notice {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: 0 0 8px;
}
.area-plan .panel-delete-confirm { padding: 4px 0; }
.area-plan .panel-delete-confirm p { font-size: 13px; margin: 0 0 6px; }
.area-plan .panel-delete-warning { color: #b45309; font-size: 12px; }

/* ── Slot add form ───────────────────────────────────────────────────────── */

.area-plan .slot-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.area-plan .slot-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.area-plan .slot-form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.area-plan .slot-form-group input,
.area-plan .slot-form-group select,
.area-plan .slot-form-group textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  box-sizing: border-box;
}
.area-plan .slot-form-group textarea { resize: vertical; min-height: 52px; }
.area-plan .slot-form-group input[type="checkbox"],
.area-plan .slot-form-group input[type="radio"] { width: auto; padding: 0; border: none; background: none; }

.area-plan .slot-form-dates {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.area-plan .slot-form-dates label { flex-shrink: 0; }
.area-plan .slot-form-dates input { flex: 1; min-width: 120px; }

.area-plan .slot-form-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.area-plan .sf-location-toggle {
  display: flex;
  gap: 16px;
  margin-bottom: 6px;
}
.area-plan .sf-radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  color: var(--color-text);
}

/* Specific-date chips */
.area-plan .specific-dates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 8px;
}
.area-plan .specific-date-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 10px;
  padding: 2px 8px 2px 10px;
  font-size: 12px;
  font-weight: 500;
}
.area-plan .btn-remove-date {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
}
.area-plan .btn-remove-date:hover { opacity: 1; }

/* ── Conflict modal (UNSCOPED — appended to document.body) ───────────────── */

.conflict-modal-overlay { z-index: 3000; }

.conflict-modal-dialog {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.conflict-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.conflict-section { margin-bottom: 16px; }
.conflict-section:last-of-type { margin-bottom: 0; }
.conflict-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 8px;
}
.conflict-section ul {
  margin: 0;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conflict-section li { font-size: 13px; line-height: 1.5; }

.conflict-scope {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: 4px;
  padding: 1px 5px;
}
.conflict-date-list {
  font-size: 11px;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
}
.conflict-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}
.conflict-modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* ── Teacher Profile page ────────────────────────────────────────────────── */

.area-plan .profile-page { padding: 24px 20px 40px; }

.area-plan .profile-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.area-plan .profile-top-row > .profile-section { margin-bottom: 0; }
@media (max-width: 640px) {
  .area-plan .profile-top-row { grid-template-columns: 1fr; }
}

.area-plan .profile-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--color-border);
  flex-wrap: wrap;
}
.area-plan .profile-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.area-plan .profile-email {
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
}
.area-plan .profile-email:hover { text-decoration: underline; }

.area-plan .profile-resync {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.area-plan .profile-resync #profile-resync-status:empty { display: none; }

.area-plan .profile-loading {
  padding: 40px 24px;
  font-size: 14px;
  color: var(--color-text-muted);
  font-style: italic;
}

.area-plan .profile-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  background: var(--color-surface);
  overflow: hidden;
}
.area-plan .profile-section-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background var(--transition);
}
.area-plan .profile-section-summary::-webkit-details-marker { display: none; }
.area-plan .profile-section-summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.area-plan details[open] > .profile-section-summary::before { transform: rotate(90deg); }
.area-plan details[open] > .profile-section-summary { border-bottom-color: var(--color-border); }
.area-plan .profile-section-summary:hover { background: var(--color-primary-light); }

.area-plan .profile-section-body { padding: 16px; }
.area-plan .profile-section-toolbar { margin-bottom: 12px; }

/* Subject fields grid */
.area-plan .subject-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.area-plan .subject-field-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.area-plan .subject-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.area-plan .subject-field-input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition);
}
.area-plan .subject-field-input:focus { outline: none; border-color: var(--color-primary); }

/* Availability toolbar + teacher notes */
.area-plan .avail-toolbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.area-plan .avail-toolbar-left { flex-shrink: 0; padding-top: 4px; }

.area-plan .teacher-notes-box {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.area-plan .teacher-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.area-plan .teacher-notes-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.area-plan #teacher-notes-text {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--transition);
}
.area-plan #teacher-notes-text:focus { outline: none; border-color: var(--color-primary); }

/* Resync / work-hours status messages (in the profile resync row) */
.area-plan .export-teacher-status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.area-plan .export-status-progress { background: #eff6ff; color: #1d4ed8; }
.area-plan .export-status-success  { background: #dcfce7; color: #15803d; }
.area-plan .export-status-error    { background: #fef2f2; color: #dc2626; }

/* ── Waitlist page ───────────────────────────────────────────────────────── */

.area-plan .waitlist-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.area-plan .waitlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--color-border);
}
.area-plan .waitlist-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.area-plan .wl-filter-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}
.area-plan .wl-filter-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.area-plan .wl-filter-btn:hover { color: var(--color-text); }
.area-plan .wl-filter-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.area-plan .wl-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.area-plan .wl-empty {
  font-size: 14px;
  color: var(--color-text-muted);
  padding: 32px 0;
  text-align: center;
}

.area-plan .wl-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.area-plan .wl-card-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: background var(--transition);
}
.area-plan .wl-card-summary::-webkit-details-marker { display: none; }
.area-plan .wl-card-summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.area-plan details[open] > .wl-card-summary::before { transform: rotate(90deg); }
.area-plan details[open] > .wl-card-summary { border-bottom-color: var(--color-border); }
.area-plan .wl-card-summary:hover { background: var(--color-primary-light); }

.area-plan .wl-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.area-plan .wl-card-teacher {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.area-plan .wl-card-date {
  font-size: 11px;
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-left: auto;
}

.area-plan .wl-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.area-plan .wl-badge-add       { background: #DCFCE7; color: #15803D; }
.area-plan .wl-badge-change    { background: #FEF9C3; color: #92400E; }
.area-plan .wl-badge-remove    { background: #FEE2E2; color: #DC2626; }
.area-plan .wl-badge-new       { background: var(--color-primary-light); color: var(--color-primary); }
.area-plan .wl-badge-ip        { background: #FEF9C3; color: #92400E; }
.area-plan .wl-badge-done      { background: #F1F5F9; color: #64748B; }
.area-plan .wl-badge-cancelled { background: #F1F5F9; color: #94A3B8; }

.area-plan .wl-card-body { padding: 14px 16px; }
.area-plan .wl-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 3px;
}
.area-plan .wl-info-field { margin-bottom: 10px; }
.area-plan .wl-info-field:last-child { margin-bottom: 0; }
.area-plan .wl-value {
  font-size: 13px;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}
.area-plan .wl-action-section {
  border-top: 1px solid var(--color-border);
  margin-top: 12px;
  padding-top: 12px;
}
.area-plan .wl-action-row { display: flex; gap: 12px; flex-wrap: wrap; }
.area-plan .wl-action-field { display: flex; flex-direction: column; }
.area-plan .wl-action-field select {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  min-width: 160px;
}
.area-plan .wl-action-field textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
  resize: vertical;
  min-height: 52px;
  box-sizing: border-box;
}
.area-plan .wl-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}
.area-plan .wl-delete-confirm p {
  font-size: 13px;
  margin: 0 0 10px;
  color: var(--color-text);
}

.area-plan .wl-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.area-plan .wl-form-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 14px;
}
.area-plan .wl-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.area-plan .wl-form-field { display: flex; flex-direction: column; }
.area-plan .wl-form-wide { grid-column: 1 / -1; }
.area-plan .wl-form input,
.area-plan .wl-form select,
.area-plan .wl-form textarea {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition);
}
.area-plan .wl-form input:focus,
.area-plan .wl-form select:focus,
.area-plan .wl-form textarea:focus { outline: none; border-color: var(--color-primary); }
.area-plan .wl-form textarea { resize: vertical; min-height: 60px; }

/* ── Appointments page ───────────────────────────────────────────────────── */

.area-plan .appt-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.area-plan .appt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--color-border);
}
.area-plan .appt-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.area-plan .appt-overview-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.area-plan .appt-overview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background var(--transition), border-color var(--transition);
}
.area-plan .appt-overview-row:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}
.area-plan .appt-overview-name { flex: 1; font-weight: 600; font-size: 13px; }

.area-plan .appt-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.area-plan .appt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.area-plan .appt-chip:hover { color: var(--color-text); border-color: var(--color-primary); }
.area-plan .appt-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}
.area-plan .appt-chip-count { font-size: 11px; opacity: 0.75; }
.area-plan .appt-chip.active .appt-chip-count { opacity: 0.9; }

.area-plan .appt-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--color-text-muted);
}
.area-plan .appt-sort select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
}

.area-plan .appt-scheduler-notes { margin: 12px 0; }
.area-plan .appt-scheduler-notes textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  resize: vertical;
}
.area-plan .appt-scheduler-notes textarea:focus { outline: none; border-color: var(--color-primary); }
.area-plan .appt-sched-status {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
  min-height: 1em;
}

.area-plan .appt-status-edit { margin-bottom: 12px; max-width: 280px; }
.area-plan .appt-status-edit select {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
}
.area-plan .appt-status-edit select:focus { outline: none; border-color: var(--color-primary); }

.area-plan .appt-orphan-section {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 2px dashed var(--color-border);
}
.area-plan .appt-orphan-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.area-plan .appt-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.area-plan .appt-open-link {
  font-size: 12px;
  color: var(--color-primary);
  text-decoration: none;
}
.area-plan .appt-open-link:hover { text-decoration: underline; }

.area-plan .appt-sessions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--color-border);
}
.area-plan .appt-sessions-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.area-plan .appt-sessions-empty {
  font-size: 13px;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
}
.area-plan .appt-sessions-list { list-style: none; margin: 0; padding: 0; }
.area-plan .appt-session-row {
  display: grid;
  grid-template-columns: 90px 140px 1fr auto;
  gap: 4px 10px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}
.area-plan .appt-session-row:last-child { border-bottom: none; }
.area-plan .appt-session-day { font-weight: 600; color: var(--color-text); }
.area-plan .appt-session-time { color: var(--color-text); }
.area-plan .appt-session-teacher { color: var(--color-text-muted); }
.area-plan .appt-session-venue { color: var(--color-text-muted); font-size: 12px; }
.area-plan .appt-session-scope {
  grid-column: 2 / -1;
  color: var(--color-text-muted);
  font-size: 12px;
  font-style: italic;
}

/* ── Setup modal content (UNSCOPED — #setup-modal sits outside #area-plan) ── */

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover  { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.setup-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.setup-section-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}
.setup-list { margin-top: 8px; }
.setup-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: 6px;
}
.setup-row-active { border-color: var(--color-primary); background: var(--color-primary-light); }
.setup-row-info {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; flex: 1; min-width: 0;
}
.setup-row-info strong { font-size: 13px; }
.setup-row-meta { font-size: 12px; color: var(--color-text-muted); }
.setup-row-actions {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}

.badge-active {
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.setup-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.setup-form h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
}

.setup-empty   { font-size: 13px; color: var(--color-text-muted); padding: 12px 0; }
.setup-loading { font-size: 13px; color: var(--color-text-muted); padding: 12px 0; font-style: italic; }
.setup-error   { font-size: 13px; color: #DC2626; padding: 12px 0; }

/* Setup / term forms */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}
.form-row label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  flex: 1;
}
.form-row-2 label { flex: 1; }
.form-row-3 label { flex: 1; }
.form-row input,
.form-row select,
.form-row textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  width: 100%;
  transition: border-color var(--transition);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { outline: none; border-color: var(--color-primary); }
.form-row textarea { resize: vertical; min-height: 56px; }

.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--color-text);
  margin-bottom: 12px; cursor: pointer;
}
.form-check input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

.form-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
}

/* ── Export view (Phase 4) ───────────────────────────────────────────────── *
 * Ported from ala-scheduler's layout.css, scoped under .area-plan. The
 * Wipe & Recreate confirm modal mounts on document.body (outside #area-plan),
 * so its rules below are intentionally left UNSCOPED. */

.area-plan .export-page {
  padding: 20px 24px;
  max-width: 900px;
}
.area-plan .export-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.area-plan .export-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.area-plan .export-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.area-plan .export-term-name {
  font-size: 13px;
  color: var(--color-text-muted);
}
.area-plan .export-all-done {
  font-size: 13px;
  color: #16a34a;
  font-weight: 600;
}
.area-plan .export-global-status {
  margin-bottom: 14px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.area-plan .export-empty {
  padding: 40px 24px;
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: center;
}

.area-plan .export-teacher-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.area-plan .export-teacher-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--color-surface-alt, #f8f9fa);
  user-select: none;
  list-style: none;
}
.area-plan .export-teacher-summary::-webkit-details-marker { display: none; }
.area-plan .export-teacher-summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.area-plan details[open] > .export-teacher-summary::before { transform: rotate(90deg); }
.area-plan .export-teacher-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  flex: 1;
}
.area-plan .export-teacher-count {
  font-size: 12px;
  color: var(--color-text-muted);
}
.area-plan .export-teacher-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.area-plan .export-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.area-plan .export-chk-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.area-plan .export-session-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.area-plan .export-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.area-plan .export-session-row:hover { background: var(--color-hover, #f1f5f9); }
.area-plan .export-session-row.is-exported { cursor: default; }
.area-plan .export-action-select {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  color: var(--color-text-muted);
}
.area-plan .export-session-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.area-plan .export-session-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.area-plan .export-session-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}
.area-plan .export-badge-done {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.area-plan .export-teacher-status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.area-plan .export-status-progress { background: #eff6ff; color: #1d4ed8; }
.area-plan .export-status-success  { background: #dcfce7; color: #15803d; }
.area-plan .export-status-error    { background: #fef2f2; color: #dc2626; }

.area-plan .wh-sync-section {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius);
  background: var(--color-surface, #f8fafc);
}
.area-plan .wh-sync-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.area-plan .wh-sync-desc {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.area-plan .wipe-section {
  margin-top: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fef2f2;
}
.area-plan .wipe-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.area-plan .wipe-text { display: flex; flex-direction: column; gap: 4px; }
.area-plan .wipe-desc {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 720px;
}
.area-plan .wipe-desc code {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 11px;
}
.area-plan .wipe-error { color: #dc2626; font-weight: 600; }

/* Filled-red wipe buttons (base.css .btn-danger is text-only). The .wipe-section
   half is scoped; the .wipe-modal half is on body (see unscoped block below). */
.area-plan .wipe-section .btn-danger,
.wipe-modal .btn-danger {
  background: #dc2626;
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: background var(--transition);
}
.area-plan .wipe-section .btn-danger:hover:not(:disabled),
.wipe-modal   .btn-danger:hover:not(:disabled) { background: #991b1b; }
.area-plan .wipe-section .btn-danger:disabled,
.wipe-modal   .btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }

/* Wipe & Recreate confirm modal — mounts on document.body, so UNSCOPED. */
.wipe-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
  padding: 24px;
}
.wipe-modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  color: var(--color-text);
}
.wipe-modal-title {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: #991b1b;
}
.wipe-modal p { margin: 8px 0; }
.wipe-modal-list {
  margin: 6px 0 12px 0;
  padding-left: 20px;
}
.wipe-modal-list li { margin-bottom: 4px; line-height: 1.4; }
.wipe-modal code {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 12px;
}
.wipe-modal-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--color-border, #cbd5e1);
  border-radius: var(--radius-md);
  margin: 4px 0 16px 0;
  font-family: inherit;
}
.wipe-modal-input:focus {
  outline: none;
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}
.wipe-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Read-only gate ──────────────────────────────────────────────────────── *
 * Mirrors layout.css's `body.is-read-only #btn-new-booking` — non-schedulers
 * can browse the Plan area but every write entry point is hidden. Graph 403s
 * are the backstop for anything not covered here. */

/* Slot panel: add-session + per-session edit/delete (inside #area-plan) */
body.is-read-only .area-plan .panel-add-btn,
body.is-read-only .area-plan .panel-session-actions { display: none; }

/* Waitlist: new request + the per-card action/status form */
body.is-read-only .area-plan #btn-wl-new,
body.is-read-only .area-plan .wl-action-section,
body.is-read-only .area-plan .wl-toolbar { display: none; }

/* Appointments: status editor + scheduler-notes textarea */
body.is-read-only .area-plan .appt-status-edit,
body.is-read-only .area-plan .appt-scheduler-notes { display: none; }

/* Setup modal (mounts outside #area-plan): new/activate/delete affordances */
body.is-read-only #btn-new-term,
body.is-read-only #setup-modal .setup-row-actions,
body.is-read-only #setup-modal .setup-form { display: none; }

/* Export view: hide the entry button + every Outlook/cache write affordance */
body.is-read-only #btn-export,
body.is-read-only .area-plan .export-page button,
body.is-read-only .area-plan .export-action-select,
body.is-read-only .area-plan .wipe-section,
body.is-read-only .area-plan .wh-sync-section { display: none; }
