@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');
:root{--forest:#173f35;--forest-2:#245848;--mint:#dff2e9;--mint-2:#eef7f2;--lime:#b9d98a;--cream:#f7f8f4;--paper:#fff;--ink:#1d2d27;--muted:#7c8982;--line:#e8ede9;--orange:#e8a16a;--red:#cd6868;--shadow:0 10px 30px rgba(24,57,45,.055);font-family:'Cairo','DM Sans',sans-serif;color:var(--ink);font-synthesis:none}*{box-sizing:border-box}body{margin:0;background:var(--cream);min-height:100vh}button,input,select{font:inherit}button{cursor:pointer}.shell{min-height:100vh;display:grid;grid-template-columns:258px minmax(0,1fr)}.sidebar{position:fixed;inset:0 0 0 auto;width:258px;background:var(--forest);color:#fff;padding:25px 17px;display:flex;flex-direction:column;z-index:20}.brand{display:flex;align-items:center;gap:12px;padding:0 10px 27px;border-bottom:1px solid rgba(255,255,255,.12)}.brand-mark{width:43px;height:43px;border-radius:15px;background:var(--lime);color:var(--forest);display:grid;place-items:center;font-size:23px;font-weight:800;box-shadow:0 6px 18px #0f302a}.brand-name{font-weight:800;font-size:18px;line-height:1.3}.brand-name small{display:block;font-size:10px;letter-spacing:1.4px;color:#b9ccc3;font-weight:500}.nav-caption{color:#8ca79a;font-size:10px;font-weight:700;margin:24px 12px 9px}.nav-list{display:grid;gap:4px}.nav-item{border:0;background:transparent;color:#c2d1c9;text-align:right;width:100%;padding:11px 12px;border-radius:11px;display:flex;align-items:center;gap:12px;font-size:13px;font-weight:600;transition:.18s}.nav-item:hover{background:rgba(255,255,255,.08);color:#fff}.nav-item.active{background:#2a5a48;color:#fff;box-shadow:inset -3px 0 var(--lime)}.nav-icon{width:21px;text-align:center;font-size:17px;opacity:.92}.nav-badge{margin-right:auto;font-size:10px;color:var(--forest);background:var(--lime);border-radius:20px;padding:2px 7px}.sidebar-bottom{margin-top:auto}.academy-card{background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.09);border-radius:14px;padding:13px;margin-bottom:14px}.academy-card-label{font-size:10px;color:#a9c0b4}.academy-card strong{display:block;margin-top:4px;font-size:13px}.academy-status{display:flex;align-items:center;gap:6px;margin-top:10px;color:#cde2d5;font-size:10px}.green-dot{height:7px;width:7px;background:#9cd17c;border-radius:50%}.user-row{display:flex;align-items:center;gap:10px;padding:12px 6px 0;border-top:1px solid rgba(255,255,255,.12)}.avatar{width:36px;height:36px;border-radius:50%;background:#f1d8b9;color:#71482d;display:grid;place-items:center;font-size:13px;font-weight:800;flex:none}.user-row strong{display:block;font-size:12px}.user-row small{color:#a9c0b4;font-size:10px}.user-more{margin-right:auto;color:#c3d2ca}.main{grid-column:2;min-width:0;padding:0 36px 45px}.topbar{height:83px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:20px}.breadcrumb{color:var(--muted);font-size:12px}.breadcrumb b{color:var(--ink);font-weight:700}.top-actions{display:flex;align-items:center;gap:10px}.icon-button{width:39px;height:39px;border:1px solid var(--line);background:#fff;border-radius:12px;color:#56665e;position:relative}.icon-button:hover{background:var(--mint-2)}.notification-dot{position:absolute;width:7px;height:7px;background:var(--orange);border-radius:50%;top:8px;left:8px;border:1px solid white}.date-pill{border:1px solid var(--line);background:#fff;border-radius:11px;padding:9px 12px;color:#64746b;font-size:11px}.mobile-menu,.sidebar-close-btn{display:none}.content{max-width:1400px;margin:0 auto}.welcome{display:flex;align-items:center;justify-content:space-between;margin:30px 0 23px;gap:18px}.welcome h1{margin:0;color:var(--ink);font-size:23px;font-weight:800;letter-spacing:-.5px}.welcome p{margin:5px 0 0;color:var(--muted);font-size:12px}.welcome p span{color:var(--forest-2);font-weight:700}.welcome-actions{display:flex;gap:9px}.btn{border:0;border-radius:10px;padding:10px 15px;font-size:12px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;gap:8px;transition:.18s}.btn-primary{background:var(--forest);color:white;box-shadow:0 5px 13px rgba(23,63,53,.14)}.btn-primary:hover{background:#245848;transform:translateY(-1px)}.btn-outline{background:white;border:1px solid var(--line);color:#495b51}.btn-outline:hover{border-color:#bed2c5;background:#fbfdfb}.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.stat-card,.panel{background:var(--paper);border:1px solid var(--line);border-radius:15px;box-shadow:var(--shadow)}.stat-card{padding:16px 17px 14px;min-height:132px;position:relative;overflow:hidden}.stat-head{display:flex;align-items:center;justify-content:space-between}.stat-label{font-size:11px;color:var(--muted);font-weight:600}.stat-icon{width:34px;height:34px;display:grid;place-items:center;border-radius:11px;color:var(--forest-2);background:var(--mint-2);font-size:17px}.stat-value{font-family:'DM Sans','Cairo',sans-serif;font-size:27px;font-weight:700;line-height:1.1;margin-top:9px;color:var(--ink);direction:rtl;text-align:right}.stat-foot{font-size:10px;color:var(--muted);margin-top:6px}.trend{color:#43835c;font-weight:700}.stat-decoration{position:absolute;left:15px;bottom:16px;color:#84a58f;font-size:10px;opacity:.8}.dashboard-grid{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(280px,.9fr);gap:15px;margin-top:15px}.panel{padding:18px}.panel-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:15px}.panel-title{font-size:14px;font-weight:800;margin:0}.panel-subtitle{font-size:10px;color:var(--muted);margin-top:3px}.link-button{border:0;background:transparent;color:var(--forest-2);font-size:11px;font-weight:700;padding:6px}.chart-legend{display:flex;gap:14px;color:var(--muted);font-size:10px}.legend-dot{width:7px;height:7px;display:inline-block;border-radius:50%;margin-left:4px}.chart{height:205px;display:flex;align-items:stretch;gap:10px;padding:10px 2px 0;position:relative;background:repeating-linear-gradient(to bottom,transparent 0,transparent 49px,#edf1ee 50px)}.chart-y{position:absolute;right:0;top:0;bottom:22px;display:flex;flex-direction:column;justify-content:space-between;color:#a3ada7;font-size:9px}.chart-bars{display:flex;justify-content:space-around;align-items:flex-end;width:100%;padding:0 38px 0 6px}.chart-col{height:100%;display:flex;align-items:center;justify-content:flex-end;flex-direction:column;gap:7px;flex:1;max-width:52px}.bars{height:calc(100% - 22px);display:flex;align-items:flex-end;gap:4px}.bar{width:11px;border-radius:5px 5px 2px 2px;background:#b9d9c8;min-height:5px}.bar.alt{background:var(--forest-2)}.chart-label{font-size:9px;color:#86938b}.chart-foot{font-size:10px;color:var(--muted);margin-top:12px;display:flex;justify-content:space-between}.schedule-list{display:grid;gap:2px}.schedule-item{display:grid;grid-template-columns:53px 1fr auto;align-items:center;gap:11px;padding:11px 0;border-bottom:1px solid #f0f2f0}.schedule-item:last-child{border-bottom:0}.schedule-time{font-family:'DM Sans','Cairo',sans-serif;font-size:10px;color:#7d8982;direction:ltr;text-align:right}.schedule-course{font-size:11px;font-weight:700}.schedule-meta{font-size:9px;color:var(--muted);margin-top:3px}.schedule-tag{font-size:9px;padding:4px 7px;border-radius:6px;background:var(--mint-2);color:#3e7159;font-weight:700}.schedule-tag.orange{background:#fff4e9;color:#b2703d}.lower-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(300px,.8fr);gap:15px;margin-top:15px}.table-wrap{overflow-x:auto}.data-table{border-collapse:collapse;width:100%;text-align:right;white-space:nowrap}.data-table th{font-size:10px;color:#89958e;font-weight:600;background:#fafbf9;padding:10px 9px;border-bottom:1px solid var(--line)}.data-table td{font-size:11px;padding:11px 9px;border-bottom:1px solid #f0f2f0}.data-table tr:last-child td{border-bottom:0}.student-cell{display:flex;align-items:center;gap:8px}.mini-avatar{height:29px;width:29px;border-radius:9px;display:grid;place-items:center;background:#edf4e9;color:#4f7657;font-size:10px;font-weight:800}.student-name{font-weight:700}.student-sub{font-size:9px;color:var(--muted);margin-top:2px}.status{display:inline-flex;align-items:center;gap:5px;border-radius:20px;padding:4px 8px;font-size:9px;font-weight:700}.status::before{content:'';width:5px;height:5px;border-radius:50%;background:currentColor}.status-paid{background:#eaf5ee;color:#47805a}.status-due{background:#fff4e7;color:#b67943}.attendance-list{display:grid;gap:0}.attendance-row{display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #f0f2f0}.attendance-row:last-child{border-bottom:0}.attendance-left{display:flex;align-items:center;gap:9px}.attendance-label{font-size:11px;font-weight:700}.attendance-meta{font-size:9px;color:var(--muted);margin-top:3px}.attendance-num{font-size:10px;color:#65766c}.progress{height:5px;width:83px;background:#edf1ed;border-radius:10px;overflow:hidden;margin-top:6px}.progress span{display:block;height:100%;background:#7aaa87;border-radius:10px}.section-heading{display:flex;align-items:end;justify-content:space-between;margin:29px 0 16px;gap:12px}.section-heading h1{font-size:22px;margin:0;font-weight:800}.section-heading p{font-size:11px;color:var(--muted);margin:4px 0 0}.toolbar{display:flex;align-items:center;gap:8px}.search-box{height:39px;min-width:210px;display:flex;align-items:center;gap:7px;padding:0 11px;background:#fff;border:1px solid var(--line);border-radius:10px;color:#8c9991}.search-box input{border:0;outline:0;width:100%;font-size:11px;background:transparent;color:var(--ink)}.empty-state{padding:38px;text-align:center;color:var(--muted);font-size:12px}.empty-icon{font-size:25px;margin-bottom:8px}.modal-backdrop{position:fixed;inset:0;background:rgba(12,35,28,.45);display:grid;place-items:center;padding:18px;z-index:40;animation:fade .18s}.modal{background:#fff;border-radius:18px;width:min(100%,470px);padding:22px;box-shadow:0 20px 60px rgba(0,0,0,.18);animation:rise .2s}.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:17px}.modal-head h2{font-size:17px;margin:0}.modal-close{border:0;background:#f4f6f3;border-radius:9px;width:32px;height:32px;font-size:17px;color:#68776e}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.form-field{display:grid;gap:6px}.form-field.full{grid-column:1/-1}.form-field label{font-size:10px;color:#627168;font-weight:700}.form-field input,.form-field select{height:41px;border:1px solid var(--line);border-radius:9px;padding:0 11px;outline:0;background:#fff;color:var(--ink);font-size:11px}.form-field input:focus,.form-field select:focus{border-color:#85ad94;box-shadow:0 0 0 3px #e6f2ea}.modal-actions{display:flex;justify-content:flex-start;gap:8px;margin-top:19px}.toast{position:fixed;bottom:22px;left:22px;background:var(--forest);color:white;padding:12px 17px;border-radius:11px;font-size:12px;box-shadow:0 9px 25px #153c3040;opacity:0;transform:translateY(10px);transition:.22s;pointer-events:none;z-index:60}.toast.show{opacity:1;transform:translateY(0)}.overlay{display:none}
@keyframes fade{from{opacity:0}to{opacity:1}}@keyframes rise{from{opacity:.7;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
@media(max-width:1100px){.main{padding:0 22px 35px}.stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.dashboard-grid{grid-template-columns:minmax(0,1.2fr) minmax(260px,.8fr)}}
@media(min-width:801px){.sidebar-close-btn{display:none !important}}
@media(max-width:800px){
  html, body {
    overflow-x: clip !important;
    max-width: 100vw;
  }
  html, body, #app, .shell, .main {
    min-height: 100dvh;
    height: auto;
  }
  .main {
    overflow: visible !important;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body.sidebar-locked {
    overflow: hidden !important;
  }
  .shell {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: 280px !important;
    max-width: calc(100vw - 44px) !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(110%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.28s !important;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.45) !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 30px)) !important;
    box-sizing: border-box !important;
  }
  .sidebar-bottom {
    margin-top: auto !important;
    padding-bottom: calc(35px + env(safe-area-inset-bottom, 20px)) !important;
    margin-bottom: 45px !important;
  }
  .sidebar-spacer {
    display: block !important;
    height: 50px !important;
    width: 100% !important;
    flex-shrink: 0 !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 29, 22, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 990;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .overlay.show {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .sidebar-top {
    position: relative;
    width: 100%;
  }
  .sidebar-close-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.15s;
  }
  .sidebar-close-btn:active {
    background: rgba(255, 255, 255, 0.28);
  }
  .main {
    padding: 0 16px 30px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .topbar {
    height: 62px !important;
    padding: 0 !important;
    gap: 8px !important;
    justify-content: flex-start !important;
  }
  .mobile-menu {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 38px;
    width: 38px !important;
    height: 38px !important;
    font-size: 19px !important;
  }
  .breadcrumb {
    margin-right: 0 !important;
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 12px !important;
  }
  .breadcrumb-logo {
    width: 20px !important;
    height: 20px !important;
    margin-left: 6px !important;
    flex-shrink: 0;
  }
  .top-actions {
    margin-right: auto !important;
    gap: 6px !important;
    flex-shrink: 0;
  }
  .date-pill {
    display: none !important;
  }
  .dashboard-grid, .lower-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  .panel {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .welcome h1 {
    font-size: 20px !important;
  }
  .chart {
    height: 190px !important;
  }
}
@media(max-width:600px){
  .btn-manager-profile .manager-btn-text {
    display: none !important;
  }
  .btn-manager-profile {
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    border-radius: 12px !important;
  }
  .breadcrumb-site, .breadcrumb-sep {
    display: none !important;
  }
}
@media(max-width:520px){
  .main {
    padding: 0 11px 22px !important;
  }
  .topbar {
    height: 58px !important;
  }
  .welcome {
    align-items: stretch !important;
    flex-direction: column !important;
    margin: 16px 0 14px !important;
    gap: 10px !important;
  }
  .welcome h1 {
    font-size: 19px !important;
  }
  .welcome p {
    font-size: 11.5px !important;
  }
  .welcome-actions {
    width: 100% !important;
    display: flex !important;
  }
  .welcome-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px !important;
    font-size: 13px !important;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .stat-card {
    padding: 11px 10px 9px !important;
    min-height: 105px !important;
    border-radius: 12px !important;
  }
  .stat-value {
    font-size: 20px !important;
    margin-top: 5px !important;
  }
  .stat-label {
    font-size: 10.5px !important;
    line-height: 1.25 !important;
  }
  .stat-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
  }
  .stat-foot {
    font-size: 9px !important;
    margin-top: 3px !important;
  }
  .dashboard-grid, .lower-grid {
    gap: 10px !important;
    margin-top: 10px !important;
  }
  .panel {
    padding: 12px !important;
    border-radius: 13px !important;
  }
  .panel-header {
    margin-bottom: 10px !important;
  }
  .panel-title {
    font-size: 14px !important;
  }
  .panel-subtitle {
    font-size: 10px !important;
  }
  .attendance-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 9px 0 !important;
    border-bottom: 1px solid #f0f2f0 !important;
    gap: 8px !important;
  }
  .attendance-row span {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    word-break: break-word !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }
  .attendance-row small {
    flex: 0 0 auto !important;
    font-size: 9.5px !important;
    color: var(--muted) !important;
    white-space: nowrap !important;
  }
  .section-heading {
    align-items: flex-start !important;
    flex-direction: column !important;
    margin: 18px 0 12px !important;
    gap: 8px !important;
  }
  .toolbar {
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  .search-box {
    flex: 1 !important;
    min-width: 120px !important;
  }
  .toolbar .btn {
    flex: none !important;
  }
  .chart-legend {
    gap: 7px !important;
    font-size: 9px !important;
  }
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .form-field.full {
    grid-column: auto !important;
  }
  .chart-bars {
    padding-right: 31px !important;
  }
  .bar {
    width: 8px !important;
  }
}
@media(max-width:340px){
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
}

/* WhatsApp Sharing Integration */
.btn-whatsapp {
  background: #25D366 !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
  transition: all 0.18s ease;
}
.btn-whatsapp:hover {
  background: #1eb956 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
}
.btn-whatsapp svg, .btn-whatsapp-sm svg {
  fill: currentColor;
  flex-shrink: 0;
}
.btn-whatsapp-sm {
  background: #eafaf1 !important;
  color: #0b7a48 !important;
  border: 1px solid #b2e8ca !important;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn-whatsapp-sm:hover {
  background: #25D366 !important;
  color: #ffffff !important;
  border-color: #25D366 !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 7px rgba(37, 211, 102, 0.35);
}

/* Brand Logo — Vertical stack, transparent without background box */
.brand {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  padding: 10px 10px 22px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
  gap: 8px !important;
}
.brand-logo {
  width: 50px !important;
  height: 50px !important;
  max-width: 50px !important;
  max-height: 50px !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 auto !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
}
.brand-name {
  font-weight: 800 !important;
  font-size: 16px !important;
  line-height: 1.3 !important;
  color: #ffffff !important;
  text-align: center !important;
}
.brand-name small {
  display: block !important;
  font-size: 10.5px !important;
  letter-spacing: 0.4px !important;
  color: #a6c4b6 !important;
  font-weight: 500 !important;
  margin-top: 2px !important;
  text-align: center !important;
}
.breadcrumb-logo {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-left: 8px;
  object-fit: contain;
}

/* Manager Card & Crown Badges */
.crown-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fbf5e5;
  color: #946800;
  border: 1px solid #ebd79e;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
}
.manager-avatar {
  background: #fdf5e6 !important;
  color: #946800 !important;
  font-size: 15px !important;
}
.user-edit-btn:hover {
  background: rgba(255, 255, 255, 0.28) !important;
  transform: scale(1.05);
}

.sidebar-spacer, .modal-bottom-spacer {
  display: none;
}

/* ========================================================
   UNIVERSAL RESPONSIVE MODALS & POPUPS (DESKTOP + MOBILE)
   ======================================================== */

.modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(10, 28, 22, 0.65) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px 16px !important;
  z-index: 2000 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
  animation: fade 0.18s ease-out !important;
}

.modal {
  background: #ffffff !important;
  border-radius: 18px !important;
  width: min(100%, 540px) !important;
  max-width: 100% !important;
  max-height: calc(100vh - 36px) !important;
  max-height: calc(100dvh - 36px) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3) !important;
  animation: rise 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  margin: auto !important;
  overflow: hidden !important;
  position: relative !important;
  box-sizing: border-box !important;
}

