/* ==========================================================================
   Stockatcom — admin panel
   Logical properties throughout so the panel works in English (LTR) and Arabic (RTL).
   ========================================================================== */

:root {
    --navy: #13265c;
    --navy-900: #0d1a40;
    --navy-800: #112150;
    --green: #00c255;
    --green-600: #00a84a;
    --green-50: #e8f9ef;
    --text: #13214a;
    --muted: #6b7489;
    --muted-2: #9aa3b5;
    --border: #e6eaf1;
    --bg: #f4f6fa;
    --white: #fff;
    --red: #dc2626;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 10px rgba(16, 24, 40, .04);
    /* status palette (state, never reused as series colors) */
    --st-processing: #d97706; --st-processing-bg: #fef3c7; --st-processing-fg: #92400e;
    --st-in_transit: #2563eb; --st-in_transit-bg: #dbeafe; --st-in_transit-fg: #1e40af;
    --st-delivered: #16a34a;  --st-delivered-bg: #dcfce7;  --st-delivered-fg: #166534;
    --st-cancelled: #dc2626;  --st-cancelled-bg: #fee2e2;  --st-cancelled-fg: #991b1b;
    --font: 'Outfit', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --sidebar: 248px;
}
html[lang="ar"] { --font: 'Cairo', 'Outfit', system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.link { color: var(--green-600); font-weight: 600; }
.link:hover { text-decoration: underline; }
.flip-rtl { transform: scaleX(1); }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.inline { display: inline; }

/* ---------- Shell ---------- */
.admin { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex-shrink: 0; background: var(--navy-900); color: #b9c3db; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; }
.brand svg { height: 40px; width: auto; }
.brand .brand-logo { height: 56px; width: auto; display: block; }
.brand span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green); background: rgba(0, 194, 85, .12); padding: 3px 8px; border-radius: 6px; }
.side-vendor { margin: 0 20px 6px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .06); color: #fff; font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: background .15s; }
.side-vendor span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-vendor svg { flex-shrink: 0; opacity: .6; }
.side-vendor:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.side-vendor:hover svg { opacity: 1; }
.side-nav { padding: 6px 12px 16px; flex: 1; }
.text-credit { color: var(--st-delivered); }
.text-debit { color: var(--st-cancelled); }
.kpi-icon.red { background: var(--st-cancelled-bg); color: var(--st-cancelled); }
.kpi-icon.amber { background: var(--st-processing-bg); color: var(--st-processing); }
.balance-pill { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.balance-pill small { font-weight: 500; font-size: 11px; opacity: .85; }
.balance-pill.credit { background: var(--st-delivered-bg); color: var(--st-delivered-fg); }
.balance-pill.debit { background: var(--st-cancelled-bg); color: var(--st-cancelled-fg); }
.balance-pill.settled { background: #eef1f6; color: var(--muted); }
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.account-card { padding: 20px; border-top: 4px solid transparent; }
.account-card.credit { border-top-color: var(--st-delivered); }
.account-card.debit { border-top-color: var(--st-cancelled); }
.account-card.net { border-top-color: var(--navy); }
.ac-label { font-weight: 600; color: var(--muted); }
.account-card > strong { display: block; font-size: 26px; font-weight: 700; margin-top: 4px; }
.account-card.credit > strong { color: var(--st-delivered); }
.account-card.debit > strong { color: var(--st-cancelled); }
.ac-balance { margin-top: 8px; }
.ac-balance .balance-pill { font-size: 18px; padding: 6px 14px; }
.account-card ul { margin-top: 14px; display: grid; gap: 6px; font-size: 13px; }
.account-card li { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }
.account-card li b { color: var(--text); font-weight: 600; white-space: nowrap; }
.account-card li.minus b { color: var(--muted); }
.account-card li.total { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; color: var(--text); font-weight: 600; }
.balance-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 18px 22px; margin-bottom: 16px; }
.balance-bar span { display: block; font-size: 13px; }
.balance-bar strong { font-size: 22px; font-weight: 700; color: var(--st-delivered); }
.balance-bar strong.neg { color: var(--st-cancelled); }
.balance-bar strong.pending { color: var(--st-processing); }
.payout-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.payout-list li:last-child { border-bottom: 0; }
.payout-list b { display: block; }
.payout-list small { display: block; color: var(--muted); font-size: 12px; }
.payout-list .note { color: var(--muted-2); }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item-actions input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; width: 150px; }
.track-link { color: var(--st-in_transit); font-weight: 600; }
.track-link:hover { text-decoration: underline; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #6f7c9c; padding: 18px 12px 6px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 500; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.active { background: rgba(0, 194, 85, .14); color: #fff; }
.side-nav a.active svg { color: var(--green); }
.side-nav a span { flex: 1; }
.nav-badge { background: var(--green); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
.side-store { display: flex; align-items: center; gap: 10px; margin: 0 12px 16px; padding: 11px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .1); font-weight: 500; }
.side-store:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 13px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; border-radius: 10px; color: var(--text); }
.icon-btn:hover { background: var(--bg); }
.menu-btn { display: none; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; font-weight: 500; }
.chip-btn:hover { border-color: var(--navy); }
.chip-private { background: #fff7e6; border-color: #f5c46b; color: #8a5a00; }
@media (max-width: 640px) { .chip-private span { display: none; } }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px; border-radius: 999px; }
.user-btn:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.user-name { font-weight: 600; }
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 200px; background: #fff; border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 16px 40px rgba(16, 24, 40, .14); padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 8px; text-align: start; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); }
.dropdown-menu .danger { color: var(--red); }
.content { padding: 24px 28px 56px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-900); }
.btn-light { background: #fff; border-color: var(--border); }
.btn-light:hover { border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #fff; color: var(--text); }
.btn-danger { background: #fff; border-color: #f6c5c5; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-action { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); vertical-align: middle; }
.icon-action:hover { background: var(--bg); color: var(--text); }
.icon-action.danger:hover { background: #fef2f2; color: var(--red); }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Toolbar / filters / tabs ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.push { margin-inline-start: auto; }
.filters-bar select, .filters-bar input[type="date"], .inline-form select, .inline-form input {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: 13px; outline: none;
}
.filters-bar select:focus, .filters-bar input:focus { border-color: var(--green); }
.search-box { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; flex: 1; min-width: 220px; max-width: 380px; color: var(--muted-2); }
.search-box:focus-within { border-color: var(--green); }
.search-box input { border: 0; outline: 0; padding: 9px 0; flex: 1; min-width: 0; background: transparent; font-size: 13px; color: var(--text); }
.date-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.segmented { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented a { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.segmented a.active { background: var(--navy); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--green); }
.tabs a b { font-size: 11px; background: var(--bg); color: var(--muted); padding: 1px 7px; border-radius: 999px; }
.tabs a.active b { background: var(--green-50); color: var(--green-600); }

/* ---------- Cards / KPIs ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .form-card h2 { font-size: 16px; font-weight: 700; }
.card-head .muted { font-size: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-grid.three { grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 18px 20px; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 500; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--green-50); color: var(--green-600); display: grid; place-items: center; }
.kpi-value { display: block; font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; }
.kpi-change { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 13px; font-weight: 600; }
.kpi-change small { color: var(--muted-2); font-weight: 400; margin-inline-start: 4px; }
.kpi-change.up { color: var(--st-delivered); }
.kpi-change.down { color: var(--st-cancelled); }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid > .card { padding: 20px; min-width: 0; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }

/* ---------- Revenue chart (inline SVG) ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: #eef1f6; stroke-width: 1; }
.chart .grid.base { stroke: #d8dee8; }
.chart .axis { fill: var(--muted-2); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: rgba(19, 38, 92, .07); }
.chart .crosshair { stroke: #c4ccda; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart .marker { fill: var(--navy); stroke: #fff; stroke-width: 2; opacity: 0; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart.hovering .crosshair, .chart.hovering .marker { opacity: 1; }
.chart-tip {
    position: absolute; pointer-events: none; background: var(--navy-900); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 12px;
    white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
}
.chart-tip b { display: block; font-size: 14px; }
.chart-tip small { color: #aab6d3; }

/* Orders by status: labeled horizontal bars */
.status-bars { display: grid; gap: 10px; }
.status-bars a { display: grid; grid-template-columns: 104px 1fr 32px; align-items: center; gap: 10px; padding: 4px; border-radius: 8px; }
.status-bars a:hover { background: var(--bg); }
.status-bars strong { text-align: end; }
.sb-track { height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.sb-fill { display: block; height: 100%; border-radius: 999px; min-width: 2px; }
.sb-processing { background: var(--st-processing); }
.sb-in_transit { background: var(--st-in_transit); }
.sb-delivered { background: var(--st-delivered); }
.sb-cancelled { background: var(--st-cancelled); }
.todo { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.todo h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.todo a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.todo a:hover { background: var(--bg); }
.todo a b { margin-inline-start: auto; background: var(--bg); padding: 1px 9px; border-radius: 999px; font-size: 12px; }
.mini-list li a { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 8px; }
.mini-list li a:hover { background: var(--bg); }
.mini-list img, .mini-list .ph { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.ml-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-name small { display: block; color: var(--muted-2); font-size: 12px; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef1f6; color: var(--muted); }
.pill + .pill { margin-inline-start: 4px; }
.pill-lg { padding: 6px 14px; font-size: 13px; }
.pill-processing { background: var(--st-processing-bg); color: var(--st-processing-fg); }
.pill-in_transit { background: var(--st-in_transit-bg); color: var(--st-in_transit-fg); }
.pill-delivered { background: var(--st-delivered-bg); color: var(--st-delivered-fg); }
.pill-cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled-fg); }
.pill-neutral { background: #eef1f6; color: #4a5470; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; background: #f9fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table tr[data-href] { cursor: pointer; }
.table .end { text-align: end; }
.table small { font-size: 12px; }
.table .empty, .empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.dash-grid .table th, .dash-grid .table td, .form-card .table th, .form-card .table td { padding-inline: 10px; }
.product-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.product-cell img, .product-cell .ph { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.ph { display: grid; place-items: center; background: #eef1f6; font-size: 20px; }
.product-cell b { display: block; font-weight: 600; }
.product-cell small { display: block; color: var(--muted-2); }
a.product-cell:hover b, .product-cell a:hover b { color: var(--green-600); }
.strike { display: block; color: var(--muted-2); text-decoration: line-through; }
.person { display: flex; align-items: center; gap: 12px; }
.person b { display: block; }
.person small { display: block; color: var(--muted); font-size: 12px; }
.person.big .avatar { width: 52px; height: 52px; font-size: 18px; }

/* ---------- Forms ---------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-main, .form-side { display: grid; gap: 20px; min-width: 0; }
.form-main > *, .form-side > * { min-width: 0; } /* let wide tables scroll inside their card */
.form-card { padding: 22px; }
.form-card > h2 { margin-bottom: 16px; }
.sticky { position: sticky; top: 92px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
/* Product services checklist (free installation / free delivery) */
.service-checks { display: grid; gap: 10px; }
.service-check { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border, #e7ebf2); border-radius: 10px; cursor: pointer; }
.service-check:has(input:checked) { border-color: #00c255; background: #effcf4; }
.service-check input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: #00c255; flex-shrink: 0; }
.service-check b { display: block; font-size: 14px; }
.service-check small { display: block; font-size: 12px; opacity: .7; margin-top: 2px; }
.field { margin-bottom: 16px; min-width: 0; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--red); }
.field input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]), .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #dde2ea; border-radius: 10px; background: #fff; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(0, 194, 85, .12); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.hint { display: block; font-size: 12px; color: var(--muted-2); margin-top: 5px; }
.error { display: block; font-size: 12px; color: var(--red); margin-top: 5px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.slider { display: inline-block; width: 40px; height: 22px; border-radius: 999px; background: #d5dbe5; position: relative; flex-shrink: 0; transition: background .15s; }
.slider::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .slider::after { transform: translateX(-18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--green); outline-offset: 2px; }
.switch-label { font-weight: 500; }
.form-actions { display: grid; gap: 8px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }

.media-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.media-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.dropzone {
    position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 2px dashed #d5dbe5; border-radius: 12px; overflow: hidden;
    cursor: pointer; background: #fafbfd; color: var(--muted); text-align: center; transition: border-color .15s;
}
.dropzone.small { aspect-ratio: 16 / 9; margin-bottom: 12px; }
.dropzone:hover { border-color: var(--green); }
.dropzone img { width: 100%; height: 100%; object-fit: cover; }
.dropzone span { display: grid; justify-items: center; gap: 6px; font-size: 13px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb-item, .thumb-add { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-item.new { outline: 2px solid var(--green); }
.thumb-del { position: absolute; top: 4px; inset-inline-end: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(13, 26, 64, .75); color: #fff; display: grid; place-items: center; }
.thumb-del:hover { background: var(--red); }
.thumb-add { display: grid; place-items: center; border: 2px dashed #d5dbe5; color: var(--muted); cursor: pointer; }
.thumb-add:hover { border-color: var(--green); color: var(--green); }
.thumb-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.repeater { display: grid; gap: 10px; }
.repeat-row { display: grid; gap: 10px; align-items: center; }
.repeat-row.cols-color { grid-template-columns: 44px 1fr 1fr 32px; }
.repeat-row.cols-spec { grid-template-columns: 1fr 1fr 1fr 1fr 32px; }
.repeat-row.cols-value { grid-template-columns: 56px 1fr 1fr 2fr 2fr 32px; }
.repeat-row input[type="text"] { width: 100%; padding: 9px 12px; border: 1px solid #dde2ea; border-radius: 10px; font-size: 13px; outline: none; }
.repeat-row input[type="text"]:focus { border-color: var(--green); }
.repeat-row input[type="color"] { width: 44px; height: 38px; border: 1px solid #dde2ea; border-radius: 10px; padding: 3px; background: #fff; }
.form-card .card-head { margin-bottom: 14px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; margin-top: 20px; border-color: #f6d0d0; }
.danger-zone p { color: var(--muted); font-size: 13px; }
.danger-zone.inner { margin-top: 16px; padding: 14px 0 0; border: 0; border-top: 1px solid var(--border); }

/* ---------- Order detail ---------- */
.totals { margin-top: 14px; margin-inline-start: auto; max-width: 320px; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.totals div span:last-child { color: var(--text); }
.totals .grand { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; font-weight: 700; font-size: 16px; color: var(--text); }
.timeline { display: grid; gap: 0; margin-bottom: 18px; }
.timeline li { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 7px; top: 18px; bottom: 0; width: 2px; background: #e5e9f0; }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #cfd6e1; background: #fff; flex-shrink: 0; margin-top: 2px; position: relative; }
.timeline li.done .dot { background: var(--st-delivered); border-color: var(--st-delivered); }
.timeline li.done::before { background: #bfe8cd; }
.timeline li.red .dot { background: var(--st-cancelled); border-color: var(--st-cancelled); }
.timeline b { display: block; font-weight: 600; }
.timeline small { color: var(--muted-2); }
.timeline li:not(.done) b { color: var(--muted-2); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.status-form { display: grid; gap: 8px; }
.radio-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--green); background: #f6fdf9; }
.radio-card input { accent-color: var(--green); }
.status-form .btn { margin-top: 6px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin-top: 14px; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { font-weight: 500; text-align: start; }
.info.wide { grid-template-columns: 180px 1fr; font-size: 14px; gap: 14px 20px; }
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.doc-item { display: grid; gap: 8px; align-content: start; font-size: 13px; }
.doc-preview { display: grid; place-items: center; height: 180px; border: 1px solid #dde2ea; border-radius: 10px; overflow: hidden; background: #f6f8fb; }
.doc-preview img { width: 100%; height: 100%; object-fit: contain; }
.doc-pdf { font-weight: 800; font-size: 22px; color: #c0392b; }
@media (max-width: 560px) { .doc-grid { grid-template-columns: 1fr; } }
.address { padding: 12px 0; border-bottom: 1px solid var(--border); }
.address:last-child { border-bottom: 0; }
.address p { color: var(--muted); margin-top: 4px; }

/* ---------- Categories tree ---------- */
.cat-tree-admin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tree-card { padding: 16px; min-width: 0; }
.tree-root { display: flex; align-items: center; gap: 12px; }
.tree-root img, .tree-root .ph { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.tree-title { flex: 1; min-width: 0; }
.tree-title b, .tree-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-title b { display: block; font-size: 15px; }
.tree-title small { color: var(--muted-2); }
.tree-children { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 6px; }
.tree-children li { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 16px; border-radius: 8px; }
[dir="rtl"] .tree-children li { padding: 6px 16px 6px 4px; }
.tree-children li:hover { background: var(--bg); }
.tc-name { flex: 1; font-weight: 500; }

/* ---------- Reviews / inbox / FAQ ---------- */
.review-list { display: grid; gap: 12px; }
.review-item { padding: 16px 18px; }
.ri-head { display: flex; align-items: center; gap: 12px; }
.ri-head > div { flex: 1; }
.ri-head b { display: block; }
.stars { color: #f5b301; letter-spacing: 1px; font-size: 13px; }
.stars i { color: #dfe3ea; font-style: normal; }
.review-item p { margin-top: 10px; color: #3d4866; }
.ri-product { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--green-600); font-weight: 600; }
.ri-product:hover { text-decoration: underline; }
.inbox { overflow: hidden; }
.inbox-row { display: grid; grid-template-columns: 34px 220px 1fr auto; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: #fafbfd; }
.inbox-row.unread { background: #f6fbff; }
.inbox-row.unread b, .inbox-row.unread .ib-body { font-weight: 600; }
.ib-from small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.ib-body { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row time { font-size: 12px; white-space: nowrap; }
.message-view .pre { margin-top: 18px; font-size: 15px; line-height: 1.7; }
/* Admin replies under a message, then the reply box */
.message-reply, .reply-form { margin-top: 16px; }
.message-reply { border-inline-start: 3px solid var(--green); background: #fbfefc; }
.message-reply .avatar { background: var(--green); }
.text-green { color: var(--st-delivered-fg); }
.text-red { color: var(--red); }
.faq-admin li { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.faq-admin li:last-child { border-bottom: 0; }
.faq-admin li > div:not(.row-actions) { flex: 1; }
.faq-admin p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.faq-admin .sort { color: var(--muted-2); font-size: 12px; min-width: 28px; padding-top: 2px; }

/* ---------- Pagination + toast ---------- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 20px; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; font-size: 13px; }
.pagination a:hover { border-color: var(--navy); }
.pagination .active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .disabled { color: var(--muted-2); background: #f7f8fa; }
.toast {
    position: fixed; z-index: 100; inset-inline-end: 24px; bottom: 24px; max-width: 400px; display: flex; align-items: center; gap: 10px;
    background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 12px 32px rgba(13, 26, 64, .3); animation: toast-in .25s ease-out;
}
.toast.success svg { color: var(--green); }
.toast.error { background: #991b1b; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; font-size: 18px; padding: 0 0 0 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .form-layout { grid-template-columns: minmax(0, 1fr); }
    .sticky { position: static; }
    .cat-tree-admin { grid-template-columns: 1fr; }
    .account-grid { grid-template-columns: 1fr 1fr; }
    .account-card.net { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); transition: transform .25s ease; }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(13, 26, 64, .45); z-index: 35; }
    .menu-btn { display: inline-grid; }
    .topbar { padding: 12px 16px; }
    .content { padding: 18px 16px 48px; }
    .user-name { display: none; }
}
@media (max-width: 640px) {
    .kpi-grid, .kpi-grid.three { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 20px; }
    .kpi-change small { display: none; }
    .grid-2, .grid-3, .media-grid { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .repeat-row.cols-spec { grid-template-columns: 1fr 1fr; }
    .repeat-row.cols-spec [data-repeat-remove] { grid-column: 1 / -1; justify-self: end; }
    .repeat-row.cols-value { grid-template-columns: 56px 1fr; }
    .repeat-row.cols-value input:nth-child(n+3) { grid-column: 1 / -1; }
    .repeat-row.cols-value [data-repeat-remove] { grid-column: 1 / -1; justify-self: end; }
    .search-box { max-width: none; min-width: 100%; }
    .filters-bar select { flex: 1; }
    .push { margin-inline-start: 0; }
    .inbox-row { grid-template-columns: 34px 1fr; }
    .inbox-row .ib-body, .inbox-row time { grid-column: 2; }
    .info.wide { grid-template-columns: 1fr; gap: 4px; }
    .info.wide dd { margin-bottom: 10px; }
    .topbar-title p { display: none; }
    .chip-btn { padding: 6px 10px; }
    .danger-zone { flex-direction: column; align-items: flex-start; }
    .toast { inset-inline: 16px; bottom: 16px; max-width: none; }
    .status-bars a { grid-template-columns: 96px 1fr 28px; }
    .tree-root { flex-wrap: wrap; }
    .tree-root .row-actions { margin-inline-start: auto; }
    .tree-children li { flex-wrap: wrap; }
    .balance-bar { grid-template-columns: 1fr; }
    .account-grid { grid-template-columns: 1fr; }
    .table th, .table td { white-space: nowrap; padding: 10px 12px; }
    .product-cell { min-width: 0; }
}

/* ---------- Control-panel login ---------- */
.login-page { background: #fff; }
.login-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-brand {
    color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px;
    background: radial-gradient(600px 400px at 85% 15%, rgba(0, 194, 85, .25), transparent 70%), linear-gradient(160deg, var(--navy-900), var(--navy));
}
.login-brand svg { height: 64px; width: auto; align-self: flex-start; }
.login-brand .brand-logo { height: 110px; width: auto; align-self: flex-start; }
.login-brand h1 { font-size: 34px; font-weight: 700; }
.login-brand p { color: #c9d3e8; font-size: 16px; max-width: 420px; line-height: 1.6; }
.login-brand ul { display: grid; gap: 10px; margin-top: 8px; color: #dbe2f1; }
.login-brand li { display: flex; align-items: center; gap: 10px; }
.login-brand li svg { color: var(--green); height: 16px; }
.login-form-wrap { display: flex; flex-direction: column; padding: 24px 40px; background: var(--bg); }
.login-top { display: flex; justify-content: flex-end; }
.login-card { width: 100%; max-width: 400px; margin: auto; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: 0 20px 50px rgba(16, 24, 40, .08); }
.login-card h2 { font-size: 26px; font-weight: 700; margin-top: 14px; }
.login-card > .muted { margin: 4px 0 20px; }
.login-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--green-50); color: var(--green-600); font-size: 12px; font-weight: 600; }
.login-demo { display: grid; gap: 2px; background: #f6f8fb; border: 1px dashed #d5dbe5; border-radius: 10px; padding: 10px 12px; margin-bottom: 18px; font-size: 12px; color: var(--muted); }
.login-demo b { color: var(--text); }
.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: -4px 0 18px; cursor: pointer; }
.remember input { accent-color: var(--green); }
.login-btn { padding: 12px; font-size: 15px; }
.login-back { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-back:hover { color: var(--text); }
@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 32px 24px; gap: 10px; }
    .login-brand ul, .login-brand p { display: none; }
    .login-brand h1 { font-size: 24px; }
    .login-brand svg { height: 48px; }
    .login-brand .brand-logo { height: 76px; }
    .login-form-wrap { padding: 16px; }
    .login-card { padding: 24px 20px; margin-top: 8px; }
}

/* ---------- Motion (control panel) ---------- */
.js-anim .topbar-title { animation: fade-up .6s cubic-bezier(.22, 1, .36, 1) both; }
.kpi, .tree-card, .review-item, .account-card { transition: transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .35s; }
.kpi:hover, .tree-card:hover, .account-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(16, 24, 40, .1); }
.kpi-icon { transition: transform .4s cubic-bezier(.34, 1.56, .64, 1); }
.kpi:hover .kpi-icon { transform: rotate(-10deg) scale(1.12); }
.side-nav a { transition: background .2s, color .2s, padding .25s cubic-bezier(.22, 1, .36, 1); }
.side-nav a:hover { padding-inline-start: 18px; }
.nav-badge { animation: dot-pulse 2.4s ease-in-out infinite; }
.table tbody tr { transition: background .2s; }
.sb-fill { transform-origin: left; animation: grow-x 1.2s cubic-bezier(.22, 1, .36, 1) both; }
[dir="rtl"] .sb-fill { transform-origin: right; }
.chart .line { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: draw-line 2s cubic-bezier(.22, 1, .36, 1) .2s forwards; }
.chart .area { animation: fade-in 1.2s ease .8s both; }
.login-card { animation: scale-in .6s cubic-bezier(.22, 1, .36, 1) both; }
.login-brand > * { animation: fade-up .8s cubic-bezier(.22, 1, .36, 1) both; }
.login-brand > *:nth-child(2) { animation-delay: .1s; }
.login-brand > *:nth-child(3) { animation-delay: .2s; }
.login-brand > *:nth-child(4) { animation-delay: .3s; }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw-line { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .chart .line { stroke-dasharray: none; stroke-dashoffset: 0; } }

/* ---------- Home ads ---------- */
.theme-navy { --promo: linear-gradient(120deg, #13265c, #1f4aa0); }
.theme-green { --promo: linear-gradient(120deg, #00843a, #00c255); }
.theme-orange { --promo: linear-gradient(120deg, #e2401f, #ff8a2b); }
.theme-purple { --promo: linear-gradient(120deg, #4a2a8a, #8a4fd8); }
.theme-teal { --promo: linear-gradient(120deg, #0d5c63, #14a3a0); }
.section-switch { display: flex; align-items: center; gap: 14px; padding: 16px 18px; margin-bottom: 18px; border-inline-start: 4px solid var(--border); }
.section-switch.on { border-inline-start-color: var(--green); }
.section-switch strong { display: block; font-size: 15px; }
.section-switch small { color: var(--muted); font-size: 13px; }
.section-switch-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #f2f4f8; color: var(--muted); }
.section-switch.on .section-switch-icon { background: var(--green-50); color: var(--green-600); }
.section-switch .push { margin-inline-start: auto; flex: none; }
.promo-thumb { width: 72px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--promo); flex: none; display: block; }
.promo-thumb img { width: 100% !important; height: 100% !important; object-fit: cover; opacity: .85; border-radius: 0 !important; }
.theme-picker { display: flex; gap: 10px; margin-bottom: 16px; }
.theme-picker label { cursor: pointer; position: relative; }
.theme-picker input { position: absolute; opacity: 0; pointer-events: none; }
.theme-picker span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--promo); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--border); transition: box-shadow .15s; }
.theme-picker input:checked + span { box-shadow: 0 0 0 2px var(--navy); }
.theme-picker input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
@media (max-width: 640px) { .section-switch { flex-wrap: wrap; } .section-switch .push { width: 100%; } }
