:root {
    --erp-bg: #f4f7fb;
    --erp-card: #ffffff;
    --erp-text: #172033;
    --erp-muted: #6b7280;
    --erp-border: #e5e7eb;
    --erp-primary: #0a6c74;
    --erp-primary-dark: #074f55;
    --erp-success: #15803d;
    --erp-warning: #b45309;
    --erp-danger: #b91c1c;
    --erp-info: #2563eb;
    --erp-radius: 18px;
    --erp-shadow: 0 10px 30px rgba(15, 23, 42, .08);
    --erp-shell-max: 1560px;
    --erp-shell-gutter: clamp(.8rem, 1vw + .55rem, 1.35rem);
    --erp-shell-mobile-max: 760px;
    --erp-glass: rgba(244, 247, 251, .88);
}

html {
    font-size: 15px;
}

body {
    font-family: "Cairo", sans-serif;
    background: var(--erp-bg);
    color: var(--erp-text);
}

/* Layout */
.app-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(10,108,116,.10), transparent 32rem),
        var(--erp-bg);
}

.app-content {
    padding: 1.25rem;
}

.app-content-shell {
    width: min(100%, var(--erp-shell-max));
    min-height: 100vh;
    margin-inline: auto;
    padding-inline: var(--erp-shell-gutter);
}

.app-main {
    padding: 1.1rem 0 calc(2.4rem + env(safe-area-inset-bottom, 0px));
}

.app-main-shell {
    width: 100%;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #ffffff;
    color: var(--erp-primary);
    font-weight: 900;
}

.brand-text {
    font-weight: 800;
    letter-spacing: .2px;
}


/* Cards */
.content-card,
.dashboard-card,
.module-card,
.quick-shortcut-card,
.card {
  border: 1px solid var(--erp-border) !important;
  border-radius: var(--erp-radius) !important;
  background: var(--erp-card) !important;
  box-shadow: var(--erp-shadow);
}

.content-card,
.dashboard-card {
  padding: 1.15rem;
}

.page-header {
    margin-bottom: 1.4rem;
    padding-bottom: 1rem;
}

.page-header h1 {
    line-height: 1.15;
}

/* Page title */
.page-title,
.section-title h1,
.section-title h2 {
    color: var(--erp-text);
    font-weight: 900;
    margin-bottom: .35rem;
}

.eyebrow {
    display: inline-block;
    color: var(--erp-primary);
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .5px;
}

/* Dashboard stats */
.erp-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.erp-stat-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border-radius: var(--erp-radius);
  background: #fff;
  border: 1px solid var(--erp-border);
  box-shadow: var(--erp-shadow);
}

.erp-stat-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 5px;
    background: var(--erp-primary);
}

.erp-stat-label {
    color: var(--erp-muted);
    font-weight: 800;
    font-size: .82rem;
}

.erp-stat-value {
    margin-top: .35rem;
    font-size: 1.65rem;
    font-weight: 900;
    color: var(--erp-text);
}

.erp-stat-note {
    margin-top: .25rem;
    color: var(--erp-muted);
    font-size: .8rem;
}

/* Tables */
.table-responsive {
    border-radius: var(--erp-radius);
    border: 1px solid var(--erp-border);
    background: #fff;
    box-shadow: var(--erp-shadow);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(37, 99, 235, .35) transparent;
}

.table-responsive::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(37, 99, 235, .28);
    border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: rgba(37, 99, 235, .42);
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #f8fafc;
    color: #334155;
    border-bottom: 1px solid var(--erp-border);
    font-size: .82rem;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: inset 0 -1px 0 var(--erp-border);
}

.table tbody td {
    color: #1f2937;
    font-weight: 600;
    transition: background-color .16s ease, color .16s ease;
    border-bottom: 1px solid #eef2f7;
}

.table tbody tr:hover {
    background: linear-gradient(90deg, #f8fafc 0%, #f2f7fb 100%);
}

.table tbody tr {
    transition: transform .12s ease;
}

.table tbody tr:hover td {
    background: transparent;
}

.table .btn.btn-sm {
    min-height: 34px;
    border-radius: 10px;
    padding-inline: .7rem;
}

.table .btn.btn-sm:hover {
    transform: translateY(-1px);
}

.table-modern tbody tr.table-active td,
.table-modern tbody tr.is-selected td {
    background: rgba(37, 99, 235, .08) !important;
}

/* Status badges */
.status-badge,
.badge-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 900;
}

.status-draft {
    background: #fef3c7;
    color: #92400e;
}

