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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f1f3f4;
  --surface-active: #e8eaed;
  --border: #dadce0;
  --border-focus: #a8a29e;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #e8f0fe;
  --accent-surface: #f0f7ff;
  --success: #1e8e3e;
  --success-light: #e6f4ea;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --danger: #d93025;
  --danger-hover: #b3261e;
  --danger-light: #fce8e6;
  --purple: #9334e6;
  --purple-light: #f3e8fd;
  --boy-bg: #e3f2fd;
  --boy-border: #64b5f6;
  --boy-text: #1565c0;
  --girl-bg: #f8e8ff;
  --girl-border: #ce93d8;
  --girl-text: #7b1fa2;
  --conflict-bg: #fff0f0;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
  --shadow: 0 1px 3px rgba(60,64,67,0.15), 0 1px 2px rgba(60,64,67,0.1);
  --shadow-md: 0 4px 8px rgba(60,64,67,0.15), 0 1px 3px rgba(60,64,67,0.1);
  --shadow-lg: 0 8px 16px rgba(60,64,67,0.15);
  --transition: 150ms ease;
  --sidebar-width: 340px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-hover: #1f2b47;
  --surface-active: #283550;
  --border: #2a3a5c;
  --border-focus: #4a5a7c;
  --text: #e8e8e8;
  --text-secondary: #a0a8b8;
  --text-muted: #6a7a8a;
  --accent: #4dabf7;
  --accent-hover: #74c0fc;
  --accent-light: #1a3a5c;
  --accent-surface: #1a2a4c;
  --success: #51cf66;
  --success-light: #1a3a2a;
  --warning: #fcc419;
  --warning-light: #3a3520;
  --danger: #ff6b6b;
  --danger-hover: #ff8787;
  --danger-light: #3a1a1a;
  --purple: #b197fc;
  --purple-light: #2a1a3a;
  --boy-bg: #1a2a4c;
  --boy-border: #4a8abf;
  --boy-text: #74c0fc;
  --girl-bg: #2a1a3a;
  --girl-border: #9a6aaf;
  --girl-text: #d0a0e0;
  --conflict-bg: #3a1a1a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.5);
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: scale(1.05);
}

.lang-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 3px;
}

.lang-btn {
  padding: 6px 12px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.lang-btn:hover { color: var(--text); background: var(--surface); }
.lang-btn.active { background: var(--accent); color: white; }

.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 57px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
  flex-shrink: 0;
}

.tab-nav-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}

.tab-nav-btn:hover { color: var(--text); background: var(--surface); }
.tab-nav-btn.active { color: var(--accent); background: var(--surface); border-bottom-color: var(--accent); }

.tab-icon { font-size: 1.2rem; }

.tab-content {
  display: none;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
}

.tab-content.active { display: flex; }

/* ===== PANELS ===== */
.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header.collapsible { cursor: pointer; user-select: none; padding: 4px 0; margin: -4px 0 8px; }
.section-header.collapsible:hover { color: var(--text); }

.collapse-icon { font-size: 0.65rem; transition: transform var(--transition); }
.collapsible-content.collapsed { display: none; }

.count, .badge-count {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  margin-left: 6px;
}

.badge-count { background: var(--danger-light); color: var(--danger); }

/* ===== INPUTS ===== */
.input-row { display: flex; gap: 8px; margin-bottom: 10px; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

textarea.bulk-input {
  min-height: 70px;
  resize: vertical;
  margin-bottom: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #1a7a36; }

[data-theme="dark"] .btn-success:hover:not(:disabled) { background: #40b856; }

.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-focus); }

.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: white; }

.btn-ghost { background: none; color: var(--text-secondary); padding: 6px 8px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

.btn.active-mode { background: var(--accent); color: white; border-color: var(--accent); }
.btn.active-mode:hover { background: var(--accent-hover); }

/* ===== STUDENT COUNT CONTROL ===== */
.student-count-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.student-count-control .count-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  line-height: 1;
  font-family: inherit;
}

.student-count-control .count-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.count-display {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  color: var(--text);
}

/* ===== RULE TYPE SELECTOR ===== */
.rule-type-selector { display: flex; flex-direction: column; gap: 6px; }

.rule-type-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
}

.rule-type-btn:hover { background: var(--surface-hover); border-color: var(--border-focus); }

