:root {
  --primary: #0B6E4F;
  --primary-dark: #085541;
  --primary-soft: #D4F0E6;
  --primary-mid: #4AA889;
  --accent: #C4A35A;
  --accent-soft: #F7EFDA;
  --bg: #F2F7F5;
  --surface: #FFFFFF;
  --text: #16332B;
  --text-muted: #5B7169;
  --border: #D7E5DF;
  --green: #14966D;
  --green-soft: #D1FAE5;
  --blue: #0E7490;
  --blue-soft: #CFFAFE;
  --orange: #D97706;
  --orange-soft: #FEF3C7;
  --red: #DC2626;
  --shadow: 0 4px 20px rgba(22, 51, 43, 0.07);
  --shadow-lg: 0 12px 36px rgba(11, 110, 79, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --topbar-h: 72px;
  --font: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", Tahoma, sans-serif;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(11, 110, 79, 0.09), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(196, 163, 90, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100vw;
  overflow-x: clip;
}

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary) 0%, #148F6B 70%, #0A5C4B 100%);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(11, 110, 79, 0.35);
  overflow: hidden;
}

.brand-icon img,
.brand-icon .brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.3;
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  text-align: right;
  width: 100%;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(11, 110, 79, 0.35);
}

.nav-logout {
  margin-top: auto;
  color: #DC2626;
}

.nav-logout:hover {
  background: #FEE2E2;
  color: #DC2626;
}

.sidebar-illustration {
  padding: 1rem 0.5rem 0.5rem;
  opacity: 0.9;
}

.sidebar-illustration svg {
  width: 100%;
  height: auto;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 90;
}

/* ========== Main ========== */
.main {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-width: 0;
  padding: 1.25rem 1.5rem 2rem;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), #148F6B);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-info strong {
  font-size: 0.95rem;
  font-weight: 700;
}

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

