:root {
  --bg: #edf4ff;
  --ink: #132033;
  --muted: #647086;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --line: rgba(49, 68, 98, 0.14);
  --blue: #2f74d0;
  --violet: #7a63d8;
  --green: #168f65;
  --orange: #d98220;
  --red: #ca3d4a;
  --shadow: 0 24px 70px rgba(58, 83, 126, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Cairo", "Tajawal", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(47, 116, 208, 0.25), transparent 34rem),
    radial-gradient(circle at 18% 12%, rgba(122, 99, 216, 0.22), transparent 32rem),
    linear-gradient(135deg, #f8fbff 0%, #eaf2ff 48%, #f5f8ff 100%);
}

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

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(255,255,255,.38));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-weight: 800;
  font-size: .78rem;
}

.hero-actions, .button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid rgba(47, 116, 208, .2);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--ink);
  background: rgba(255,255,255,.56);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47, 116, 208, .14); }
.btn.primary { color: white; background: linear-gradient(135deg, var(--blue), var(--violet)); border-color: transparent; }
.btn.soft { background: rgba(47,116,208,.1); color: #245ca4; }
.btn.ghost { background: rgba(255,255,255,.4); }

.dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(58, 83, 126, .08);
}

.stat-card strong { display: block; font-size: 1.55rem; line-height: 1; }
.stat-card span { color: var(--muted); font-size: .82rem; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.46);
  backdrop-filter: blur(18px);
}

.tab {
  white-space: nowrap;
  border: 0;
  border-radius: 18px;
  padding: 11px 15px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active { color: white; background: linear-gradient(135deg, var(--blue), var(--violet)); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: 1.45fr 1.45fr 1fr; }
.span-two { grid-column: span 2; }

.glass-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--glass);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 14px;
}

h2, h3 { margin: 0 0 14px; line-height: 1.25; }
h3 { font-size: 1rem; }

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 148px;
  margin-bottom: 14px;
  border: 1px dashed rgba(47, 116, 208, .45);
  border-radius: 24px;
  background: rgba(255,255,255,.36);
  text-align: center;
  color: var(--muted);
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.field { display: grid; gap: 7px; margin-bottom: 12px; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(49, 68, 98, .16);
  border-radius: 18px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  outline: none;
}

textarea { resize: vertical; min-height: 110px; }

.form-grid, .manual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.manual-grid { grid-template-columns: 1.4fr 1.2fr 1fr auto; align-items: end; }

.switch-grid, .multi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.switch-grid.dense { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.switch-grid label, .inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.42);
}

.switch-grid input, .inline-check input { width: auto; }

.multi-filter {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.38);
}

.multi-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
}

.pill {
  border: 1px solid rgba(47,116,208,.18);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255,255,255,.6);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.pill.active { color: white; background: var(--blue); }
.pill.warning { background: rgba(217,130,32,.13); color: #9a5b14; }
.pill.danger { background: rgba(202,61,74,.12); color: #a22d38; }
.pill.success { background: rgba(22,143,101,.12); color: #126e50; }

.table-wrap { overflow: auto; border-radius: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid rgba(49,68,98,.1); text-align: right; vertical-align: top; }
th { color: var(--muted); font-size: .82rem; background: rgba(255,255,255,.34); }
td { background: rgba(255,255,255,.25); }

.status-list {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0 18px 0 0;
  color: var(--muted);
}

.quick-actions, .chips, .operation-list, .teacher-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-actions { margin: 12px 0; }
.chip, .operation-card, .teacher-card, .conflict-card, .unresolved-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.48);
  padding: 12px 14px;
}

.chip strong { color: var(--blue); }

.compact-data-panel summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--blue);
}

.case-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.school-date-card {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,.62), rgba(235,244,255,.42));
}

.school-date-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.school-date-info h2 {
  margin: 2px 0 4px;
}

.school-date-info span {
  display: inline-flex;
  margin-left: 14px;
  color: var(--muted);
}

.school-date-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
}

.school-date-actions input {
  min-width: 150px;
}

