:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --warning: #d97706;
    --warning-soft: #fff7ed;
    --radius: 18px;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    color: var(--text);
    background: #eef2ff;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

strong {
    font-weight: 700;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #1e3a8a, #0f172a 50%, #020617 100%);
}

.login-card {
    width: 100%;
    max-width: 460px;
    background: rgba(255,255,255,0.98);
    border-radius: 26px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.28);
    padding: 32px;
}

.login-brand,
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
}

.login-brand h1,
.brand h1 {
    margin: 0;
    font-size: 1.5rem;
}

.login-brand p,
.brand p,
.topbar p,
.panel-head p,
.login-note,
.muted,
.info-label,
.stat-label {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.app-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    padding: 28px 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand h1,
.sidebar .brand p {
    color: #fff;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 28px;
}

.nav-links a {
    color: #dbeafe;
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.main-content {
    padding: 28px;
}

.topbar {
    margin-bottom: 24px;
}

.topbar h2,
.panel-head h3 {
    margin: 0;
    font-size: 1.55rem;
}

.panel {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.6);
    padding: 24px;
    margin-bottom: 24px;
}

.panel-head {
    margin-bottom: 18px;
}

.panel-head-row,
.actions-row,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.narrow-panel {
    max-width: 900px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.stat-card-warning {
    background: linear-gradient(180deg, #fff7ed, #fffbeb);
    border-color: #fed7aa;
}

.stat-value {
    display: block;
    font-size: 2rem;
    margin-top: 10px;
}

.content-grid {
    display: grid;
    gap: 24px;
}

.two-col {
    grid-template-columns: 380px 1fr;
}

.two-col-wide {
    grid-template-columns: 1.1fr 1fr;
}

.single-mobile {
    grid-template-columns: 1fr;
}

.form-panel {
    align-self: start;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: 2fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 700;
    font-size: 0.95rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.btn-secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-ghost {
    background: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.btn-small {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.88rem;
}

.alert {
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    font-weight: 600;
}

.alert-success {
    background: var(--success-soft);
    border-color: #bbf7d0;
    color: #166534;
}

.alert-danger {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #991b1b;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

thead th {
    text-align: left;
    padding: 14px 12px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: top;
}

tbody tr:hover {
    background: #f8fbff;
}

.empty-row {
    text-align: center;
    color: var(--muted);
    padding: 22px !important;
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 18px;
}

.info-label {
    display: block;
    margin-bottom: 6px;
}

.text-danger {
    color: var(--danger);
    font-weight: 700;
}

.toolbar input {
    min-width: 320px;
    flex: 1;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col,
    .two-col-wide {
        grid-template-columns: 1fr;
    }

    .form-grid-4,
    .form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

    .main-content {
        padding: 18px;
    }

    .stats-grid,
    .form-grid-2,
    .form-grid-3,
    .form-grid-4,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .toolbar input {
        min-width: 0;
        width: 100%;
    }
}

.product-thumb {
    width: 58px  !important;
    height: 58px !important;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #f8fafc;
}
.product-thumb-large {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #f8fafc;
}
.current-image-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fafc;
}
.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.checkbox-row input { width: auto; }
.image-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}
table td img {
    max-width: 58px;
    max-height: 58px;
    width: 58px;
    height: 58px;
    object-fit: cover;
    display: block;
}
td:first-child {
    width: 70px;
    min-width: 70px;
}

/* Hard fix product photos in product table */
td > img.product-thumb {
    width: 58px !important;
    height: 58px !important;
    max-width: 58px !important;
    max-height: 58px !important;
    object-fit: cover !important;
    display: block !important;
}
.product-thumb {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: zoom-in;
    position: relative;
    z-index: 1;
}

.product-thumb:hover {
    transform: scale(3);
    position: absolute;
    z-index: 9999;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.table-wrap {
    overflow: visible !important;
}

table {
    overflow: visible !important;
}
.image-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    background: #fff;
    padding: 10px;
    cursor: zoom-out;
}