/* =====================================================
   School Platform — 2026 minimalist theme
   Dark (default) + Light
   Только чёрный / белый / серый + зелёный для «сейчас».
   Красный — ошибки и удаление.
   Жёлтый — notice-warn в админке.
   ===================================================== */

:root {
  color-scheme: dark;

  --bg: #000000;
  --bg-soft: #0a0a0a;
  --card: #000000;
  --card-hover: #0a0a0a;
  --card-bg: rgba(255, 255, 255, 0.02);
  --card-bg-hover: rgba(255, 255, 255, 0.05);
  --card-bg-pinned: rgba(255, 255, 255, 0.05);
  --card-border-pinned: rgba(255, 255, 255, 0.20);
  --border: rgba(255, 255, 255, 0.09);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-input: rgba(255, 255, 255, 0.10);
  --text: #ffffff;
  --text-dim: #b0b0b0;
  --muted: #6a6a6a;
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-bg-focus: rgba(255, 255, 255, 0.06);
  --select-option-bg: #0a0a0a;
  --select-option-text: #ffffff;
  --chip-bg: rgba(255, 255, 255, 0.03);
  --btn-primary-bg: #ffffff;
  --btn-primary-text: #000000;
  --btn-primary-hover-bg: transparent;
  --btn-primary-hover-text: #ffffff;
  --table-head-bg: #000000;
  --shadow-qr: 0 60px 140px rgba(0, 0, 0, 0.75),
               0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-box: 0 40px 100px rgba(0, 0, 0, 0.65);
  --overlay-bg: rgba(0, 0, 0, 0.92);
  --loading-overlay-bg: rgba(0, 0, 0, 0.6);
  --loading-box-bg: rgba(10, 10, 10, 0.94);
  --eye-fill: #ffffff;
  --eye-pupil: #000000;

  /* Нейтральные «статусные» акценты */
  --accent-strong: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.55);
  --accent-glow: rgba(255, 255, 255, 0.55);

  /* Зелёный — «сейчас идёт урок / текущий урок» */
  --green: #4ade80;
  --green-glow: rgba(74, 222, 128, 0.7);
  --row-current-bg: rgba(74, 222, 128, 0.10);
  --row-current-border: rgba(74, 222, 128, 0.28);

  /* Красный/жёлтый — только для ошибок и предупреждений */
  --red: #f87171;
  --amber: #fbbf24;

  --err-bg: rgba(248, 113, 113, 0.06);
  --err-border: rgba(248, 113, 113, 0.24);
  --danger-border: rgba(248, 113, 113, 0.4);

  --warn-bg: rgba(251, 191, 36, 0.06);
  --warn-border: rgba(251, 191, 36, 0.32);

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
          'Helvetica Neue', Arial, sans-serif;
}

/* =====================================================
   Light theme
   ===================================================== */

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f7f7f8;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f1f3;
  --card-bg: #ffffff;
  --card-bg-hover: #f4f4f6;
  --card-bg-pinned: #f4f4f6;
  --card-border-pinned: rgba(0, 0, 0, 0.16);
  --border: rgba(0, 0, 0, 0.09);
  --border-hover: rgba(0, 0, 0, 0.20);
  --border-input: rgba(0, 0, 0, 0.12);
  --text: #111111;
  --text-dim: #555555;
  --muted: #888888;
  --input-bg: #ffffff;
  --input-bg-focus: #ffffff;
  --select-option-bg: #ffffff;
  --select-option-text: #111111;
  --chip-bg: #ffffff;
  --btn-primary-bg: #111111;
  --btn-primary-text: #f7f7f8;
  --btn-primary-hover-bg: transparent;
  --btn-primary-hover-text: #111111;
  --table-head-bg: #f2f2f4;
  --shadow-qr: 0 30px 80px rgba(0, 0, 0, 0.2),
               0 0 0 1px rgba(0, 0, 0, 0.06);
  --shadow-box: 0 30px 80px rgba(0, 0, 0, 0.18);
  --overlay-bg: rgba(255, 255, 255, 0.92);
  --loading-overlay-bg: rgba(0, 0, 0, 0.25);
  --loading-box-bg: rgba(255, 255, 255, 0.96);
  --eye-fill: #111111;
  --eye-pupil: #f7f7f8;

  --accent-strong: #111111;
  --accent-soft: rgba(0, 0, 0, 0.55);
  --accent-glow: rgba(0, 0, 0, 0.35);

  /* Зелёный в светлой теме — чуть темнее для читаемости */
  --green: #109646;
  --green-glow: rgba(16, 150, 70, 0.45);
  --row-current-bg: rgba(16, 150, 70, 0.12);
  --row-current-border: rgba(16, 150, 70, 0.32);

  --red: #d53232;
  --amber: #b88000;

  --err-bg: rgba(213, 50, 50, 0.07);
  --err-border: rgba(213, 50, 50, 0.24);
  --danger-border: rgba(213, 50, 50, 0.4);

  --warn-bg: rgba(184, 128, 0, 0.08);
  --warn-border: rgba(184, 128, 0, 0.32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: inherit; }