.date-warning {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  color: #9a5b14;
  background: rgba(217,130,32,.13);
}

.department-case-group, .case-detail-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.34);
}

.section-head.compact {
  margin-bottom: 0;
  align-items: center;
}

.case-teacher-list {
  display: grid;
  gap: 10px;
}

.case-teacher-row {
  display: grid;
  grid-template-columns: minmax(230px, .9fr) minmax(320px, 1.7fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(49,68,98,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.45);
}

.teacher-identity, .lesson-card {
  display: grid;
  gap: 5px;
}

.teacher-identity span, .lesson-card span, .lesson-card small {
  color: var(--muted);
  font-size: .86rem;
}

.case-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}

.case-actions, .lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.lesson-card {
  padding: 12px;
  border: 1px solid rgba(49,68,98,.1);
  border-radius: 18px;
  background: rgba(255,255,255,.5);
}

.lesson-card p {
  margin: 0;
  font-weight: 700;
}

.empty-state {
  display: block;
  padding: 14px;
  border: 1px dashed rgba(47,116,208,.25);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255,255,255,.34);
}

.teacher-card {
  flex: 1 1 280px;
  display: grid;
  gap: 9px;
}

.teacher-card .mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.operation-list { display: grid; }
.operation-card { display: grid; gap: 8px; }
.operation-card.coverage { border-right: 5px solid var(--green); }
.operation-card.move { border-right: 5px solid var(--blue); }
.operation-card.swap { border-right: 5px solid var(--violet); }
.operation-card.accepted, .operation-card.accepted-edited { background: rgba(22,143,101,.09); }
.operation-card.rejected { opacity: .62; background: rgba(202,61,74,.09); border-right-color: var(--red); }
.operation-card.pinned { box-shadow: inset 0 0 0 2px rgba(22,143,101,.22); }
.operation-card.edited { outline: 1px dashed rgba(217,130,32,.5); }
.unresolved-card, .conflict-card.high { border-right: 5px solid var(--red); }
.conflict-card.medium { border-right: 5px solid var(--orange); }
.conflict-card.low { border-right: 5px solid var(--blue); }

.meta-row { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }
.json-preview, .report-panel pre {
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  padding: 16px;
  border-radius: 18px;
  background: rgba(19,32,51,.06);
  color: #24334a;
  overflow: auto;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.cell {
  min-width: 132px;
  border-radius: 14px;
  padding: 9px;
  background: rgba(255,255,255,.45);
}
.cell.free { color: var(--muted); }
.cell.absent { background: rgba(202,61,74,.13); }
.cell.covered { background: rgba(22,143,101,.15); }
.cell.moved { background: rgba(47,116,208,.14); }
.cell.protected { outline: 1px dashed rgba(122,99,216,.55); }
.cell.excluded { opacity: .56; filter: grayscale(.25); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  padding: 13px 18px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: var(--shadow);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateY(0); }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (max-width: 1100px) {
  .dashboard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.two, .grid.three, .compare-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 18px, 1480px); padding-top: 12px; }
  .hero, .section-head { flex-direction: column; }
  .school-date-info { align-items: flex-start; flex-direction: column; }
  .dashboard, .form-grid, .switch-grid, .switch-grid.dense, .multi-grid, .manual-grid { grid-template-columns: 1fr; }
  .case-teacher-row { grid-template-columns: 1fr; }
  .glass-panel, .hero { border-radius: 22px; padding: 16px; }
  .hero h1 { font-size: 2rem; }
}

@media print {
  body { background: white; color: black; }
  .no-print, .tabs, .dashboard, .toast, #tab-data, #tab-scope, #tab-commands, #tab-instructions, #tab-plan, #tab-timetable { display: none !important; }
  .app-shell { width: 100%; padding: 0; }
  .hero, .glass-panel { box-shadow: none; border: 0; background: white; padding: 0; }
  .tab-panel { display: none; }
  #tab-reports { display: block; }
  .grid.two { grid-template-columns: 1fr; }
  pre { border: 0; background: white !important; }
}
