/* assets/css/frontend.css — Mobile-First Responsive Design (Fixed v2) */

/* ══════════════════════════════════════════════
   1. CSS Variables & Reset
══════════════════════════════════════════════ */
:root {
    --charcoal-black:          #2d3a42;
    --charcoal-dark:           #1f282e;
    --light-grey:              #f4f5f7;
    --vibrant-red:             #e63946;
    --red-hover:               #d62828;
    --success:                 #28a745;
    --warning:                 #f0a500;
    --text-main:               #333333;
    --text-muted:              #888888;
    --text-heading:            #2d3a42;
    --white:                   #ffffff;
    --border:                  #e8e8e8;
    --border-faint:            #f0f0f0;
    --bg-subtle:               #f8f9fa;
    --bg-hover:                #fafbfc;
    --sidebar-width:           260px;
    --sidebar-collapsed-width: 60px;
    --topbar-height:           56px;
    --bottom-nav-height:       62px;
    --radius-sm:               6px;
    --radius-md:               10px;
    --radius-lg:               16px;
    --radius:                  var(--radius-md);
    --shadow-sm:               0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:               0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg:               0 18px 45px rgba(15,20,25,0.25);
    --transition:              0.25s cubic-bezier(0.4,0,0.2,1);
    --font-sans:               'IBM Plex Sans Arabic', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }

/* SVG icon sizing — explicit constraints prevent browser expansion */
svg.app-icon { width: 18px; height: 18px; max-width: 18px; max-height: 18px; display: inline-block; vertical-align: middle; fill: currentColor; flex-shrink: 0; overflow: hidden; }
svg.mob-icon-svg { width: 22px; height: 22px; max-width: 22px; max-height: 22px; display: block; fill: currentColor; flex-shrink: 0; overflow: hidden; }

