@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --brand: #6c0c2f;
    --brand-dark: #250d1a;
    --brand-deep: #160811;
    --brand-soft: #f7edf1;
    --brand-light: #8b1a45;
    --gold: #c8a15a;
    --text: #29232a;
    --muted: #7c747b;
    --bg: #f6f5f7;
    --card: #ffffff;
    --border: #ece7ea;
}

* { box-sizing: border-box; }

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

.topbar {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    min-height: 70px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 8px 25px rgba(37,13,26,.12);
}

.topbar .navbar-brand {
    letter-spacing: -.3px;
}

.topbar .navbar-brand i {
    margin-left: 8px;
}

.sidebar {
    min-height: calc(100vh - 70px);
    background:
        radial-gradient(circle at 20% 10%, rgba(255,255,255,.08), transparent 28%),
        linear-gradient(180deg, var(--brand-deep) 0%, var(--brand-dark) 52%, #3a0c21 100%);
    padding: 22px 14px !important;
    box-shadow: inset -1px 0 rgba(255,255,255,.05);
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    padding: 13px 15px;
    margin-bottom: 7px;
    border-radius: 12px;
    transition: .2s ease;
    font-weight: 600;
}

.sidebar a i {
    width: 22px;
    text-align: center;
    color: #fff;
}

.sidebar a:hover,
.sidebar a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(139,26,69,.85), rgba(108,12,47,.55));
    transform: translateX(-2px);
}

main {
    min-height: calc(100vh - 70px);
}

.dashboard-head {
    background:
        radial-gradient(circle at 85% 25%, rgba(200,161,90,.24), transparent 25%),
        linear-gradient(135deg, #250d1a, #6c0c2f);
    border-radius: 24px;
    padding: 28px 30px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(108,12,47,.16);
}

.dashboard-head::after {
    content: "";
    position: absolute;
    width: 240px;
    height: 240px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 50%;
    left: -70px;
    bottom: -130px;
}

.dashboard-head h2 {
    font-weight: 800;
    margin-bottom: 5px;
}

.dashboard-head p {
    color: rgba(255,255,255,.75);
    margin-bottom: 0;
}

.brand-badge {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.14);
    font-size: 25px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    height: 100%;
    box-shadow: 0 10px 30px rgba(34,17,26,.055);
    transition: .2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 35px rgba(34,17,26,.10);
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 21px;
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 16px;
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
    margin-top: 5px;
}

.modern-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(34,17,26,.05);
}

.module-card {
    display: block;
    height: 100%;
    text-decoration: none;
    color: var(--text);
    padding: 22px;
    transition: .2s ease;
}

.module-card:hover {
    color: var(--brand);
    transform: translateY(-3px);
}

.module-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 19px;
}

.module-title {
    font-weight: 800;
    margin-top: 16px;
}

.module-text {
    color: var(--muted);
    font-size: 13px;
    margin: 5px 0 0;
}

.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-brand:hover {
    background: #540923;
    border-color: #540923;
    color: #fff;
}

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

.btn-outline-brand:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.card-modern {
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(34,17,26,.05);
}

.form-control, .form-select {
    min-height: 46px;
    border-color: #ddd5da;
    border-radius: 11px;
}

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

.table thead th {
    white-space: nowrap;
    background: #fbf8fa;
    color: #5f555b;
    border-bottom: 1px solid var(--border);
}

.badge-brand {
    background: var(--brand-soft);
    color: var(--brand);
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 20%, rgba(200,161,90,.16), transparent 24%),
        linear-gradient(135deg, #160811 0%, #250d1a 48%, #6c0c2f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 430px;
    border: 0;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0,0,0,.28);
}

@media (max-width: 991.98px) {
    .sidebar {
        min-height: auto;
    }
}

/* Stage 4 responsive enhancements */
.app-layout{display:flex;min-height:calc(100vh - 70px)}
.sidebar{width:260px;flex:0 0 260px;min-height:calc(100vh - 70px);position:sticky;top:0;z-index:1030}
.sidebar-inner{position:sticky;top:15px}
.content-area{flex:1;min-width:0;padding:24px}
.page-heading{display:flex;justify-content:space-between;align-items:center;gap:15px;margin-bottom:22px}.page-heading h2{font-weight:800;margin:0}.page-heading p{color:var(--muted);margin:5px 0 0;font-size:13px}
.modern-card{background:#fff;border:1px solid var(--border);border-radius:20px;box-shadow:0 10px 30px rgba(34,17,26,.05)}
.stock-toggle{display:flex;align-items:center;gap:10px;border:1px solid #eadfe4;border-radius:14px;padding:10px 12px;width:100%;background:#fff}.stock-toggle input{width:20px;height:20px;accent-color:var(--brand)}.stock-toggle label{display:flex;flex-direction:column;cursor:pointer}.stock-toggle small{color:var(--muted);font-size:10px}
.table-responsive{border-radius:15px}.table{min-width:720px}
@media(max-width:991.98px){.sidebar{position:fixed;right:-280px;top:70px;height:calc(100vh - 70px);width:270px;transition:right .25s ease;box-shadow:-10px 0 30px rgba(0,0,0,.18)}.sidebar.show{right:0}.content-area{padding:16px}.app-layout{display:block}.page-heading{align-items:flex-start;flex-direction:column}}
@media(max-width:575.98px){.content-area{padding:10px}.topbar{min-height:60px}.page-heading h2{font-size:22px}.modern-card{border-radius:15px}.btn{font-size:13px}.form-control,.form-select{font-size:14px}}


/* Stage 4 responsive hardening */
.table-responsive{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.table{min-width:680px}
.form-control,.form-select{min-height:44px}
.btn{border-radius:10px}
.modal-dialog{max-width:min(96vw,1100px)}
.content-area{overflow-x:hidden}
@media(max-width:991.98px){.sidebar{min-height:auto}.content-area{padding:14px!important}.modern-card{border-radius:16px}.table{font-size:13px}}
@media(max-width:575.98px){.content-area{padding:10px!important}.dashboard-head{padding:20px;border-radius:18px}.stat-card{padding:16px;border-radius:16px}.btn{min-height:42px}.modal-dialog{margin:.5rem}.modal-content{border-radius:16px}.form-section{padding:14px}.table{min-width:620px}}

.sidebar-portal{margin:5px 8px}.portal-toggle{width:100%;border:0;background:rgba(255,255,255,.06);color:#fff;border-radius:10px;padding:10px 11px;display:flex;justify-content:space-between;align-items:center;font-weight:800;font-size:13px;cursor:pointer}.portal-toggle span{display:flex;gap:9px;align-items:center}.portal-arrow{font-size:10px;transition:.2s}.portal-items{display:none;padding:3px 0}.sidebar-portal.open .portal-items{display:block}.sidebar-portal.open .portal-arrow{transform:rotate(180deg)}.portal-items a{margin:2px 0!important;padding:9px 12px!important;border-radius:9px}.portal-items a.active{background:rgba(255,255,255,.16)}
