/* Shared Arabic typography and action styling */
:root {
  --font-arabic: 'Cairo', Tahoma, Arial, sans-serif;
  font-family: var(--font-arabic);
  font-size: 15px;
  line-height: 1.7;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body, button, input, select, textarea {
  font-family: var(--font-arabic);
}

html { font-size: 16px !important; }
body { font-size: 16px !important; line-height: 1.75; }
body :where(button, input, select, textarea) { font-family: var(--font-arabic) !important; font-size: 14px !important; line-height: 1.55; }
.nav-item { font-size: 14px !important; line-height: 1.55; }
.nav-caption, .academy-card-label, .academy-status, .user-row small { font-size: 12px !important; }
.brand-name { font-size: 20px !important; }
.brand-name small { font-size: 13px !important; letter-spacing: 0; }
.breadcrumb { font-size: 14px !important; }
.welcome h1, .section-heading h1 { font-size: clamp(23px, 2vw, 29px) !important; line-height: 1.4; letter-spacing: 0; }
.welcome p, .section-heading p { font-size: 15px !important; line-height: 1.85; }
.panel-title { font-size: 18px !important; line-height: 1.55; }
.panel h3, .panel > h3 { font-size: 16px !important; line-height: 1.55; }
.panel-subtitle, .panel-subtitle small { font-size: 14px !important; line-height: 1.8; }
.data-table th { font-size: 13px !important; line-height: 1.6; }
.data-table td { font-size: 14px !important; line-height: 1.7; }
.student-sub { font-size: 12px !important; line-height: 1.55; }
.stat-label, .stat-foot { font-size: 13px !important; }
.stat-value { font-size: 29px !important; }
.btn, .link-button { font-size: 14px !important; }
.form-field label { font-size: 14px !important; }
.empty-state { font-size: 15px !important; line-height: 1.85; }
.table-wrap {
  max-width: 100%;
  overscroll-behavior-inline: contain;
  scrollbar-color: #a8c0b1 #eef3ef;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.table-wrap::-webkit-scrollbar { height: 7px; }
.table-wrap::-webkit-scrollbar-track { background: #eef3ef; border-radius: 99px; }
.table-wrap::-webkit-scrollbar-thumb { background: #a8c0b1; border: 1px solid #eef3ef; border-radius: 99px; }
.data-table th, .data-table td { vertical-align: middle; }
.data-table tbody tr:hover td { background: #fbfdfb; }

/* Keep the mobile navigation and the account/academy footer reachable on short screens. */
.sidebar { height: 100vh; height: 100dvh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.sidebar .nav-list { flex: 0 0 auto; }
.sidebar-bottom { flex: 0 0 auto; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 12; }
.mobile-menu { display: none; }
.sidebar-close-btn { display: none; }
.overlay { display: none; }
.modal-backdrop { overflow-y: auto; }

.btn-danger {
  color: #fff;
  background: #a83232;
  border: 1px solid #a83232;
}
.btn-danger:hover { background: #8e2525; border-color: #8e2525; }
.danger-link { color: #a83232 !important; }
.archive-actions { display: flex; align-items: center; gap: 14px; }
.data-table td .link-button { white-space: nowrap; }
.brand { gap: 10px; }
.brand-mark { flex: 0 0 43px; }
.brand-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; font-size: 18px !important; letter-spacing: 0; }
.brand-name small { white-space: nowrap; font-size: 12px !important; line-height: 1.5; }
.role-switch, #role-select, #teacher-select { display: none !important; }
.course-assignment-help { display: block; margin-top: 8px; color: #9a5d24; font-size: 13px; line-height: 1.7; }
.settlement-amount { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 7px 0; }
.settlement-amount strong { color: var(--forest); }
.settled-badge { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: #e8f5ed; color: #286b45; font-size: 12px; font-weight: 700; }
.monthly-settlement-panel h3 { margin: 22px 0 10px; }
.monthly-settlement-panel .data-table td { vertical-align: top; }
.monthly-settlement-panel .btn { white-space: nowrap; }
.monthly-family-collection { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: -6px 0 14px; padding: 10px 12px; border-radius: 10px; background: #fff8e9; color: #74541b; font-size: 13px; }

@media (max-width: 800px) {
  .sidebar { overflow-y: auto; padding-bottom: calc(100px + env(safe-area-inset-bottom, 30px)) !important; }
  .sidebar-bottom { padding-bottom: calc(35px + env(safe-area-inset-bottom, 20px)) !important; margin-bottom: 45px !important; }
  .mobile-menu { display: grid !important; }
  .overlay.show { display: block; }
  .welcome h1, .section-heading h1 { font-size: 25px !important; }
  .data-table th { font-size: 12px !important; }
  .data-table td { font-size: 13px !important; }
}
@media (max-width: 520px) {
  body { font-size: 15px !important; }
  body :where(button, input, select, textarea) { font-size: 14px !important; }
  .welcome h1, .section-heading h1 { font-size: 23px !important; }
  .panel-title { font-size: 17px !important; }
  .panel-subtitle { font-size: 13px !important; }
  .stat-label, .stat-foot { font-size: 12px !important; }
  .data-table td { font-size: 12px !important; }
  .archive-actions { gap: 8px; }
}

:root {
  --forest: #0b2b26;
  --forest-2: #235347;
  --mint: #daf1de;
  --mint-2: #eef6f0;
  --lime: #8eb69b;
  --cream: #f3f7f4;
  --paper: #fff;
  --ink: #163832;
  --muted: #71877c;
  --line: #e1ebe4;
  --shadow: 0 10px 28px rgba(11, 43, 38, .07);
}

.sidebar {
  background: #173f35;
  box-shadow: -10px 0 34px rgba(5, 31, 32, .13);
}

.brand {
  border-bottom-color: rgba(218, 241, 222, .16);
}

.brand-mark {
  background: linear-gradient(145deg, #daf1de, #8eb69b);
  color: #051f20;
  box-shadow: 0 6px 18px rgba(5, 31, 32, .4);
}

.nav-caption {
  color: #8eb69b;
}

.nav-item {
  color: #c4d8cb;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(218, 241, 222, .09);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(110deg, #235347, #163832);
  color: #fff;
  border-color: rgba(142, 182, 155, .2);
  box-shadow: inset -3px 0 #8eb69b, 0 5px 14px rgba(5, 31, 32, .16);
}

.nav-icon {
  color: #a9c8b3;
}

.nav-item.active .nav-icon {
  color: #daf1de;
}

.nav-badge {
  color: #051f20;
  background: #daf1de;
}

.academy-card {
  background: rgba(218, 241, 222, .08);
  border-color: rgba(218, 241, 222, .14);
  border-radius: 16px;
}

.academy-card-label,
.user-row small {
  color: #a9c8b3;
}

.academy-status {
  color: #daf1de;
}

.user-row {
  border-top-color: rgba(218, 241, 222, .16);
  border-radius: 14px;
}

.stat-card,
.panel {
  border-color: var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stat-icon,
.mini-avatar {
  background: #e8f3eb;
  color: var(--forest-2);
}

.btn-primary {
  background: linear-gradient(110deg, #235347, #163832);
}

.btn-primary:hover {
  background: #0b2b26;
}

@media (max-width: 800px) {
  .sidebar {
    box-shadow: -12px 0 36px rgba(5, 31, 32, .3);
  }
}

:root {
  --gold: #c9a33f;
  --gold-deep: #9b7724;
  --gold-soft: #f5efd9;
}

@media (min-width: 801px) {
  .shell {
    grid-template-columns: 272px minmax(0, 1fr);
  }

  .sidebar {
    inset: 14px 14px 14px auto;
    height: calc(100vh - 28px);
    height: calc(100dvh - 28px);
    padding: 14px 15px;
    border: 1px solid rgba(218, 241, 222, .1);
    border-radius: 24px;
    overflow: visible;
  }

  .sidebar-top,
  .sidebar-bottom {
    display: contents;
  }

  .sidebar .brand {
    order: 1;
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 9px !important;
    padding: 7px 6px 10px !important;
    text-align: right !important;
  }

  .sidebar .brand-logo {
    width: 38px !important;
    height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    flex: 0 0 38px;
  }

  .sidebar .brand-name {
    font-size: 16px !important;
    line-height: 1.35;
  }

  .sidebar .brand-name small {
    font-size: 10px !important;
    line-height: 1.3;
  }

  .user-row {
    position: relative;
    order: 2;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(218, 241, 222, .12);
    border-radius: 13px;
    background: rgba(218, 241, 222, .07);
    text-align: right;
  }

  .user-row .avatar {
    width: 36px;
    height: 36px;
    margin: 0;
    border: 2px solid rgba(201, 163, 63, .85);
    background: #daf1de;
    color: #163832;
  }

  .user-row strong {
    font-size: 12px;
    line-height: 1.4;
  }

  .user-row small {
    font-size: 10px !important;
    line-height: 1.35;
  }

  .user-row .user-edit-btn {
    position: absolute !important;
    top: 6px;
    left: 6px;
  }

  .nav-caption {
    order: 3;
    margin: 12px 10px 5px;
  }

  .sidebar .nav-list {
    order: 4;
    position: relative;
    left: 16px;
    align-content: start;
    flex: 1 1 auto;
    gap: 4px;
    width: calc(100% + 66px);
    min-height: 0;
    margin-left: -50px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  .nav-list:hover {
    scrollbar-color: rgba(218, 241, 222, .22) transparent;
  }

  .nav-item:not(.active) {
    width: calc(100% - 40px);
    margin-left: 40px;
  }

  .nav-item {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 11px;
  }

  .nav-item.active {
    position: relative;
    z-index: 1;
    width: calc(100% - 40px) !important;
    max-width: none !important;
    margin-left: 0;
    transform: translateX(-16px);
    padding-inline: 12px;
    border-color: transparent;
    border-radius: 0 16px 16px 0 !important;
    background: var(--cream) !important;
    color: #173f35;
    box-shadow: none;
  }

  .nav-item.active .nav-icon {
    color: var(--forest-2);
  }

  .academy-card {
    order: 5;
    margin: auto 0 8px;
    padding: 8px 10px;
    border-radius: 12px;
    line-height: 1.4;
  }

  .academy-card-label {
    font-size: 10px !important;
    line-height: 1.35;
  }

  .academy-card strong {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
  }

  .academy-status {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.35;
  }

  .btn-pwa-install { order: 6; }
  .sidebar-spacer { display: none !important; }
}

.btn-primary {
  background: linear-gradient(115deg, #d6b553, #bd9635);
  color: #163832;
  box-shadow: 0 6px 16px rgba(175, 137, 43, .22);
}

.btn-primary:hover {
  background: linear-gradient(115deg, #c9a33f, #a98227);
  color: #102e27;
  box-shadow: 0 8px 18px rgba(175, 137, 43, .28);
}

.btn-pwa-install {
  border-color: rgba(201, 163, 63, .65) !important;
  background: linear-gradient(115deg, #d6b553, #bd9635) !important;
  color: #163832 !important;
}

.nav-badge {
  background: #c9a33f;
  color: #163832;
}

.stat-card {
  border-color: #eee6d4;
  background: linear-gradient(145deg, #fff 62%, #fffdf7);
  box-shadow: 0 10px 28px rgba(11, 43, 38, .065), 0 3px 10px rgba(175, 137, 43, .045);
}

.stat-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #ead8a3, #c9a33f, #ead8a3);
  content: "";
}

.stat-icon {
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.trend {
  color: var(--gold-deep);
}

html,
body,
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

html:hover,
body:hover {
  scrollbar-color: rgba(11, 43, 38, .2) transparent;
}

.sidebar:hover {
  scrollbar-color: rgba(218, 241, 222, .22) transparent;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: rgba(11, 43, 38, .28);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(218, 241, 222, .3);
}

.nav-list::-webkit-scrollbar {
  width: 5px;
}

.nav-list::-webkit-scrollbar-track {
  background: transparent;
}

.nav-list::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: transparent;
}

.nav-list:hover::-webkit-scrollbar-thumb {
  background: rgba(218, 241, 222, .18);
}

.nav-list::-webkit-scrollbar-thumb:hover {
  background: rgba(218, 241, 222, .3);
}

@media (max-width: 800px) {
  .sidebar {
    top: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    left: auto !important;
    width: 280px !important;
    max-width: calc(100vw - 24px) !important;
    height: calc(100vh - 24px) !important;
    height: calc(100dvh - 24px) !important;
    padding: 14px 15px !important;
    border: 1px solid rgba(218, 241, 222, .1) !important;
    border-radius: 24px !important;
    overflow: visible !important;
    box-shadow: -12px 0 36px rgba(5, 31, 32, .3) !important;
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }

  .sidebar-top {
    position: relative;
    order: 1;
    width: 100%;
  }

  .sidebar-bottom {
    display: contents !important;
    flex: 0 0 auto;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sidebar-close-btn {
    top: 6px !important;
    left: 6px !important;
  }

  .sidebar-spacer {
    display: none !important;
  }

  .sidebar .brand {
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 9px !important;
    padding: 7px 6px 10px !important;
    text-align: right !important;
  }

  .sidebar .brand-logo {
    width: 38px !important;
    height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    flex: 0 0 38px;
  }

  .sidebar .brand-name {
    font-size: 16px !important;
    line-height: 1.35;
  }

  .sidebar .brand-name small {
    font-size: 10px !important;
    line-height: 1.3;
  }

  .sidebar .user-row {
    position: relative;
    order: 2;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(218, 241, 222, .12);
    border-radius: 13px;
    background: rgba(218, 241, 222, .07);
    text-align: right;
  }

  .sidebar .user-row .user-edit-btn {
    position: absolute !important;
    top: 6px;
    left: 6px;
  }

  .sidebar .user-row .avatar {
    width: 36px;
    height: 36px;
    margin: 0;
  }

  .sidebar .user-row strong {
    font-size: 12px;
    line-height: 1.4;
  }

  .sidebar .user-row small {
    font-size: 10px !important;
    line-height: 1.35;
  }

  .sidebar .nav-caption {
    order: 3;
    margin: 12px 10px 5px;
  }

  .sidebar .nav-list {
    position: relative;
    left: auto;
    order: 4;
    align-content: start;
    flex: 1 1 auto;
    gap: 4px;
    width: 100%;
    min-height: 0;
    margin-left: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  .sidebar .nav-list:hover {
    scrollbar-color: rgba(218, 241, 222, .22) transparent;
  }

  .sidebar .nav-item:not(.active) {
    width: 100%;
    margin-left: 0;
  }

  .sidebar .nav-item {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 11px;
  }

  .sidebar .nav-item.active {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0;
    transform: none;
    padding-inline: 12px;
    border-color: transparent;
    border-radius: 11px !important;
    background: var(--cream) !important;
    color: #173f35;
    box-shadow: none;
  }

  .sidebar .nav-item.active .nav-icon {
    color: var(--forest-2);
  }

  .sidebar .academy-card {
    order: 5;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 12px;
    line-height: 1.4;
  }

  .sidebar .academy-card-label {
    font-size: 10px !important;
    line-height: 1.35;
  }

  .sidebar .academy-card strong {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
  }

  .sidebar .academy-status {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.35;
  }

  .sidebar .btn-pwa-install {
    order: 6;
  }
}