.modal-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 18px 22px 14px !important;
  border-bottom: 1px solid #edf1ee !important;
  flex-shrink: 0 !important;
  background: #fafbf9 !important;
}

.modal-head h2 {
  font-size: 17.5px !important;
  font-weight: 800 !important;
  color: var(--forest) !important;
  margin: 0 !important;
  letter-spacing: -0.2px !important;
}

.modal-close {
  border: 0 !important;
  background: #eef2ef !important;
  border-radius: 10px !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  font-size: 20px !important;
  line-height: 1 !important;
  color: #53645c !important;
  display: grid !important;
  place-items: center !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.modal-close:hover, .modal-close:active {
  background: #e0e8e3 !important;
  color: #173f35 !important;
  transform: scale(1.06) !important;
}

/* Modal Form Body with Native Momentum Scrolling */
.modal form {
  display: flex !important;
  flex-direction: column !important;
  padding: 20px 22px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

.form-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px 12px !important;
  width: 100% !important;
}

.form-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  min-width: 0 !important;
}

.form-field.full {
  grid-column: 1 / -1 !important;
}

.form-field label {
  font-size: 13px !important;
  color: #35473f !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100% !important;
  box-sizing: border-box !important;
  border: 1.5px solid #dbe3de !important;
  border-radius: 10px !important;
  background: #ffffff !important;
  color: var(--ink) !important;
  font-family: inherit !important;
  transition: border-color 0.18s, box-shadow 0.18s !important;
}