.rule-type-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.rule-type-btn[data-rule="noAdjacent"].active { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.rule-type-btn[data-rule="mustAdjacent"].active { background: var(--success-light); border-color: var(--success); color: var(--success); }
.rule-type-btn[data-rule="frontRow"].active,
.rule-type-btn[data-rule="backRow"].active { background: var(--purple-light); border-color: var(--purple); color: var(--purple); }

.rule-icon { font-size: 1.1rem; }

/* ===== RESTRICTION SELECTOR ===== */
.restriction-selector { display: flex; gap: 8px; align-items: center; }
.restriction-selector select { flex: 1; min-width: 0; }
.separator { color: var(--text-muted); font-weight: 600; }

/* ===== STUDENT SEARCH ===== */
.student-search {
  margin-bottom: 8px;
  position: relative;
}

.student-search input {
  padding: 8px 32px 8px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius);
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: var(--surface-active);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  line-height: 1;
}

.search-clear-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* ===== STUDENT LIST ===== */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 250px;
  overflow-y: auto;
}

.student-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.student-item:hover { background: var(--surface-hover); }

.student-name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 450;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.student-name:hover { text-decoration: underline; color: var(--accent); }

.student-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.student-item:hover .student-actions { opacity: 1; }

/* ===== GENDER TOGGLE ===== */
.gender-toggle {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  font-weight: 700;
}

.gender-toggle.gender-boy { background: var(--boy-bg); border-color: var(--boy-border); color: var(--boy-text); }
.gender-toggle.gender-girl { background: var(--girl-bg); border-color: var(--girl-border); color: var(--girl-text); }
.gender-toggle:hover { transform: scale(1.2); box-shadow: var(--shadow-sm); }

/* ===== PIN BUTTON ===== */
.pin-btn { opacity: 0.3; font-size: 0.7rem; transition: opacity var(--transition); }
.pin-btn.pin-active { opacity: 1; }
.student-item:hover .pin-btn { opacity: 0.6; }
.pin-btn:hover { opacity: 1 !important; }

/* ===== RESTRICTION LIST ===== */
.restriction-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.restriction-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.82rem;
}

.restriction-item.noAdjacent { background: var(--danger-light); border: 1px solid var(--danger); }
.restriction-item.mustAdjacent { background: var(--success-light); border: 1px solid var(--success); }
.restriction-item.frontRow,
.restriction-item.backRow { background: var(--purple-light); border: 1px solid var(--purple); }

.restriction-item .rule-text { flex: 1; font-weight: 500; }
.restriction-item .rule-icon-small { font-size: 0.9rem; }

/* ===== GRID CONFIG ===== */
.grid-config, .desk-config { display: flex; gap: 12px; margin-bottom: 12px; }

.config-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 70px; }
.config-field label { font-size: 0.72rem; font-weight: 500; color: var(--text-secondary); }
.config-field input { text-align: center; }

/* ===== HINT TEXT ===== */
.hint-text { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 8px; }

.hint-text.rule-click-active {
  color: var(--warning);
  font-weight: 600;
  font-style: normal;
  background: var(--warning-light);
  padding: 6px 10px;
  border-radius: var(--radius);
  animation: pulse-hint 1.5s ease infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== TEMPLATE SELECTOR ===== */
.template-selector { display: flex; flex-direction: column; gap: 6px; }

.template-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
}

.template-btn:hover { background: var(--surface-hover); border-color: var(--border-focus); }
.template-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.template-icon { font-size: 1.1rem; }

/* ===== EXPORT BUTTONS ===== */
.export-buttons { display: flex; flex-direction: column; gap: 8px; }

/* ===== MAIN AREA ===== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.main-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar-info { display: flex; gap: 12px; flex-wrap: wrap; }

.info-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-hover);
  border-radius: 99px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ===== CLASSROOM CONTAINER ===== */
.classroom-container {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.classroom-container.blocking-mode { cursor: crosshair; }
.classroom-container.desk-placement-mode { cursor: crosshair; }

.classroom-grid-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.classroom-row { display: flex; gap: 8px; }

.classroom-cell {
  position: relative;
  width: 90px;
  height: 56px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--surface);
  transition: all var(--transition);
  margin: 3px;
  padding: 4px 6px;
}

