:root {
    --forest: #006653;
    --evergreen: #087f68;
    --jade: #21ad91;
    --lime: #b8e75b;
    --cream: #f8fbf8;
    --mist: #eff4f1;
    --ink: #18372f;
    --muted: #5d7a71;
    --line: rgba(0, 102, 83, 0.12);
    --danger: #a3372a;
    --shadow: 0 24px 60px -34px rgba(0, 63, 50, 0.45);
    --shadow-sm: 0 10px 30px -22px rgba(0, 63, 50, 0.5);
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

.boot-screen {
    min-height: 100vh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.boot-mark {
    width: 46px; height: 46px; border-radius: 14px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--lime), var(--jade) 55%, var(--forest));
    color: #fff; font-weight: 800; font-size: 15px; letter-spacing: 0;
}

/* ---------------------------------------------------------------- Shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 256px;
    flex: 0 0 256px;
    background: linear-gradient(180deg, #006653 0%, #005243 100%);
    color: #fff;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 13px; flex: none;
    background: linear-gradient(140deg, var(--lime), var(--jade) 55%, var(--forest));
    display: grid; place-items: center;
    font-weight: 800; color: var(--forest); font-size: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.brand-text strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255, 255, 255, 0.48); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    padding: 0 10px 6px;
    font-size: 9.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.34);
}
.nav-link {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-radius: 11px;
    font-weight: 600; font-size: 13px; color: rgba(255, 255, 255, 0.72);
    transition: background 0.18s ease, color 0.18s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-link.active { background: rgba(184, 231, 91, 0.16); color: var(--lime); }
.nav-count {
    min-width: 24px; height: 20px; padding: 0 7px;
    display: inline-grid; place-items: center;
    border-radius: 999px; background: rgba(255, 255, 255, 0.1);
    font-size: 10.5px; font-weight: 800; color: rgba(255, 255, 255, 0.78);
}
.nav-link.active .nav-count { background: rgba(184, 231, 91, 0.22); color: var(--lime); }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 16px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 0 4px 12px; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.12);
    font-weight: 800; font-size: 12px; color: var(--lime);
}
.user-name { font-size: 12px; font-weight: 700; }
.user-email { font-size: 10.5px; color: rgba(255, 255, 255, 0.45); word-break: break-all; }
.signout {
    width: 100%; height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #fff; border-radius: 999px;
    font-size: 11.5px; font-weight: 800; cursor: pointer;
    transition: background 0.18s ease;
}
.signout:hover { background: rgba(255, 255, 255, 0.16); }

.main { flex: 1; min-width: 0; padding: 28px 34px 64px; }
.topbar {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 18px; flex-wrap: wrap; margin-bottom: 24px;
}
.eyebrow {
    margin: 0 0 6px; font-size: 10px; font-weight: 800;
    letter-spacing: 0.18em; text-transform: uppercase; color: var(--jade);
}
.topbar h1 { font-size: 27px; }
.topbar .sub { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 40px; padding: 0 20px; border-radius: 999px;
    font-size: 12.5px; font-weight: 800; cursor: pointer; border: 0;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--evergreen); }
.btn-lime { background: var(--lime); color: var(--forest); }
.btn-lime:hover { background: #c8f075; }
.btn-ghost { background: #fff; color: var(--forest); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--forest); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid rgba(163, 55, 42, 0.28); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 11.5px; }
.btn-link { background: none; border: 0; color: var(--forest); font-weight: 800; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Cards + stats */
.card {
    background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; }
