/* نظام الاحتياط — هوية مدرسة زينب بنت أبي سلمة */
:root {
  --bg: #f7f4f2;
  --surface: #ffffff;
  --ink: #2a1520;
  --muted: #6e5a62;
  --line: #e8dfd8;
  --primary: #6b1a38;
  --primary-hover: #54142c;
  --primary-dark: #3d0c1f;
  --primary-soft: #f5e8ec;
  --accent: #c4a06a;
  --accent-hover: #b08c56;
  --accent-soft: #f5efe6;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #2d6a4f;
  --success-soft: #e8f6ee;
  --warning: #b7791f;
  --shadow: 0 1px 3px rgba(61, 12, 31, 0.06), 0 8px 24px rgba(61, 12, 31, 0.05);
  --radius: 14px;
  --sidebar-w: 270px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}

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

/* —— Sidebar —— */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #3d0c1f 0%, #6b1a38 48%, #7a2344 100%);
  color: #f8f0f3;
  padding: 1.25rem 0.85rem;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 160, 106, 0.55) transparent;
  transition: transform var(--transition);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(196, 160, 106, 0.55);
  border-radius: 999px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  padding: 0.35rem 0.35rem 0.9rem;
  border-bottom: 1px solid rgba(196, 160, 106, 0.28);
  flex-shrink: 0;
}

.brand-logo-wrap {
  width: 100px;
  height: 100px;
  border-radius: 16px;
  background: #fffaf6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(196, 160, 106, 0.45);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
}

.sidebar-brand .brand-text strong {
  display: block;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.35;
}

