.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  border-inline-end: 1px solid var(--color-sidebar-border);
}

.sidebar-brand,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand {
  height: 64px;
  min-height: 64px;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-mark,
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5d5fef 0%, #8b5cf6 100%);
  box-shadow: 0 4px 14px rgba(93, 95, 239, 0.35);
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
  font-family: "Rubik", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 15.5px;
  letter-spacing: -0.3px;
  line-height: 1;
}

.brand-tagline {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 1px;
  flex: 1;
  overflow: auto;
}

.nav-group {
  margin-bottom: 20px;
}

.nav-section {
  margin: 0 10px 5px;
  padding-top: 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.22);
}

.nav-item,
.nav-item-disabled {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--color-sidebar-text);
  font-size: 13.5px;
  font-weight: 400;
  position: relative;
}

.nav-item .nav-ico,
.nav-item-disabled .nav-ico {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  opacity: 0.86;
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: rgba(255, 255, 255, 0.88);
}

.nav-item:focus-visible {
  box-shadow: var(--focus-ring);
}

.nav-item.is-active {
  background: var(--color-sidebar-active-bg);
  color: #fff;
  font-weight: 500;
}

.nav-item.is-active .nav-ico {
  opacity: 1;
  color: #fff;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  inset-inline-end: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 2px 0 0 2px;
  background: var(--color-primary);
}

.nav-item-disabled {
  opacity: 0.5;
  cursor: default;
}

.nav-item-disabled .badge {
  margin-inline-start: auto;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.75rem 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--color-sidebar-border);
}

.sidebar-tenant {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-control);
  background: var(--color-sidebar-elevated);
}

.sidebar-tenant-label {
  font-size: var(--font-size-label);
  letter-spacing: var(--letter-spacing-label);
  text-transform: uppercase;
  color: var(--color-sidebar-text);
}

.sidebar-tenant strong {
  color: #fff;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  overflow-wrap: anywhere;
}

.sidebar-version {
  padding-inline: 0.7rem;
  font-size: var(--font-size-caption);
  color: var(--color-sidebar-text);
}

.support-card {
  background: var(--color-sidebar-elevated);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  color: rgba(255, 255, 255, 0.72);
}

.support-card strong {
  display: block;
  color: #fff;
  margin-bottom: 0.2rem;
}

.support-card p {
  font-size: 0.78rem;
  color: #9eb0cb;
}

.sidebar-logout {
  width: 100%;
  justify-content: flex-start;
  color: #f8b4b4;
}

.sidebar-logout:hover:not(:disabled) {
  background: rgba(225, 29, 72, 0.14);
  color: #fff;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-cluster {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.topbar .brand-lockup {
  color: var(--color-text);
}

.topbar .brand-mark {
  width: 1.9rem;
  height: 1.9rem;
}

.topbar .form-select {
  min-height: 2.25rem;
  width: auto;
  padding-inline: 0.7rem 1.8rem;
  background-color: var(--color-surface);
}

