/* Ishtirak – shared styles. Cairo font, Bootstrap overrides, theme variables. */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

* { box-sizing: border-box; }

:root {
    --ishtirak-font: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    --ishtirak-bg: #f5f5f5;
    --ishtirak-primary: #1976d2;
    --ishtirak-primary-hover: #1565c0;
    --ishtirak-card: #b0b0b0;
    --ishtirak-text: #1a1a1a;
    --ishtirak-muted: #666;
    --ishtirak-placeholder: #b0b0b0;
}

body {
    margin: 0;
    padding: 1rem;
    min-height: 100vh;
    font-family: var(--ishtirak-font);
    background: var(--ishtirak-bg);
    color: var(--ishtirak-text);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

/* Theme: Customer / Consumer area – teal/green */
.theme-customer {
    --ishtirak-bg: #e8f5e9;
    --ishtirak-primary: #00897b;
    --ishtirak-primary-hover: #00695c;
    --ishtirak-card: #fff;
}
.theme-customer .card { border-right: 4px solid var(--ishtirak-primary); }
.theme-customer .btn-primary { background: var(--ishtirak-primary); border-color: var(--ishtirak-primary); }
.theme-customer .btn-primary:hover { background: var(--ishtirak-primary-hover); border-color: var(--ishtirak-primary-hover); }
.theme-customer .nav-link, .theme-customer a.link-primary { color: var(--ishtirak-primary) !important; }
.theme-customer .alert-success { background: #c8e6c9; color: #2e7d32; }
.theme-customer .form-label { font-size: 0.8rem; color: var(--ishtirak-primary); font-weight: 700; }

/* Customer area: always use mobile-style layout (compact padding, buttons, spacing) */
body.theme-customer {
    --ishtirak-safe-top: env(safe-area-inset-top, 0);
    --ishtirak-safe-bottom: env(safe-area-inset-bottom, 0);
    --ishtirak-safe-left: env(safe-area-inset-left, 0);
    --ishtirak-safe-right: env(safe-area-inset-right, 0);
    padding: calc(0.35rem + var(--ishtirak-safe-top)) calc(0.35rem + var(--ishtirak-safe-left)) calc(0.5rem + var(--ishtirak-safe-bottom)) calc(0.35rem + var(--ishtirak-safe-right));
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
body.theme-customer .container,
body.theme-customer .container.py-4 {
    max-width: 420px !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 0.35rem 0.5rem 0.5rem !important;
}

/* Customer portal: use full desktop width on large screens (top nav layout) */
@media (min-width: 992px) {
    body.theme-customer .container,
    body.theme-customer .container.py-4 {
        max-width: min(1200px, calc(100vw - 2.5rem)) !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}
body.theme-customer .card {
    padding: 1rem !important;
    margin: 0 0 0.5rem 0 !important;
    border-radius: 12px;
}
body.theme-customer .card-body,
body.theme-customer .card-body.p-4,
body.theme-customer .card-body.py-4 { padding: 1rem !important; }
body.theme-customer form.p-3,
body.theme-customer form.p-4 { padding: 0.5rem !important; }
body.theme-customer .p-3,
body.theme-customer .p-4 { padding: 0.5rem !important; }
body.theme-customer .mb-4 { margin-bottom: 0.5rem !important; }
body.theme-customer .mb-3 { margin-bottom: 0.35rem !important; }
body.theme-customer .mb-2 { margin-bottom: 0.35rem !important; }
body.theme-customer .py-4 { padding-top: 0.35rem !important; padding-bottom: 0.5rem !important; }
body.theme-customer .row.g-2 { --bs-gutter-x: 0.4rem; --bs-gutter-y: 0.4rem; }
body.theme-customer .row.g-3 { --bs-gutter-x: 0.5rem; --bs-gutter-y: 0.5rem; }
body.theme-customer .gap-2,
body.theme-customer .d-flex.gap-2 { gap: 0.35rem !important; }
body.theme-customer .table th,
body.theme-customer .table td { padding: 0.4rem 0.35rem; }
body.theme-customer .mt-2,
body.theme-customer .mt-3 { margin-top: 0.35rem !important; }
body.theme-customer .mt-4 { margin-top: 0.5rem !important; }
body.theme-customer .my-4 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
body.theme-customer .alert { padding: 0.5rem 0.6rem !important; margin-bottom: 0.5rem !important; }
body.theme-customer .btn,
body.theme-customer .nav-link,
body.theme-customer .form-control,
body.theme-customer .form-select,
body.theme-customer a.btn {
    min-height: 44px;
}
body.theme-customer .btn-sm { min-height: 40px; }
body.theme-customer .btn-lg { min-height: 48px; }
/* Buttons: mobile-style (icon prominent; hide optional text on small breakpoints) */
body.theme-customer .btn .d-sm-inline,
body.theme-customer .btn .d-md-inline { display: none !important; }
body.theme-customer .btn i:first-child { margin-left: 0; margin-right: 0.35rem; }
body.theme-customer .btn i:last-child { margin-right: 0; margin-left: 0.35rem; }
body.theme-customer hr.my-4 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
body.theme-customer .dl.row.g-3 { --bs-gutter-y: 0.4rem; }
body.theme-customer .d-flex.gap-3 { gap: 0.5rem !important; }

/* Customer: space for sticky bottom nav (screens below lg only; lg+ uses top icon bar) */
@media (max-width: 991.98px) {
    body.theme-customer.customer-with-nav {
        padding-bottom: calc(4.25rem + var(--ishtirak-safe-bottom));
    }
}

/* Customer portal: bottom nav — only below lg (Bootstrap d-lg-none on nav) */
@media (max-width: 991.98px) {
    body.theme-customer .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1040;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 0.35rem;
        padding: 0.6rem calc(0.5rem + var(--ishtirak-safe-left)) 0.6rem calc(0.5rem + var(--ishtirak-safe-right));
        padding-bottom: calc(0.6rem + var(--ishtirak-safe-bottom));
        margin: 0;
        background: var(--ishtirak-bg);
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
        width: 100%;
    }
    body.theme-customer .mobile-bottom-nav__link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.35rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ishtirak-primary) !important;
        text-decoration: none !important;
        border-radius: 10px;
        min-height: 56px;
        transition: background 0.15s ease, color 0.15s ease;
    }
    body.theme-customer .mobile-bottom-nav__link i {
        font-size: 1.5rem;
        margin-bottom: 0.2rem;
        display: block;
    }
    body.theme-customer .mobile-bottom-nav__link:hover,
    body.theme-customer .mobile-bottom-nav__link:focus {
        background: rgba(0, 0, 0, 0.06);
        color: var(--ishtirak-primary-hover) !important;
        text-decoration: none !important;
    }
    .theme-customer .mobile-bottom-nav__link.active {
        background: rgba(0, 137, 123, 0.12);
        color: var(--ishtirak-primary) !important;
    }
}
.customer-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem calc(0.5rem + var(--ishtirak-safe-left)) 0.4rem calc(0.5rem + var(--ishtirak-safe-right));
    padding-bottom: calc(0.4rem + var(--ishtirak-safe-bottom));
    margin: 0;
    background: var(--ishtirak-bg);
    border-top: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
    width: 100%;
}
.customer-bottom-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ishtirak-primary) !important;
    text-decoration: none !important;
    border-radius: 8px;
    min-height: 44px;
    transition: background 0.15s ease, color 0.15s ease;
}
.customer-bottom-nav__link i {
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
    display: block;
}
.customer-bottom-nav__link:hover,
.customer-bottom-nav__link:focus {
    background: rgba(0,0,0,0.06);
    color: var(--ishtirak-primary-hover) !important;
    text-decoration: none !important;
}
.theme-customer .customer-bottom-nav__link.active {
    background: rgba(0, 137, 123, 0.12);
    color: var(--ishtirak-primary) !important;
}