img { display: block; max-width: 100%; }

/* =====================================================
   Header
   ===================================================== */

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 26px 40px;
  flex: 0 0 auto;
  z-index: 10;
}

.top-left {
  justify-self: start;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.top-right {
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Weather chip */
.weather {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: opacity .35s ease, background-color .25s ease,
              border-color .25s ease;
}
.weather[hidden] { display: none; }
.weather-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; color: var(--text); flex: 0 0 auto;
}
.weather-icon svg { width: 100%; height: 100%; display: block; }
.weather-temp { color: var(--text); letter-spacing: 0.01em; }

/* Brand switcher */
.brand-switcher {
  justify-self: center;
  align-self: center;
  position: relative;
  height: 46px;
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brand-item {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .7s cubic-bezier(.4, 0, .2, 1),
              transform .7s cubic-bezier(.4, 0, .2, 1);
}

.brand-eye { opacity: 1; transform: scale(1); }

.brand-eye .eye-svg {
  height: 100%;
  width: auto;
  display: block;
  animation: eyeBlink 5s ease-in-out infinite;
  transform-origin: center;
}

.eye-iris {
  transform-box: fill-box;
  transform-origin: center;
  animation: eyeLook 6s ease-in-out infinite;
}

.eye-outline, .eye-stroke { transition: fill .25s ease, stroke .25s ease; }
.brand-eye .eye-stroke { stroke: var(--eye-fill); }
.brand-eye .eye-outline { fill: var(--eye-fill); }
.brand-eye .eye-iris circle:first-child { fill: var(--eye-pupil); }
.brand-eye .eye-iris circle:last-child { fill: var(--eye-fill); }

@keyframes eyeLook {
  0%, 100%    { transform: translate(0, 0); }
  15%, 30%    { transform: translate(-16px, 0); }
  45%, 60%    { transform: translate(16px, 0); }
  78%         { transform: translate(-7px, 0); }
}

@keyframes eyeBlink {
  0%, 42%, 46%, 100% { transform: scaleY(1); }
  44%                { transform: scaleY(0.08); }
}

.brand-text {
  opacity: 0;
  transform: scale(0.94);
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  transition: opacity .7s cubic-bezier(.4, 0, .2, 1),
              transform .7s cubic-bezier(.4, 0, .2, 1),
              color .25s ease;
}

.brand-switcher.show-text .brand-eye {
  opacity: 0;
  transform: scale(0.92);
}

.brand-switcher.show-text .brand-text {
  opacity: 1;
  transform: scale(1);
}

/* Clock */
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  white-space: nowrap;
  transition: background-color .25s ease, border-color .25s ease,
              color .25s ease;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--text-dim);
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, border-color .2s ease,
              color .2s ease, transform .2s ease;
}
.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--input-bg-focus);
}
.theme-toggle:active { transform: scale(0.94); }

.theme-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.nav-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--text-dim);
  text-decoration: none;
  transition: .2s;
  flex: 0 0 auto;
}
.nav-back:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--input-bg-focus);
}

/* =====================================================
   Main stage
   ===================================================== */

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 240px;
}

.now {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 720px;
}

.now-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .3s;
}

.now-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .3s, box-shadow .3s;
}

/* Сейчас идёт урок — зелёный маркер (в любой теме) */
.now.status-lesson .dot {
  background: var(--green);
  box-shadow: 0 0 14px var(--green-glow);
  animation: pulse 2s ease-in-out infinite;
}
/* Перемена — нейтральный белый/чёрный */
.now.status-break .dot {
  background: var(--accent-strong);
  box-shadow: 0 0 14px var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}
/* Скоро начало — приглушённый */
.now.status-before .dot {
  background: var(--accent-soft);
  box-shadow: none;
}
.now.status-after .dot,
.now.status-off .dot {
  background: var(--muted);
  box-shadow: none;
}

