/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 230px;
  --primary:   #1e3a5f;
  --primary-light: #2c5282;
  --accent:    #3182ce;
  --accent-hover: #2b6cb0;
  --success:   #38a169;
  --danger:    #e53e3e;
  --warning:   #d69e2e;
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #2d3748;
  --text-muted:#718096;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: 'Segoe UI', 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 10000;
  padding: .6rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
}
.skip-link:focus {
  left: .75rem;
  top: .75rem;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.is-open { display: block; }
body.sidebar-open { overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .2s ease-out;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-icon { font-size: 1.4rem; }

.nav-list { list-style: none; padding: .5rem 0; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1rem;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  border-radius: 0 24px 24px 0;
  margin: 2px .5rem 2px 0;
  transition: background .15s, color .15s;
}
.nav-link:hover  { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.5rem;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sidebar-toggle-bars {
  display: block;
  width: 1.1rem;
  height: 1px;
  background: var(--text);
  box-shadow: 0 .35em 0 var(--text), 0 -.35em 0 var(--text);
}
.page-title { font-size: 1.2rem; font-weight: 600; color: var(--primary); flex: 1; min-width: 0; }

.lang-switch {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-shrink: 0;
  font-size: .82rem;
  font-weight: 600;
}
.lang-switch__opt {
  color: var(--text-muted);
  text-decoration: none;
  padding: .25rem .45rem;
  border-radius: var(--radius);
}
.lang-switch__opt:hover { color: var(--accent); }
.lang-switch__opt.is-active {
  color: var(--primary);
  background: #ebf4ff;
}
.lang-switch__sep { color: var(--border); opacity: .8; user-select: none; }

.content-area { padding: 1.5rem; flex: 1; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-success { background: #c6f6d5; color: #276749; border: 1px solid #9ae6b4; }
.alert-danger   { background: #fed7d7; color: #9b2c2c; border: 1px solid #fc8181; }
.alert-warning  { background: #fefcbf; color: #744210; border: 1px solid #f6e05e; }

/* ── Cards / Panels ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.glance-card {
  overflow: visible;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .95rem;
}
h2.card-header { margin: 0; }
.modal-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2f855a; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #c53030; }
.btn-secondary { background: #edf2f7; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; min-height: 2.25rem; }
.btn-xs { padding: .35rem .65rem; font-size: .75rem; min-height: 2.25rem; min-width: 2.25rem; justify-content: center; }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inline-delete-form { display: inline; }
.inline-delete-form .btn { vertical-align: middle; }

.group-remove-btn {
  background: rgba(0,0,0,.1);
  border: none;
  cursor: pointer;
  border-radius: 3px;
  min-width: 1.35rem;
  min-height: 1.35rem;
  padding: 0 .15rem;
  font-size: .65rem;
  line-height: 1;
  vertical-align: middle;
  margin-left: 2px;
}
.group-remove-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.is-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
th {
  background: #f7fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .65rem 1rem;
  border-bottom: 2px solid var(--border);
  text-align: left;
}
td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7fafc; }
.actions { display: flex; gap: .4rem; }

/* ── Color Dot ───────────────────────────────────────────── */
.color-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,.15);
  margin-right: 6px;
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 9999px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-blue   { background: #bee3f8; color: #2a69ac; }
.badge-green  { background: #c6f6d5; color: #276749; }
.badge-purple { background: #e9d8fd; color: #553c9a; }
.badge-orange { background: #feebc8; color: #c05621; }
.badge-gray   { background: #edf2f7; color: #4a5568; }

/* ── Dashboard stats grid ────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  text-align: center;
}
.stat-icon { font-size: 2rem; margin-bottom: .4rem; }
.stat-num  { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label{ font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
label.form-group { cursor: pointer; }
.form-group > .label-text,
label.form-group > span:first-child { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
input[type=text], input[type=email], input[type=time], input[type=number],
input[type=color], select, textarea {
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49,130,206,.15);
}
select[multiple] { min-height: 90px; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}
.modal-backdrop.open { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -60%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 300;
  width: min(700px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  transition: transform .2s, opacity .2s;
  opacity: 0;
}
.modal.open {
  display: block;
  transform: translate(-50%, -50%);
  opacity: 1;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-header .modal-title { flex: 1; min-width: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
}

/* ── Glance conflict modal ───────────────────────────────── */
.glance-conflict-intro { margin: 0 0 .75rem; color: var(--danger); font-weight: 600; }
.glance-conflict-list { margin: 0 0 1.25rem; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.glance-conflict-list li { display: flex; align-items: baseline; gap: .5rem; padding: .5rem .75rem; background: #fff5f5; border: 1px solid #fed7d7; border-radius: var(--radius); font-size: .875rem; }
.glance-conflict-icon { font-size: 1rem; flex-shrink: 0; }
.glance-free-slots-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.glance-free-slots-label { margin: 0 0 .6rem; font-size: .875rem; font-weight: 600; }
.glance-free-slots { display: flex; flex-wrap: wrap; gap: .4rem; }
.glance-free-slot-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: .35rem .6rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-size: .75rem; line-height: 1.3;
  transition: border-color .15s, background .15s;
}
.glance-free-slot-btn:hover { border-color: var(--accent); background: #ebf4ff; }
.glance-slot-day { font-weight: 700; font-size: .7rem; text-transform: uppercase; color: var(--accent); }
.glance-slot-period { font-weight: 600; }
.glance-slot-time { color: var(--text-muted, #718096); font-size: .7rem; }
.glance-no-free-slots { margin: .75rem 0 0; font-size: .875rem; color: var(--text-muted, #718096); font-style: italic; }

/* ── Timetable Grid ──────────────────────────────────────── */
.tt-wrap { overflow-x: auto; }
.tt-grid {
  border-collapse: collapse;
  min-width: 700px;
  width: 100%;
  font-size: .8rem;
}
.tt-grid th, .tt-grid td {
  border: 1px solid var(--border);
  padding: .4rem .5rem;
  vertical-align: top;
  min-width: 110px;
}
.tt-grid th {
  background: var(--primary);
  color: #fff;
  text-align: center;
  font-size: .75rem;
  letter-spacing: .04em;
  padding: .6rem .5rem;
}
.tt-period-label {
  background: #f7fafc;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  min-width: 80px;
}
.tt-period-label .time { font-size: .7rem; font-weight: 400; color: #a0aec0; }
.tt-cell { min-height: 52px; }
.tt-grid--transposed .tt-cell:not(.tt-cell--break) .lesson-block {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Transposed: days as rows (left), periods as columns (top) */
.tt-card-actions {
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .75rem;
}
/* Fixed layout: equal period columns; breaks are narrower */
.tt-grid--transposed {
  table-layout: fixed;
  width: max-content;
  min-width: min(100%, 700px);
}
.tt-grid--transposed th,
.tt-grid--transposed td {
  min-width: 0;
  box-sizing: border-box;
}
.tt-grid--transposed .tt-corner {
  background: var(--primary);
  color: #fff;
  text-align: left;
  min-width: var(--tt-day-col);
  width: var(--tt-day-col);
  max-width: var(--tt-day-col);
}
.tt-grid--transposed .tt-period-head-col {
  vertical-align: bottom;
  line-height: 1.25;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.tt-grid--transposed .tt-period-head-col:not(.tt-period-head-col--break) {
  width: var(--tt-period-col);
  min-width: var(--tt-period-col);
  max-width: var(--tt-period-col);
}
.tt-grid--transposed .tt-period-head-col--break {
  width: var(--tt-break-col);
  min-width: var(--tt-break-col);
  max-width: var(--tt-break-col);
}
.tt-grid--transposed tbody td.tt-cell:not(.tt-cell--break) {
  width: var(--tt-period-col);
  min-width: var(--tt-period-col);
  max-width: var(--tt-period-col);
}
.tt-grid--transposed tbody td.tt-cell--break {
  width: var(--tt-break-col);
  min-width: var(--tt-break-col);
  max-width: var(--tt-break-col);
}
.tt-grid--transposed .tt-ph-short {
  display: block;
  font-size: .78rem;
  font-weight: 700;
}
.tt-grid--transposed .tt-ph-time {
  display: block;
  font-size: .65rem;
  font-weight: 500;
  opacity: .92;
  margin-top: .15rem;
}
.tt-grid--transposed .tt-day-label {
  background: #f7fafc;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  font-size: .8rem;
  min-width: var(--tt-day-col);
  width: var(--tt-day-col);
  max-width: var(--tt-day-col);
}
.tt-export-root {
  --tt-day-col: 5.75rem;
  --tt-period-col: 7rem;
  --tt-break-col: 4rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.tt-period-head-col--break {
  background: #2c7a7b !important;
  color: #fff !important;
}
.tt-cell--break {
  background: repeating-linear-gradient(
    -45deg,
    #e6fffa,
    #e6fffa 4px,
    #b2f5ea 4px,
    #b2f5ea 8px
  ) !important;
  vertical-align: middle !important;
  text-align: center;
}
.tt-break-label {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  color: #234e52;
  line-height: 1.25;
}

.tt-undo-bar { margin-bottom: 0.75rem; }
.tt-cell.tt-cell--drop {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  background: rgba(30, 58, 95, 0.06);
}
.tt-draggable { cursor: grab; }
.tt-draggable.lesson-block--tt-dragging {
  cursor: grabbing;
  opacity: 0.88;
}

.glance-period-head--break {
  background: #2c7a7b !important;
  color: #fff !important;
}
.glance-cell--break {
  background: #e6fffa !important;
  vertical-align: middle !important;
  text-align: center;
}
.glance-break-label {
  font-size: .52rem;
  font-weight: 700;
  color: #234e52;
  letter-spacing: .02em;
}

.lesson-block {
  border-radius: 5px;
  padding: .3rem .45rem;
  margin-bottom: 3px;
  font-size: .75rem;
  line-height: 1.3;
}
.lesson-block strong { display: block; font-size: .8rem; }
.lesson-block .teacher-name { opacity: .9; }
.lesson-block .room-name { opacity: .75; font-size: .7rem; }
.lesson-block--light .teacher-name,
.lesson-block--light .room-name { opacity: .88; }

/* ── At a glance (whole school) ──────────────────────────── */
.glance-intro {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1.25rem;
  max-width: 52rem;
}
.glance-undo-bar {
  margin-bottom: 0.75rem;
}
.glance-confirm-list {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
}
.glance-confirm-list li {
  margin-bottom: 0.35rem;
}
.glance-confirm-note {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.glance-card-body { padding: 0 !important; }
.glance-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  scrollbar-width: none;
}
.glance-wrap::-webkit-scrollbar {
  height: 0;
  width: 0;
}

/* Fixed bottom bar: horizontal scrollbar always in view while scrolling the page */
.glance-hscroll-dock {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 0;
  right: 0;
  z-index: 300;
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}
.glance-hscroll-dock::-webkit-scrollbar {
  height: 12px;
}
.glance-hscroll-dock::-webkit-scrollbar-track {
  background: var(--border);
}
.glance-hscroll-dock::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 4px;
}
.glance-hscroll-dock::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
.glance-hscroll-dock {
  scrollbar-width: thin;
  scrollbar-color: #64748b var(--border);
}
.glance-hscroll-dock-inner {
  height: 1px;
  pointer-events: none;
}
body.glance-hscroll-active {
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
@media print {
  .glance-hscroll-dock {
    display: none !important;
  }
  body.glance-hscroll-active {
    padding-bottom: 0;
  }
}
.glance-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: .65rem;
  table-layout: fixed;
}
.glance-grid th,
.glance-grid td {
  border: 1px solid var(--border);
  padding: 2px 3px;
  vertical-align: top;
  background: var(--surface);
}
.glance-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--primary);
  color: #fff;
  text-align: center;
  font-weight: 600;
  padding: .3rem .2rem;
  font-size: .58rem;
  line-height: 1.15;
  min-width: 3.5rem;
  max-width: 5rem;
}
.glance-col-day {
  display: block;
  font-weight: 700;
  letter-spacing: .02em;
  opacity: .95;
}
.glance-period-short { display: block; font-weight: 700; }
.glance-period-time {
  display: block;
  font-weight: 400;
  opacity: .88;
  font-size: .48rem;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.glance-corner {
  left: 0;
  z-index: 4 !important;
  min-width: 5.5rem;
  max-width: 7rem;
  width: 6.5rem;
  vertical-align: middle;
  background: var(--primary) !important;
  box-shadow: 2px 0 4px rgba(0,0,0,.12);
}
.glance-class-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  font-weight: 600;
  font-size: .72rem;
  background: #f7fafc !important;
  color: var(--text);
  border-right: 2px solid var(--border) !important;
  box-shadow: 2px 0 6px rgba(0,0,0,.06);
  min-width: 5.5rem;
  max-width: 7rem;
  width: 6.5rem;
  padding: .35rem .5rem !important;
}
.glance-cell {
  min-width: 3.25rem;
  max-width: 4.5rem;
  width: 3.75rem;
  background: #fafcfd;
}
.glance-cell--drop {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  background: #e6fffa;
}
.glance-cell--break {
  cursor: default;
}
.glance-block[draggable="true"] {
  cursor: grab;
}
.glance-block[draggable="true"]:active {
  cursor: grabbing;
}
.glance-block--dragging {
  opacity: 0.65;
}
.glance-block.lesson-block {
  font-size: .58rem;
  padding: .2rem .25rem;
  margin-bottom: 2px;
  border-radius: 3px;
}
.glance-block.lesson-block strong {
  font-size: .62rem;
  line-height: 1.15;
}
.glance-block .teacher-name,
.glance-block .room-name {
  font-size: .55rem;
  display: block;
  line-height: 1.2;
}
.glance-legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .83rem;
}

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.filter-bar label { margin: 0; font-weight: 600; color: var(--text); }
.filter-bar select { width: auto; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .periods-page-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .index-two-col { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .btn { transition: none; }
  .btn:active { transform: none; }
}
