* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0f172a;
    --primary-dark: #020617;
    --accent: #22c55e;
    --accent-dark: #16a34a;
    --success: #16a34a;
    --danger: #dc2626;
    --gray-100: #f8fafc;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-600: #64748b;
    --gray-800: #0f172a;
    --white: #ffffff;
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 28px 60px rgba(2, 6, 23, 0.22);
    --radius-xl: 36px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: 'Inter', 'Tajawal', Arial, sans-serif;
    background: linear-gradient(145deg, #f8fafc 0%, #eef2f7 100%);
    color: var(--gray-800);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #020617 0%, #0f172a 55%, #111827 100%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: -20%;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.08) 2px, transparent 2px);
    background-size: 42px 42px;
    animation: drift 35s linear infinite;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 40px); }
}

.login-card {
    width: 100%;
    max-width: 470px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 40px;
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(34, 197, 94, 0.20);
    position: relative;
    z-index: 2;
}

.premium-login-card {
    text-align: center;
}

.login-logo-wrap {
    margin-bottom: 1.6rem;
}

.login-logo-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.25);
}

.admin-logo-icon {
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #ffffff;
}

.login-title {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 1rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.login-form-modern {
    text-align: left;
}

.login-main-btn {
    width: 100%;
    margin-top: 8px;
    padding: 14px 16px;
    font-size: 15px;
    background: linear-gradient(135deg, var(--primary), #1e293b);
    color: var(--white);
}

.login-main-btn:hover {
    background: linear-gradient(135deg, #111827, #334155);
}

.login-footer-text {
    margin-top: 18px;
    text-align: center;
    color: var(--gray-600);
    font-size: 0.86rem;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: var(--white);
    padding: 22px 0;
    flex-shrink: 0;
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.10);
}

.brand {
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 900;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.22);
}

.brand h2 {
    color: var(--white);
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.brand small {
    color: #86efac;
    font-size: 0.75rem;
}

.sidebar-nav a {
    display: block;
    padding: 13px 20px;
    color: #dbe4ee;
    border-left: 3px solid transparent;
    transition: 0.25s ease;
    font-weight: 500;
}

.sidebar-nav a i {
    width: 22px;
    margin-right: 8px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-left-color: var(--accent);
}

.content {
    flex: 1;
    min-width: 0;
    padding: 22px;
}

.topbar {
    background: linear-gradient(135deg, var(--primary), #1e293b);
    color: var(--white);
    padding: 14px 18px;
    border-radius: 22px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-md);
    border-bottom: 2px solid var(--accent);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topbar-title strong {
    font-size: 1rem;
}

.topbar-title span {
    font-size: 0.88rem;
    color: #cbd5e1;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #edf2f7;
    margin-bottom: 16px;
}

.inner-card {
    margin-bottom: 0;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.section-head h2 {
    color: var(--primary);
    font-size: 1.28rem;
    font-weight: 800;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--white);
    border-radius: 24px;
    padding: 18px;
    border-bottom: 4px solid var(--accent);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.08));
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.stat-card h3 {
    color: var(--primary);
    font-size: 1.9rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.stat-card p {
    color: var(--gray-600);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.94rem;
}

label i {
    margin-right: 6px;
    color: var(--accent-dark);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    font-size: 15px;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-800);
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

textarea {
    resize: vertical;
    min-height: 110px;
}

/* Buttons */
button,
.btn {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 11px 16px;
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: #111827;
}

.btn-accent {
    background: var(--accent);
    color: var(--white);
}

.btn-accent:hover {
    background: var(--accent-dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--gray-200);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    background: var(--white);
}

thead th {
    background: var(--primary);
    color: var(--white);
    padding: 12px;
    text-align: left;
    font-size: 0.92rem;
    white-space: nowrap;
}

tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: top;
    font-size: 0.93rem;
}

tbody tr:hover {
    background: #f8fafc;
}

/* Flash */
.flash {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.flash-success {
    background: #dcfce7;
    color: var(--success);
}

.flash-error {
    background: #fee2e2;
    color: var(--danger);
}

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    display: inline-block;
}

.badge-active {
    background: #dcfce7;
    color: var(--success);
}

.badge-disabled {
    background: #fee2e2;
    color: var(--danger);
}

.badge-plan {
    background: #dcfce7;
    color: var(--accent-dark);
}

/* Misc */
.inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.info-grid,
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.info-box,
.upload-box {
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: 18px;
    padding: 16px;
}

.info-box p {
    margin-bottom: 8px;
}

.totals-preview {
    margin-top: 14px;
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 14px;
}

.totals-preview p {
    margin-bottom: 6px;
}

.logo-preview {
    width: 95px;
    height: 95px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    background: #fff;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.84rem;
}

.items-table input,
.items-table select {
    min-width: 110px;
}

.items-table .wide {
    min-width: 220px;
}

/* Item table */
.item-table {
    overflow-x: auto;
}

.item-table table {
    min-width: 1700px;
    border-collapse: separate;
    border-spacing: 0;
}

.item-table th,
.item-table td {
    min-width: 110px;
    vertical-align: middle;
    padding: 8px;
}

.item-table th:nth-child(1),
.item-table td:nth-child(1) {
    min-width: 180px;
}

.item-table th:nth-child(2),
.item-table td:nth-child(2) {
    min-width: 130px;
}

.item-table th:nth-child(3),
.item-table td:nth-child(3),
.item-table th:nth-child(4),
.item-table td:nth-child(4) {
    min-width: 220px;
}

.item-table th:nth-child(5),
.item-table td:nth-child(5) {
    min-width: 150px;
}

.item-table th:nth-child(6),
.item-table td:nth-child(6) {
    min-width: 110px;
}

.item-table th:nth-child(7),
.item-table td:nth-child(7),
.item-table th:nth-child(8),
.item-table td:nth-child(8),
.item-table th:nth-child(9),
.item-table td:nth-child(9),
.item-table th:nth-child(10),
.item-table td:nth-child(10),
.item-table th:nth-child(11),
.item-table td:nth-child(11),
.item-table th:nth-child(12),
.item-table td:nth-child(12),
.item-table th:nth-child(13),
.item-table td:nth-child(13) {
    min-width: 120px;
}

.item-table th:last-child,
.item-table td:last-child {
    min-width: 120px;
}

.item-table select,
.item-table input {
    width: 100%;
    min-width: 100%;
    height: 42px;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 12px;
    box-sizing: border-box;
}

.item-table input.wide {
    min-width: 100%;
}

.item-table .btn-sm {
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 992px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .content {
        padding: 14px;
    }

    .topbar {
        border-radius: 18px;
    }

    .login-card {
        border-radius: 28px;
        padding: 1.7rem;
    }

    .login-title {
        font-size: 2.4rem;
    }
}

@media (max-width: 600px) {
    .content {
        padding: 10px;
    }

    .card,
    .stat-card {
        padding: 14px;
        border-radius: 18px;
    }

    table {
        min-width: 620px;
    }

    .login-title {
        font-size: 2rem;
    }

    .login-subtitle {
        font-size: 0.94rem;
    }
}

.login-logo-img {
    width: 62px;
    height: 62px;
    max-width: 62px;
    max-height: 62px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px auto;
    background: #060505;
    padding: 6px;
    border-radius: 50%;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.18);
}
.brand-logo-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: #060505;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.brand {
    align-items: center;
    gap: 14px;
}
/* =========================================
   RESPONSIVE IMPROVEMENTS
========================================= */