.tenant-chip,
.year-chip {
  min-height: 2.25rem;
  border-radius: var(--radius-pill);
  padding-inline: 0.85rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant-chip {
  color: var(--color-text-muted);
  font-weight: var(--font-weight-medium);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.icon-btn:hover {
  color: var(--color-text);
  background: var(--color-bg);
  border-color: var(--color-border);
}

.icon-btn:focus-visible {
  box-shadow: var(--focus-ring);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn .badge-dot {
  position: absolute;
  top: -0.15rem;
  inset-inline-end: -0.15rem;
  min-width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 0.25rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  min-height: 2.5rem;
  cursor: pointer;
}

.user-chip:focus-visible {
  box-shadow: var(--focus-ring);
}

html[dir="rtl"] .user-chip {
  padding: 0.2rem 0.2rem 0.2rem 0.55rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #5d5fef, #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: start;
}

.user-meta strong {
  font-size: 0.85rem;
}

.user-meta span {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.page {
  padding: 28px 32px 40px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin-inline: auto;
}

.workspace:has(.timetable-board),
.workspace:has(.bell-workspace),
.workspace:has(.ops-workspace) {
  height: 100dvh;
  overflow: hidden;
}

.workspace:has(.timetable-board) .app-footer,
.workspace:has(.bell-workspace) .app-footer,
.workspace:has(.ops-workspace) .app-footer {
  display: none;
}

.page:has(.timetable-board),
.page:has(.bell-workspace),
.page:has(.ops-workspace) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.page:has(.bell-tabs),
.page:has(.ops-tabs) {
  padding-block: var(--space-3);
}

.page:has(.bell-tabs) .page-header,
.page:has(.ops-tabs) .page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  flex: 0 0 6.5rem;
  height: 6.5rem;
  min-height: 6.5rem;
  max-height: 6.5rem;
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.page:has(.bell-tabs) .page-header > :first-child,
.page:has(.ops-tabs) .page-header > :first-child {
  display: grid;
  grid-template-rows: 1.05rem 1.85rem 2.5rem;
  gap: 0.2rem;
  min-width: 0;
}

.page:has(.bell-tabs) .page-kicker,
.page:has(.ops-tabs) .page-kicker {
  margin: 0;
  line-height: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page:has(.bell-tabs) .page-header h1,
.page:has(.ops-tabs) .page-header h1 {
  margin: 0;
  line-height: 1.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page:has(.bell-tabs) .page-header-subtitle,
.page:has(.ops-tabs) .page-header-subtitle {
  margin: 0;
  height: 2.5rem;
  overflow: hidden;
  font-size: 0.85rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.page:has(.bell-tabs) .page-header-subtitle:empty,
.page:has(.ops-tabs) .page-header-subtitle:empty {
  visibility: hidden;
  display: -webkit-box;
}

.page:has(.bell-tabs) .page-header > :last-child,
.page:has(.ops-tabs) .page-header > :last-child {
  align-self: center;
  flex-wrap: nowrap;
}

.page:has(.bell-tabs) .tabs-wrap,
.page:has(.ops-tabs) .tabs-wrap {
  flex: 0 0 auto;
  margin-bottom: var(--space-3);
}

.app-footer {
  display: none;
}

.app-shell .scope-banner + .topbar {
  top: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-header > :last-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.page-kicker {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.page-kicker:empty {
  display: none;
}

.page-header-subtitle {
  margin-top: 0.4rem;
  color: var(--color-text-muted);
}

.page-header-subtitle:empty {
  display: none;
}

.sidebar-toggle {
  display: none;
  min-width: 2.25rem;
  padding-inline: 0.45rem;
}

.sidebar-backdrop {
  display: none;
}

.auth-app {
  min-height: 100vh;
  background: var(--color-bg);
}

.auth-app .workspace {
  min-height: 100vh;
}

.auth-app .topbar .brand-lockup {
  color: var(--color-text);
}

.auth-app .topbar .brand-name {
  color: var(--color-text);
}

.auth-app .topbar .brand-tagline {
  color: var(--color-text-subtle);
}

.page.auth-page {
  display: grid;
  place-items: center;
  max-width: none;
  min-height: calc(100vh - var(--topbar-height));
}

.auth-card {
  width: min(26.5rem, 100%);
}

.auth-card .card-body {
  padding: 1.75rem 1.75rem 1.5rem;
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.15;
  color: var(--color-text);
}

.auth-card .auth-lead {
  margin: 0 0 1.5rem;
  color: var(--color-text-subtle);
  font-size: 14px;
  line-height: 1.45;
}

.auth-card .form-field {
  margin-bottom: 1rem;
}

.auth-card .permission-item {
  margin: 0 0 1.15rem;
}

.auth-card .btn-block {
  width: 100%;
}

.auth-switch {
  margin: 1.15rem 0 0;
  text-align: center;
}

.auth-switch a {
  color: var(--color-text-subtle);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.mfa-steps {
  margin: 0 0 0.85rem;
  padding: 0 1.25rem;
  color: var(--color-text-subtle);
  font-size: 14px;
  line-height: 1.5;
}

.mfa-qr {
  display: grid;
  place-items: center;
  width: 220px;
  margin: 0 auto 1.25rem;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.mfa-qr img {
  display: block;
  width: 188px;
  height: 188px;
}

.mfa-key {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  letter-spacing: 0.06em;
  text-align: center;
  unicode-bidi: isolate;
}

.mfa-test-code {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem 0.15rem;
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  background: var(--color-info-soft, #eef6ff);
}

.mfa-test-code p {
  margin: 0 0 0.75rem;
  color: var(--color-info-text, var(--color-text-subtle));
  font-size: 13px;
  line-height: 1.4;
}

.welcome-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.2rem 0.15rem 0.2rem 0;
  background: none;
  box-shadow: none;
  min-width: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.welcome-hello {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--color-text);
}

.welcome-school {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  width: 100%;
}

.welcome-logo {
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 6.5rem;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-navy);
}

.welcome-logo img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
  padding: 0.35rem;
}

.welcome-school-copy {
  flex: 1 1 0;
  min-width: 0;
}

.welcome-school-copy h2 {
  margin: 0;
  color: var(--color-text);
  font-size: 1.28rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.welcome-school-meta {
  margin: 0.22rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.metric-card {
  padding: 1rem 1.1rem 1.05rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.metric-card .stat-card-value {
  font-size: 1.55rem;
}

.progress,
.progress-bar {
  height: 0.375rem;
  border-radius: var(--radius-pill);
  background: var(--color-border-light);
  overflow: hidden;
}

.progress > span,
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--color-success);
  border-radius: inherit;
}

.progress.is-warn > span { background: var(--color-warning); }
.progress.is-danger > span { background: var(--color-danger); }

.hub-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-4);
}

.hub-identity {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(17rem, 0.85fr) minmax(0, 1.7fr);
  gap: var(--space-4);
  align-items: center;
  min-width: 0;
}

.hub-metrics,
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  min-width: 0;
  position: relative;
  z-index: 0;
}

.kpi-strip {
  grid-column: 1 / -1;
}

.kpi-card .stat-card-label {
  font-size: var(--font-size-label);
  letter-spacing: var(--letter-spacing-label);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.kpi-card .stat-card-value {
  font-size: var(--font-size-metric);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.kpi-card .stat-card-value.is-danger {
  color: var(--color-danger);
}
.hub-schedule { grid-column: span 4; }
.hub-next { grid-column: span 4; }
.hub-devices { grid-column: span 4; }
.hub-screens { grid-column: span 4; }
.hub-activity { grid-column: span 4; }
.hub-modules { grid-column: span 4; }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 0.8rem;
}

.timeline-row.is-current {
  background: var(--color-accent-soft);
}

.timeline-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-name {
  font-weight: 600;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: #cbd5e1;
}

.dot.is-done { background: var(--color-success); }
.dot.is-live { background: var(--color-accent); }
.dot.is-off { background: var(--color-danger); }

.next-bell {
  text-align: center;
  padding: 0.4rem 0 0.2rem;
}

.next-bell-time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.18em;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.next-bell-time .clock {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
}

.next-bell-time .ico-bell {
  width: 1em;
  height: 1em;
}

.next-bell-time-sm {
  font-size: 2rem;
}

.next-bell h3 {
  margin: 0.55rem 0 0.25rem;
}

.next-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 1rem;
}

.device-row,
.activity-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border);
}

.device-row-main {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
}

.device-row-main .platform-ico {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.15rem;
}

.device-row:last-child,
.activity-row:last-child {
  border-bottom: 0;
}

.screen-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.screen-tile {
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.screen-tile-art {
  height: 4.6rem;
  background: linear-gradient(135deg, #dbe7f8, #9bb6de);
}

.screen-tile-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.65rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 650;
}

.module-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-health {
  padding: 0.95rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.module-health.is-ok {
  background: var(--color-success-soft);
  border-color: #b7ead4;
}

.module-health.is-warn {
  background: var(--color-warning-soft);
  border-color: #f3d7a3;
}

@media (max-width: 1280px) {
  .hub-schedule,
  .hub-next,
  .hub-devices,
  .hub-screens,
  .hub-activity,
  .hub-modules { grid-column: span 6; }
  .hub-identity {
    grid-column: 1 / -1;
    grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.4fr);
  }
}

@media (max-width: 1100px) {
  .hub-identity { grid-template-columns: 1fr; }
}

@media (min-width: 961px) {
  .topbar .topbar-brand { display: none; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(20rem, 86vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.is-open,
  html[dir="rtl"] .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: var(--color-overlay);
    opacity: 0;
    pointer-events: none;
    z-index: 25;
    transition: opacity 180ms ease;
  }
  .sidebar.is-open ~ .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.sidebar-open { overflow: hidden; }
  .page.auth-page { padding: 24px 16px 32px; }
  .hub-identity,
  .hub-schedule,
  .hub-next,
  .hub-devices,
  .hub-screens,
  .hub-activity,
  .hub-modules { grid-column: span 12; }
  .hub-metrics,
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .next-actions { grid-template-columns: 1fr; }
  .app-footer { flex-direction: column; }
}

@media (max-width: 640px) {
  .hub-metrics,
  .kpi-strip,
  .screen-grid { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .tenant-chip { display: none; }
  .year-chip { display: none; }
}