.form-field input,
.form-field select {
  height: 42px !important;
  padding: 0 13px !important;
  font-size: 13.5px !important;
}

.form-field select {
  background-color: #fff !important;
  cursor: pointer !important;
}

.form-field select[multiple] {
  height: auto !important;
  min-height: 115px !important;
  padding: 6px !important;
}

.form-field select[multiple] option {
  padding: 7px 10px !important;
  border-radius: 6px !important;
  margin-bottom: 2px !important;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: #3b745a !important;
  box-shadow: 0 0 0 3px rgba(59, 116, 90, 0.18) !important;
  outline: none !important;
}

.form-field textarea {
  min-height: 85px !important;
  padding: 10px 13px !important;
  font-size: 13.5px !important;
  line-height: 1.6 !important;
  resize: vertical !important;
}

.form-field small {
  font-size: 11.5px !important;
  color: #6d8076 !important;
  line-height: 1.5 !important;
  margin-top: 3px !important;
}

/* Modal Actions */
.modal-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  margin-top: 18px !important;
  padding-top: 16px !important;
  border-top: 1px solid #edf1ee !important;
  flex-shrink: 0 !important;
  width: 100% !important;
}

.modal-actions .btn {
  min-height: 42px !important;
  padding: 10px 18px !important;
  font-size: 13px !important;
  border-radius: 10px !important;
}