.status-posted {
    background: #dcfce7;
    color: #166534;
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.status-deleted {
    background: #e5e7eb;
    color: #374151;
}

/* Forms */
.form-control,
.form-select {
    min-height: 44px;
    border-radius: 13px;
    border-color: var(--erp-border);
    font-weight: 700;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 .2rem rgba(10,108,116,.12);
}

label,
.form-label {
    font-weight: 900;
    color: #374151;
}

/* Buttons */
.btn {
    border-radius: 13px;
    font-weight: 900;
    min-height: 42px;
}

.btn-primary {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

.btn-primary:hover {
    background: var(--erp-primary-dark);
    border-color: var(--erp-primary-dark);
}

.btn-outline-primary {
    color: var(--erp-primary);
    border-color: var(--erp-primary);
}

.btn-outline-primary:hover {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

/* Invoice create/edit layout */
.erp-form-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1rem;
}

.erp-form-main,
.erp-form-side {
    display: grid;
    gap: 1rem;
}

.erp-summary-box {
    position: sticky;
    top: 1rem;
    padding: 1rem;
    border-radius: var(--erp-radius);
    background: #fff;
    border: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow);
}

.erp-save-bar {
    position: sticky;
    bottom: 1rem;
    z-index: 20;
    display: flex;
    gap: .65rem;
    justify-content: flex-end;
    padding: .85rem;
    margin-top: 1rem;
    border-radius: var(--erp-radius);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow);
}

/* Mobile */
@media (max-width: 991.98px) {
    .app-content-shell {
        max-width: min(100%, 920px);
    }

    .app-content {
        padding: .85rem;
    }

    .app-mobile-header,
    .app-public-header {
        margin-inline: calc(var(--erp-shell-gutter) * -1);
        padding-inline: var(--erp-shell-gutter);
        background: var(--erp-glass);
        backdrop-filter: blur(16px);
    }

    .mobile-quick-actions {
        margin-inline: calc(var(--erp-shell-gutter) * -1);
        padding-inline: var(--erp-shell-gutter);
        padding-bottom: .7rem;
        gap: .5rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        background: linear-gradient(180deg, rgba(244, 247, 251, .94), rgba(244, 247, 251, .78));
        backdrop-filter: blur(16px);
        -webkit-overflow-scrolling: touch;
    }

    .mobile-quick-actions::-webkit-scrollbar {
        display: none;
    }

    .mobile-quick-link {
        min-height: 2.55rem;
        padding-inline: .95rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, .76);
        border: 1px solid rgba(15, 23, 42, .08);
        box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
        white-space: nowrap;
    }

    .mobile-quick-link.active {
        box-shadow: 0 12px 24px rgba(10, 108, 116, .18);
    }

    .content-card,
    .dashboard-card,
    .card {
        border-radius: 22px !important;
        padding: 1rem;
    }

    .erp-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .erp-form-grid {
        grid-template-columns: 1fr;
    }

    .erp-summary-box {
        position: static;
    }
}

@media (max-width: 575.98px) {
    html {
        font-size: 14px;
    }

    .app-content-shell {
        max-width: min(100%, 560px);
        padding-inline: .8rem;
    }

    .app-main {
        padding: .9rem 0 calc(1.8rem + env(safe-area-inset-bottom, 0px));
    }

    .page-header {
        margin-bottom: 1.1rem;
        padding-bottom: .85rem;
    }

    .page-header h1 {
        font-size: 1.45rem;
    }

    .erp-stats-grid {
        grid-template-columns: 1fr;
    }

    .table-responsive {
        border: 0;
        box-shadow: none;
        background: transparent;
    }

    .table.mobile-cards thead {
        display: none;
    }

    .table.mobile-cards,
    .table.mobile-cards tbody,
    .table.mobile-cards tr,
    .table.mobile-cards td {
        display: block;
        width: 100%;
    }

    .table.mobile-cards tr {
        margin-bottom: .85rem;
        padding: .8rem;
        border-radius: 16px;
        background: #fff;
        border: 1px solid var(--erp-border);
        box-shadow: var(--erp-shadow);
    }

    .content-card,
    .dashboard-card,
    .card {
        border-radius: 20px !important;
    }

    .table.mobile-cards td {
        display: flex;
        justify-content: space-between;
        gap: .9rem;
        border: 0;
        padding: .48rem 0;
        align-items: flex-start;
    }

    .table.mobile-cards td::before {
        content: attr(data-label);
        color: var(--erp-muted);
        font-weight: 900;
        flex: 0 0 auto;
        max-width: 55%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* UX: تخفيف تكدس الأزرار داخل mobile cards */
    .table.mobile-cards .btn {
        min-height: 38px;
        border-radius: 12px;
        padding-inline: .7rem;
    }
}

body.login-page-shell .app-content-shell {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    padding-inline: 0;
}

body.login-page-shell .app-main-shell {
    width: 100%;
}

body.page-home-index .app-content-shell {
    max-width: none;
    padding-inline: 0;
}