/* ══════════════════════════════════════════════
   2. Base Layout
══════════════════════════════════════════════ */
body.ittihad-admin-app {
    margin: 0; font-family: var(--font-sans); background-color: var(--light-grey);
    color: var(--text-main); direction: rtl; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════
   3. Mobile Top Bar
══════════════════════════════════════════════ */
.app-topbar {
    display: none; position: fixed; top: 0; right: 0; left: 0;
    height: var(--topbar-height); background: var(--charcoal-black);
    z-index: 1100; align-items: center; justify-content: space-between;
    padding: 0 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.app-topbar .topbar-brand { color: var(--white); font-size: 16px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hamburger-btn { background: none; border: none; cursor: pointer; padding: 10px 8px; display: flex; flex-direction: column; gap: 5px; border-radius: 6px; transition: background var(--transition); -webkit-tap-highlight-color: transparent; }
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }
.hamburger-btn span { display: block; width: 22px; height: 2px; background: var(--white); border-radius: 2px; transition: transform var(--transition), opacity var(--transition); }
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ══════════════════════════════════════════════
   4. Sidebar Overlay
══════════════════════════════════════════════ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1050; backdrop-filter: blur(2px); animation: fadeIn 0.2s ease; }
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════════
   5. Sidebar
══════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--sidebar-width); background: linear-gradient(160deg, var(--charcoal-black) 0%, var(--charcoal-dark) 100%);
    color: var(--white); display: flex; flex-direction: column; position: fixed;
    top: 0; right: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
    z-index: 1060; box-shadow: -3px 0 15px rgba(0,0,0,0.2);
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1), transform var(--transition);
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-geometry { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sidebar-square { position: absolute; border: 2px solid rgba(255,255,255,0.03); transform: rotate(45deg); border-radius: 4px; }
.sq-1 { width: 180px; height: 180px; top: -60px; right: -60px; background: rgba(255,255,255,0.015); }
.sq-2 { width: 280px; height: 280px; bottom: 5%; left: -120px; border-color: rgba(230,57,70,0.12); }
.sq-3 { width: 100px; height: 100px; top: 40%; right: 20px; border-color: rgba(255,255,255,0.02); }

.app-brand { padding: 28px 22px 22px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.07); position: relative; z-index: 1; }
.app-brand h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: 0.5px; color: var(--white); }
.app-brand span { font-size: 11px; color: #a0aab2; letter-spacing: 0.3px; }

.app-nav { flex-grow: 1; padding: 12px 0; position: relative; z-index: 1; }
.app-nav a { display: flex; align-items: center; gap: 10px; padding: 13px 22px; color: #b0bec5; text-decoration: none; font-size: 14px; transition: all var(--transition); border-right: 3px solid transparent; margin: 1px 0; position: relative; }
.app-nav a:hover { background: rgba(255,255,255,0.06); color: var(--white); border-right-color: rgba(230,57,70,0.5); }
.app-nav a.active { background: rgba(230,57,70,0.12); color: var(--white); border-right-color: var(--vibrant-red); font-weight: 600; }
.app-nav a.active::before { content: ''; position: absolute; right: -1px; top: 50%; transform: translateY(-50%); width: 3px; height: 60%; background: var(--vibrant-red); border-radius: 0 3px 3px 0; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
svg.app-icon { width: 18px !important; height: 18px !important; max-width: 18px !important; max-height: 18px !important; flex-shrink: 0; fill: currentColor; display: inline-block; overflow: hidden; }
svg.mob-icon-svg { width: 22px !important; height: 22px !important; max-width: 22px !important; max-height: 22px !important; flex-shrink: 0; fill: currentColor; display: block; overflow: hidden; }
.app-logout { padding: 18px 22px; border-top: 1px solid rgba(255,255,255,0.07); position: relative; z-index: 1; }
.app-logout a { display: flex; align-items: center; gap: 8px; color: #90a4ae; text-decoration: none; font-size: 13px; padding: 8px 10px; border-radius: 6px; transition: all var(--transition); }
.app-logout a:hover { color: var(--vibrant-red); background: rgba(230,57,70,0.08); }

.pwa-install-btn { display: none; align-items: center; gap: 8px; width: calc(100% - 44px); margin: 0 22px 16px; padding: 9px 14px; background: rgba(230,57,70,0.15); border: 1px solid rgba(230,57,70,0.35); border-radius: 8px; color: #ffb3b8; font-size: 13px; cursor: pointer; transition: all var(--transition); position: relative; z-index: 1; }
.pwa-install-btn:hover { background: rgba(230,57,70,0.3); border-color: var(--vibrant-red); color: #fff; }

/* ══════════════════════════════════════════════
   6. Main Content
══════════════════════════════════════════════ */
.app-content {
    flex-grow: 1; padding: 36px 40px; margin-right: var(--sidebar-width);
    min-height: 100vh; overflow-x: hidden; animation: pageSlideIn 0.3s ease;
    transition: margin-right 0.3s cubic-bezier(0.4,0,0.2,1), padding var(--transition);
}
@keyframes pageSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* 7. Content Header */
.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; padding-bottom: 16px; border-bottom: 2px solid var(--border); flex-wrap: wrap; gap: 8px; }
.content-header h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--text-heading); }
.content-header span { font-size: 13px; color: var(--text-muted); background: var(--white); padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); }

/* 8. Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card { background: var(--white); padding: 22px 20px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border-bottom: 4px solid var(--charcoal-black); transition: transform var(--transition), box-shadow var(--transition); position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; top: -20px; left: -20px; width: 80px; height: 80px; border-radius: 50%; background: rgba(45,58,66,0.04); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card.accent-red { border-bottom-color: var(--vibrant-red); }
.stat-card.accent-red::after { background: rgba(230,57,70,0.05); }
.stat-card.accent-green { border-bottom-color: var(--success); }
.stat-card h3 { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--charcoal-black); margin: 0; line-height: 1.2; }
.stat-accent-success { border-top: 4px solid var(--success); }
.stat-accent-danger  { border-top: 4px solid var(--vibrant-red); }
.stat-accent-dynamic-success { border-top: 4px solid var(--success); }
.stat-accent-dynamic-danger  { border-top: 4px solid var(--vibrant-red); }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--vibrant-red); }
.text-accent { color: var(--charcoal-black); }

/* Tabs */
.tabs-row { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-link { padding: 10px 20px; text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.tab-link--active-main { border-bottom-color: var(--charcoal-black); color: var(--charcoal-black); }
.tab-link--active-danger { border-bottom-color: var(--vibrant-red); color: var(--vibrant-red); }
.tab-count-pill { background: var(--vibrant-red); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; }

/* Filter bar */
.filter-card { margin-bottom: 20px; padding: 15px 25px; }
.filter-row { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.filter-row .form-group { margin: 0; flex-grow: 1; min-width: 0; }

/* ═══ Two-panel split layout ═══ */
.split-layout { display: flex; gap: 24px; align-items: flex-start; }
.split-layout .split-form { flex: 1; min-width: 0; }
.split-layout .split-table { flex: 2; min-width: 0; overflow-x: auto; }

/* Summary strips */
.summary-strip-danger { background: #fff8f8; border: 1px solid #f5c6cb; border-radius: 6px; padding: 15px 20px; margin-bottom: 20px; }
.summary-strip { display: flex; gap: 30px; flex-wrap: wrap; }
.summary-label { font-size: 13px; color: var(--text-muted); }
.summary-value-danger { font-size: 24px; font-weight: 700; color: var(--vibrant-red); }

/* Residents forms */
.flex-row-lg { display: flex; gap: 24px; align-items: flex-start; }
.form-card-lg { flex: 1; min-width: 0; margin-bottom: 20px; }
.form-row-2 { display: flex; gap: 15px; }
.form-row-2 > div { flex: 1; min-width: 0; }
.section-separator { margin: 25px 0; border: 0; border-top: 1px dashed #ccc; }
.section-subtitle { margin-top: 0; margin-bottom: 10px; color: var(--charcoal-black); }
.section-note { font-size: 12px; color: #666; margin-bottom: 15px; line-height: 1.5; }

/* Layout utilities */
.flex-row { display: flex; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.mt-20 { margin-top: 20px; }
.minw-280 { min-width: 0; }
.card-title-sm { margin: 0 0 10px; font-size: 15px; }

/* Inline flex helpers */
.inline-flex-row { display: flex; gap: 15px; }
.inline-flex-row > * { flex: 1; min-width: 0; }

/* 9. Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.corp-table { width: 100%; border-collapse: collapse; background: var(--white); }
.corp-table th { background: var(--charcoal-black); color: var(--white); padding: 14px 16px; text-align: right; font-weight: 500; font-size: 13px; white-space: nowrap; }
.corp-table th:first-child { border-radius: 0 var(--radius) 0 0; }
.corp-table th:last-child  { border-radius: var(--radius) 0 0 0; }
.corp-table td { padding: 13px 16px; border-bottom: 1px solid var(--border-faint); font-size: 14px; color: var(--text-main); vertical-align: middle; }
.corp-table tbody tr { transition: background var(--transition); }
.corp-table tbody tr:hover { background: var(--bg-hover); }
.corp-table tbody tr:last-child td { border-bottom: none; }

/* 10. Buttons */
.btn-primary, .btn-secondary, .btn-success { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 22px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; transition: all var(--transition); white-space: nowrap; position: relative; overflow: hidden; min-height: 44px; font-family: inherit; }
.btn-primary { background: var(--vibrant-red); color: var(--white); }
.btn-primary:hover { background: var(--red-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(230,57,70,0.35); }
.btn-secondary { background: var(--charcoal-black); color: var(--white); }
.btn-secondary:hover { background: var(--charcoal-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(45,58,66,0.3); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #218838; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(40,167,69,0.35); }
.btn-primary:active, .btn-secondary:active, .btn-success:active { transform: translateY(0); box-shadow: none; }
.btn-danger { color: var(--vibrant-red); text-decoration: none; font-weight: 600; font-size: 13px; background: none; border: none; cursor: pointer; padding: 6px 10px; border-radius: 4px; transition: all var(--transition); min-height: 36px; display: inline-flex; align-items: center; font-family: inherit; }
.btn-danger:hover { background: rgba(230,57,70,0.08); }
.btn-block { width: 100%; }
.btn-primary::after, .btn-secondary::after, .btn-success::after { content: ''; position: absolute; border-radius: 50%; width: 0; height: 0; background: rgba(255,255,255,0.3); transform: translate(-50%,-50%); transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease; opacity: 0; }
.btn-primary:active::after, .btn-secondary:active::after, .btn-success:active::after { width: 200px; height: 200px; left: 50%; top: 50%; opacity: 0; }

/* 11. Form Cards */
.form-card { background: var(--white); padding: 24px 26px; border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 24px; border: 1px solid rgba(0,0,0,0.04); }
.form-card h3 { margin: 0 0 20px; font-size: 16px; color: var(--text-heading); font-weight: 600; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; color: #444; }
.form-control { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 14px; box-sizing: border-box; background: var(--white); color: var(--text-main); transition: border-color var(--transition), box-shadow var(--transition); font-family: inherit; min-height: 44px; }
.form-control:focus { outline: none; border-color: var(--charcoal-black); box-shadow: 0 0 0 3px rgba(45,58,66,0.08); }
.form-control:hover:not(:focus) { border-color: #bbb; }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* 12. Checkbox Grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 14px; background: var(--bg-subtle); border-radius: 6px; border: 1.5px solid var(--border); }
.checkbox-grid label { font-weight: 500; font-size: 13px; margin: 0; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px; border-radius: 5px; transition: background var(--transition); color: var(--text-main); }
.checkbox-grid label:hover { background: rgba(45,58,66,0.05); }
.checkbox-grid input[type="checkbox"] { accent-color: var(--vibrant-red); width: 15px; height: 15px; }

/* 13. Toast */
#ittihad-toast-container { position: fixed; bottom: 24px; left: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.ittihad-toast { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--white); min-width: 260px; max-width: 360px; box-shadow: 0 6px 24px rgba(0,0,0,0.18); pointer-events: all; animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards; }
.ittihad-toast.hide { animation: toastOut 0.25s ease forwards; }
.ittihad-toast.success { background: linear-gradient(135deg, #28a745, #1e7e34); }
.ittihad-toast.error { background: linear-gradient(135deg, #e63946, #c0392b); }
.ittihad-toast.warning { background: linear-gradient(135deg, #f0a500, #d68910); }
.ittihad-toast .toast-icon { font-size: 18px; flex-shrink: 0; }
.ittihad-toast .toast-msg { flex-grow: 1; line-height: 1.4; }
.ittihad-toast .toast-close { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 16px; padding: 0 2px; flex-shrink: 0; line-height: 1; transition: color var(--transition); }
.ittihad-toast .toast-close:hover { color: var(--white); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-30px) scale(0.95); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-20px); } }

/* 14-16. Spinner, Badges, Animations */
.ittihad-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: var(--white); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-grey { background: #f0f0f0; color: #555; }
.badge-red { background: #fdecea; color: #c62828; }
.badge-yellow { background: #fff8e1; color: #856404; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 17. Alerts */
.alert { padding: 13px 18px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: slideDown 0.3s ease; }
.alert-success { background: #e8f5e9; color: #1b5e20; border-right: 4px solid var(--success); }
.alert-error { background: #fdecea; color: #b71c1c; border-right: 4px solid var(--vibrant-red); }
.alert-warning { background: #fff8e1; color: #6d4c00; border-right: 4px solid var(--warning); }

/* Filter form inline */
.filter-form-inline { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; align-items: flex-end; }
.filter-form-inline .filter-field { flex: 1; min-width: 120px; }
.filter-form-inline .filter-field label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.filter-form-inline .filter-field-wide { flex: 2; min-width: 140px; }
.filter-form-inline .filter-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-end; }
.pagination-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 15px; justify-content: center; }
.pagination-row a { padding: 8px 14px; border-radius: 4px; text-decoration: none; font-size: 14px; min-width: 40px; text-align: center; transition: all var(--transition); }
.pagination-row a.current { background: var(--charcoal-black); color: var(--white); }
.pagination-row a:not(.current) { background: #f0f0f0; color: #333; }
.pagination-row a:not(.current):hover { background: #ddd; }
.record-count { font-size: 12px; color: #888; margin: 0 0 10px; }

/* Form card summary footer */
.form-card-summary { margin-top: 25px; padding-top: 20px; border-top: 1px dashed #ccc; text-align: center; }
.form-card-summary .summary-label { font-size: 13px; color: var(--text-muted); }
.form-card-summary .summary-value { margin: 5px 0 0; direction: ltr; }
.accounting-note { font-size: 12px; color: var(--text-muted); margin-top: 15px; }

/* Utility classes */
.border-top-success { border-top: 4px solid var(--success); }
.border-top-danger { border-top: 4px solid var(--vibrant-red); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.font-bold { font-weight: bold; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-20 { margin-bottom: 20px; }
.mt-15 { margin-top: 15px; }
.mt-25 { margin-top: 25px; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }

/* ══════════════════════════════════════════════
   18. TABLET
══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .app-content { padding: 28px 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .split-layout { flex-direction: column; }
    .split-layout .split-form, .split-layout .split-table { width: 100%; }
    .flex-row-lg { flex-direction: column; }
    .form-card-lg { width: 100%; }
}

/* ══════════════════════════════════════════════
   19. MOBILE
══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .app-topbar { display: flex; }
    .app-sidebar { transform: translateX(100%); top: 0; width: var(--sidebar-width); }
    .app-sidebar.open { transform: translateX(0); }
    .app-content { margin-right: 0 !important; padding: 20px 16px; padding-top: calc(var(--topbar-height) + 16px); padding-bottom: calc(var(--bottom-nav-height) + 20px); }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px 14px; }
    .stat-card .value { font-size: 20px; }
    .content-header { margin-bottom: 18px; }
    .content-header h2 { font-size: 18px; }
    .content-header span { font-size: 11px; }
    .form-card { padding: 18px 16px; }
    .inline-flex-row, .form-row-2 { flex-direction: column; gap: 0; }
    .split-layout { flex-direction: column; }
    .split-layout .split-form, .split-layout .split-table { width: 100%; }
    .flex-row-lg { flex-direction: column; }
    .form-card-lg { width: 100%; }
    .form-card .btn-block { width: 100%; }
    .filter-form-inline { flex-direction: column; gap: 8px; }
    .filter-form-inline .filter-field, .filter-form-inline .filter-field-wide { min-width: 100%; }
    .filter-form-inline .filter-actions { width: 100%; }
    .filter-form-inline .filter-actions .btn-primary, .filter-form-inline .filter-actions .btn-secondary { flex: 1; }
    .filter-row { flex-direction: column; gap: 10px; }
    #ittihad-toast-container { left: 12px; right: 12px; bottom: calc(var(--bottom-nav-height) + 12px); }
    .ittihad-toast { min-width: unset; max-width: 100%; }
    .tabs-row { gap: 0; }
    .tab-link { padding: 10px 14px; font-size: 13px; }
    .actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .app-content { padding: 14px 12px; padding-top: calc(var(--topbar-height) + 14px); padding-bottom: calc(var(--bottom-nav-height) + 16px); }
    .stat-card .value { font-size: 18px; }
    .content-header h2 { font-size: 16px; }
}

/* WP Admin Bar */
body.admin-bar .app-sidebar { top: 32px; height: calc(100vh - 32px); }
body.admin-bar .app-topbar { top: 32px; }
@media screen and (max-width: 782px) { body.admin-bar .app-sidebar { top: 46px; height: calc(100vh - 46px); } body.admin-bar .app-topbar { top: 46px; } }
@media screen and (max-width: 600px) { body.admin-bar .app-sidebar { top: 0; height: 100vh; } body.admin-bar .app-topbar { top: 0; } }

/* ══════════════════════════════════════════════
   20. DARK MODE
══════════════════════════════════════════════ */
[data-theme="dark"] { --light-grey: #0f1419; --white: #1a2332; --text-main: #e6edf3; --text-muted: #8b949e; --text-heading: #c9d1d9; --border: #30363d; --border-faint: #21262d; --bg-subtle: #21262d; --bg-hover: #252d3a; --shadow-sm: 0 2px 8px rgba(0,0,0,0.4); --shadow-md: 0 4px 20px rgba(0,0,0,0.5); }
.theme-changing, .theme-changing * { transition-property: background-color, border-color, color, box-shadow !important; transition-duration: 0.3s !important; transition-timing-function: ease !important; }
.theme-changing .app-sidebar, .theme-changing .hamburger-btn span, .theme-changing .app-content { transition-property: background-color, border-color, color, box-shadow, margin-right, width, transform !important; transition-duration: 0.3s !important; }
[data-theme="dark"] body.ittihad-admin-app { background-color: var(--light-grey); }
[data-theme="dark"] .form-card, [data-theme="dark"] .stat-card, [data-theme="dark"] .corp-table, [data-theme="dark"] .table-wrapper, [data-theme="dark"] .content-header span { background: var(--white); border-color: var(--border); }
[data-theme="dark"] .corp-table th { background: #1f2937; }
[data-theme="dark"] .corp-table td { color: var(--text-main); }
[data-theme="dark"] .stat-card h3 { color: var(--text-muted); }
[data-theme="dark"] .stat-card .value { color: var(--text-main); }
[data-theme="dark"] .form-control { background: #21262d; color: var(--text-main); border-color: var(--border); }
[data-theme="dark"] .form-control:focus { border-color: #58a6ff; box-shadow: 0 0 0 3px rgba(88,166,255,0.15); }
[data-theme="dark"] .form-group label { color: var(--text-muted); }
[data-theme="dark"] .checkbox-grid label { color: var(--text-main); }
[data-theme="dark"] .checkbox-grid label:hover { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .badge-green { background: #1a3328; color: #56d364; }
[data-theme="dark"] .badge-grey { background: #21262d; color: #8b949e; }
[data-theme="dark"] .badge-red { background: #3d1c1f; color: #f85149; }
[data-theme="dark"] .badge-yellow { background: #2d2208; color: #d29922; }
[data-theme="dark"] .badge-blue { background: #0d2035; color: #58a6ff; }
[data-theme="dark"] .alert-success { background: #1a3328; color: #56d364; }
[data-theme="dark"] .alert-error { background: #3d1c1f; color: #f85149; }
[data-theme="dark"] .alert-warning { background: #2d2208; color: #d29922; }
[data-theme="dark"] .filter-form-inline .filter-field label, [data-theme="dark"] .record-count { color: var(--text-muted); }
[data-theme="dark"] .pagination-row a:not(.current) { background: #21262d; color: var(--text-main); }
[data-theme="dark"] .summary-strip-danger { background: #3d1c1f; border-color: #5a2628; }
[data-theme="dark"] .summary-label { color: var(--text-muted); }
[data-theme="dark"] .mobile-bottom-nav { background: #0d1117; border-top-color: #30363d; }

/* 21. Modal */
#ittihad-edit-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10000; align-items: center; justify-content: center; padding: 16px; }
.ittihad-modal-panel { background: #fff; border-radius: var(--radius-md); padding: 30px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; position: relative; direction: rtl; box-shadow: var(--shadow-lg); }
.ittihad-modal-close { position: absolute; top: 12px; left: 12px; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all var(--transition); }
.ittihad-modal-close:hover { color: var(--vibrant-red); background: rgba(230,57,70,0.08); }
#ittihad-modal-title { margin-top: 0; margin-bottom: 20px; color: var(--text-heading); }
[data-theme="dark"] .ittihad-modal-panel { background: #1a2332; color: var(--text-main); }
[data-theme="dark"] #ittihad-modal-title { color: var(--text-heading); }

/* 22. Skeleton */
.skeleton-row td { padding: 12px 16px; }
.skeleton-cell { height: 14px; border-radius: 4px; background: linear-gradient(90deg, #e8e8e8 25%, #f0f0f0 50%, #e8e8e8 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
[data-theme="dark"] .skeleton-cell { background: linear-gradient(90deg, #21262d 25%, #30363d 50%, #21262d 75%); background-size: 200% 100%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-stat { height: 32px; border-radius: 6px; margin: 4px 0; background: linear-gradient(90deg, #e8e8e8 25%, #f0f0f0 50%, #e8e8e8 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
[data-theme="dark"] .skeleton-stat { background: linear-gradient(90deg, #21262d 25%, #30363d 50%, #21262d 75%); background-size: 200% 100%; }

/* 23. Collapsible Sidebar (Desktop) */
.app-sidebar.collapsed { width: var(--sidebar-collapsed-width); overflow: visible; }
.app-content.sidebar-collapsed { margin-right: var(--sidebar-collapsed-width); }
.app-sidebar.collapsed .nav-label, .app-sidebar.collapsed .app-brand-text, .app-sidebar.collapsed .app-logout a span:last-child, .app-sidebar.collapsed .pwa-install-btn, .app-sidebar.collapsed .sidebar-theme-row .theme-label, .app-sidebar.collapsed .app-brand > span { opacity: 0; width: 0; overflow: hidden; white-space: nowrap; display: inline-block; transition: opacity 0.2s ease, width 0.3s ease; }
.nav-label, .app-brand-text, .sidebar-theme-row .theme-label { transition: opacity 0.2s ease, width 0.3s ease; display: inline; }
.app-sidebar.collapsed .app-nav a { justify-content: center; padding: 14px 0; }
.app-sidebar.collapsed .app-brand { padding: 20px 0; display: flex; justify-content: center; }
.app-sidebar.collapsed .app-logout { padding: 12px 0; display: flex; justify-content: center; }
.app-sidebar.collapsed .app-logout a { padding: 8px 0; justify-content: center; }
.app-sidebar.collapsed .sidebar-geometry { display: none; }
.app-sidebar.collapsed .app-nav a { position: relative; overflow: visible; }
.app-sidebar.collapsed .app-nav a::after { content: attr(data-label); position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%); background: #1f282e; color: #fff; padding: 6px 12px; border-radius: 6px; white-space: nowrap; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.3); opacity: 0; pointer-events: none; transition: opacity 0.15s ease; z-index: 2000; }
.app-sidebar.collapsed .app-nav a:hover::after { opacity: 1; }
.sidebar-collapse-btn { position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; background: var(--charcoal-black); border: 2px solid rgba(255,255,255,0.15); border-radius: 50%; color: rgba(255,255,255,0.7); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; z-index: 1001; transition: all var(--transition); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.sidebar-collapse-btn:hover { background: var(--vibrant-red); border-color: var(--vibrant-red); color: #fff; }
@media (max-width: 768px) { .sidebar-collapse-btn { display: none !important; } .app-sidebar.collapsed { width: var(--sidebar-width); } .app-content.sidebar-collapsed { margin-right: 0 !important; } }

/* 24. Mobile Bottom Nav */
.mobile-bottom-nav { display: none; }
@media (max-width: 768px) {
    .mobile-bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-height); background: var(--charcoal-black); border-top: 1px solid rgba(255,255,255,0.08); z-index: 1040; align-items: stretch; box-shadow: 0 -4px 20px rgba(0,0,0,0.25); padding-bottom: env(safe-area-inset-bottom, 0px); }
    .mob-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: #78909c; font-size: 10px; font-weight: 500; padding: 6px 4px; border-top: 2px solid transparent; border-left: none; border-right: none; border-bottom: none; transition: all var(--transition); -webkit-tap-highlight-color: transparent; cursor: pointer; background: none; font-family: inherit; min-width: 0; }
    .mob-nav-item .mob-icon { font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; overflow: hidden; }
    .mob-nav-item .mob-icon svg { width: 22px !important; height: 22px !important; max-width: 22px !important; max-height: 22px !important; display: block; }
    .mob-nav-item .mob-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; font-size: 9px; }
    .mob-nav-item:hover, .mob-nav-item:active { color: #b0bec5; background: rgba(255,255,255,0.05); }
    .mob-nav-item.active { color: var(--vibrant-red); border-top-color: var(--vibrant-red); }
    body.sidebar-open .mobile-bottom-nav { display: none; }
}

/* Theme toggle */
.theme-toggle-btn { background: none; border: 1px solid rgba(255,255,255,0.15); color: #b0bec5; cursor: pointer; padding: 7px 10px; border-radius: 6px; font-size: 13px; line-height: 1; transition: all var(--transition); display: flex; align-items: center; gap: 6px; min-height: 36px; font-family: inherit; -webkit-tap-highlight-color: transparent; }
.theme-toggle-btn:hover { background: rgba(255,255,255,0.1); color: var(--white); border-color: rgba(255,255,255,0.3); }
.app-topbar .theme-toggle-btn { border-color: rgba(255,255,255,0.2); padding: 6px 10px; }
.sidebar-theme-row { padding: 10px 22px 16px; position: relative; z-index: 1; }

/* Split form/table responsive helpers */
.split-form { flex: 1; min-width: 0; margin-bottom: 20px; }
.split-table { flex: 2; min-width: 0; overflow-x: auto; }