/* ========================================================
   WIDE MODALS (Family Statements, Audit Archives)
   ======================================================== */
.wide-modal {
  width: min(980px, calc(100vw - 28px)) !important;
  max-width: 100% !important;
}

.wide-modal .family-statement,
.wide-modal .audit-archive-view {
  padding: 18px 22px !important;
  overflow-y: auto !important;
  max-height: calc(100vh - 120px) !important;
  max-height: calc(100dvh - 120px) !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
}

.wide-modal .panel-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin-bottom: 14px !important;
}

.wide-modal .table-wrap {
  margin: 12px 0 !important;
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
}

/* ========================================================
   MOBILE SCREEN SIZES (Tablets & Phones <= 640px)
   ======================================================== */
@media (max-width: 640px) {
  .modal-backdrop {
    display: block !important;
    align-items: unset !important;
    justify-content: unset !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 12px 10px !important;
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 35px)) !important;
    box-sizing: border-box !important;
  }

  .modal {
    width: 100% !important;
    max-width: 520px !important;
    margin: 12px auto 50px !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    border-radius: 20px !important;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35) !important;
  }

  .modal-head {
    position: sticky !important;
    top: -12px !important;
    z-index: 30 !important;
    background: #fafbf9 !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 16px 18px 12px !important;
    border-bottom: 1px solid #edf1ee !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
  }

  .modal-head h2 {
    font-size: 16.5px !important;
  }

  .modal-close {
    width: 36px !important;
    height: 36px !important;
    font-size: 19px !important;
  }

  .modal form {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 18px 16px 22px !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 13px !important;
  }

  .form-field.full {
    grid-column: auto !important;
  }

  .form-field label {
    font-size: 13px !important;
  }

  /* 16px font-size prevents iOS Safari from automatically zooming into the form */
  .form-field input,
  .form-field select,
  .form-field textarea {
    font-size: 16px !important;
    height: 44px !important;
    border-radius: 11px !important;
  }

  .form-field textarea {
    height: auto !important;
    min-height: 90px !important;
  }

  .modal-actions {
    flex-direction: column-reverse !important;
    gap: 10px !important;
    margin-top: 20px !important;
    padding-top: 16px !important;
    padding-bottom: 30px !important;
    margin-bottom: 30px !important;
  }

  .modal-actions .btn {
    width: 100% !important;
    min-height: 46px !important;
    font-size: 15px !important;
    justify-content: center !important;
  }

  .modal-actions .btn-outline {
    background: #f4f6f4 !important;
    border-color: #dbe2de !important;
  }

  .modal-bottom-spacer {
    display: block !important;
    height: 45px !important;
    width: 100% !important;
    flex-shrink: 0 !important;
  }

  .wide-modal {
    width: 100% !important;
    max-width: 100% !important;
    margin: 12px auto 50px !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    border-radius: 20px !important;
  }

  .wide-modal .family-statement,
  .wide-modal .audit-archive-view {
    max-height: none !important;
    overflow: visible !important;
    padding: 16px 14px 35px !important;
  }

  .wide-modal .panel-header {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .wide-modal .panel-header .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .wide-modal .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}

@media (max-width: 360px) {
  .wide-modal .stats-grid {
    grid-template-columns: 1fr !important;
  }
}