.now.status-lesson .now-status { color: var(--green); }
.now.status-break .now-status  { color: var(--text); }
.now.status-before .now-status { color: var(--text-dim); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.now-title {
  font-size: clamp(34px, 4.4vw, 60px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
  margin: 0;
  transition: color .25s ease;
}

/* Лёгкое зелёное свечение заголовка, когда идёт урок */
.now.status-lesson .now-title {
  text-shadow: 0 0 60px rgba(74, 222, 128, 0.18);
}
html[data-theme="light"] .now.status-lesson .now-title {
  text-shadow: none;
}

.now-sub {
  font-size: 14px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* =====================================================
   Cards
   ===================================================== */

.cards {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 220px));
  justify-content: center;
  gap: 18px;
  padding: 16px 40px 44px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  text-align: center;
  transition: border-color .3s, background .3s, transform .3s,
              box-shadow .3s;
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--card-bg-hover);
  transform: translateY(-3px);
}

html[data-theme="light"] .card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
html[data-theme="light"] .card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.card.clickable { cursor: pointer; }

.card.pinned {
  border-color: var(--card-border-pinned);
  background: var(--card-bg-pinned);
}

.card-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.25;
}

.card-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
  line-height: 1.3;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: auto;
}

.card-link {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  word-break: break-all;
  letter-spacing: 0.01em;
  transition: color .2s;
  max-width: 100%;
}
.card-link:hover { color: var(--text); }

.btn-text-mobile { display: none; }
.qr-trigger { display: none; }

/* =====================================================
   QR overlay
   ===================================================== */

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--overlay-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: pointer;
  animation: qrOverlayIn .22s ease;
}
.qr-overlay[hidden] { display: none; }

.qr-overlay-img {
  display: block;
  width: min(85vmin, 900px);
  height: min(85vmin, 900px);
  object-fit: contain;
  background: #ffffff;
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow-qr);
  animation: qrPop .3s cubic-bezier(.2, 1.15, .3, 1);
}

@keyframes qrOverlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes qrPop {
  from { transform: scale(.88); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* =====================================================
   Loading overlay
   ===================================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: var(--loading-overlay-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: wait;
  animation: qrOverlayIn .2s ease;
}
.loading-overlay[hidden] { display: none; }

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px 48px;
  background: var(--loading-box-bg);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 440px;
  box-shadow: var(--shadow-box);
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}
.loading-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

/* =====================================================
   Buttons
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--btn-primary-text);
  background: var(--btn-primary-bg);
  border: 1px solid var(--btn-primary-bg);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: .2s ease;
}
.btn:hover {
  background: var(--btn-primary-hover-bg);
  color: var(--btn-primary-hover-text);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-hover);
}
.btn-outline:hover {
  border-color: var(--text);
  background: var(--input-bg-focus);
}

.btn.small { padding: 7px 14px; font-size: 12px; }

.btn.danger {
  background: transparent;
  color: var(--red);
  border-color: var(--danger-border);
}
.btn.danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn[disabled], .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
input[disabled], select[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================
   Page container
   ===================================================== */

.page {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 40px 60px;
}

.page.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.page-title {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title-sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.shift-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-hover);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.02em;
  background: var(--chip-bg);
}

.page-foot {
  margin-top: 26px;
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mode tabs */
.mode-tabs {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  gap: 2px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
  transition: .2s;
  white-space: nowrap;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  background: var(--text);
  color: var(--bg);
}

/* =====================================================
   Forms
   ===================================================== */

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .2s, background .2s, color .2s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  border-color: var(--border-hover);
  background: var(--input-bg-focus);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 4.5L6 7.5L9 4.5' stroke='%23b0b0b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
select option {
  background: var(--select-option-bg);
  color: var(--select-option-text);
}
select optgroup {
  background: var(--select-option-bg);
  color: var(--muted);
}

input[type=date], input[type=time], input[type=datetime-local] {
  color-scheme: dark;
}
html[data-theme="light"] input[type=date],
html[data-theme="light"] input[type=time],
html[data-theme="light"] input[type=datetime-local] {
  color-scheme: light;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 9999s ease-in-out 0s;
}

input[type=file] {
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
}
input[type=file]::file-selector-button {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
  margin-right: 10px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: .2s;
}
input[type=file]::file-selector-button:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.filter {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter label,
.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 140px;
  min-width: 120px;
}

.grid-form label.narrow,
.filter label.narrow { flex: 0 1 90px; min-width: 80px; }

.filter label > span,
.grid-form label > span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 16px 0;
}