.topbar-date {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.date-gregorian {
  font-weight: 700;
  font-size: 0.95rem;
}

.date-hijri {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.notif-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.notif-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.notif-btn svg {
  width: 20px;
  height: 20px;
}

.notif-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.notif-badge:empty,
.notif-badge[data-count="0"] {
  display: none;
}

/* ========== Views ========== */
.view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon.purple { background: var(--primary-soft); color: var(--primary); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }

.stat-body h3 {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

.stat-main {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ========== Dashboard grid ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

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

.panel-header.compact {
  margin-bottom: 0.5rem;
}

.panel-header h2,
.panel-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.week-range {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
}

/* ========== Site footer / Developer credit ========== */
.site-footer {
  margin-top: 2rem;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, rgba(11, 110, 79, 0.08) 0%, rgba(196, 163, 90, 0.06) 55%, #fff 100%),
    var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.site-footer-copy {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.site-footer-dev {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  background: linear-gradient(145deg, var(--primary), #148F6B);
  color: #fff;
  box-shadow: 0 6px 16px rgba(11, 110, 79, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.site-footer-dev:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(11, 110, 79, 0.36);
  color: #fff;
}

.site-footer-dev-label {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.9;
}

.site-footer-dev-brand {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.site-footer-dev svg {
  width: 14px;
  height: 14px;
  opacity: 0.95;
}

.site-footer--login {
  margin-top: 1.25rem;
  padding: 0.85rem 0.9rem;
  width: 100%;
}

.site-footer--login .site-footer-inner {
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.week-supervisor-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #E8F6F1 0%, #F7EFDA 100%);
  border: 1px solid #C5E4D8;
}

.week-supervisor-banner.is-readonly {
  margin-top: 0.75rem;
}

.week-supervisor-main {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.week-supervisor-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--primary);
}

.week-supervisor-people {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
}

.week-supervisor-person {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.week-supervisor-person .name {
  font-weight: 700;
  font-size: 0.9rem;
}

.week-supervisor-person.is-me .name {
  color: var(--primary);
}

.week-supervisor-card {
  margin-bottom: 0.75rem;
  border: 1px solid #E0E7FF;
  background: #F8F7FF;
}

.week-supervisor-card.is-mine {
  border-color: var(--primary-mid);
  box-shadow: inset 3px 0 0 var(--primary);
}

.side-widgets {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(11, 110, 79, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

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

.btn-ghost {
  color: var(--text-muted);
  background: transparent;
}

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

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  background: #FEE2E2;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all 0.2s;
}

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

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.week-nav {
  display: flex;
  gap: 0.35rem;
}

.select-input,
.settings-form input,
.settings-form select,
.settings-form textarea,
.note-form textarea,
.modal select,
.modal input {
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.select-input:focus,
.settings-form input:focus,
.settings-form select:focus,
.note-form textarea:focus,
.modal select:focus,
.modal input:focus {
  border-color: var(--primary);
}

.link-btn {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.88rem;
  margin-top: 0.75rem;
  display: inline-block;
}

.link-btn:hover {
  text-decoration: underline;
}

.badge-chip {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

/* ========== Duty table ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.duty-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

@media (min-width: 901px) {
  .duty-table,
  .data-table {
    min-width: 700px;
  }
}

.duty-table th,
.data-table th {
  background: #FAFAFC;
  padding: 0.85rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.duty-table th small {
  display: block;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.15rem;
  font-size: 0.75rem;
}

.duty-table th:first-child,
.duty-table td:first-child {
  text-align: right;
  width: 110px;
  background: #FAFAFC;
}

.duty-table td,
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.85rem;
}

.duty-table tr:last-child td,
.data-table tr:last-child td {
  border-bottom: none;
}

.duty-table tr:hover td {
  background: #FCFBFF;
}

.day-cell {
  display: flex;
  flex-direction: column;
}

.day-cell strong {
  font-weight: 800;
}

.day-cell span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.duty-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.duty-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  background: #FAFAFC;
}

.duty-person .name {
  font-weight: 600;
  font-size: 0.82rem;
}

.role-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  white-space: nowrap;
}

.role-tag.primary,
.role-tag.primary2 {
  background: var(--primary-soft);
  color: var(--primary);
}

.role-tag.substitute {
  background: var(--blue-soft);
  color: var(--blue);
}

.role-tag.reserve {
  background: var(--green-soft);
  color: var(--green);
}

.duty-person.has-late {
  background: #FFF7ED;
  box-shadow: inset 3px 0 0 #F59E0B;
}

.duty-person.has-permission {
  background: #EFF6FF;
  box-shadow: inset 3px 0 0 #3B82F6;
}

.duty-person.has-absent {
  background: #FEF2F2;
  box-shadow: inset 3px 0 0 #EF4444;
}

.duty-person .status-chip {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.footer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 0.35rem;
}

.legend .dot.primary { background: var(--primary); }
.legend .dot.substitute { background: var(--blue); }
.legend .dot.reserve { background: var(--green); }
.legend .dot.late { background: #F59E0B; }
.legend .dot.permission { background: #3B82F6; }

/* ========== Mini calendar ========== */
.mini-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.mini-cal-nav strong {
  font-size: 0.95rem;
}

.mini-calendar,
.full-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
}

.cal-head {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.35rem 0;
}

.cal-day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50%;
  color: var(--text);
  transition: all 0.2s;
  border: none;
  background: transparent;
  max-width: 36px;
  margin: 0 auto;
  width: 100%;
}

.cal-day:hover:not(.empty):not(.today) {
  background: var(--primary-soft);
  color: var(--primary);
}

.cal-day.empty {
  visibility: hidden;
}

.cal-day.today {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(11, 110, 79, 0.4);
}

.cal-day.has-duty:not(.today) {
  background: var(--primary-soft);
  color: var(--primary);
}

.cal-day.selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.full-calendar .cal-day {
  max-width: 48px;
  font-size: 0.9rem;
  aspect-ratio: 1;
}

.full-calendar {
  gap: 0.4rem;
  padding: 0.5rem 0 1rem;
}

.day-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.day-detail h4 {
  margin-bottom: 0.75rem;
  font-weight: 800;
}

.day-detail-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== Upcoming ========== */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  background: #FAFAFC;
  transition: background 0.2s;
}

.upcoming-item:hover {
  background: var(--primary-soft);
}

.upcoming-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.upcoming-icon svg {
  width: 20px;
  height: 20px;
}

.upcoming-icon.orange { background: var(--orange-soft); color: var(--orange); }
.upcoming-icon.blue { background: var(--blue-soft); color: var(--blue); }
.upcoming-icon.green { background: var(--green-soft); color: var(--green); }

.upcoming-body strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
}

.upcoming-body span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========== Notes ========== */
.note-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.note-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 80px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: #FAFAFC;
  border: 1px solid var(--border);
}

.note-item p {
  flex: 1;
  font-size: 0.92rem;
}

.note-item time {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.35rem;
}

/* ========== Settings ========== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.25rem;
}

.settings-grid .panel h3 {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.time-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.time-row input {
  flex: 1;
}

.switch-label {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
}

.switch-label input[type="checkbox"] {
  width: 42px;
  height: 24px;
  accent-color: var(--primary);
}

/* ========== Data table ========== */
.data-table th,
.data-table td {
  text-align: right;
  padding: 0.85rem 1rem;
}

.data-table td {
  vertical-align: middle;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(560px, 100%);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ========== Notifications panel ========== */
.notif-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 1.5rem);
  left: 1.5rem;
  width: min(340px, calc(100vw - 2rem));
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  padding: 1rem;
  animation: slideUp 0.25s ease;
  max-height: 400px;
  overflow-y: auto;
}

.notif-panel[hidden] {
  display: none;
}

.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.notif-panel-header h3 {
  font-size: 1rem;
  font-weight: 800;
}

#notif-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#notif-list li {
  padding: 0.75rem;
  border-radius: 10px;
  background: #FAFAFC;
  font-size: 0.85rem;
  border-right: 3px solid var(--primary);
}

#notif-list li strong {
  display: block;
  margin-bottom: 0.2rem;
}

#notif-list li time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

#notif-list .empty-notif {
  text-align: center;
  color: var(--text-muted);
  border: none;
  background: transparent;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.85rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.toast[hidden] {
  display: none;
}

.toast.success {
  background: var(--green);
}

.toast.alert {
  background: var(--primary);
}

/* ========== Print ========== */
@media print {
  .sidebar,
  .topbar,
  .panel-footer,
  .panel-controls,
  .side-widgets,
  .menu-toggle,
  .notif-panel,
  .modal-overlay {
    display: none !important;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .panel {
    box-shadow: none;
  }

  .stats-row {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== Responsive ========== */
@media (max-width: 1200px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .schedule-panel {
    order: -1;
  }

  .side-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* بطاقات المناوبات للجوال — مخفية على الشاشات الكبيرة */
.duty-mobile-cards {
  display: none;
}

.duty-day-card {
  background: linear-gradient(180deg, #fff 0%, #FAFAFC 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(31, 41, 55, 0.05);
}

.duty-day-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, #148F6B 100%);
  color: #fff;
}

.duty-day-card-head strong {
  font-size: 1.05rem;
  font-weight: 800;
}

.duty-day-card-head span {
  font-size: 0.8rem;
  opacity: 0.9;
}

.duty-day-card-body {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem;
}

.m-shift {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
}

.m-shift-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.m-shift-head strong {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary);
}

.m-shift-head span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.m-shift-dept {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.m-shift .duty-person {
  background: var(--bg);
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(100%);
    width: min(300px, 86vw);
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: -8px 0 40px rgba(15, 23, 42, 0.18);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .sidebar-illustration {
    display: none;
  }

  .main {
    margin-right: 0;
    padding: 0.85rem 0.85rem 1.5rem;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .menu-toggle {
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }

  .topbar {
    height: auto;
    min-height: 56px;
    padding: 0.55rem 0.75rem;
    gap: 0.5rem;
    border-radius: 12px;
    position: sticky;
    top: max(0.5rem, env(safe-area-inset-top));
    z-index: 50;
  }

  .topbar-date {
    display: none;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .user-info strong {
    font-size: 0.88rem;
  }

  .user-info span {
    display: none;
  }

  .notif-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }

  .side-widgets {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .stat-card {
    padding: 0.85rem 0.9rem;
    gap: 0.65rem;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .stat-number {
    font-size: 1.35rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .page-header h2 {
    font-size: 1.2rem;
  }

  .page-header-actions {
    width: 100%;
  }

  .page-header-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .week-nav {
    width: 100%;
    justify-content: space-between;
  }

  .week-nav .select-input {
    flex: 1;
    min-width: 0;
  }

  .panel {
    padding: 0.95rem;
    border-radius: 14px;
  }

  .panel-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .panel-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

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

  .footer-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 0.82rem;
    padding: 0.65rem 0.5rem;
  }

  .panel-footer > .btn-primary {
    width: 100%;
    justify-content: center;
  }

  .legend {
    flex-wrap: wrap;
    gap: 0.65rem;
    font-size: 0.8rem;
  }

  /* جداول المناوبات → بطاقات يومية */
  .desktop-only-table {
    display: none !important;
  }

  .duty-mobile-cards {
    display: grid;
    gap: 0.85rem;
  }

  .duty-table,
  .data-table {
    min-width: 0;
  }

  /* جداول البيانات كبطاقات */
  .table-wrap:not(.desktop-only-table) {
    overflow: visible;
    border: none;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.65rem;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.04);
  }

  .data-table td {
    border: none;
    padding: 0.35rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: right;
    flex-shrink: 0;
  }

  .data-table td.actions-cell {
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 0.55rem;
    margin-top: 0.35rem;
    border-top: 1px dashed var(--border);
  }

  .data-table td.actions-cell::before {
    content: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .absence-list {
    grid-template-columns: 1fr;
    max-height: min(50vh, 320px);
  }

  .absence-toolbar {
    flex-direction: column;
  }

  .absence-toolbar input,
  .absence-toolbar .btn {
    width: 100%;
  }

  .portal-link-box {
    flex-direction: column;
  }

  .portal-link-box input,
  .portal-link-box .btn {
    width: 100%;
    min-width: 0;
  }

  .modal {
    width: calc(100% - 1rem);
    max-width: none;
    margin: 0.5rem;
    max-height: calc(100dvh - 1rem);
    border-radius: 16px;
  }

  .modal-overlay {
    padding: max(0.5rem, env(safe-area-inset-top)) 0.5rem max(0.5rem, env(safe-area-inset-bottom));
    align-items: flex-end;
  }

  .notif-panel {
    width: min(100vw - 1rem, 360px);
    right: 0.5rem;
    left: auto;
    top: calc(var(--topbar-h) + 0.5rem);
  }

  .dept-item {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .footer-actions {
    grid-template-columns: 1fr;
  }

  .full-calendar {
    gap: 0.25rem;
  }

  .cal-day {
    min-height: 42px;
    font-size: 0.78rem;
  }

  .shift-cards,
  .my-shifts {
    gap: 0.65rem;
  }
}

@media (max-width: 700px) {
  .shift-card {
    flex-direction: column;
    align-items: stretch;
  }

  .shift-card-action .btn {
    width: 100%;
  }

  .staff-login {
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .staff-login-card {
    padding: 1.5rem 1.15rem;
    border-radius: 16px;
  }
}

/* ========== Staff portal ========== */
.staff-loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background: rgba(245, 246, 250, 0.88);
  backdrop-filter: blur(4px);
}

.staff-loading[hidden] {
  display: none !important;
}

.staff-loading-card {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem 1.75rem;
  text-align: center;
  min-width: 240px;
}

.staff-loading-card .brand-icon {
  margin: 0 auto 0.75rem;
}

.staff-loading-card p {
  color: var(--text-muted);
  font-weight: 600;
}

.staff-portal #staff-app[hidden],
.staff-portal #staff-login[hidden] {
  display: none !important;
}

a.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  transition: 0.2s ease;
}

a.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

a.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sync-status {
  display: block;
  font-size: 0.72rem;
  color: var(--green);
  margin-top: 0.15rem;
}

.pin-code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.page-header-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.staff-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 18% 18%, rgba(11, 110, 79, 0.14), transparent 42%),
    radial-gradient(circle at 85% 8%, rgba(196, 163, 90, 0.16), transparent 38%),
    linear-gradient(160deg, #EAF6F1 0%, #F2F7F5 45%, #F8F4EA 100%);
}

.staff-login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.5rem;
}

.staff-login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.staff-login-brand .brand-icon {
  margin: 0 auto 0.85rem;
}

.staff-login-brand h1 {
  font-size: 1.4rem;
  color: var(--primary);
}

.staff-login-brand p {
  color: var(--text-muted);
}

.staff-login-form {
  display: grid;
  gap: 1rem;
}

.staff-login-form label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--text);
}

.staff-login-form select,
.staff-login-form input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.login-hint,
.staff-login-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.login-error {
  color: var(--red);
  font-weight: 600;
  text-align: center;
}

.my-shifts-list {
  display: grid;
  gap: 0.85rem;
  padding: 0.25rem 0 0.5rem;
}

.shift-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.shift-card.is-today {
  border-color: var(--primary-mid);
  background: var(--primary-soft);
}

.shift-card.is-done {
  border-color: #6ee7b7;
  background: var(--green-soft);
}

.shift-card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.shift-time {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.attendance-done {
  display: inline-block;
  color: #047857;
  font-weight: 700;
  text-align: center;
  font-size: 0.9rem;
}

.duty-person.is-me {
  background: rgba(11, 110, 79, 0.12);
  border-radius: 8px;
  padding: 0.2rem 0.35rem;
}

.duty-person.is-me .name {
  color: var(--primary);
  font-weight: 800;
}

.legend-me .dot.me {
  background: var(--primary);
}

.readonly-chip {
  background: var(--orange-soft);
  color: #b45309;
}

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

.alert-status {
  padding: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.alert-ok {
  color: #047857;
  font-weight: 700;
}

.staff-stats .stat-card {
  min-height: 110px;
}

.duty-dept {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.portal-card .portal-desc,
.portal-desc {
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
}

.portal-link-box {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.portal-link-box input {
  flex: 1;
  min-width: 220px;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.portal-steps {
  margin-top: 1.1rem;
  display: grid;
  gap: 0.45rem;
  color: var(--text-muted);
  padding-right: 1.1rem;
  list-style: decimal;
}

.portal-steps li {
  list-style: decimal;
}

.dept-list {
  display: grid;
  gap: 0.45rem;
  margin: 0.5rem 0 1rem;
}

.dept-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.attendance-done-wrap {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.icon-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-action svg {
  width: 16px;
  height: 16px;
}

.icon-action:hover {
  background: var(--primary);
  color: #fff;
}

.cover-tag {
  display: inline-block;
  background: var(--orange-soft);
  color: #b45309;
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  margin-right: 0.25rem;
}

.duty-list.has-cover {
  outline: 1px dashed var(--orange);
  border-radius: 8px;
  padding: 0.25rem;
}

.absence-panel {
  margin-bottom: 1.25rem;
}

.absence-toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.absence-toolbar input {
  flex: 1;
  min-width: 180px;
}

.absence-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
  max-height: 280px;
  overflow: auto;
  padding: 0.15rem;
}

.absence-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.55rem;
  row-gap: 0.1rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}

.absence-item input {
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.absence-name {
  font-weight: 700;
}

.absence-meta {
  grid-column: 2;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.absence-item.has-duty {
  border-color: var(--primary-mid);
}

.absence-item.is-absent {
  background: #FEF2F2;
  border-color: #FECACA;
}

.absence-result {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--orange-soft);
  color: #92400e;
  font-size: 0.92rem;
}

/* ========== Mobile fix (must stay last — overrides earlier rules) ========== */
@media (max-width: 900px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .app,
  .main,
  .view,
  .panel,
  .page-header,
  .dashboard-grid,
  .side-widgets,
  .stats-row,
  .settings-grid,
  .table-wrap,
  .duty-mobile-cards,
  .modal,
  .portal-link-box,
  .absence-toolbar,
  .panel-footer,
  .footer-actions {
    max-width: 100%;
    min-width: 0;
  }

  .main {
    width: 100%;
    margin-right: 0 !important;
    padding: 0.7rem 0.7rem calc(1.25rem + env(safe-area-inset-bottom));
  }

  .topbar {
    width: 100%;
    max-width: 100%;
  }

  .topbar-user {
    min-width: 0;
    flex: 1;
  }

  .user-info {
    min-width: 0;
  }

  .user-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 42vw;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  .stats-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    overflow: visible !important;
    gap: 0.6rem;
  }

  .stat-card {
    min-width: 0 !important;
    width: 100%;
    flex-shrink: 1;
    padding: 0.8rem;
  }

  .stat-body {
    min-width: 0;
  }

  .stat-body h3,
  .stat-sub,
  .stat-main {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat-number {
    font-size: 1.3rem;
  }

  .desktop-only-table {
    display: none !important;
  }

  .duty-mobile-cards {
    display: grid !important;
    gap: 0.75rem;
    width: 100%;
  }

  .duty-day-card,
  .m-shift,
  .duty-list,
  .duty-person {
    max-width: 100%;
    min-width: 0;
  }

  .duty-person {
    flex-wrap: wrap;
  }

  .duty-person .name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn {
    white-space: normal;
    text-align: center;
    max-width: 100%;
  }

  .btn.icon-btn,
  .icon-btn,
  .icon-action,
  .menu-toggle,
  .notif-btn {
    white-space: nowrap;
    width: auto;
    flex-shrink: 0;
  }

  .settings-grid {
    grid-template-columns: 1fr !important;
  }

  .time-row {
    flex-wrap: wrap;
  }

  .time-row input {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  .absence-list {
    grid-template-columns: 1fr !important;
    max-height: min(48vh, 300px);
  }

  .absence-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .absence-toolbar input {
    min-width: 0 !important;
    width: 100%;
  }

  .portal-link-box {
    flex-direction: column;
  }

  .portal-link-box input {
    min-width: 0 !important;
    width: 100%;
  }

  .data-table,
  .duty-table {
    min-width: 0 !important;
  }

  .table-wrap:not(.desktop-only-table) {
    overflow-x: visible;
    border: none;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    margin-bottom: 0.65rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    border: none;
    padding: 0.3rem 0;
    text-align: left;
    word-break: break-word;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.78rem;
    flex: 0 0 auto;
    text-align: right;
  }

  .data-table td.actions-cell {
    justify-content: flex-end;
    flex-wrap: wrap;
    border-top: 1px dashed var(--border);
    margin-top: 0.35rem;
    padding-top: 0.55rem;
  }

  .data-table td.actions-cell::before {
    content: none;
  }

  .panel-controls {
    width: 100%;
  }

  .panel-controls .select-input {
    width: 100%;
    min-width: 0;
  }

  .week-nav {
    width: 100%;
  }

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

  .footer-actions .btn,
  .panel-footer > .btn {
    width: 100%;
  }

  .modal-overlay {
    align-items: stretch;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    margin: 0;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
    overflow: auto;
  }

  .edit-form {
    grid-template-columns: 1fr !important;
  }

  .notif-panel {
    position: fixed;
    inset: auto 0.5rem auto 0.5rem;
    top: calc(4.5rem + env(safe-area-inset-top));
    width: auto;
    max-width: none;
    max-height: min(70vh, 420px);
  }

  .shift-card {
    flex-direction: column;
    align-items: stretch;
  }

  .shift-card-action .btn {
    width: 100%;
  }

  .full-calendar .cal-day {
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  html {
    font-size: 14px;
  }

  .main {
    padding-inline: 0.55rem;
  }

  .stats-row {
    gap: 0.5rem;
  }

  .stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.7rem;
  }

  .stat-icon {
    width: 34px;
    height: 34px;
  }

  .page-header h2 {
    font-size: 1.1rem;
  }

  .duty-day-card-head {
    padding: 0.7rem 0.85rem;
  }

  .m-shift {
    padding: 0.6rem 0.7rem;
  }
}


/* ========== Staff status actions ========== */
.status-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
  min-width: min(100%, 220px);
}

.status-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.55rem 0.35rem;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 0.72rem;
  transition: 0.15s ease;
}

.status-btn svg {
  width: 18px;
  height: 18px;
}

.status-btn.present {
  color: #047857;
  background: var(--green-soft);
  border-color: #6ee7b7;
}

.status-btn.late {
  color: #b45309;
  background: var(--orange-soft);
  border-color: #fcd34d;
}

.status-btn.permission {
  color: #1d4ed8;
  background: var(--blue-soft);
  border-color: #93c5fd;
}

.status-btn.absent {
  color: #b91c1c;
  background: #FEE2E2;
  border-color: #FECACA;
}

.status-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.status-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.status-chip.status-present { background: var(--green-soft); color: #047857; }
.status-chip.status-late { background: var(--orange-soft); color: #b45309; }
.status-chip.status-permission { background: var(--blue-soft); color: #1d4ed8; }
.status-chip.status-absent { background: #FEE2E2; color: #b91c1c; }

.shift-card.has-absent {
  border-color: #FECACA;
  background: #FFF5F5;
}

.shift-card.has-late {
  border-color: #fcd34d;
}

.shift-card.has-permission {
  border-color: #93c5fd;
}

.datetime-plain {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

.phones-by-class {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.phone-class-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.phone-class-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  background: linear-gradient(135deg, #E8F6F1, #F7EFDA);
  border-bottom: 1px solid var(--border);
}

.late-student-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow: auto;
  padding-top: 0.35rem;
}

.late-student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FAFAFC;
}

.late-student-item.is-marked {
  background: #FFF7ED;
  border-color: #FCD34D;
}

.late-student-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.late-student-info strong {
  font-size: 0.92rem;
}

.late-student-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.late-home-panel {
  border-top: 3px solid #F59E0B;
}

.empty-state.soft {
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.35rem;
  background: #FFFBEB;
  border-radius: var(--radius-sm);
  color: #92400E;
  font-size: 0.85rem;
  font-weight: 600;
}

/* جرس مستمر */
.alarm-banner {
  position: fixed;
  inset-inline: 0.75rem;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 5000;
  animation: alarmPulse 1s ease-in-out infinite;
}

.alarm-banner[hidden] {
  display: none !important;
}

.alarm-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #fff;
  box-shadow: 0 10px 30px rgba(185, 28, 28, 0.35);
}

.alarm-banner-inner strong {
  font-size: 1rem;
}

.alarm-banner-inner span {
  flex: 1;
  font-size: 0.85rem;
  opacity: 0.95;
}

.alarm-banner-inner .btn {
  background: #fff;
  color: #b91c1c;
  box-shadow: none;
}

@keyframes alarmPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@media (max-width: 900px) {
  .status-actions {
    min-width: 0;
  }

  .shift-card-action {
    width: 100%;
  }
}

/* ========== Admin login gate ========== */
body.is-admin-login {
  overflow: auto;
}

body.is-admin-login #admin-app {
  display: none !important;
}

body.admin-portal:not(.is-admin-login) #admin-login {
  display: none !important;
}

.admin-login .brand-icon {
  background: linear-gradient(145deg, #085541, #0B6E4F 55%, #148F6B);
}

.brand-icon--logo {
  padding: 0;
  background: transparent;
  box-shadow: 0 4px 14px rgba(11, 110, 79, 0.28);
}

.staff-login-brand .brand-icon--logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}