.card-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.card-body { padding: 22px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat span { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat strong { display: block; margin-top: 6px; font-size: 27px; letter-spacing: -0.03em; }
.stat.accent { background: linear-gradient(150deg, #006653, #087f68); color: #fff; border-color: transparent; }
.stat.accent span { color: rgba(255, 255, 255, 0.55); }
.stat.accent strong { color: var(--lime); }

/* ---------------------------------------------------------------- Flash / errors */
.flash {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 18px; padding: 12px 16px; border-radius: 12px;
    font-size: 13px; font-weight: 600;
    background: rgba(33, 173, 145, 0.12); border: 1px solid rgba(33, 173, 145, 0.3);
    color: #0a5a4a;
}
.flash.error { background: rgba(163, 55, 42, 0.07); border-color: rgba(163, 55, 42, 0.24); color: #8f3125; }

.form-error {
    margin: 0; padding: 12px 16px 12px 32px; border-radius: 12px;
    background: rgba(163, 55, 42, 0.06); border: 1px solid rgba(163, 55, 42, 0.22);
    color: #8f3125; font-size: 12.5px;
}
.form-error li + li { margin-top: 4px; }

/* ---------------------------------------------------------------- Toolbar + fields */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label {
    font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--muted);
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
    width: 100%; font-size: 13px; color: var(--ink);
    background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
    padding: 9px 12px; outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
input[type="file"] { background: #fff; padding: 8px 10px; font-size: 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--jade); background: #fff; box-shadow: 0 0 0 3px rgba(33, 173, 145, 0.12); }
input.invalid, select.invalid, textarea.invalid { border-color: rgba(163, 55, 42, 0.6); }
textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
.grow { flex: 1 1 220px; }
.help { font-size: 11px; color: var(--muted); }
.field-error { font-size: 11px; font-weight: 600; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }

/* ---------------------------------------------------------------- Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); background: var(--mist); white-space: nowrap; }
tbody tr:hover { background: rgba(239, 244, 241, 0.5); }
tbody tr:last-child td { border-bottom: 0; }
.thumb {
    width: 46px; height: 58px; border-radius: 9px; background: var(--mist);
    overflow: hidden; display: block; border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.name-cell { min-width: 210px; }
.name-en { display: block; font-weight: 700; font-size: 13px; }
.name-ar { display: block; font-size: 12px; color: var(--muted); }
.slug { display: block; font-family: ui-monospace, "Cascadia Code", monospace; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    height: 23px; padding: 0 10px; border-radius: 999px;
    font-size: 10.5px; font-weight: 800; white-space: nowrap;
}
.pill + .pill { margin-left: 4px; }
.pill.on { background: rgba(33, 173, 145, 0.14); color: #0a6b56; }
.pill.off { background: rgba(93, 122, 113, 0.14); color: #4b625b; }
.pill.featured { background: rgba(184, 231, 91, 0.35); color: #4a6512; }
.pill.tag { background: var(--mist); color: var(--forest); }
.table-wrap td { white-space: nowrap; }
.actions-col { text-align: center; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; justify-content: center; }
.icon-btn {
    width: 30px; height: 30px; padding: 0; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; border: 1px solid var(--line); background: #fff;
    color: var(--forest); cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.icon-btn svg {
    width: 15px; height: 15px; fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn:hover { border-color: var(--forest); background: var(--mist); }
.icon-btn.active { border-color: rgba(154, 199, 61, 0.65); background: rgba(184, 231, 91, 0.3); color: #4a6512; }
.icon-btn.active svg { fill: currentColor; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: rgba(163, 55, 42, 0.08); border-color: rgba(163, 55, 42, 0.4); }

.empty { padding: 56px 22px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

.pagination { display: flex; gap: 6px; padding: 14px 20px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); }
.pagination p { margin: 0 auto 0 0; font-size: 11.5px; color: var(--muted); }
.page-btn {
    min-width: 32px; height: 32px; padding: 0 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 8px;
    background: #fff; font-size: 12px; font-weight: 700; color: var(--forest); cursor: pointer;
}
.page-btn:hover:not(:disabled) { border-color: var(--forest); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn.current { background: var(--forest); color: #fff; border-color: var(--forest); }

/* ---------------------------------------------------------------- Product form */
.form { padding: 22px; display: grid; gap: 26px; }
.form-section { display: grid; gap: 14px; }
.form-section h2 {
    font-size: 15px; display: flex; align-items: center; gap: 9px;
    padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.form-section h2::before { content: ""; width: 4px; height: 16px; border-radius: 3px; background: var(--jade); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.lang-ar input, .lang-ar textarea { direction: rtl; text-align: right; }
.check-row { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--forest); }
.image-box { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.image-preview {
    width: 104px; height: 132px; border-radius: 12px; background: var(--mist);
    border: 1px solid var(--line); overflow: hidden;
    display: grid; place-items: center; font-size: 10px; color: var(--muted); text-align: center; padding: 6px;
}
.image-preview img { width: 100%; height: 100%; object-fit: contain; }
.form-actions {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 16px 22px; border-top: 1px solid var(--line); background: var(--mist);
    position: sticky; bottom: 0; z-index: 2;
}
.form-actions .spacer { flex: 1; }

/* ---------------------------------------------------------------- Settings */
.settings-list { display: grid; gap: 0; }
.setting-row {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
    padding: 20px 0; border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-copy { max-width: 560px; }
.setting-copy strong { display: block; font-size: 14px; margin-bottom: 4px; }
.setting-copy p { margin: 0; font-size: 12.5px; color: var(--muted); }
.setting-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--muted); }
.setting-meta code { font-size: 11px; background: var(--mist); padding: 1px 6px; border-radius: 5px; }

.switch { position: relative; display: inline-flex; flex: none; width: 46px; height: 26px; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch-track {
    position: absolute; inset: 0; border-radius: 999px;
    background: rgba(93, 122, 113, 0.28);
    transition: background 0.2s ease;
}
.switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%; background: #fff;
    box-shadow: 0 2px 6px rgba(0, 63, 50, 0.25);
    transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--forest); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(33, 173, 145, 0.25); }

/* ---------------------------------------------------------------- Auth */
.auth-screen {
    min-height: 100vh; display: grid; place-items: center; padding: 28px;
    background:
        radial-gradient(65% 55% at 10% 0%, rgba(184, 231, 91, 0.32), transparent 70%),
        radial-gradient(60% 55% at 95% 100%, rgba(33, 173, 145, 0.3), transparent 70%),
        var(--cream);
}
.auth-card {
    width: 100%; max-width: 412px; background: #fff;
    border: 1px solid var(--line); border-radius: 24px;
    padding: 30px; box-shadow: 0 34px 80px -44px rgba(0, 63, 50, 0.6);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-card h1 { font-size: 23px; margin-bottom: 4px; }
.auth-sub { margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.auth-card label { display: block; margin-bottom: 6px; }
.auth-card .field { margin-bottom: 15px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-note {
    margin-top: 18px; padding: 12px 14px; border-radius: 12px;
    background: var(--mist); font-size: 11.5px; color: var(--muted); text-align: center;
}
.auth-footer { margin-top: 20px; text-align: center; font-size: 11px; color: var(--muted); }
.error-box {
    margin-bottom: 16px; padding: 11px 14px; border-radius: 11px;
    background: rgba(163, 55, 42, 0.07); border: 1px solid rgba(163, 55, 42, 0.22);
    color: #8f3125; font-size: 12.5px;
}
.dev-code {
    margin: 0 0 16px; padding: 11px 14px; border-radius: 11px;
    background: rgba(184, 231, 91, 0.22); border: 1px dashed rgba(0, 102, 83, 0.35);
    color: #2f4a12; font-size: 12px;
}
.dev-code strong { letter-spacing: 0.18em; font-size: 14px; }
.otp-input {
    text-align: center; font-size: 26px !important; letter-spacing: 0.32em;
    font-weight: 700; padding: 12px 8px 12px 16px !important;
}
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.auth-links a, .auth-links button { font-size: 12px; font-weight: 700; color: var(--forest); }
.auth-links a:hover, .auth-links button:hover { text-decoration: underline; }
.auth-links button { background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------------------------------------------------------------- Skeleton */
.skeleton {
    border-radius: 12px;
    background: linear-gradient(100deg, var(--mist) 30%, #f8fbf8 50%, var(--mist) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.skeleton-stack { display: grid; gap: 14px; padding: 22px; }
.skeleton-stack .skeleton { height: 18px; }
.skeleton-stack .skeleton:nth-child(2n) { width: 78%; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

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

@media (max-width: 960px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto; position: static;
        flex-direction: row; align-items: center; gap: 12px;
        padding: 12px 16px; flex-wrap: wrap;
    }
    .brand-text span { display: none; }
    .nav { flex-direction: row; margin-left: auto; gap: 2px; }
    .nav-label { display: none; }
    .nav-link { padding: 8px 11px; }
    .nav-count { display: none; }
    .sidebar-foot { margin: 0; border: 0; padding: 0; }
    .user-card { display: none; }
    .signout { width: auto; padding: 0 14px; height: 32px; }
    .main { padding: 22px 18px 52px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .topbar h1 { font-size: 22px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 13px 14px; }
    .stat strong { font-size: 22px; }
    .toolbar { padding: 14px; }
    .form { padding: 16px; }
    .card-body { padding: 16px; }
    .setting-row { flex-direction: column; gap: 12px; }
    .auth-card { padding: 24px; }
}

/* ------------------------------------------------------- Selection & delete modal */
body.modal-open { overflow: hidden; }
.select-col { width: 44px; }
.select-col input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--forest);
    cursor: pointer; margin: 0; display: block;
}
tbody tr.selected { background: rgba(184, 231, 91, 0.16); }
.bulk-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 20px; border-bottom: 1px solid var(--line);
    background: rgba(184, 231, 91, 0.18);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar strong { font-size: 12px; color: var(--forest); margin-right: auto; }

.modal-backdrop {
    position: fixed; inset: 0; z-index: 90;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(10, 32, 25, 0.52);
}
.modal {
    width: 100%; max-width: 440px; background: #fff;
    border-radius: 16px; padding: 24px;
    display: grid; gap: 14px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 26px 70px rgba(10, 32, 25, 0.32);
}
.modal-head { display: flex; gap: 14px; align-items: flex-start; }
.modal-head h2 { font-size: 17px; margin: 0 0 6px; }
.modal-head p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.modal-icon {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(163, 55, 42, 0.1); color: var(--danger);
}
.modal-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.modal-list {
    list-style: none; margin: 0; padding: 12px 14px;
    background: var(--mist); border-radius: 10px;
    font-size: 12px; color: var(--forest); display: grid; gap: 4px;
}
.modal .field { margin: 0; }
.modal .otp-input { text-align: center; letter-spacing: 0.4em; font-size: 18px; font-weight: 800; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.modal-actions .btn { flex: 0 0 auto; }