img {
    max-width: 100%;
    height: auto;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    transition: all 0.25s ease;
}

.content {
    min-width: 0;
    width: 100%;
}

.topbar-actions,
.inline-actions,
.section-head {
    gap: 10px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
}

/* Better form controls on touch devices */
input,
select,
textarea,
button,
.btn {
    min-height: 44px;
}

/* Keep cards from overflowing */
.card,
.stat-card,
.info-box,
.upload-box,
.mini-stat {
    min-width: 0;
}

/* Brand/logo safety */
.brand img,
.brand-logo-img,
.login-logo-icon-img,
.logo-preview {
    max-width: 100%;
    height: auto;
}

/* =========================================
   TABLET
========================================= */
@media (max-width: 1024px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 14px 0;
    }

    .brand {
        padding: 0 16px 14px 16px;
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0 12px;
    }

    .sidebar-nav a {
        border-left: none;
        border-radius: 12px;
        padding: 10px 14px;
        background: rgba(255,255,255,0.04);
    }

    .sidebar-nav a:hover,
    .sidebar-nav a.active {
        border-left-color: transparent;
    }

    .content {
        padding: 14px;
    }

    .topbar {
        border-radius: 18px;
        padding: 14px;
    }

    .topbar-title strong {
        font-size: 0.98rem;
    }

    .topbar-title span {
        font-size: 0.84rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid,
    .info-grid,
    .upload-grid,
    .super-grid-2,
    .super-grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================
   MOBILE
========================================= */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .content {
        padding: 10px;
    }

    .card,
    .stat-card,
    .info-box,
    .upload-box,
    .mini-stat {
        padding: 14px;
        border-radius: 18px;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-head h2 {
        font-size: 1.05rem;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        border-radius: 16px;
    }

    .topbar-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .topbar-actions .btn,
    .topbar-actions button {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card h3 {
        font-size: 1.6rem;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    input,
    select,
    textarea {
        font-size: 16px; /* prevents mobile browser zoom */
        border-radius: 14px;
        padding: 12px;
    }

    .btn,
    button {
        width: auto;
        justify-content: center;
    }

    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-actions .btn,
    .inline-actions button,
    .inline-actions a {
        width: 100%;
    }

    .sidebar {
        padding-bottom: 10px;
    }

    .brand {
        gap: 10px;
    }

    .brand h2 {
        font-size: 1rem;
    }

    .brand small {
        font-size: 0.72rem;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 0 10px;
    }

    .sidebar-nav a {
        font-size: 0.92rem;
        padding: 10px 12px;
        margin: 0;
        text-align: left;
    }

    .sidebar-nav a i {
        width: 18px;
        margin-right: 6px;
    }

    table {
        min-width: 640px;
    }

    .table-wrap {
        border-radius: 12px;
    }

    .mono {
        font-size: 0.78rem;
    }

    .logo-preview {
        width: 80px;
        height: 80px;
    }
}

/* =========================================
   SMALL MOBILE
========================================= */
@media (max-width: 480px) {
    .login-page {
        padding: 14px;
    }

    .login-card {
        padding: 1.4rem;
        border-radius: 24px;
        max-width: 100%;
    }

    .login-title {
        font-size: 2rem;
        line-height: 1.1;
    }

    .login-subtitle {
        font-size: 0.9rem;
    }

    .login-footer-text {
        font-size: 0.78rem;
    }

    .brand-logo-img,
    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .content {
        padding: 8px;
    }

    .card,
    .stat-card,
    .info-box,
    .upload-box,
    .mini-stat {
        padding: 12px;
        border-radius: 16px;
    }

    .sidebar-nav {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 12px;
    }

    .topbar-title strong {
        font-size: 0.92rem;
    }

    .topbar-title span {
        font-size: 0.78rem;
    }

    .section-head h2 {
        font-size: 1rem;
    }

    table {
        min-width: 580px;
    }
}
.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.12);
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.14);
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: inline-flex;
    }

    .layout {
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 86vw;
        height: 100vh;
        z-index: 1200;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        overflow-y: auto;
        padding-bottom: 20px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.55);
        z-index: 1100;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .content {
        width: 100%;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
    }

    .sidebar-nav a {
        border-radius: 0;
        background: transparent;
        margin: 0;
    }

    .sidebar-nav a:hover,
    .sidebar-nav a.active {
        border-left-color: var(--accent);
    }
}
.login-logo-icon-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px auto;
    filter: brightness(0.6) contrast(1.3);
    
}