.sidebar-brand .brand-text small {
  display: block;
  margin-top: 0.25rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.sidebar-brand .brand-app {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(196, 160, 106, 0.18);
  color: #f3e4c8;
  font-size: 0.72rem;
  font-weight: 500;
}

.sidebar-brand .brand-credit {
  display: block;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: rgba(243, 228, 200, 0.88);
  line-height: 1.4;
}

.brand-mark {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  padding-bottom: 1rem;
  min-height: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 3px 0 0 var(--accent);
}

.main-wrap {
  flex: 1;
  margin-inline-start: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-heading {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
  color: var(--primary);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-meta {
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  line-height: 1.3;
}

.topbar-school {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--ink);
}
.menu-toggle svg {
  width: 24px;
  height: 24px;
}

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

.app-footer {
  padding: 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.app-footer .footer-credit {
  color: var(--primary);
  font-weight: 500;
}

/* —— Panels / cards —— */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

/* —— Stats —— */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card.accent {
  background: linear-gradient(145deg, var(--primary) 0%, #8a2a4e 100%);
  color: #fff;
  border-color: transparent;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.stat-card.accent .stat-label {
  color: rgba(255, 255, 255, 0.8);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-value.text-sm {
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sub {
  font-size: 0.85rem;
  opacity: 0.85;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.quick-link {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-weight: 500;
  color: var(--ink);
  transition: border-color var(--transition), background var(--transition);
}
.quick-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* —— Forms —— */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.field-full {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon {
  width: 16px;
  height: 16px;
}

input[type="text"],
input[type="date"],
input[type="file"],
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 160, 106, 0.28);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.form-status {
  font-size: 0.9rem;
}
.form-status.ok {
  color: var(--success);
}
.form-status.err {
  color: var(--danger);
}

.banner-info {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.help-text {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

/* —— Autocomplete —— */
.autocomplete-field {
  position: relative;
}

.autocomplete-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.35rem;
  position: absolute;
  inset-inline: 0;
  top: 100%;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  animation: fadeSlide 0.15s ease;
}

.autocomplete-list li {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background var(--transition);
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.autocomplete-list mark {
  background: #f0dfb8;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.schedule-suggestions {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--primary-soft);
  border-radius: 12px;
}

.schedule-suggestions h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--primary);
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.chip:hover {
  background: var(--primary);
  color: #fff;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), transform 0.1s ease;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn:hover {
  border-color: var(--muted);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
.btn-secondary:hover {
  background: #ecd9df;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover {
  background: #f8d7d4;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}
.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-block {
  width: 100%;
  margin-top: 0.75rem;
}

.inline-form {
  display: inline;
}

/* —— Tables —— */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.85rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  background: #fafbfc;
}

.data-table tbody tr:hover {
  background: #f8fafb;
}

/* CRITICAL: أسماء المعلمات بسطر واحد */
.names-nowrap .col-name,
.col-name {
  white-space: nowrap;
  min-width: 11rem;
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
}

.actions {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  margin: 0;
}

/* —— Alerts —— */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-success {
  background: var(--success-soft);
  color: var(--success);
}
.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* —— Log layout + calendar —— */
.log-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.calendar-nav h2 {
  margin: 0;
  font-size: 1.05rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  padding: 0.25rem 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--ink);
  background: transparent;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.cal-day.empty {
  pointer-events: none;
}
.cal-day:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.cal-day.has-records {
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}
.cal-day.selected {
  background: var(--primary);
  color: #fff;
}
.cal-day.today:not(.selected) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.filters-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 140px;
  flex: 1;
}

/* —— Statistics chart —— */
.stats-chart {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.5rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr 2.5rem;
  gap: 0.65rem;
  align-items: center;
}

.bar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}

.bar-track {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.bar-count {
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
}

/* —— Star of month —— */
.star-hero {
  text-align: center;
  background: linear-gradient(160deg, #3d0c1f 0%, #6b1a38 50%, #8a2a4e 100%);
  color: #fff;
  border: none;
}

.star-nav h2 {
  color: #fff;
}
.star-nav .btn-icon {
  background: rgba(255, 255, 255, 0.12);
  border-color: transparent;
  color: #fff;
}

.star-badge {
  padding: 1.5rem 1rem 0.5rem;
}
.star-badge svg {
  width: 48px;
  height: 48px;
  color: var(--accent);
}
.star-title {
  margin: 0.5rem 0 0;
  opacity: 0.85;
  font-size: 0.95rem;
}
.star-name {
  margin: 0.35rem 0;
  font-size: 1.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.star-meta {
  margin: 0;
  opacity: 0.9;
}

.podium-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.podium-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.podium-list .rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.podium-list .times {
  margin-inline-start: auto;
  font-weight: 600;
  color: var(--primary);
}

.teachers-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.teachers-cards {
  display: none;
}

.teachers-search-field {
  margin-bottom: 1rem;
}

.teacher-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.65rem;
  box-shadow: var(--shadow);
}

.teacher-card-top {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.teacher-card-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.teacher-card-info {
  min-width: 0;
  flex: 1;
}

.teacher-card-name {
  display: block;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
  word-break: break-word;
}

.teacher-card-subject {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.teacher-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.teacher-card-actions .btn,
.teacher-card-actions .inline-form,
.teacher-card-actions .inline-form .btn {
  width: 100%;
  margin: 0;
}

.teacher-card-actions .inline-form {
  display: block;
}

.teacher-card-actions .btn {
  min-height: 42px;
  justify-content: center;
}

.class-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
}

.class-card-actions .btn,
.class-card-actions .inline-form,
.class-card-actions .inline-form .btn {
  width: 100%;
  margin: 0;
}

.class-card-actions .inline-form {
  display: block;
}

.class-card-actions .btn {
  min-height: 42px;
  justify-content: center;
  font-size: 0.8rem;
  padding: 0.35rem 0.4rem;
}

.class-card .status-on,
.class-card .status-off {
  display: inline-block;
  margin-top: 0.35rem;
}

.row-muted {
  opacity: 0.55;
}

.status-on {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 500;
}

.status-off {
  color: var(--muted);
  font-size: 0.85rem;
}
.schedule-block h3 {
  margin: 0;
  font-size: 1rem;
}

.schedule-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.schedule-portal-card {
  background: linear-gradient(135deg, #fff 0%, #faf6f2 100%);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
}

.portal-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.portal-inner h2 {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 1.2rem;
}

.btn-lg {
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
}

.teacher-lookup {
  max-width: 520px;
}

.schedule-add-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  align-items: start;
}

.schedule-add-form .autocomplete-field {
  position: relative;
}

.schedule-search-actions {
  margin-top: 0.85rem;
}

@media (max-width: 900px) {
  .schedule-add-grid {
    grid-template-columns: 1fr;
  }
}

.timetable-grid {
  min-width: 640px;
}

.timetable-grid th,
.timetable-grid td {
  text-align: center;
}

.timetable-grid tbody th {
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}

/* —— Responsive —— */
@media (max-width: 1024px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
  .log-layout,
  .teachers-layout {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .calendar-panel {
    max-width: 420px;
  }
}

@media (max-width: 768px) {
  /* درج القائمة الجانبية */
  .sidebar {
    width: min(86vw, 300px);
    transform: translateX(110%);
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.28);
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(110%);
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .main-wrap {
    margin-inline-start: 0;
    width: 100%;
  }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
  }

  .topbar {
    padding: 0.65rem 0.85rem;
    gap: 0.55rem;
    position: sticky;
    top: 0;
  }
  .page-heading {
    font-size: 1.05rem;
    line-height: 1.3;
  }
  .topbar-meta {
    display: none;
  }

  .content {
    padding: 0.85rem;
  }
  .app-footer {
    padding: 0.85rem;
    font-size: 0.8rem;
    text-align: center;
    flex-direction: column;
    gap: 0.25rem;
  }

  .panel {
    padding: 1rem 0.9rem;
    margin-bottom: 0.9rem;
    border-radius: 12px;
  }
  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }
  .panel-head h2,
  .panel-head h3 {
    font-size: 1.02rem;
  }
  .panel-head .btn,
  .panel-head .btn-sm {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  /* بطاقات الإحصائيات */
  .stats-row {
    gap: 0.7rem;
    margin-bottom: 0.9rem;
  }
  .stat-card {
    padding: 0.95rem 1rem;
  }
  .stat-value {
    font-size: 1.65rem;
  }
  .stat-value.text-sm {
    font-size: 1rem;
    white-space: normal;
  }

  .quick-links {
    gap: 0.55rem;
  }
  .quick-link {
    flex: 1 1 calc(50% - 0.55rem);
    text-align: center;
    justify-content: center;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
  }

  /* نماذج */
  .form-grid {
    gap: 0.85rem;
  }
  input[type="text"],
  input[type="date"],
  input[type="month"],
  input[type="number"],
  input[type="file"],
  select,
  textarea,
  .autocomplete-input {
    font-size: 16px; /* يمنع تكبير iOS التلقائي */
    min-height: 44px;
    padding: 0.7rem 0.85rem;
  }
  textarea {
    min-height: 88px;
  }
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .form-actions .btn {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }
  .form-status {
    text-align: center;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .filters-bar label {
    min-width: 0;
    width: 100%;
  }
  .filters-bar .btn,
  .filters-bar .btn-secondary,
  .filters-bar .btn-ghost,
  .filters-bar .btn-primary {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .stack-form .btn {
    width: 100%;
    min-height: 44px;
  }

  /* جداول */
  .table-scroll {
    margin-inline: -0.25rem;
    padding-bottom: 0.25rem;
  }
  .data-table {
    font-size: 0.82rem;
  }
  .data-table th,
  .data-table td {
    padding: 0.6rem 0.55rem;
  }
  .names-nowrap .col-name,
  .col-name {
    min-width: 9rem;
    font-size: 0.82rem;
  }
  .actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .actions .btn,
  .actions .btn-sm {
    min-height: 36px;
  }

  /* سجل الغياب + التقويم */
  .log-layout {
    gap: 0.9rem;
  }
  .calendar-panel {
    max-width: none;
  }
  .calendar-nav h2 {
    font-size: 0.98rem;
  }
  .cal-day {
    font-size: 0.8rem;
  }

  /* الإحصائيات */
  .bar-label {
    font-size: 0.8rem;
    white-space: normal;
  }

  /* صفحة المعلمات — النموذج أولاً ثم البطاقات */
  .teachers-layout {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
  }
  .teachers-table-wrap {
    display: none;
  }
  .teachers-cards {
    display: block;
  }
  .teachers-form-panel {
    order: 0;
    position: relative;
    z-index: 2;
  }
  .teachers-list-panel {
    order: 1;
  }
  .teachers-search-field input {
    font-size: 16px;
    min-height: 44px;
  }
  .teachers-form-panel .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .teachers-form-panel .form-actions .btn {
    width: 100%;
    min-height: 46px;
  }
  .class-card-actions {
    grid-template-columns: 1fr;
  }

  /* بوابة الجدول / البحث */
  .portal-inner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .portal-inner .btn,
  .btn-lg {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }
  .teacher-lookup {
    max-width: none;
  }
  .schedule-add-grid {
    grid-template-columns: 1fr;
  }
  .schedule-search-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .schedule-search-actions .btn {
    width: 100%;
    min-height: 46px;
  }
  .timetable-grid {
    min-width: 560px;
  }
  .schedule-block-head {
    flex-direction: column;
    align-items: stretch;
  }
  .schedule-block-head .actions {
    width: 100%;
  }
  .schedule-block-head .actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* نجمة الشهر */
  .star-name {
    font-size: 1.2rem;
    white-space: normal;
  }
  .star-badge {
    padding: 1rem 0.5rem 0.35rem;
  }

  /* اقتراحات الحصص */
  .suggestion-chips {
    gap: 0.45rem;
  }
  .chip {
    min-height: 40px;
  }

  /* قائمة الإكمال التلقائي */
  .autocomplete-list {
    max-height: 260px;
  }
  .autocomplete-list li {
    padding: 0.7rem 0.8rem;
    white-space: normal;
  }

  .btn {
    min-height: 40px;
  }
  .empty-state {
    padding: 1.4rem 0.5rem;
    font-size: 0.92rem;
  }
  .alert {
    font-size: 0.88rem;
  }
  .help-text {
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 0.7rem;
  }
  .panel {
    padding: 0.85rem 0.75rem;
  }
  .page-heading {
    font-size: 0.98rem;
  }
  .brand-logo-wrap {
    width: 88px;
    height: 88px;
  }
  .sidebar-nav a {
    padding: 0.8rem 0.85rem;
    font-size: 0.95rem;
  }
  .quick-link {
    flex: 1 1 100%;
  }
  .data-table {
    font-size: 0.78rem;
  }
  .timetable-grid {
    min-width: 520px;
  }
}

/* overlay when sidebar open on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.show {
  display: block;
}
