/* ==========================================================================
   محاسب الأسمنت — Web clone matching the real Flutter app's Material 3
   visual language: AppBar, overlay Drawer, colored status-header cards,
   chips, gradient tiles, tab treasury view, bottom sheets, FAB, snackbars.
   ========================================================================== */

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-50: #EEF2FF;
    --primary-100: #E0E7FF;
    --primary-300: #A5B4FC;
    --primary-700: #4338CA;
    --secondary: #6366F1;
    --tertiary: #F59E0B;
    --tertiary-bg: #FEF3C7;
    --error: #DC2626;
    --error-bg: #FEE2E2;
    --success: #16A34A;
    --success-bg: #DCFCE7;

    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    --card-border: #D0D5DD;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: #F4F7FA;
    color: var(--gray-800);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 8px; }

/* ---------------------------------------------------------------------- */
/* AppBar                                                                  */
/* ---------------------------------------------------------------------- */
.app-bar {
    height: 56px; background: var(--primary); color: #fff;
    display: flex; align-items: center; gap: 10px; padding: 0 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,.16);
    position: sticky; top: 0; z-index: 40;
}
.app-bar button { background: none; border: none; color: #fff; font-size: 19px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.app-bar button:hover { background: rgba(255,255,255,.12); }
.app-bar .app-bar-title { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.app-bar .app-bar-actions { margin-inline-start: auto; display: flex; gap: 2px; }

/* ---------------------------------------------------------------------- */
/* Drawer (overlay, matches Flutter's Scaffold drawer — not a persistent  */
/* sidebar, since the real app never keeps it open even on wide screens) */
/* ---------------------------------------------------------------------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; display: none; }
body.drawer-open .drawer-overlay { display: block; }
.drawer {
    position: fixed; top: 0; bottom: 0; right: 0; width: 300px; max-width: 85vw;
    background: #fff; z-index: 95; transform: translateX(100%);
    transition: transform .25s ease; overflow-y: auto; box-shadow: -4px 0 24px rgba(0,0,0,.2);
}
body.drawer-open .drawer { transform: translateX(0); }
.drawer-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
    color: #fff; padding: 28px 20px 18px;
}
.drawer-header i.icon { font-size: 42px; }
.drawer-header .app-name { font-size: 19px; font-weight: 800; margin-top: 8px; }
.drawer-header .user-name { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.drawer-section-title { font-size: 11px; font-weight: 800; color: var(--primary); letter-spacing: .05em; padding: 14px 16px 4px; }
.drawer-item { display: flex; align-items: center; gap: 14px; padding: 11px 16px; color: var(--gray-700); font-size: 13.5px; cursor: pointer; }
.drawer-item:hover, .drawer-item.active { background: var(--primary-50); }
.drawer-item i { width: 20px; text-align: center; color: var(--gray-500); font-size: 16px; }
.drawer-divider { height: 1px; background: var(--gray-100); margin: 6px 0; }

/* ---------------------------------------------------------------------- */
/* Page body                                                               */
/* ---------------------------------------------------------------------- */
.page-body { padding: 12px; max-width: 1100px; margin: 0 auto; }
@media (min-width: 900px) { .page-body { padding: 18px; } }

.section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.section-header .icon-badge { padding: 6px; background: var(--primary-100); border-radius: 8px; display: flex; }
.section-header .icon-badge i { color: var(--primary); font-size: 14px; }
.section-header span { font-size: 16px; font-weight: 800; color: var(--gray-900); }

/* ---------------------------------------------------------------------- */
/* Stat cards (home screen grids)                                          */
/* ---------------------------------------------------------------------- */
.stats-grid-flutter { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.stats-grid-flutter.small { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-card-flutter {
    display: flex; background: #fff; border-radius: 14px; border: 1px solid rgba(0,0,0,.06);
    box-shadow: 0 3px 8px rgba(0,0,0,.06); overflow: hidden;
}
.stat-card-flutter .accent-bar { width: 5px; flex-shrink: 0; }
.stat-card-flutter .body { flex: 1; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.stat-card-flutter .text { min-width: 0; }
.stat-card-flutter .text .label { font-size: 11px; color: var(--gray-500); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card-flutter .text .value { font-size: 16px; font-weight: 800; color: var(--gray-900); white-space: nowrap; }
.stat-card-flutter .icon-box { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-flutter.small .body { padding: 8px 12px; }
.stat-card-flutter.small .text .value { font-size: 13px; }
.stat-card-flutter.small .icon-box { width: 30px; height: 30px; font-size: 13px; }

/* Gradient main action tiles */
.action-tiles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.action-tile {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 16px 18px; border-radius: 16px; color: #fff; cursor: pointer; border: none;
    background: linear-gradient(120deg, var(--primary-dark), var(--secondary));
    box-shadow: 0 6px 16px rgba(79,70,229,.32);
    font-family: inherit; text-align: right; width: 100%;
}
.action-tile .label { font-size: 16px; font-weight: 800; }
.action-tile .icon-badge { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0; }

/* Service list tiles */
.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.service-tile {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
    background: #fff; border: 1px solid var(--gray-100); box-shadow: 0 2px 6px rgba(0,0,0,.04);
    cursor: pointer; width: 100%; text-align: right; font-family: inherit;
}
.service-tile .icon-box { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.service-tile .label { font-size: 14px; font-weight: 800; color: var(--gray-900); flex: 1; }
.service-tile .chevron { color: var(--gray-300); }

/* ---------------------------------------------------------------------- */
/* Top filter bar (search + count + sort + filter)                        */
/* ---------------------------------------------------------------------- */
.topbar-flutter { display: flex; align-items: center; gap: 6px; background: var(--gray-100); border-radius: 12px; padding: 6px 8px; margin-bottom: 10px; box-shadow: 0 2px 4px rgba(0,0,0,.05); }
.topbar-flutter .search-wrap { flex: 1; display: flex; align-items: center; background: rgba(255,255,255,.5); border-radius: 10px; height: 36px; padding: 0 10px; }
.topbar-flutter .search-wrap i { color: var(--gray-400); font-size: 13px; margin-inline-end: 6px; }
.topbar-flutter input[type=text] { border: none; background: transparent; flex: 1; font-size: 13px; outline: none; }
.count-badge-flutter { background: var(--primary-100); color: var(--primary-700); font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 8px; white-space: nowrap; }
.chip-btn-flutter { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 10px; font-size: 10px; font-weight: 800; background: transparent; border: 1px solid transparent; color: var(--gray-500); cursor: pointer; white-space: nowrap; }
.chip-btn-flutter.active { background: rgba(79,70,229,.12); color: var(--primary); border-color: rgba(79,70,229,.3); }

/* ---------------------------------------------------------------------- */
/* Entity cards (plans / loads / polisas)                                 */
/* ---------------------------------------------------------------------- */
.entity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.entity-card { border-radius: 18px; background: #fff; border: 1px solid var(--card-border); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; }
.entity-card-header { padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.entity-card-header .status-pill { padding: 3px 9px; border-radius: 8px; color: #fff; font-size: 9.5px; font-weight: 800; white-space: nowrap; }
.entity-card-header .bon { font-weight: 800; font-size: 15px; margin: 0 auto; }
.entity-card-header i.doc-icon { font-size: 24px; }
.entity-card-body { padding: 8px 14px 4px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--gray-600); min-height: 90px; }
.entity-card-body .row { display: flex; align-items: center; gap: 6px; }
.entity-card-body .row i { width: 15px; color: var(--gray-400); font-size: 12px; }
.entity-card-body .row.primary-text { font-weight: 700; color: var(--gray-900); font-size: 13.5px; }
.entity-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.entity-chip { padding: 3px 8px; border-radius: 7px; font-size: 9.5px; font-weight: 800; display: inline-flex; align-items: center; gap: 3px; }
.entity-card-actions { padding: 8px 10px 10px; display: flex; gap: 5px; }
.entity-action-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px;
    border-radius: 8px; font-size: 11px; font-weight: 800; border: 1px solid; cursor: pointer; background: transparent;
}
.entity-dates-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 9.5px; color: var(--gray-400); }

/* ---------------------------------------------------------------------- */
/* Treasury tab bar + gradient balance card                                */
/* ---------------------------------------------------------------------- */
.tabbar-flutter { display: flex; background: var(--primary); box-shadow: 0 3px 6px rgba(0,0,0,.12); }
.tabbar-flutter button {
    flex: 1; padding: 12px 8px; color: rgba(255,255,255,.7); background: none; border: none;
    font-weight: 700; font-size: 13px; font-family: inherit; border-bottom: 3px solid transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tabbar-flutter button.active { color: #fff; border-bottom-color: #fff; }

.balance-card-flutter {
    border-radius: 14px; padding: 14px; color: #fff;
    background: linear-gradient(135deg, var(--primary), rgba(79,70,229,.75));
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.balance-card-flutter .stat-box { flex: 1; text-align: center; }

/* ---------------------------------------------------------------------- */
/* Generic card / list                                                     */
/* ---------------------------------------------------------------------- */
.mcard { background: #fff; border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.05); overflow: hidden; margin-bottom: 10px; }
.mcard-pad { padding: 14px; }
.list-tile { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--gray-50); }
.list-tile:last-child { border-bottom: none; }
.list-tile .avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-100); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.list-tile .content { flex: 1; min-width: 0; }
.list-tile .title { font-weight: 800; font-size: 14px; color: var(--gray-900); }
.list-tile .subtitle { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.list-tile .trailing { display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------------- */
/* Chips / badges                                                          */
/* ---------------------------------------------------------------------- */
.mbadge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.mbadge.success { background: var(--success-bg); color: #166534; }
.mbadge.warning { background: var(--tertiary-bg); color: #92400E; }
.mbadge.danger { background: var(--error-bg); color: #991B1B; }
.mbadge.info { background: var(--primary-100); color: var(--primary-700); }
.mbadge.neutral { background: var(--gray-100); color: var(--gray-600); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                  */
/* ---------------------------------------------------------------------- */
.mbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 700; border: none; cursor: pointer; font-family: inherit; }
.mbtn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,.3); }
.mbtn-primary:hover { background: var(--primary-dark); }
.mbtn-outline { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-300); }
.mbtn-danger { background: var(--error); color: #fff; }
.mbtn-block { width: 100%; }
.mbtn-sm { padding: 7px 14px; font-size: 12.5px; border-radius: 8px; }
.icon-btn-m { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: none; background: transparent; cursor: pointer; color: var(--gray-500); }
.icon-btn-m:hover { background: var(--gray-100); }

/* FAB */
.fab { position: fixed; bottom: 24px; left: 24px; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 6px 16px rgba(0,0,0,.3); border: none; cursor: pointer; z-index: 55; }
.fab:hover { background: var(--primary-dark); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                    */
/* ---------------------------------------------------------------------- */
.mform-group { margin-bottom: 12px; }
.mform-label { display: block; font-size: 12px; font-weight: 700; color: var(--gray-600); margin-bottom: 5px; }
.mform-input, .mform-select, textarea.mform-input {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-200); border-radius: 10px;
    font-size: 13.5px; font-family: inherit; outline: none; background: #fff; color: var(--gray-800);
}
.mform-input:focus, .mform-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.mform-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 500px) { .mform-row-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------- */
/* Dialog (Material AlertDialog, centered)                                 */
/* ---------------------------------------------------------------------- */
.dlg-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.dlg-overlay.active { display: flex; }
.dlg { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 20px; animation: dlgIn .18s ease; }
.dlg.wide { max-width: 520px; }
@keyframes dlgIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.dlg-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Bottom sheet (filter/sort panels) */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.sheet-overlay.active { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 16px 20px 22px; animation: sheetUp .2s ease; }
@keyframes sheetUp { from { transform: translateY(30px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.sheet-handle { width: 40px; height: 4px; background: var(--gray-300); border-radius: 2px; margin: 0 auto 12px; }
.sheet-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; margin-bottom: 12px; }
.sheet-options { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-option {
    display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 12px;
    border: 1px solid; font-size: 13px; font-weight: 700; cursor: pointer; background: transparent;
}
.sheet-list-option { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.sheet-list-option:hover { background: var(--gray-50); }
.sheet-list-option.active { color: var(--primary); font-weight: 800; }

/* ---------------------------------------------------------------------- */
/* Snackbar / toast                                                        */
/* ---------------------------------------------------------------------- */
#snackbar-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.snackbar { padding: 13px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 16px rgba(0,0,0,.25); animation: snackIn .2s ease; }
.snackbar.success { background: #16A34A; }
.snackbar.error { background: #DC2626; }
.snackbar.warning { background: #EA580C; }
.snackbar.info { background: var(--primary); }
@keyframes snackIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------- */
/* Table (governorates, backups)                                          */
/* ---------------------------------------------------------------------- */
.mtable-wrap { overflow-x: auto; }
table.mtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mtable thead th { background: var(--primary); color: #fff; padding: 10px 8px; font-size: 11px; font-weight: 800; text-align: center; }
table.mtable thead th:first-child { text-align: right; border-radius: 10px 0 0 0; }
table.mtable tbody td { padding: 10px 8px; text-align: center; border-bottom: 0.5px solid var(--gray-200); }
table.mtable tbody td:first-child { text-align: right; font-weight: 800; }
table.mtable tbody tr:nth-child(even) { background: var(--gray-50); }
.rate-highlight { padding: 2px 6px; border-radius: 4px; font-weight: 800; display: inline-block; }
.rate-highlight.office { background: var(--primary-100); color: var(--primary-700); }
.rate-highlight.company { background: var(--tertiary-bg); color: #92400E; }

/* ---------------------------------------------------------------------- */
/* Auth page                                                               */
/* ---------------------------------------------------------------------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.auth-card { background: rgba(255,255,255,.96); border-radius: 24px; padding: 30px; width: 100%; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.auth-icon-circle { width: 92px; height: 92px; border-radius: 50%; background: var(--primary-100); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth-icon-circle i { font-size: 56px; color: var(--primary); }
.auth-card h1 { text-align: center; font-size: 26px; font-weight: 800; color: var(--primary); }
.auth-card .subtitle { text-align: center; color: var(--gray-500); margin: 6px 0 24px; font-size: 14px; }
.auth-input-wrap { position: relative; }
.auth-input-wrap i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.auth-input-wrap input { padding-inline-start: 40px; height: 52px; }
.auth-demo-box { background: var(--primary-50); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; font-size: 12.5px; color: var(--primary-700); }

/* ---------------------------------------------------------------------- */
/* Misc                                                                     */
/* ---------------------------------------------------------------------- */
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state i { font-size: 56px; display: block; margin-bottom: 8px; opacity: .5; }
.demo-strip { background: linear-gradient(90deg,#FFFBEB,#FEF3C7 50%,#FFFBEB); border-bottom: 1px solid #FDE68A; color: #92400E; font-size: 12px; padding: 8px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.demo-strip button { background: #92400E; color: #fff; border: none; cursor: pointer; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.app-footer { text-align: center; padding: 16px; font-size: 11px; color: var(--gray-400); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--gray-500); }
.text-center { text-align: center; }


/* language toggle */
.lang-switch { display:inline-flex; align-items:center; gap:6px; padding:5px 11px; border-radius:999px; font-size:12px; font-weight:700; text-decoration:none; color:inherit; border:1px solid currentColor; opacity:.8; white-space:nowrap; cursor:pointer; background:transparent; }
.lang-switch:hover { opacity:1; }
.app-bar .lang-switch { color:#fff; }
.lang-switch-fixed { position:fixed; top:16px; inset-inline-end:16px; z-index:300; }
.lang-switch-fixed .lang-switch { background:rgba(255,255,255,.92); color:var(--primary); border-color:rgba(0,0,0,.12); box-shadow:0 2px 8px rgba(0,0,0,.12); }
