
    :root {
      --primary: #0b5d3b;
      --secondary: #c9972b;
      --bg: #f5f7f6;
      --text: #102033;
      --muted: #64748b;
      --border: #e5ece8;
      --soft: #eef7f2;
      --white: #ffffff;
      --shell: 1180px;
      --shadow: 0 10px 28px rgba(0,0,0,.06);
      --radius: 20px;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background:
        radial-gradient(circle at 12% 0%, rgba(11,93,59,.06), transparent 32%),
        radial-gradient(circle at 88% 8%, rgba(201,151,43,.08), transparent 30%),
        var(--bg);
      color: var(--text);
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 1000;
      color: white;
      padding: 12px 14px;
      background:
        radial-gradient(circle at top right, rgba(255,255,255,.18), transparent 30%),
        linear-gradient(135deg, var(--primary), #073a27);
      box-shadow: 0 10px 28px rgba(0,0,0,.12);
    }

    .topbar-inner {
      width: min(var(--shell), calc(100% - 28px));
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 11px;
      min-width: 260px;
    }

    .brand-logo {
      width: 54px;
      height: 54px;
      border-radius: 16px;
      background: white;
      border: 1px solid rgba(255,255,255,.35);
      overflow: hidden;
      flex: 0 0 auto;
      box-shadow: 0 8px 20px rgba(0,0,0,.14);
    }

    .brand-logo img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      display: block;
      padding: 0px;
      background: white;
    }

    .brand-logo-fallback {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #ffffff, #edf8f2);
      color: var(--primary);
      font-weight: 650;
      font-size: 16px;
      letter-spacing: .15px;
      padding: 2px;
      text-align: center;
      line-height: 1;
      white-space: nowrap;
    }

    .brand-logo-fallback.is-hidden { display: none; }

    .brand-title {
      margin: 0;
      font-size: 19px;
      line-height: 1.08;
      letter-spacing: -.25px;
    }

    .brand-subtitle {
      opacity: .92;
      font-size: 14px;
      margin-top: 4px;
      line-height: 1.25;
    }

    .nav {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 9px;
      row-gap: 9px;
      flex-wrap: wrap;
      max-width: 100%;
    }

    .nav a,
    .nav-btn {
      color: white;
      text-decoration: none;
      font-weight: 650;
      padding: 8px 11px;
      border-radius: 999px;
      background: rgba(255,255,255,.12);
      border: 1px solid rgba(255,255,255,.20);
      font-size: 14px;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 39px;
      transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
    }

    .nav a:hover,
    .nav-btn:hover {
      background: rgba(255,255,255,.22);
      transform: translateY(-1px);
    }

    .nav a.active,
    .nav-btn.active {
      background: white;
      color: var(--primary);
      border-color: rgba(255,255,255,.9);
      box-shadow: 0 8px 20px rgba(0,0,0,.14);
    }

    .nav form { margin: 0; display: inline-flex; }

    .nav-icon {
      width: 25px;
      height: 25px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: white;
      box-shadow: 0 4px 12px rgba(0,0,0,.16);
      flex: 0 0 auto;
    }

    .nav-icon svg {
      width: 15px;
      height: 15px;
      stroke: currentColor;
      stroke-width: 2.4;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .nav-icon.home { background: linear-gradient(135deg, #f59e0b, #d97706); }
    .nav-icon.dashboard { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
    .nav-icon.students { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
    .nav-icon.admin { background: linear-gradient(135deg, #0f766e, #115e59); }
    .nav-icon.halaqs { background: linear-gradient(135deg, #0891b2, #0e7490); }
    .nav-icon.log { background: linear-gradient(135deg, #dc2626, #991b1b); }
    .nav-icon.musabaqah { background: linear-gradient(135deg, #c9972b, #9a6200); }

    .nav a.active .nav-icon {
      background: linear-gradient(135deg, var(--primary), #073a27);
    }

    .wrap {
      width: min(var(--shell), calc(100% - 28px));
      margin: 24px auto 34px;
    }

    .hero, .card, .table-card, .panel {
      background: white;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }

    .hero {
      padding: 24px;
      margin-bottom: 16px;
    }

    .hero h1 {
      margin: 0;
      font-size: 34px;
      line-height: 1.1;
      letter-spacing: -.5px;
    }

    .hero p {
      margin: 10px 0 0;
      color: var(--muted);
      line-height: 1.5;
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-decoration: none;
      background: var(--primary);
      color: white;
      padding: 11px 15px;
      border-radius: 13px;
      font-weight: 650;
      border: none;
      cursor: pointer;
      min-height: 42px;
    }

    .btn-soft {
      background: var(--soft);
      color: var(--primary);
      border: 1px solid #d7eadf;
    }

    .btn-gold {
      background: #fff8e8;
      border: 1px solid #e7c76d;
      color: #7a5200;
      box-shadow: 0 8px 20px rgba(122,82,0,.08);
    }

    .muted {
      color: var(--muted);
      font-size: 14px;
    }

    .cards {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .card { padding: 18px; }

    .card b {
      display: block;
      color: var(--primary);
      font-size: 28px;
      line-height: 1.1;
    }

    .card span {
      color: #5b6670;
      font-size: 14px;
    }

    .quick-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
    }

    .quick-card {
      text-decoration: none;
      color: var(--text);
      padding: 18px;
      border-radius: 18px;
      background: white;
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      transition: .15s ease;
    }

    .quick-card:hover {
      transform: translateY(-2px);
      border-color: #cfe7d9;
    }

    .quick-card h3 {
      margin: 0 0 6px;
      color: var(--primary);
    }

    .quick-card p {
      margin: 0;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.45;
    }

    .table-card { overflow: hidden; }

    .table-head {
      padding: 18px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
    }

    .table-head h2 { margin: 0; }

    .table-scroll { overflow-x: auto; }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 14px;
    }

    th, td {
      padding: 12px;
      border-bottom: 1px solid #eef2f0;
      text-align: left;
      vertical-align: top;
    }

    th {
      background: #f7faf8;
      color: var(--primary);
      font-size: 14px;
      text-transform: uppercase;
    }

    .badge {
      display: inline-block;
      padding: 6px 10px;
      border-radius: 999px;
      font-weight: 650;
      font-size: 14px;
    }

    .on { background: #e5f7ed; color: #0b5d3b; }
    .support { background: #ffecec; color: #9b1c1c; }
    .behind { background: #fff4dc; color: #9a6200; }
    .none { background: #eef2f6; color: #4b5563; }

    .student-link,
    .halaq-link {
      color: var(--text);
      text-decoration: none;
      font-weight: 650;
    }

    .student-link:hover,
    .halaq-link:hover {
      color: var(--primary);
      text-decoration: underline;
    }

    .page-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .flash {
      position: fixed;
      top: 84px;
      left: 50%;
      transform: translateX(-50%);
      width: min(var(--shell), calc(100% - 28px));
      z-index: 10000;
      background: rgba(255,255,255,.94);
      backdrop-filter: blur(8px);
      border: 1px solid var(--border);
      border-left: 6px solid var(--primary);
      border-radius: 16px;
      padding: 12px 46px 12px 14px;
      box-shadow: 0 16px 35px rgba(0,0,0,.14);
      font-weight: 650;
    }

    .flash ul { list-style: none; padding-left: 0; margin: 0; }
    .flash li { margin: 5px 0; }

    .flash-close {
      position: absolute;
      top: 8px;
      right: 9px;
      width: 31px;
      height: 31px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: white;
      cursor: pointer;
      font-weight: 650;
      line-height: 1;
    }

    .offline-pill {
      position: fixed;
      left: 50%;
      bottom: 16px;
      transform: translateX(-50%) translateY(80px);
      z-index: 9999;
      background: #fff8e8;
      border: 1px solid #e7c76d;
      color: #7a5200;
      border-radius: 999px;
      padding: 10px 14px;
      font-weight: 650;
      font-size: 14px;
      box-shadow: 0 10px 28px rgba(0,0,0,.14);
      opacity: 0;
      pointer-events: none;
      transition: .2s ease;
    }

    .offline-pill.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .install-app-banner {
      position: fixed;
      left: 50%;
      bottom: 72px;
      transform: translateX(-50%);
      z-index: 9998;
      width: min(92vw, 520px);
      background: white;
      border: 1px solid #d7eadf;
      border-radius: 20px;
      box-shadow: 0 18px 45px rgba(0,0,0,.18);
      padding: 14px;
      display: none;
      gap: 12px;
      align-items: center;
    }

    .install-app-banner.show { display: flex; }

    .push-alert-banner {
      position: fixed;
      left: 18px;
      right: 18px;
      bottom: 18px;
      z-index: 1000;
      display: none;
      max-width: 560px;
      margin: 0 auto;
      padding: 13px 14px;
      border-radius: 18px;
      background: #ffffff;
      border: 1px solid rgba(11,93,59,.16);
      box-shadow: 0 18px 44px rgba(0,0,0,.16);
    }

    .push-alert-banner.show {
      display: block;
    }

    .push-alert-banner strong {
      display: block;
      color: var(--primary);
      font-size: 15px;
    }

    .push-alert-banner span {
      display: block;
      margin-top: 3px;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.35;
    }

    .push-alert-actions {
      display: flex;
      gap: 8px;
      margin-top: 10px;
      flex-wrap: wrap;
    }

    .push-alert-actions button {
      border: 0;
      border-radius: 999px;
      padding: 9px 12px;
      font-weight: 650;
      cursor: pointer;
    }

    .push-alert-enable {
      background: var(--primary);
      color: white;
    }

    .push-alert-later {
      background: var(--soft);
      color: var(--primary);
    }
    .install-app-icon {
      width: 46px;
      height: 46px;
      border-radius: 15px;
      background: var(--soft);
      color: var(--primary);
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 650;
      flex: 0 0 auto;
      overflow: hidden;
    }

    .install-app-icon img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      padding: 4px;
    }

    .install-app-body { flex: 1; min-width: 0; }

    .install-app-body b {
      display: block;
      color: var(--text);
      font-size: 15px;
    }

    .install-app-body span {
      display: block;
      color: var(--muted);
      font-size: 14px;
      margin-top: 3px;
      line-height: 1.35;
    }

    .install-app-actions {
      display: flex;
      gap: 7px;
      flex-wrap: wrap;
      margin-top: 8px;
    }

    .install-app-actions button {
      border: none;
      cursor: pointer;
      border-radius: 999px;
      padding: 9px 11px;
      font-weight: 650;
      font-size: 14px;
    }

    .install-app-actions .install-primary { background: var(--primary); color: white; }
    .install-app-actions .install-close { background: #eef2f6; color: #475569; }

    @media (max-width: 980px) {
      .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
      }

      .brand {
        width: 100%;
        min-width: 0;
      }

      .nav {
        width: 100%;
        justify-content: flex-start;
      }
    }

    @media (max-width: 900px) {
      table { min-width: 900px; }
      .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .hero h1 { font-size: 28px; }
    }

    @media (max-width: 740px) {
      body.nav-fixed-ready { padding-top: var(--tahfidh-expanded-topbar, 0px); }

      body.nav-fixed-ready .topbar {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
      }

      .topbar { padding: 9px 8px 8px; }

      .topbar-inner {
        width: 100%;
        gap: 7px;
      }

      .brand-logo {
        width: 36px;
        height: 36px;
        border-radius: 11px;
      }

      .brand-title {
        font-size: 14px;
        line-height: 1.05;
      }

      .brand-subtitle { display: none; }

      .nav {
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 7px;
        padding: 1px 2px 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
      }

      .nav::-webkit-scrollbar { display: none; }

      .nav a,
      .nav-btn {
        flex: 0 0 auto;
        width: auto;
        min-height: 35px;
        padding: 7px 11px;
        font-size: 14px;
        line-height: 1;
        text-align: center;
        border-radius: 999px;
        flex-direction: row;
        gap: 6px;
        white-space: nowrap;
      }

      .nav-icon {
        width: 21px;
        height: 21px;
      }

      .wrap {
        width: calc(100% - 24px);
        margin: 16px auto 30px;
      }

      .hero {
        padding: 18px;
        border-radius: 18px;
      }

      .hero h1 {
        font-size: 26px;
        line-height: 1.12;
      }

      .hero p { font-size: 14px; }

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

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

      .card {
        padding: 14px 15px;
        border-radius: 17px;
      }

      .card b { font-size: 24px; }
      .card span { font-size: 14px; }

      .page-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .page-actions .btn {
        text-align: center;
        padding: 10px 8px;
        min-height: 42px;
        border-radius: 13px;
        font-size: 14px;
      }

      .install-app-banner { align-items: flex-start; }
      .install-app-actions { width: 100%; }
      .install-app-actions button { flex: 1; }

      body.nav-compact .topbar {
        box-shadow: 0 12px 30px rgba(0,0,0,.18);
      }

      body.nav-compact .topbar-inner {
        gap: 7px;
      }

      body.nav-compact .brand-logo {
        width: 36px;
        height: 36px;
        border-radius: 11px;
      }

      body.nav-compact .brand-title {
        font-size: 14px;
        line-height: 1.05;
      }

      body.nav-compact .brand-subtitle { display: none; }

      body.nav-compact .nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 7px;
        padding: 1px 2px 6px;
        -webkit-overflow-scrolling: touch;
      }

      body.nav-compact .nav::-webkit-scrollbar { display: none; }

      body.nav-compact .nav a,
      body.nav-compact .nav-btn {
        flex: 0 0 auto;
        width: auto;
        min-height: 35px;
        padding: 7px 11px;
        font-size: 14px;
        line-height: 1;
        flex-direction: row;
        white-space: nowrap;
      }

      body.nav-compact .nav-icon {
        width: 21px;
        height: 21px;
      }
    }

    @media (max-width: 360px) {
      .cards,
      .page-actions { grid-template-columns: 1fr; }
    }

    /* Arabic / RTL polish
       This keeps the English system safe while giving Arabic centres a more natural Islamic dashboard feel. */
    :root {
      --arabic-ui-font: "Tajawal", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, Arial, sans-serif;
      --arabic-quran-font: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Traditional Arabic", serif;
    }

    html[dir="rtl"] body {
      direction: rtl;
      text-align: start;
      font-family: var(--arabic-ui-font);
      letter-spacing: 0;
      -webkit-font-smoothing: antialiased;
      text-rendering: optimizeLegibility;
    }

    html[dir="rtl"] body,
    html[dir="rtl"] h1,
    html[dir="rtl"] h2,
    html[dir="rtl"] h3,
    html[dir="rtl"] h4,
    html[dir="rtl"] h5,
    html[dir="rtl"] h6,
    html[dir="rtl"] p,
    html[dir="rtl"] a,
    html[dir="rtl"] span,
    html[dir="rtl"] b,
    html[dir="rtl"] strong,
    html[dir="rtl"] label,
    html[dir="rtl"] button,
    html[dir="rtl"] input,
    html[dir="rtl"] select,
    html[dir="rtl"] textarea,
    html[dir="rtl"] th,
    html[dir="rtl"] td {
      letter-spacing: 0;
    }

    html[dir="rtl"] .hero h1,
    html[dir="rtl"] .brand-title,
    html[dir="rtl"] .table-head h2,
    html[dir="rtl"] .section-head h2,
    html[dir="rtl"] .admin-section-head h2,
    html[dir="rtl"] .report-section-head h2 {
      line-height: 1.28;
      font-weight: 650;
    }

    html[dir="rtl"] .hero p,
    html[dir="rtl"] p,
    html[dir="rtl"] .muted,
    html[dir="rtl"] .card span,
    html[dir="rtl"] .quick-card p,
    html[dir="rtl"] td,
    html[dir="rtl"] .report-note,
    html[dir="rtl"] .admin-note,
    html[dir="rtl"] .teacher-note,
    html[dir="rtl"] .student-note,
    html[dir="rtl"] .plan-note,
    html[dir="rtl"] .halaq-note,
    html[dir="rtl"] .logs-note,
    html[dir="rtl"] .template-note {
      line-height: 1.72;
    }

    html[dir="rtl"] .topbar-inner,
    html[dir="rtl"] .brand,
    html[dir="rtl"] .nav,
    html[dir="rtl"] .page-actions,
    html[dir="rtl"] .cards,
    html[dir="rtl"] .quick-grid,
    html[dir="rtl"] .table-head,
    html[dir="rtl"] .section-head {
      direction: rtl;
    }

    html[dir="rtl"] th,
    html[dir="rtl"] td {
      text-align: start;
    }

    html[dir="rtl"] th {
      text-transform: none;
      font-weight: 650;
    }

    html[dir="rtl"] .btn,
    html[dir="rtl"] .nav a,
    html[dir="rtl"] .nav-btn,
    html[dir="rtl"] .badge,
    html[dir="rtl"] .admin-pill,
    html[dir="rtl"] .teacher-pill,
    html[dir="rtl"] .student-pill,
    html[dir="rtl"] .plan-pill,
    html[dir="rtl"] .halaq-pill,
    html[dir="rtl"] .logs-pill,
    html[dir="rtl"] .template-pill,
    html[dir="rtl"] .report-pill {
      font-weight: 650;
      line-height: 1.35;
    }

    html[dir="rtl"] .flash {
      border-left: 1px solid var(--border);
      border-right: 6px solid var(--primary);
      padding: 12px 14px 12px 46px;
      text-align: start;
    }

    html[dir="rtl"] .flash-close {
      right: auto;
      left: 9px;
    }

    html[dir="rtl"] .student-link,
    html[dir="rtl"] .halaq-link,
    html[dir="rtl"] .teacher-name,
    html[dir="rtl"] .student-name,
    html[dir="rtl"] .brand-title,
    html[dir="rtl"] .report-row-title,
    html[dir="rtl"] .student-meta,
    html[dir="rtl"] .entry-item {
      unicode-bidi: plaintext;
    }

    html[dir="rtl"] input,
    html[dir="rtl"] textarea,
    html[dir="rtl"] select {
      text-align: start;
      font-family: var(--arabic-ui-font);
    }

    html[dir="rtl"] input[type="date"],
    html[dir="rtl"] input[type="month"],
    html[dir="rtl"] input[type="number"],
    html[dir="rtl"] input[type="time"],
    html[dir="rtl"] .ltr,
    html[dir="rtl"] code,
    html[dir="rtl"] pre {
      direction: ltr;
      unicode-bidi: embed;
    }

    html[dir="rtl"] .admin-note,
    html[dir="rtl"] .teacher-note,
    html[dir="rtl"] .student-note,
    html[dir="rtl"] .plan-note,
    html[dir="rtl"] .halaq-note,
    html[dir="rtl"] .logs-note,
    html[dir="rtl"] .template-note,
    html[dir="rtl"] .filter-status,
    html[dir="rtl"] .log-note,
    html[dir="rtl"] .report-explanation-note,
    html[dir="rtl"] .parent-note {
      border-left-width: 1px;
      border-right-width: 6px;
      border-right-style: solid;
      border-right-color: var(--secondary);
    }

    html[dir="rtl"] .report-explanation-note {
      border-right-color: #f59e0b;
    }

    html[dir="rtl"] .log-note {
      border-right-color: #d88418;
    }

    html[dir="rtl"] .manage-student-table th:first-child,
    html[dir="rtl"] .manage-student-table td:first-child {
      left: auto;
      right: 0;
      box-shadow: -8px 0 18px rgba(0,0,0,.045);
    }

    html[dir="rtl"] .feature-text.left {
      text-align: right;
      padding-left: 0;
      padding-right: 20px;
    }

    html[dir="rtl"] .feature-text.right {
      text-align: left;
      padding-right: 0;
      padding-left: 20px;
    }

    html[dir="rtl"] .feature-text.left::before {
      left: auto;
      right: 0;
    }

    html[dir="rtl"] .feature-text.right::before {
      right: auto;
      left: 0;
    }

    html[dir="rtl"] .centre-card::after {
      content: "فتح مساحة العمل";
      right: auto;
      left: 18px;
    }

    html[dir="rtl"] .report-section-card[open] .report-section-toggle::after {
      content: "إخفاء";
    }

    html[dir="rtl"] .report-section-card:not([open]) .report-section-toggle::after {
      content: "فتح";
    }

    html[dir="rtl"] .hero-ayah-text,
    html[dir="rtl"] .quran-text,
    html[dir="rtl"] .quran-arabic,
    html[dir="rtl"] [data-quran-text] {
      font-family: var(--arabic-quran-font);
      line-height: 1.9;
      font-weight: 700;
    }

    [dir="auto"] {
      unicode-bidi: plaintext;
    }

    @media print {
      html[dir="rtl"] body {
        font-family: "Tajawal", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
      }

      html[dir="rtl"] th,
      html[dir="rtl"] td {
        text-align: start;
      }
    }
