/* School Master — mobile dashboard dark-mode hardening + centered logout confirmation v1.
   Loaded after the master redesign layers so phone-specific fixes win the cascade. */

.sm-logout-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483500;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 8, 31, .66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sm-logout-confirm-backdrop[hidden] {
  display: none !important;
}

body.sm-logout-confirm-open {
  overflow: hidden !important;
}

.sm-logout-confirm {
  width: min(420px, 100%);
  max-width: 100%;
  border: 1px solid color-mix(in srgb, #7c3aed 24%, var(--sm-border));
  border-radius: 22px;
  padding: 26px;
  background: var(--sm-surface);
  color: var(--sm-text);
  box-shadow: 0 30px 90px rgba(15, 8, 43, .38);
  text-align: center;
  outline: none;
}

.sm-logout-confirm-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #6d28d9;
  background: linear-gradient(145deg, #fff, #eee7ff);
  border: 1px solid #ded1fa;
  box-shadow: inset 0 2px 2px rgba(255,255,255,.92), 0 12px 24px rgba(91,33,182,.16);
}

.sm-logout-confirm-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sm-logout-confirm h2 {
  margin: 0;
  color: var(--sm-text);
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.sm-logout-confirm p {
  max-width: 330px;
  margin: 9px auto 0;
  color: var(--sm-muted);
  font-size: 13px;
  line-height: 1.55;
}

.sm-logout-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.sm-logout-confirm-actions button {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.sm-logout-confirm-cancel {
  border: 1px solid var(--sm-border);
  background: var(--sm-surface-2);
  color: var(--sm-text);
}

.sm-logout-confirm-yes {
  border: 0;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: #fff;
  box-shadow: 0 9px 22px rgba(109,40,217,.22);
}

.sm-logout-confirm-actions button:focus-visible {
  outline: 3px solid rgba(124,58,237,.24);
  outline-offset: 2px;
}

html[data-sm-theme="dark"] .sm-logout-confirm {
  border-color: #3e3661;
  background: #171e36;
  box-shadow: 0 30px 90px rgba(0,0,0,.56);
}

html[data-sm-theme="dark"] .sm-logout-confirm-icon {
  color: #c4a7ff;
  background: linear-gradient(145deg, #27203f, #1d1933);
  border-color: #40365e;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.06), 0 12px 24px rgba(0,0,0,.28);
}

html[data-sm-theme="dark"] .sm-logout-confirm-cancel {
  background: #12182e;
  border-color: #35405f;
  color: #f1f3ff;
}

/* The master redesign adds light 3D tiles after app.css; explicitly restore dark surfaces. */
html[data-sm-theme="dark"] .sm-kpi-icon {
  color: var(--accent) !important;
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--accent) 18%, #252d49),
    color-mix(in srgb, var(--accent) 9%, #171e36)) !important;
  border-color: color-mix(in srgb, var(--accent) 35%, #35405f) !important;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.08), 0 9px 18px rgba(0,0,0,.24) !important;
}

html[data-sm-theme="dark"] .sm-kpi-icon svg {
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.26)) !important;
}

html[data-sm-theme="dark"] .sm-dashboard-grid > article:has(.sm-quick-grid) .sm-quick-grid button {
  color: var(--sm-text) !important;
  background: linear-gradient(145deg, #171e36, #12182e) !important;
  border-color: #303a59 !important;
  box-shadow: 0 9px 22px rgba(0,0,0,.2) !important;
}

html[data-sm-theme="dark"] .sm-dashboard-grid > article:has(.sm-quick-grid) .sm-quick-grid button > span {
  color: #c4a7ff !important;
  background: linear-gradient(145deg, #27203f, #1d1933) !important;
  border-color: #40365e !important;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.06), 0 9px 18px rgba(0,0,0,.24) !important;
}

@media (max-width: 640px) {
  /* Keep all three mobile topbar actions visible. The legacy 560px rule hid Dark Mode. */
  .sm-topbar {
    min-width: 0 !important;
    padding-inline: 9px !important;
    gap: 5px !important;
  }

  .sm-topbar-left {
    min-width: 42px !important;
    flex: 0 0 42px !important;
  }

  .sm-topbar::before {
    width: 84px !important;
    min-width: 58px !important;
    max-width: 84px !important;
    height: 42px !important;
    flex: 0 1 84px !important;
  }

  .sm-topbar-right {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    justify-content: flex-end !important;
    gap: 3px !important;
    overflow: visible !important;
  }

  .sm-topbar-actions {
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    gap: 3px !important;
  }

  .sm-topbar-right .sm-icon-btn,
  .sm-topbar-right .sm-icon-btn:nth-of-type(2) {
    display: grid !important;
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px !important;
    border-radius: 10px !important;
  }

  /* Dashboard children shrink inside the phone viewport instead of being clipped by body overflow. */
  .sm-content,
  .sm-content > *,
  .sm-dashboard-grid,
  .sm-dashboard-grid > *,
  .sm-panel,
  .sm-panel > *,
  .sm-panel-head,
  .sm-panel-head > *,
  .sm-foundation-grid,
  .sm-foundation-grid > *,
  .sm-quick-grid,
  .sm-quick-grid > *,
  .sm-kpi-grid,
  .sm-kpi-grid > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .sm-kpi-card {
    gap: 5px !important;
    padding: 12px 8px 10px !important;
  }

  .sm-kpi-icon {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex: 0 0 40px !important;
    border-radius: 12px !important;
  }

  .sm-kpi-icon svg {
    width: 20px !important;
    height: 20px !important;
  }

  .sm-kpi-info {
    min-width: 0 !important;
    padding-left: 4px !important;
  }

  .sm-kpi-info span,
  .sm-kpi-info strong,
  .sm-kpi-info small,
  .sm-panel-head h2,
  .sm-panel-head p,
  .sm-foundation-action strong,
  .sm-foundation-action span,
  .sm-quick-grid strong {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-overflow: clip !important;
  }

  .sm-kpi-info strong,
  .sm-kpi-money .sm-kpi-info strong {
    font-size: clamp(17px, 5vw, 21px) !important;
    line-height: 1.08 !important;
  }

  .sm-kpi-trend {
    top: 6px !important;
    right: 6px !important;
  }

  .sm-chart-area,
  .sm-chart-area svg,
  .sm-summary-hero,
  .sm-donut-wrap,
  .sm-stat-list {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .sm-chart-area {
    overflow: hidden !important;
  }

  .sm-chart-area svg {
    display: block !important;
    height: auto !important;
    min-height: 190px;
  }

  .sm-summary-hero strong,
  .sm-summary-hero span {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .sm-dashboard-grid > article:has(.sm-quick-grid) .sm-quick-grid button {
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 86px !important;
    padding: 11px 8px !important;
  }

  .sm-foundation-action {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .sm-logout-confirm-backdrop {
    padding: 16px;
  }

  .sm-logout-confirm {
    width: min(390px, 100%);
    padding: 22px 18px 18px;
    border-radius: 19px;
  }

  .sm-logout-confirm-actions {
    gap: 8px;
  }
}

@media (max-width: 380px) {
  .sm-topbar {
    padding-inline: 7px !important;
    gap: 3px !important;
  }

  .sm-topbar-left {
    min-width: 40px !important;
    flex-basis: 40px !important;
  }

  .sm-menu-btn {
    width: 40px !important;
    height: 40px !important;
    flex-basis: 40px !important;
  }

  .sm-topbar::before {
    width: 66px !important;
    min-width: 48px !important;
    max-width: 66px !important;
    flex-basis: 66px !important;
  }

  .sm-topbar-right .sm-icon-btn,
  .sm-topbar-right .sm-icon-btn:nth-of-type(2) {
    width: 35px !important;
    height: 35px !important;
    flex-basis: 35px !important;
  }

  .sm-logout-confirm-actions {
    grid-template-columns: 1fr;
  }
}