/* Theme: Provider / Supplier area – indigo/purple */
.theme-provider {
    --ishtirak-bg: #e8eaf6;
    --ishtirak-primary: #3949ab;
    --ishtirak-primary-hover: #303f9f;
    --ishtirak-card: #fff;
}
.theme-provider .card { border-right: 4px solid var(--ishtirak-primary); margin: 2rem 0; }
.theme-provider form { padding: 1.25rem; border: 1px solid var(--ishtirak-primary); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); background-color: var(--ishtirak-bg); }
.theme-provider .btn-primary { background: var(--ishtirak-primary); border-color: var(--ishtirak-primary); }
.theme-provider .btn-primary:hover { background: var(--ishtirak-primary-hover); border-color: var(--ishtirak-primary-hover); }
.theme-provider .nav-link, .theme-provider a.link-primary { color: var(--ishtirak-primary) !important; }
.theme-provider .alert-success { background: #c5cae9; color: #283593; }
/* Provider dashboard grid: icons and text use theme primary */
.theme-provider .dashboard-grid .dashboard-grid-card .card-body i,
.theme-provider .dashboard-grid .dashboard-grid-card .card-body span { color: var(--ishtirak-primary); }
.theme-provider .dashboard-grid .dashboard-grid-card:hover .card-body i,
.theme-provider .dashboard-grid .dashboard-grid-card:hover .card-body span { color: var(--ishtirak-primary-hover); }
.theme-provider .dashboard-grid-title { color: var(--ishtirak-text, #1a1a1a); }
.theme-provider .form-label { font-size: 0.8rem; color: var(--ishtirak-primary); font-weight: 700; }

/* Theme: Admin / My area – red */
.theme-admin {
    --ishtirak-bg: #ffebee;
    --ishtirak-primary: #c62828;
    --ishtirak-primary-hover: #b71c1c;
    --ishtirak-card: #fff;
}
.theme-admin .card { border-left: 4px solid var(--ishtirak-primary); }
.theme-admin form { padding: 1.25rem; border: 1px solid var(--ishtirak-primary); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); background-color: var(--ishtirak-bg); }
/* Inline / table row forms — skip the default “card” box (e.g. invoice actions) */
.theme-admin form.admin-form-plain {
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background-color: transparent;
}
.theme-admin .btn-primary { background: var(--ishtirak-primary); border-color: var(--ishtirak-primary); }
.theme-admin .btn-primary:hover { background: var(--ishtirak-primary-hover); border-color: var(--ishtirak-primary-hover); }
.theme-admin .nav-link, .theme-admin a.link-primary { color: var(--ishtirak-primary) !important; }
.theme-admin .alert-success { background: #ffcdd2; color: #b71c1c; }
.theme-admin .form-label { font-size: 0.8rem; color: var(--ishtirak-primary); font-weight: 700; }

/* Layout */
.wrap { max-width: 900px; margin: 0 auto; }
.wrap-narrow { max-width: 520px; margin: 0 auto; }
.page { max-width: 360px; margin: 0 auto; padding: 1.25rem; background: var(--ishtirak-card); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.box { max-width: 320px; width: 100%; padding: 1.5rem; background: var(--ishtirak-card); border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

/* Auto-dismiss confirmation/success alerts (fade out before remove) */
.alert.alert-dismissing { opacity: 0; transition: opacity 0.35s ease-out; pointer-events: none; }

/* Space between top header and page content (all areas) */
.page-header { margin-bottom: 1.25rem !important; }

/* Customer area: top header bar (provider logo, name, contact, logout) */
.customer-header {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 1.25rem;
}
.customer-header__logo {
    border-radius: 4px;
    background: #fff;
}
.customer-header__name { font-family: var(--ishtirak-font); }
.customer-header__phone:hover { color: var(--ishtirak-primary) !important; }
/* Extra space between customer header and profile/content card */
body.theme-customer .customer-header.page-header {
    margin-bottom: 1.75rem !important;
}

/* Header / nav */
.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.5rem; }
h1, h2, h3, h4, h5, h6 { font-family: var(--ishtirak-font); }

/* Page navbar – universal style for list/CRUD pages (title + optional action) */
.page-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    background: transparent;
}
.page-navbar__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ishtirak-text, #1a1a1a);
}
.page-navbar__title a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.page-navbar__title a:hover {
    color: var(--ishtirak-primary);
}
.page-navbar__title .fa, .page-navbar__title i {
    margin-inline-end: 0.35rem;
}
.page-navbar__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.page-navbar__actions .btn {
    white-space: nowrap;
}

/* Add meter reading form: on desktop always visible; on mobile hidden until ?add=1 */
.add-reading-form-section { display: block; }
@media (max-width: 767px) {
    .add-reading-form-section { display: none; }
    .add-reading-form-section.add-reading-form-section--open { display: block !important; }
}

/* Compact search bar (single row, minimal height) */
.search-bar-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.search-bar-compact .form-control-sm,
.search-bar-compact .form-select-sm {
    min-height: 32px;
    padding: 0.2rem 0.5rem;
}
.search-bar-compact .form-control-sm {
    flex: 1 1 8rem;
    min-width: 6rem;
}
.search-bar-compact .form-select-sm {
    flex: 0 1 auto;
    min-width: 6rem;
}
@media (min-width: 768px) {
    .search-bar-compact .form-control-sm { max-width: 12rem; flex: 0 1 12rem; }
    .search-bar-compact .form-select-sm { max-width: 10rem; }
}

h1 { margin: 0; font-size: 1.35rem; }
h1 a, .head-title { color: inherit; text-decoration: none; }
nav { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
nav a { color: var(--ishtirak-primary); text-decoration: none; }
nav a:hover { text-decoration: underline; }

/* Nav as mobile-app style buttons (stacked, full-width tap targets) */
.nav-app {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}
.nav-app .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: 2px solid var(--ishtirak-primary);
    background: #fff;
    color: var(--ishtirak-primary) !important;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-app .nav-link:hover {
    background: var(--ishtirak-primary);
    color: #fff !important;
    text-decoration: none !important;
}
.nav-app .nav-link i { opacity: 0.9; }
@media (min-width: 768px) {
    .nav-app { flex-direction: row; flex-wrap: wrap; width: auto; }
    .nav-app .nav-link { width: auto; min-width: 120px; }
}

/* Anchor tags with btn class: no underline */
a.btn { text-decoration: none !important; }
a.btn:hover { text-decoration: none !important; }
a { color: var(--ishtirak-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Cards */
.card { background-color: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 1.25rem; margin-bottom: 1rem; }
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; color: #333; }

/* Customer list cards (mobile) */
.customer-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.customer-card {
    display: block;
    padding: 0.6rem 0.75rem;
    background: var(--ishtirak-card, #fff);
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-decoration: none !important;
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.customer-card:hover, .customer-card:focus {
    background: #fff;
    border-color: var(--ishtirak-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: inherit;
}
.customer-card__row { font-size: 0.85rem; line-height: 1.35; }
.customer-card__row + .customer-card__row { margin-top: 0.2rem; }
.customer-card__name { font-weight: 700; font-size: 0.95rem; color: var(--ishtirak-text, #1a1a1a); margin-bottom: 0.25rem; }
.customer-card__label { color: var(--ishtirak-muted, #666); margin-inline-end: 0.25rem; }
.customer-card__value { color: var(--ishtirak-text, #1a1a1a); font-size: 0.9rem; }
.customer-card__sep { color: var(--ishtirak-muted, #999); margin: 0 0.35rem; font-size: 0.75rem; }
.customer-card__status { margin-top: 0.35rem; }
.customer-card__status .badge { font-size: 0.7rem; font-weight: 600; }

/* Generic data list cards (mobile) – same style as customer cards for all table lists */
.data-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.data-card {
    display: block;
    padding: 0.6rem 0.75rem;
    background: var(--ishtirak-card, #fff);
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
a.data-card { text-decoration: none !important; }
a.data-card:hover, a.data-card:focus {
    background: #fff;
    border-color: var(--ishtirak-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: inherit;
}
.data-card__title { font-weight: 700; font-size: 0.95rem; color: var(--ishtirak-text, #1a1a1a); margin-bottom: 0.25rem; }
.data-card__row { font-size: 0.85rem; line-height: 1.35; }
.data-card__row + .data-card__row { margin-top: 0.2rem; }
.data-card__label { color: var(--ishtirak-muted, #666); margin-inline-end: 0.25rem; }
.data-card__value { color: var(--ishtirak-text, #1a1a1a); }
.data-card__sep { color: var(--ishtirak-muted, #999); margin: 0 0.35rem; font-size: 0.75rem; }
.data-card__actions { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.data-card__actions .btn { font-size: 0.8rem; }

/* Mobile reading cards: content + invoice button(s) in one card, no Edit button */
.reading-card-mobile { display: block; }
.reading-card-mobile__main { display: block; }
.reading-card-mobile__invoice-row { min-height: 2.25rem; }
.reading-card-mobile__invoice-row .btn { flex-shrink: 0; }

/* Messages */
.msg, .alert { padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: 8px; font-size: 0.9rem; font-family: var(--ishtirak-font); }
.msg.ok, .alert-success { background: #e8f5e9; color: #2e7d32; }
.msg.err, .alert-danger { background: #ffebee; color: #c62828; }

/* Form */
form { background-color: #f4f4f4; border-radius: 12px; }
label, .form-label { font-family: var(--ishtirak-font); font-weight: 700; font-size: 1rem; line-height: 1; direction: ltr; text-align: left; }
input, select, textarea { font-family: var(--ishtirak-font); }
/* Force placeholder color (override Bootstrap and others) */
input::placeholder,
textarea::placeholder,
input.form-control::placeholder,
textarea.form-control::placeholder,
.form-control::placeholder,
.form-select::placeholder {
    color: var(--ishtirak-placeholder) !important;
    opacity: 1 !important;
}
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder,
input.form-control::-webkit-input-placeholder,
textarea.form-control::-webkit-input-placeholder {
    color: var(--ishtirak-placeholder) !important;
    opacity: 1 !important;
}
input::-moz-placeholder,
textarea::-moz-placeholder,
input.form-control::-moz-placeholder,
textarea.form-control::-moz-placeholder {
    color: var(--ishtirak-placeholder) !important;
    opacity: 1 !important;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder,
input.form-control:-ms-input-placeholder,
textarea.form-control:-ms-input-placeholder {
    color: var(--ishtirak-placeholder) !important;
}
input:focus, select:focus, textarea:focus { border-color: var(--ishtirak-primary); box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
.rtl { direction: rtl; text-align: right; }

/* Meter */
#meter_id, .meter-id { letter-spacing: 0.35em; }
.meter-row { display: flex; gap: 0.35rem; margin-bottom: 1rem; direction: ltr; }
.meter-row input { flex: 1; text-align: center; font-size: 1.5rem; font-family: ui-monospace, Consolas, monospace; direction: ltr; }
.meter-row input.red { border-color: #c62828; background: #ffebee; color: #b71c1c; }

/* Numeric meter readings in tables, cards, labels (single-line, not meter-display boxes) */
.reading-value-mono {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

/* Previous/last reading display: meter-style (5 grey boxes + 1 red decimal), monospace */
.meter-display {
    display: inline-flex;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    gap: 0.15rem;
    align-items: stretch;
}
.meter-display__digit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25em;
    padding: 0.2em 0.35em;
    background: #e0e0e0;
    border: 1px solid #bdbdbd;
    border-radius: 3px;
    font-size: 1rem;
    font-weight: 600;
    color: #424242;
}
.meter-display__decimal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25em;
    padding: 0.2em 0.35em;
    background: #ffebee;
    border: 1px solid #c62828;
    border-radius: 3px;
    font-size: 1rem;
    font-weight: 600;
    color: #b71c1c;
}

/* Tables */
.table { font-family: var(--ishtirak-font); }
.profile dl { font-family: var(--ishtirak-font); }
.back { font-family: var(--ishtirak-font); }

/* ========== Mobile app–like behavior (small screens) ========== */
@media (max-width: 767px) {
    :root {
        --ishtirak-safe-top: env(safe-area-inset-top, 0);
        --ishtirak-safe-bottom: env(safe-area-inset-bottom, 0);
        --ishtirak-safe-left: env(safe-area-inset-left, 0);
        --ishtirak-safe-right: env(safe-area-inset-right, 0);
    }

    body {
        padding: calc(0.35rem + var(--ishtirak-safe-top)) calc(0.35rem + var(--ishtirak-safe-left)) calc(5rem + var(--ishtirak-safe-bottom)) calc(0.35rem + var(--ishtirak-safe-right));
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Minimize paddings and layout for mobile app */
    .container,
    .container.py-4 {
        max-width: 100% !important;
        width: 100%;
        padding: 0.35rem 0 0.5rem 0 !important;
    }
    .card {
        padding: 0.5rem !important;
        margin: 0 0 0.5rem 0 !important;
        border-radius: 12px;
    }
    .card-body,
    .card-body.p-4 { padding: 0.5rem !important; }
    form.p-3, form.p-4,
    .theme-provider form,
    .theme-admin form { padding: 0.5rem !important; }
    .theme-admin form.admin-form-plain {
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .p-3, .p-4 { padding: 0.5rem !important; }
    .mb-4 { margin-bottom: 0.5rem !important; }
    .mb-3 { margin-bottom: 0.35rem !important; }
    .py-4 { padding-top: 0.35rem !important; padding-bottom: 0.5rem !important; }
    .row.g-2 { --bs-gutter-x: 0.4rem; --bs-gutter-y: 0.4rem; }
    .row.g-3 { --bs-gutter-x: 0.5rem; --bs-gutter-y: 0.5rem; }
    .gap-2, .d-flex.gap-2 { gap: 0.35rem !important; }
    .nav-link {
        padding: 0.4rem 0.5rem;
        display: inline-flex;
        align-items: center;
    }
    .table th, .table td { padding: 0.4rem 0.35rem; }
    .dashboard-grid .row.g-3 { --bs-gutter-x: 0.4rem; --bs-gutter-y: 0.4rem; }
    .dashboard-grid .dashboard-grid-card .card-body { padding: 0.5rem !important; }
    .dashboard-grid .dashboard-grid-card { margin-bottom: 0.5rem; }
    .mb-2 { margin-bottom: 0.35rem !important; }
    .mt-2, .mt-3 { margin-top: 0.35rem !important; }
    .mt-4 { margin-top: 0.5rem !important; }
    .alert { padding: 0.5rem 0.6rem !important; margin-bottom: 0.5rem !important; }

    /* Form labels: smaller size + theme color on mobile */
    body.theme-customer .form-label { font-size: 0.8rem !important; color: var(--ishtirak-primary); font-weight: 600; }
    body.theme-provider .form-label { font-size: 0.8rem !important; color: var(--ishtirak-primary); font-weight: 600; }
    body.theme-admin .form-label { font-size: 0.8rem !important; color: var(--ishtirak-primary); font-weight: 600; }

    /* Hide button text on mobile (icon-only); use .search-btn-text for optional text */
    .search-btn-text {
        display: none !important;
    }
    .search-bar-compact button[type="submit"] .me-1,
    .page-navbar__actions .btn .me-1 {
        margin-right: 0;
        margin-inline-end: 0;
    }

    /* Compact search bar on mobile: single line, icon-only search button */
    .search-bar-compact {
        flex-wrap: nowrap;
        gap: 0.25rem;
        margin-bottom: 0.35rem;
    }
    .search-bar-compact .form-control-sm,
    .search-bar-compact .form-select-sm {
        min-height: 36px;
        padding: 0.2rem 0.4rem;
        font-size: 0.9rem;
        min-width: 0;
    }
    .search-bar-compact .form-control-sm {
        flex: 1 1 0;
    }
    .search-bar-compact .form-select-sm {
        flex: 0 1 auto;
        max-width: 6rem;
    }
    .search-bar-compact .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    .search-bar-compact .search-btn-text {
        display: none;
    }
    .search-bar-compact button[type="submit"] .me-1 {
        margin-right: 0;
    }

    /* Mobile sticky bottom nav: Dashboard, Profile, Customers, Readings, Invoicing */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 0.35rem;
        padding: 0.6rem calc(0.5rem + var(--ishtirak-safe-left)) 0.6rem calc(0.5rem + var(--ishtirak-safe-right));
        padding-bottom: calc(0.6rem + var(--ishtirak-safe-bottom));
        margin: 0;
        background: var(--ishtirak-bg);
        border-top: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
        width: 100%;
    }
    .mobile-bottom-nav__link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.35rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ishtirak-primary) !important;
        text-decoration: none !important;
        border-radius: 10px;
        min-height: 56px;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .mobile-bottom-nav__link i {
        font-size: 1.5rem;
        margin-bottom: 0.2rem;
        display: block;
    }
    .mobile-bottom-nav__link:hover,
    .mobile-bottom-nav__link:focus {
        background: rgba(0,0,0,0.06);
        color: var(--ishtirak-primary-hover) !important;
        text-decoration: none !important;
    }
    .theme-provider .mobile-bottom-nav__link.active {
        background: rgba(57, 73, 171, 0.12);
        color: var(--ishtirak-primary) !important;
    }

    /* Header nav (Log out) stays in flow on mobile when bottom nav is present */
    .nav-app {
        flex-direction: row !important;
        flex-wrap: wrap;
    }

    .wrap, .wrap-narrow, .page, .box { max-width: 100%; }

    /* Prevent iOS zoom when focusing inputs (font-size < 16px triggers zoom) */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="search"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea.form-control {
        font-size: 16px !important;
    }

    /* Touch-friendly targets (min 44px) */
    .btn,
    .nav-link,
    .form-control,
    .form-select,
    input[type="submit"],
    input[type="button"],
    a.btn {
        min-height: 44px;
    }
    .btn-sm { min-height: 40px; }
    .form-control-lg, .btn-lg { min-height: 48px; }

    /* Tables: horizontal scroll with visible shadow */
    .table-responsive {
        margin-left: calc(-0.75rem - var(--ishtirak-safe-left));
        margin-right: calc(-0.75rem - var(--ishtirak-safe-right));
        padding-left: calc(0.75rem + var(--ishtirak-safe-left));
        padding-right: calc(0.75rem + var(--ishtirak-safe-right));
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-responsive .table { margin-bottom: 0; min-width: 400px; }

    /* Stack header elements; nav is fixed at bottom so header only shows logo/title */
    .d-flex.justify-content-between.align-items-center.flex-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        margin-bottom: 0.5rem !important;
    }
    .d-flex.justify-content-between .nav:not(.nav-app) { justify-content: flex-start; flex-wrap: wrap; }

    /* Dashboard grid: one column, full width cards */
    .dashboard-grid .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }

    /* Form rows: stack on mobile */
    .row.g-2 .col-12, .row.g-2 .col-md-6, .row.g-2 .col-md-4 { margin-bottom: 0.5rem; }

    /* Reduce large headings on small screens */
    h1.fs-4, .fs-4 { font-size: 1.2rem !important; }
    .card-title.h6 { font-size: 1rem; }

    /* Logo/header: compact */
    .d-flex.align-items-center.gap-2 img.img-fluid { max-height: 40px; }

    /* Prevent double-tap zoom on buttons (keep pinch-zoom) */
    button, .btn, a.btn { touch-action: manipulation; }
}