.add-form {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 22px;
  margin-bottom: 18px;
}

/* =====================================================
   Schedule — чёрный фон / белый текст,
   текущий урок подсвечивается зелёным
   ===================================================== */

.schedule-filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.schedule-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}
.schedule-filters label > span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  transition: background-color .25s ease;
}

table.schedule {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card);
}

table.schedule thead th {
  padding: 16px 18px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--table-head-bg);
}

table.schedule tbody td {
  padding: 16px 18px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table.schedule tbody tr:last-child td { border-bottom: none; }

table.schedule td.num {
  width: 60px;
  text-align: center;
  font-weight: 500;
  font-size: 16px;
  color: var(--text-dim);
}

table.schedule td.time {
  white-space: nowrap;
  text-align: left;
  width: 120px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
table.schedule td.time span { color: var(--text); }
table.schedule td.time small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

table.schedule.schedule-day tr.empty-row { opacity: .35; }

table.schedule .subj {
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  font-size: 15px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
table.schedule .subgroup {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}
table.schedule .dash { color: var(--muted); }
table.schedule .teacher-cell,
table.schedule .room-cell {
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}
table.schedule .teacher-cell > div,
table.schedule .room-cell > div { padding: 1px 0; }

table.schedule .class-cell {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}
table.schedule .class-cell .shift-mark {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

table.schedule tr.break-row td {
  padding: 10px 18px;
  background: var(--break-bg);
  border-bottom: 1px dashed var(--border);
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
table.schedule tr.break-row .break-label {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-right: 10px;
}
table.schedule tr.break-row .break-time {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
}
table.schedule tr.break-row .break-duration {
  color: var(--muted);
  font-size: 11px;
}

/* === ТЕКУЩИЙ УРОК — зелёная подсветка в любой теме === */
table.schedule tr.current td {
  background: var(--row-current-bg);
  border-bottom-color: var(--row-current-border);
  color: var(--text);
}
table.schedule tr.current td.num { color: var(--green); }
table.schedule tr.current .subj { color: var(--green); }
table.schedule tr.current td.time span { color: var(--green); }
table.schedule tr.current td.time small { color: var(--green); opacity: 0.75; }
table.schedule tr.current .teacher-cell,
table.schedule tr.current .room-cell {
  color: var(--green);
  opacity: 0.9;
}
/* Лёгкая левая полоска для акцента */
table.schedule tr.current td:first-child {
  box-shadow: inset 3px 0 0 0 var(--green);
}

/* =====================================================
   Login
   ===================================================== */

.auth { padding-top: 40px; }
.auth-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.auth-form label > span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-form .btn { margin-top: 8px; }

/* =====================================================
   Admin details
   ===================================================== */

details { border-top: 1px solid var(--border); padding: 22px 0; }
details:last-of-type { border-bottom: 1px solid var(--border); }

details.nested {
  border-top: 1px dashed var(--border);
  border-bottom: none;
  margin-top: 18px;
  padding-top: 18px;
}
details.nested:last-of-type { border-bottom: none; }

details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color .2s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .25s;
  margin-left: 2px;
  flex: 0 0 auto;
}
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--text); }
.details-body { padding-top: 18px; }

/* Notices */
.notice {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  margin: 12px 0 18px;
}
.notice b { color: var(--text); font-weight: 500; }
.notice-warn {
  color: var(--amber);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.bells-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 12px;
}
.bells-status-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.bells-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.bells-status-item.ok {
  border-color: var(--border-hover);
  color: var(--text);
}
.bells-status-item.ok .bells-status-dot {
  background: var(--accent-strong);
  box-shadow: 0 0 10px var(--accent-glow);
}
.bells-status-item.missing {
  border-color: var(--warn-border);
  color: var(--amber);
}
.bells-status-item.missing .bells-status-dot {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

/* Admin rows */
.rows { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: border-color .2s, background-color .2s;
}
.admin-row:hover { border-color: var(--border-hover); }
.admin-row.pinned {
  border-color: var(--card-border-pinned);
  background: var(--card-bg-pinned);
  box-shadow: inset 0 0 0 1px var(--border);
}
.badge-pin {
  position: absolute;
  top: -9px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--text);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.row-form {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.row-form > input,
.row-form > select {
  flex: 1 1 110px;
  min-width: 90px;
}
.thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  flex: 0 0 auto;
}
.qr-title {
  flex: 0 0 120px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.check {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}
.check input { width: auto; }

.shift-group { margin-top: 22px; }
.shift-group:first-of-type { margin-top: 4px; }
.shift-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

/* Batch form */
.batch-form {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
}
.batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.batch-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.batch-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.batch-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.batch-foot.end { justify-content: flex-end; }

.lesson-rows-head, .lesson-row {
  display: grid;
  grid-template-columns: 70px 1fr 1fr 90px 40px;
  gap: 8px;
  align-items: center;
}
.lesson-rows-head {
  padding: 0 4px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.lesson-rows { display: flex; flex-direction: column; gap: 8px; }
.lesson-row input { padding: 9px 11px; }
.lesson-row .row-remove {
  padding: 6px 10px;
  font-size: 12px;
  justify-self: start;
}

/* Misc */
.empty {
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
  font-size: 14px;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
  line-height: 1.55;
}
.link-muted {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
  margin: 0;
}
.qr-large {
  width: min(360px, 80vw);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
  border-radius: 22px;
  padding: 14px;
}

.flashes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 40px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
}
.flash.ok {
  color: var(--text);
  background: var(--card-bg);
  border-color: var(--border-hover);
}
.flash.error {
  color: var(--red);
  background: var(--err-bg);
  border-color: var(--err-border);
}

/* =====================================================
   STAND MODE (9:16)
   ===================================================== */

.stand .card-link { display: none !important; }
.stand .card.clickable { cursor: default; }
.stand .qr-trigger { display: inline-flex; }
.stand .theme-toggle { display: none; }

.stand .top { padding: 40px 60px; gap: 24px; }
.stand .top-left { gap: 18px; }
.stand .brand-switcher { height: 68px; min-width: 340px; }
.stand .brand-text { font-size: 28px; }

.stand .weather { padding: 14px 22px; gap: 12px; font-size: 18px; }
.stand .weather-icon { width: 26px; height: 26px; }

.stand .clock { font-size: 18px; padding: 14px 22px; letter-spacing: 0.14em; }
.stand .nav-back { width: 48px; height: 48px; }

.stand .stage { padding: 20px 40px; min-height: 200px; }
.stand .now-title { font-size: clamp(38px, 3.2vw, 56px); }
.stand .now-sub { font-size: 16px; }

.stand .cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
  max-width: 820px;
  padding: 20px 60px 70px;
}
.stand .card {
  padding: 32px 26px;
  gap: 20px;
  border-radius: 26px;
}
.stand .card:hover { transform: none; }
.stand .card-title { font-size: 18px; font-weight: 500; }
.stand .card-desc { font-size: 13px; }
.stand .card-actions { gap: 12px; }
.stand .card-actions .btn { padding: 14px 22px; font-size: 15px; }

.stand .schedule-filters { display: flex; gap: 20px; }
.stand .schedule-filters label { min-width: 200px; }
.stand .schedule-filters label > span { font-size: 12px; letter-spacing: 0.1em; }
.stand .schedule-filters select {
  font-size: 18px;
  padding: 14px 44px 14px 18px;
  border-radius: 14px;
}
.stand .schedule-foot { display: none !important; }

.stand .page-head { justify-content: space-between; align-items: flex-end; }
.stand .page-title { font-size: 34px; }
.stand .page-title-sub { font-size: 18px; }
.stand .shift-pill { font-size: 16px; padding: 5px 14px; }

.stand table.schedule { font-size: 18px; }
.stand table.schedule thead th { padding: 20px 22px; font-size: 12px; }
.stand table.schedule tbody td { padding: 20px 22px; }
.stand table.schedule td.num { font-size: 22px; width: 80px; }
.stand table.schedule .subj { font-size: 20px; }
.stand table.schedule .teacher-cell,
.stand table.schedule .room-cell { font-size: 16px; }
.stand table.schedule tr.break-row td { padding: 12px 22px; font-size: 14px; }
.stand table.schedule tr.break-row .break-label { font-size: 11px; }
.stand table.schedule tr.break-row .break-duration { font-size: 13px; }

.stand body, .stand { overflow: hidden; }

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 900px) {
  .top { padding: 20px 24px; gap: 10px; }
  .top-left { gap: 8px; }
  .top-right { gap: 8px; }
  .nav-back { width: 36px; height: 36px; }
  .theme-toggle { width: 36px; height: 36px; }
  .theme-icon { width: 16px; height: 16px; }
  .weather { padding: 7px 11px; gap: 6px; font-size: 12px; }
  .weather-icon { width: 16px; height: 16px; }
  .clock { font-size: 12px; padding: 8px 12px; }
  .brand-switcher { height: 40px; min-width: 180px; }
  .brand-text { font-size: 16px; }

  .stage { padding: 16px; min-height: 180px; }
  .cards {
    padding: 12px 20px 32px;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    max-width: 640px;
  }
  .card { padding: 18px 14px; border-radius: 18px; gap: 12px; }
  .card-title { font-size: 14px; }
  .now-title { font-size: clamp(26px, 8vw, 40px); }
  .page { padding: 12px 20px 48px; }

  .page-head { align-items: flex-start; gap: 16px; }
  .schedule-filters { width: 100%; }
  .schedule-filters label { flex: 1; min-width: 130px; }

  .lesson-rows-head, .lesson-row { grid-template-columns: 60px 1fr 1fr 80px 40px; }

  .loading-box { padding: 30px 32px; }
}

@media (max-width: 640px) {
  .btn-text-desktop { display: none; }
  .btn-text-mobile  { display: inline; }
  .schedule-foot { display: none; }
}

@media (max-width: 520px) {
  .top { padding: 14px 14px; gap: 8px; }
  .top-left { gap: 6px; }
  .top-right { gap: 6px; }
  .nav-back { width: 34px; height: 34px; }
  .theme-toggle { width: 32px; height: 32px; }
  .theme-icon { width: 15px; height: 15px; }
  .weather { padding: 6px 10px; gap: 5px; font-size: 11px; }
  .weather-icon { width: 14px; height: 14px; }
  .clock { font-size: 11px; padding: 6px 10px; letter-spacing: 0.06em; }
  .brand-switcher { height: 34px; min-width: 120px; }
  .brand-text { font-size: 13px; }

  .now-status { font-size: 10px; letter-spacing: 0.16em; }
  .now-sub { font-size: 12px; }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px 14px 24px;
    gap: 10px;
  }
  .card { padding: 14px 10px; gap: 10px; }
  .card-desc { display: none; }
  .btn { font-size: 12px; padding: 9px 14px; }

  .page-head { gap: 10px; }
  .page-title { font-size: 20px; }
  .page-title-sub { font-size: 12px; }
  .shift-pill { font-size: 11px; padding: 2px 8px; }

  .mode-tabs { padding: 3px; }
  .mode-tab { padding: 6px 12px; font-size: 12px; }

  table.schedule thead th { padding: 12px 12px; }
  table.schedule tbody td { padding: 12px 12px; }
  table.schedule td.num { width: 44px; font-size: 14px; }
  table.schedule td.time { width: 90px; font-size: 13px; }
  table.schedule .subj { font-size: 14px; }
  table.schedule .teacher-cell,
  table.schedule .room-cell { font-size: 12px; white-space: normal; }
  table.schedule tr.break-row td { padding: 8px 12px; font-size: 11px; }
  table.schedule tr.break-row .break-label { font-size: 9px; margin-right: 6px; }
  table.schedule tr.break-row .break-time { margin-right: 6px; }

  .admin-row { flex-wrap: wrap; }
  .row-form > input, .row-form > select { flex: 1 1 100%; }
  .qr-title { flex: 1 1 100%; }

  .lesson-rows-head { display: none; }
  .lesson-row {
    grid-template-columns: 60px 1fr 40px;
    grid-template-areas:
      "num subj close"
      "num teacher close"
      "num room close";
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .lesson-row > input:nth-child(1) { grid-area: num; }
  .lesson-row > input:nth-child(2) { grid-area: subj; }
  .lesson-row > input:nth-child(3) { grid-area: teacher; }
  .lesson-row > input:nth-child(4) { grid-area: room; }
  .lesson-row .row-remove { grid-area: close; align-self: start; }

  .batch-form { padding: 12px; }
  .batch-head { gap: 8px; }

  .loading-box { padding: 24px; max-width: 90vw; }
}

@media (max-width: 380px) {
  .weather { padding: 6px 8px; }
  .weather-temp { display: none; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .top { padding: 10px 24px; gap: 10px; }
  .brand-switcher { height: 30px; }
  .weather { padding: 5px 10px; font-size: 11px; gap: 5px; }
  .weather-icon { width: 14px; height: 14px; }
  .stage { padding: 8px 16px; min-height: 100px; }
  .now-title { font-size: 24px !important; }
  .now-sub { display: none; }
  .cards { padding: 8px 16px 16px; gap: 10px; }
  .card { padding: 12px; gap: 8px; }
}