/* ===== STUDENT CELLS ===== */
.classroom-cell.student {
  cursor: grab;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.classroom-cell.student.gender-boy { background: var(--boy-bg); border-color: var(--boy-border); color: var(--boy-text); }
.classroom-cell.student.gender-girl { background: var(--girl-bg); border-color: var(--girl-border); color: var(--girl-text); }

.classroom-cell.student .student-name-cell {
  display: block;
  width: 100%;
  text-align: center;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.15;
  font-size: 0.75rem;
  max-height: 36px;
}

.classroom-cell.student:active { cursor: grabbing; }
.classroom-cell.student.dragging { opacity: 0.5; transform: scale(0.95); }

/* ===== PINNED ===== */
.classroom-cell.student.pinned { border-width: 3px; }

.cell-pin {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 0.55rem;
  cursor: pointer;
  z-index: 2;
  transition: all var(--transition);
}

.cell-pin.pinned {
  opacity: 0.8;
}

.cell-pin.pinned:hover {
  opacity: 1;
  transform: scale(1.3);
}

.cell-pin.unpinned {
  opacity: 0;
}

.classroom-cell.student:hover .cell-pin.unpinned {
  opacity: 0.4;
}

.cell-pin.unpinned:hover {
  opacity: 0.8 !important;
  transform: scale(1.3);
}

/* ===== GENDER INDICATOR IN CELL ===== */
.cell-gender {
  position: absolute;
  top: 0px;
  left: 16px;
  font-size: 0.85rem;
  cursor: pointer;
  z-index: 2;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  transition: all var(--transition);
}

.cell-gender:hover { transform: scale(1.3); }
.gender-indicator-boy { color: var(--boy-text); background: var(--boy-bg); }
.gender-indicator-girl { color: var(--girl-text); background: var(--girl-bg); }

/* ===== RULE CLICK ===== */
.classroom-cell.student.rule-clickable { cursor: pointer; }

.classroom-cell.student.rule-click-selected {
  box-shadow: 0 0 0 3px rgba(249, 171, 0, 0.4);
  border-color: var(--warning) !important;
}

/* ===== CONFLICT - bright red, clearly distinct from girl purple ===== */
.classroom-cell.conflict {
  background: var(--conflict-bg) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  box-shadow: inset 0 0 0 2px rgba(217, 48, 37, 0.2);
  animation: pulse-conflict 1.5s ease infinite;
}

.classroom-cell.conflict::after {
  content: '⚠';
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 0.7rem;
  color: var(--danger);
  z-index: 2;
}

@keyframes pulse-conflict {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(217, 48, 37, 0.2), 0 0 0 0 rgba(217, 48, 37, 0.3); }
  50% { box-shadow: inset 0 0 0 2px rgba(217, 48, 37, 0.2), 0 0 0 6px rgba(217, 48, 37, 0); }
}

/* ===== OTHER CELL STATES ===== */
.classroom-cell.drag-over { border-color: var(--accent); background: var(--accent-surface); border-style: dashed; }

.classroom-cell.empty { border-style: dashed; color: var(--text-muted); font-size: 0.75rem; }

.classroom-cell.blocked { background: var(--surface-active); border-color: var(--text-muted); color: var(--text-muted); }
.classroom-cell.blocked::after { content: '✕'; font-size: 1.2rem; color: var(--text-muted); }

.classroom-cell.teacher {
  background: var(--warning-light);
  border-color: var(--warning);
  color: var(--text);
  font-weight: 600;
  cursor: move;
  user-select: none;
}

.classroom-cell.teacher.dragging-desk { opacity: 0.6; cursor: grabbing; }
.classroom-cell.teacher:hover { background: #fef3c7; border-color: #f59e0b; }

[data-theme="dark"] .classroom-cell.teacher:hover { background: var(--warning-light); }

.classroom-cell.placement-preview {
  background: rgba(249, 171, 0, 0.3);
  border-color: var(--warning);
  border-style: dashed;
}

.no-select { user-select: none; -webkit-user-select: none; }

.seat-number {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 30px; color: var(--text-secondary); }
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state-text { font-size: 1rem; max-width: 300px; line-height: 1.6; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 20px;
  background: var(--text);
  color: white;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 250ms ease;
  max-width: 360px;
  pointer-events: auto;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); color: var(--text); }

[data-theme="dark"] .toast { color: #fff; }
[data-theme="dark"] .toast.warning { color: #1a1a2e; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== CONFIRM MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 200ms ease;
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modal-slide-in 200ms ease;
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
}

/* ===== PRINT ===== */
@media print {
  header, .sidebar, .main-toolbar, .toast-container { display: none !important; }
  .main-layout { display: block; }
  .main-area { overflow: visible; }
  .classroom-container { padding: 0; }
  body { background: white; }
  .classroom-cell { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-layout { flex-direction: column; height: auto; }
  .sidebar {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .tab-content { max-height: 35vh; }
  .classroom-cell { width: 70px; height: 44px; font-size: 0.72rem; }
  .main-toolbar { padding: 12px 16px; }
  .classroom-container { padding: 16px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }