:root {
    --bg: #f4f6f8;
    --text: #1f2937;
    --card-bg: #ffffff;
    --border: #cbd5e1;
    --th-bg: #f1f5f9;
    --th-text: #334155;
    --row-hover: #f8fafc;
    --muted: #94a3b8;
    --badge-bg: #e2e8f0;
    --badge-text: #334155;
    --shadow: rgba(0,0,0,.08);
    --brand: #1f4e78;
    --brand-hover: #163a5c;
}
:root[data-theme="dark"] {
    --bg: #0f172a;
    --text: #e5e7eb;
    --card-bg: #1e293b;
    --border: #334155;
    --th-bg: #17263c;
    --th-text: #cbd5e1;
    --row-hover: #24334a;
    --muted: #8899b0;
    --badge-bg: #334155;
    --badge-text: #cbd5e1;
    --shadow: rgba(0,0,0,.35);
    --brand: #1f4e78;
    --brand-hover: #2c6099;
}
* { box-sizing: border-box; }
body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    direction: rtl;
}
header.top {
    background: var(--brand);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
header.top .brand {
    font-size: 18px; font-weight: bold; color: #fff; text-decoration: none;
    display: flex; align-items: center; gap: 10px;
}
.brand-logo { height: 36px; width: auto; }
.auth-wrap {
    position: relative;
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #163a5c 0%, #0b1f33 65%, #05101c 100%);
    border-radius: 16px;
    padding: 50px 20px;
    overflow: hidden;
}
.auth-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('logo_small.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: min(480px, 70%);
    opacity: .16;
    pointer-events: none;
}
.auth-wrap .card { position: relative; background: var(--card-bg); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.site-footer {
    max-width: 1100px; margin: 40px auto 20px; padding: 16px;
    text-align: center; color: var(--muted); font-size: 13px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;
}
nav.main { display: flex; align-items: center; }
nav.main a {
    color: #dbe9f7;
    text-decoration: none;
    margin-inline-start: 18px;
    font-size: 15px;
}
nav.main a:hover, nav.main a.active { color: #fff; text-decoration: underline; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.flash {
    background: #d1fae5;
    border: 1px solid #10b981;
    color: #065f46;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}
:root[data-theme="dark"] .flash { background: #064e3b; border-color: #10b981; color: #a7f3d0; }
.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px var(--shadow);
    margin-bottom: 20px;
}
h1, h2 { color: var(--text); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
input[type=text], input[type=number], input[type=search], input[type=date],
input[type=password], select, textarea {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 180px; }
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    align-items: start;
}
.cards-grid > .card { margin-bottom: 0; }
button, .btn {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover { background: var(--brand-hover); }
.btn.secondary { background: #64748b; }
.cat-btn {
    font-size: 16px !important;
    padding: 14px 22px !important;
    border-radius: 10px !important;
    font-weight: 600;
}
.cat-btn.active-cat { background: #0c4a6e; box-shadow: 0 0 0 3px #7dd3fc inset; }
.btn.danger { background: #dc2626; }
.btn.small { padding: 5px 10px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); }
th { background: var(--th-bg); color: var(--th-text); }
tr:hover { background: var(--row-hover); }
.muted { color: var(--muted); font-size: 12px; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--badge-bg);
    color: var(--badge-text);
}
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.low { background: #fee2e2; color: #991b1b; }
:root[data-theme="dark"] .badge.warn { background: #78350f; color: #fde68a; }
:root[data-theme="dark"] .badge.low { background: #7f1d1d; color: #fecaca; }
.search-box { margin-bottom: 18px; }
.search-box input { font-size: 16px; padding: 12px 14px; }
.cart-total { font-size: 20px; font-weight: bold; }
.stat-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.stat {
    flex: 1;
    min-width: 160px;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 1px 3px var(--shadow);
}
.stat .num { font-size: 26px; font-weight: bold; color: var(--brand); }
:root[data-theme="dark"] .stat .num { color: #7dd3fc; }
.stat .label { font-size: 13px; color: var(--muted); }
form.inline { display: inline; }

/* لوحة الأيقونات الرئيسية */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 22px;
}
.tile {
    background: var(--card-bg);
    border-radius: 18px;
    box-shadow: 0 1px 3px var(--shadow);
    padding: 38px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    transition: transform .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 6px 16px var(--shadow); }
.tile .tile-icon { font-size: 56px; }
.tile .tile-label { font-size: 17px; font-weight: 600; }

.price-preview-box { background: #f0f9ff; border: 1px solid #bae6fd; padding: 12px; }
.price-preview-box .price-preview-value { color: #0c4a6e; }
:root[data-theme="dark"] .price-preview-box { background: #0c2d42; border-color: #0e4a68; }
:root[data-theme="dark"] .price-preview-box .price-preview-value { color: #7dd3fc; }

.warn-flash { background: #fef3c7; border-color: #f59e0b !important; color: #92400e; }
:root[data-theme="dark"] .warn-flash { background: #78350f; color: #fde68a; }

#ai-fab {
    position: fixed; bottom: 24px; left: 24px; z-index: 999;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--brand); color: #fff; border: none; font-size: 26px;
    box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer;
}
#ai-fab:hover { background: var(--brand-hover); }
#ai-fab-panel {
    display: none; position: fixed; bottom: 90px; left: 24px; z-index: 999;
    width: 320px; max-width: calc(100vw - 48px); background: var(--card-bg);
    border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.35); padding: 14px;
    border: 1px solid var(--border);
}
