/* =====================================================================
   TailorSys — تصميم الواجهة (كحلي + ذهبي)
   الألوان الأساسية قابلة للتغيير من الإعدادات عبر المتغيرين --brand و --accent
   اللذين يُضبطان على وسم <html>. كل الاتجاهات تستخدم خصائص منطقية
   (inline-start/end) فتعمل في العربية (RTL) والإنجليزية/الفرنسية (LTR).
   ===================================================================== */

:root {
    --brand: #13233D;
    --accent: #C9A24A;
    --brand-deep: color-mix(in srgb, var(--brand) 82%, #000);
    --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, #fff);
    --accent-strong: color-mix(in srgb, var(--accent) 78%, #000);

    --bg: #F4F2EE;
    --surface: #FFFFFF;
    --border: #E6E1D8;
    --text: #1C2330;
    --muted: #6B7280;

    --sidebar-w: 18.75rem;
    --topbar-h: 4rem;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);

    --bs-body-font-family: "Droid Arabic Kufi", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 19, 35, 61;
    --bs-link-hover-color: var(--accent-strong);
    --bs-focus-ring-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/*
 * حجم الخط الأساسي يكبر مع عرض الشاشة. كل المقاسات في الواجهة بوحدة rem،
 * فتكبر النصوص والأزرار والحقول والقائمة الجانبية معاً بنفس النسبة.
 */
html {
    -webkit-text-size-adjust: 100%;
    font-size: 106.25%; /* 17px */
}
@media (min-width: 1400px) { html { font-size: 112.5%; } }   /* 18px */
@media (min-width: 1800px) { html { font-size: 118.75%; } }  /* 19px */
@media (min-width: 2400px) { html { font-size: 131.25%; } }  /* 21px — شاشات 2K/4K */

body {
    font-family: var(--bs-body-font-family);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.75;
}

/* أرقام لاتينية بعرض ثابت في الجداول والمبالغ */
table, .stat-value, .clock, .code-chip, time { font-variant-numeric: tabular-nums; }

/* ===== إمكانية الوصول ===== */
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
.form-control:focus, .form-select:focus, .form-check-input:focus, .btn:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 .22rem var(--bs-focus-ring-color);
}

/* أيقونات الاتجاه: تنعكس في الواجهات من اليسار لليمين */
[dir="ltr"] .flip-rtl { display: inline-block; transform: scaleX(-1); }

/* ===================== الهيكل العام ===================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-deep) 100%);
    color: #E8ECF3;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.main {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.content {
    padding: 1.5rem;
    max-width: 87.5rem;
    width: 100%;
}

/* ===== الشعار ===== */
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand:hover { color: #fff; }
.brand .abaya-mark { width: 2.625rem; height: 3.25rem; color: #fff; flex-shrink: 0; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; color: var(--accent); line-height: 1.4; overflow-wrap: anywhere; }
.brand-slogan {
    font-size: .75rem;
    color: rgba(255, 255, 255, .6);
    line-height: 1.5;
    /* سطران ثم قص، بدل قص الاسم في سطر واحد */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== القائمة الجانبية ===== */
.nav-menu { padding: .75rem .6rem 1.5rem; display: flex; flex-direction: column; gap: 2px; }

.nav-section {
    margin: 1rem .6rem .35rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: color-mix(in srgb, var(--accent) 75%, #fff);
    text-transform: uppercase;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    font-weight: 500;
    transition: background-color .15s, color .15s;
    position: relative;
}
.nav-link-item .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.nav-link-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link-item.active {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: #fff;
}
.nav-link-item.active::before {
    content: "";
    position: absolute;
    inset-block: .45rem;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
}
.nav-link-item.active .bi { color: var(--accent); }
.nav-link-item.disabled { color: rgba(255, 255, 255, .38); cursor: default; }
.nav-link-item.disabled:hover { background: transparent; }
.nav-link-item .soon {
    margin-inline-start: auto;
    font-size: .65rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18);
    color: rgba(255, 255, 255, .5);
}

.sidebar-backdrop { display: none; }

/* ===== الشريط العلوي ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--brand);
    border: 0;
    font-size: 1.2rem;
}
.btn-icon:hover { background: var(--brand-soft); }

.branch-switch { display: flex; align-items: center; gap: .5rem; color: var(--brand); }
.branch-switch .form-select { min-width: 12.5rem; max-width: 17.5rem; }

.branch-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .8rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 500;
    font-size: .88rem;
}

.clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    font-size: .8rem;
    color: var(--muted);
}
.clock [data-clock-time] { font-weight: 700; color: var(--brand); font-size: .95rem; }
.clock:empty, .clock [data-clock-date]:empty { display: none; }

.user-btn { display: inline-flex; align-items: center; gap: .5rem; border: 0; color: var(--text); padding: .25rem .5rem; border-radius: 999px; }
.user-btn:hover { background: var(--brand-soft); }

.avatar {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: var(--accent);
    font-weight: 700;
    flex-shrink: 0;
}

.dropdown-menu { border-color: var(--border); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: .35rem; }
.dropdown-item { border-radius: 8px; display: flex; align-items: center; gap: .5rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); color: #fff; }

/* ===================== الأزرار والشارات ===================== */
.btn { border-radius: var(--radius-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { border-radius: 8px; }

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-deep);
    --bs-btn-hover-border-color: var(--brand-deep);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-deep);
    --bs-btn-active-border-color: var(--brand-deep);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-disabled-color: #fff;
}
.btn-brand .bi { color: var(--accent); }

.btn-outline-brand {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: color-mix(in srgb, var(--brand) 35%, #fff);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.btn-light { --bs-btn-bg: #F3F1EC; --bs-btn-border-color: #F3F1EC; --bs-btn-hover-bg: #E9E5DC; --bs-btn-hover-border-color: #E9E5DC; }

.badge-soft {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}
.badge-soft-success { background: #E5F5EC; color: #11734B; }
.badge-soft-danger { background: #FDECEC; color: #B42318; }
.badge-soft-muted { background: #EEF0F3; color: #5B6472; }
.badge-soft-gold { background: var(--accent-soft); color: var(--accent-strong); }
.badge-soft-brand { background: var(--brand-soft); color: var(--brand); }

.code-chip {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 6px;
    background: var(--brand-soft);
    color: var(--brand);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .82rem;
    font-weight: 600;
}

/* ===================== عناصر الصفحة ===================== */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.page-title .bi { color: var(--accent); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.panel.narrow { max-width: 35rem; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.panel-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.panel-title .bi { color: var(--accent); }

.info-strip {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff);
    color: color-mix(in srgb, var(--accent-strong) 70%, #000);
    font-size: .9rem;
}
.info-strip .bi { margin-top: .15rem; }
.info-strip code { color: inherit; }

/* ===== النماذج ===== */
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--border); }
.form-control[readonly] { background: #F7F5F1; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-text { font-size: .8rem; }

.form-section {
    font-size: .95rem;
    font-weight: 700;
    color: var(--brand);
    margin: 1.5rem 0 .75rem;
    padding-bottom: .4rem;
    border-bottom: 1px dashed var(--border);
}
.panel > .form-section:first-of-type,
.panel > .alert + .form-section,
.panel > .validation-summary-valid + .form-section { margin-top: 0; }

.form-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
form > .form-actions, fieldset > .form-actions { border-top: 0; padding-top: 0; margin-top: 0; }

.input-validation-error { border-color: #DC3545 !important; }
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-inline-start: 1.1rem; }

fieldset[disabled] .form-control, fieldset[disabled] .form-select { background: #F7F5F1; }

/* ===== شريط البحث والفلاتر ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-bar .input-group { flex: 1 1 16.25rem; max-width: 26.25rem; }
.filter-bar .form-select { width: auto; min-width: 11.25rem; }
.filter-date { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .85rem; color: var(--muted); }
.filter-date .form-control { width: auto; }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; margin-inline: -1.25rem; padding-inline: 1.25rem; }
.table { --bs-table-hover-bg: #FAF8F4; margin-bottom: 0; }
.table > thead th {
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .02em;
    background: #FAF8F4;
    border-bottom-color: var(--border);
    white-space: nowrap;
}
.table > :not(caption) > * > * { padding: .7rem .75rem; border-bottom-color: #EFEBE4; }
.row-muted > * { color: var(--muted) !important; }
.table .btn-sm { width: 2rem; height: 2rem; padding: 0; }
.table form.d-inline { display: inline-flex !important; }

.pager-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }

/* ===== الحالات الفارغة ===== */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state > .bi { font-size: 3rem; color: var(--accent); display: block; margin-bottom: .75rem; }
.empty-state.small-state { padding: 2rem 1rem; }
.empty-state.small-state > .bi { font-size: 2.2rem; }
.status-code { font-size: 4.5rem; font-weight: 700; color: var(--brand); line-height: 1; margin-bottom: .75rem; }

/* ===================== لوحة التحكم ===================== */
.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1.25rem;
    border-radius: calc(var(--radius) + 4px);
    color: #fff;
    background:
        radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 30%, transparent) 0, transparent 45%),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
    box-shadow: var(--shadow);
}
[dir="rtl"] .hero {
    background:
        radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--accent) 30%, transparent) 0, transparent 45%),
        linear-gradient(225deg, var(--brand) 0%, var(--brand-deep) 100%);
}
.hero-name { font-size: 1.9rem; font-weight: 700; color: var(--accent); margin: 0 0 .25rem; }
.hero-slogan { margin: 0 0 .9rem; color: rgba(255, 255, 255, .8); }
.hero-meta { display: flex; flex-wrap: wrap; gap: .5rem; }
.hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .15);
    font-size: .85rem;
}
.hero-figure { flex-shrink: 0; }
.hero-figure .abaya-mark { width: 6rem; height: 7.5rem; color: #fff; opacity: .9; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat > .bi {
    width: 3rem;
    height: 3rem;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-blue > .bi { background: #E8EEF9; color: #1D4ED8; }
.stat-gold > .bi { background: var(--accent-soft); color: var(--accent-strong); }
.stat-green > .bi { background: #E5F5EC; color: #11734B; }
.stat-purple > .bi { background: #F0EAFB; color: #6D28D9; }

.stages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding-bottom: .25rem;
    counter-reset: stage;
}
.stage {
    flex: 1 0 6.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .45rem;
    text-align: center;
    position: relative;
    counter-increment: stage;
}
.stage:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 24px;
    inset-inline-start: calc(50% + 28px);
    inset-inline-end: calc(-50% + 28px);
    border-top: 2px dashed color-mix(in srgb, var(--accent) 55%, #fff);
}
.stage-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: var(--accent);
    font-size: 1.2rem;
    position: relative;
}
.stage-icon::after {
    content: counter(stage);
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--brand);
    font-size: .7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.stage-name { font-size: .82rem; font-weight: 500; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .75rem;
    padding: .6rem 0;
    border-bottom: 1px solid #EFEBE4;
}
.activity-list li:last-child { border-bottom: 0; }
.activity-list time { min-width: 7.5rem; }

/* ===================== المجموعات والصلاحيات ===================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
    gap: 1rem;
}
.group-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.group-card-head { display: flex; align-items: flex-start; gap: .75rem; }
.group-icon {
    width: 2.625rem;
    height: 2.625rem;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.2rem;
    flex-shrink: 0;
}
.group-icon.is-admin { background: var(--brand); color: var(--accent); }
.group-name { font-size: 1.05rem; font-weight: 700; margin: 0 0 .25rem; color: var(--brand); }
.group-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.group-meta .bi { color: var(--accent); }
.group-card-actions { display: flex; gap: .5rem; margin-top: auto; padding-top: .75rem; border-top: 1px solid #EFEBE4; }

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14.375rem, 1fr));
    gap: 1rem;
}
.perm-module {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    margin: 0;
    background: #FCFBF9;
}
.perm-module-head {
    float: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .92rem;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: .5rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}
.perm-module-head .bi { color: var(--accent); }
.perm-module .form-check { margin-bottom: .2rem; }
.perm-module .form-check-input:disabled ~ .form-check-label { opacity: .55; }
[data-permissions-panel].is-admin .perm-grid { opacity: .55; pointer-events: none; }

/* ===================== الإعدادات ===================== */
.logo-box { display: flex; align-items: flex-start; gap: 1rem; }
.logo-preview {
    width: 5.25rem;
    height: 5.25rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    object-fit: contain;
    padding: 6px;
    flex-shrink: 0;
}
.logo-default { display: inline-flex; align-items: center; justify-content: center; background: var(--brand); }
.logo-default .abaya-mark { width: 3.25rem; height: 4rem; color: #fff; }

.color-field { display: flex; align-items: center; gap: .75rem; }
.color-field .form-control-color { width: 3.5rem; height: 2.625rem; padding: .25rem; }
.color-field code { color: var(--text); font-size: .9rem; }

.color-sample { display: flex; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.color-sample span { flex: 1; padding: .65rem 1rem; font-weight: 500; text-align: center; }
.sample-brand { background: var(--brand); color: var(--accent); }
.sample-accent { background: var(--accent); color: var(--brand); }

/* ===================== تسجيل الدخول ===================== */
.login-body { background: var(--bg); }
.login-shell { display: flex; min-height: 100vh; }

.login-art {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #fff;
    background:
        radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--accent) 28%, transparent) 0, transparent 50%),
        linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%);
}
.login-art-inner { text-align: center; max-width: 23.75rem; }
.login-art .abaya-mark { width: 8.75rem; height: 10.9375rem; color: #fff; margin-bottom: 1.25rem; }
.login-logo { max-width: 180px; max-height: 180px; border-radius: 20px; background: #fff; padding: 10px; margin-bottom: 1.25rem; }
.login-name { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.3; }
.login-slogan { color: rgba(255, 255, 255, .75); margin: .5rem 0 0; }

.login-panel {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    position: relative;
    background: var(--surface);
}
.login-panel > .empty-state { max-width: 27.5rem; }
.login-lang { position: absolute; top: 1rem; inset-inline-end: 1rem; }
.login-lang .btn-link { color: var(--brand); text-decoration: none; }
.login-form { width: 100%; max-width: 25rem; }
.login-title { font-size: 1.6rem; font-weight: 700; color: var(--brand); margin-bottom: .25rem; }

/* ===================== الشاشات الصغيرة ===================== */
@media (max-width: 1199.98px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: none;
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar-open .sidebar,
    [dir="rtl"] .sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }

    .sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 16, 28, .45);
        z-index: 1035;
    }
    .main { margin-inline-start: 0; }
    .topbar { padding: 0 .75rem; }
    .content { padding: 1rem; }
    .branch-switch .form-select { min-width: 8.75rem; }
    .clock { display: none; }
}

@media (max-width: 767.98px) {
    .login-shell { flex-direction: column; }
    .login-art { flex: 0 0 auto; padding: 2.5rem 1rem 1.5rem; }
    .login-art .abaya-mark { width: 4.375rem; height: 5.5rem; margin-bottom: .5rem; }
    .login-logo { max-width: 5.625rem; max-height: 5.625rem; margin-bottom: .5rem; }
    .login-name { font-size: 1.4rem; }
    .login-panel { padding-top: 3.5rem; }

    .hero { padding: 1.25rem; }
    .hero-name { font-size: 1.4rem; }
    .hero-figure { display: none; }
    .page-title { font-size: 1.2rem; }
    .panel { padding: 1rem; }
    .table-wrap { margin-inline: -1rem; padding-inline: 1rem; }
    .filter-bar .input-group { max-width: none; }
    .branch-switch .bi { display: none; }
}

@media (max-width: 479.98px) {
    .stats { grid-template-columns: 1fr; }
    .logo-box { flex-direction: column; }
}

/* =====================================================================
   المرحلة 2أ — الزبائن والمقاسات والأصناف
   ===================================================================== */

.section-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.section-title .bi { color: var(--accent); }

/* ===== البحث السريع برقم الهاتف ===== */
.lookup {
    max-width: 35rem;
    margin: 2rem auto;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    padding: 2.25rem 1.5rem;
}
.lookup-icon {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--brand);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
}
.lookup-title { font-size: 1.5rem; font-weight: 700; color: var(--brand); }
.lookup-form { display: flex; gap: .5rem; margin-top: 1.25rem; }
.lookup-form .form-control { text-align: center; font-size: 1.35rem; letter-spacing: .04em; }
.lookup-result {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
}

/* ===== بطاقة الزبون ===== */
.customer-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.avatar-lg { width: 3.5rem; height: 3.5rem; font-size: 1.4rem; }
.customer-phones { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.phone-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .8rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}
.phone-link:hover { background: color-mix(in srgb, var(--brand) 16%, #fff); color: var(--brand); }
.phone-link.whatsapp { background: #E6F6EC; color: #128C4B; }
.customer-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; font-size: .88rem; color: var(--muted); }
.customer-meta .bi { color: var(--accent); }
.customer-notes { margin: .6rem 0 0; font-size: .9rem; white-space: pre-line; }
.customer-actions { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ===== ملفات المقاسات ===== */
.profile { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.profile:target { outline: 2px solid var(--accent); outline-offset: 2px; }

.garment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16.25rem, 1fr));
    gap: 1rem;
}
.garment-card {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FCFBF9;
}
.garment-card.is-empty { background: var(--surface); border-style: dashed; }
.garment-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.garment-name { margin: 0; font-size: 1rem; font-weight: 700; color: var(--brand); }
.garment-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }

.measure-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .25rem .75rem;
    margin: 0;
}
.measure-item {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding: .2rem 0;
    border-bottom: 1px dotted var(--border);
    font-size: .86rem;
    min-width: 0;
}
.measure-item dt { font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.measure-item dd { margin: 0; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.measure-notes { margin: 0; font-size: .85rem; white-space: pre-line; }
.measure-notes .bi { color: var(--accent); }

/* ===== نموذج أخذ المقاسات ===== */
.measure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.625rem, 1fr));
    gap: 1rem;
}
.measure-field.is-wide { grid-column: span 2; }
.measure-input { font-size: 1.25rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.unit-switch { display: inline-flex; gap: .25rem; }
.current-image { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.current-image img {
    width: 5.25rem;
    height: 5.25rem;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: .75rem 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ===== تاريخ المقاسات ===== */
.history-table th[scope="row"] { font-weight: 500; color: var(--muted); white-space: nowrap; }
.history-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-table .is-current { background: color-mix(in srgb, var(--accent) 8%, #fff); }
.history-table td.is-changed { color: var(--accent-strong); font-weight: 700; }
.history-table td.small { white-space: normal; min-width: 10rem; }

/* ===== الدمج ===== */
.merge-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; }
.merge-arrow { align-self: center; font-size: 2rem; color: var(--accent); }
.mini-card {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FCFBF9;
}
.candidate-list { display: flex; flex-direction: column; gap: .4rem; }
.candidate {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .9rem;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
}
.candidate:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16.25rem, 1fr)); gap: 1rem; }

/* ===== الأصناف وأنواع القطع ===== */
.chip-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: .8rem;
}
.piece-list { list-style: none; margin: 0; padding: 0; }
.piece-list li {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px dotted var(--border);
    font-size: .9rem;
}
.piece-total {
    display: flex;
    justify-content: space-between;
    padding-top: .35rem;
    font-weight: 700;
    color: var(--brand);
}
.col-order { width: 6.875rem; }
.col-price { width: 12.5rem; }
tr.group-start > td { border-top: 2px solid var(--border); }
.group-card.row-muted { opacity: .65; }

@media (max-width: 767.98px) {
    .merge-grid { grid-template-columns: 1fr; }
    .merge-arrow { transform: rotate(90deg); justify-self: center; }
    [dir="rtl"] .merge-arrow { transform: rotate(-90deg); }
    .measure-list { grid-template-columns: 1fr; }
    .measure-field.is-wide { grid-column: auto; }
    .lookup-form { flex-direction: column; }
    .customer-actions { width: 100%; }
}

/* =====================================================================
   المرحلة 2ب — الطلبات والإنتاج
   ===================================================================== */

/* ===== تبويبات الحالة ===== */
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
}
.tab span { font-size: .75rem; padding: 0 .45rem; border-radius: 999px; background: #EEF0F3; color: var(--muted); }
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab.active span { background: rgba(255, 255, 255, .18); color: #fff; }
.tab-danger span { background: #FDECEC; color: #B42318; }
.tab-success span { background: #E5F5EC; color: #11734B; }

.row-late > td { background: #FFF6F5; }
.mini-progress { width: 90px; height: 6px; border-radius: 3px; background: #EEF0F3; overflow: hidden; }
.mini-progress span { display: block; height: 100%; background: #11734B; }

/* ===== تخطيط الطلب ===== */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 21.25rem; gap: 1.25rem; align-items: start; }
.order-side { position: sticky; top: calc(var(--topbar-h) + 1rem); }

.order-line {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .85rem 1rem;
    margin-bottom: .85rem;
    background: #FCFBF9;
}
.order-line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.line-no { font-weight: 700; color: var(--brand); }
.line-errors { margin: 0 0 .5rem; padding: .5rem 1.5rem; border-radius: 8px; background: #FDECEC; color: #B42318; font-size: .85rem; }
.line-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: .5rem; margin-top: .75rem; }
.line-piece {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .35rem .6rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.line-piece-name { font-size: .88rem; font-weight: 500; }
.line-piece input { width: 6.875rem; }
.line-total { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .6rem; font-size: .9rem; color: var(--muted); }
.line-total strong { color: var(--brand); }

.totals { margin: 0; }
.totals > div { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .35rem 0; border-bottom: 1px dotted var(--border); }
.totals dt { font-weight: 500; color: var(--muted); }
.totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals dd input, .totals dd select { width: 8.75rem; }
.totals-grand dt, .totals-grand dd { color: var(--brand); font-size: 1.15rem; }
.totals-remaining dd { font-size: 1.05rem; }
.totals-remaining.has-due dd { color: #B42318; }

/* ===== تفاصيل الطلب ===== */
.action-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.btn-whatsapp { --bs-btn-color: #fff; --bs-btn-bg: #1FA855; --bs-btn-border-color: #1FA855; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #178C46; --bs-btn-hover-border-color: #178C46; }

.piece-list-cards { display: flex; flex-direction: column; gap: .75rem; }
.piece-card {
    display: flex;
    gap: 1rem;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FCFBF9;
    border-inline-start: 4px solid var(--border);
}
.piece-card.status-inprogress { border-inline-start-color: var(--accent); }
.piece-card.status-ready { border-inline-start-color: #11734B; background: #F4FBF7; }
.piece-card.status-delivered { opacity: .7; }
.piece-card.status-cancelled { opacity: .5; text-decoration: line-through; }
.piece-qr { width: 4rem; flex-shrink: 0; }
.piece-qr svg { width: 100%; height: auto; display: block; }
.piece-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.piece-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.piece-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; font-size: .85rem; }
.piece-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .35rem; }

.route { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; }
.route li {
    font-size: .75rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: #EEF0F3;
    color: var(--muted);
}
.route li.done { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.route li.current { background: var(--accent); color: var(--brand); font-weight: 700; }
.route li.done-final { background: #11734B; color: #fff; }
.route-lg li { font-size: .95rem; padding: .35rem .9rem; }

.inline-form { display: inline-block; }
.inline-form > summary { list-style: none; cursor: pointer; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] { display: block; width: 100%; }
.inline-form-body { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.inline-form-body select { width: auto; min-width: 9.375rem; }
.inline-form-body input[type=text] { flex: 1 1 12.5rem; }
.stack-form { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; }

.deliver-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: 1rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    background: #E5F5EC;
}

.payment-list { list-style: none; margin: 0; padding: 0; }
.payment-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px dotted var(--border); font-size: .88rem; }
.payment-list li.is-refund strong { color: #B42318; }

.info-list { margin: 0 0 .75rem; }
.info-list > div { display: flex; justify-content: space-between; gap: .75rem; padding: .3rem 0; font-size: .9rem; }
.info-list dt { font-weight: 500; color: var(--muted); }
.info-list dd { margin: 0; }
.notes-box { padding: .6rem .75rem; border-radius: 8px; background: var(--accent-soft); white-space: pre-line; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item {
    position: relative;
    padding: .5rem 0;
    padding-inline-start: 1.25rem;
    border-inline-start: 2px solid var(--border);
    margin-inline-start: .35rem;
}
.timeline-item::before {
    content: "";
    position: absolute;
    top: .95rem;
    inset-inline-start: -6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}
.timeline-item.action-skip::before, .timeline-item.action-back::before { background: #D97706; }
.timeline-item.action-deliver::before, .timeline-item.action-ready::before { background: #11734B; }
.timeline-item.action-cancel::before { background: #B42318; }

/* ===== لوحة الإنتاج ===== */
.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(13.75rem, 1fr);
    gap: .85rem;
    overflow-x: auto;
    padding-bottom: .5rem;
    align-items: start;
}
.board-col { background: #EFECE6; border-radius: var(--radius); padding: .6rem; min-height: 200px; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; padding: .25rem .35rem .6rem; font-weight: 700; color: var(--brand); }
.board-col-head .bi { color: var(--accent); }
.board-count { min-width: 28px; padding: 0 .5rem; border-radius: 999px; background: var(--brand); color: #fff; text-align: center; font-size: .8rem; }
.board-ready .board-count { background: #11734B; }
.board-cards { display: flex; flex-direction: column; gap: .5rem; }
.board-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.board-card.is-urgent { border-inline-start: 4px solid #D97706; }
.board-card.is-late { border-color: #F0B4AE; background: #FFF8F7; }
.board-card-link { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .7rem; color: var(--text); text-decoration: none; }
.board-card-link:hover { background: var(--accent-soft); color: var(--text); }
.board-card-action { border-top: 1px solid #EFEBE4; }
.board-card-action .btn { border-radius: 0; }
.board-empty { text-align: center; color: var(--muted); margin: 1rem 0; }

/* ===== المسح ===== */
.scan-page { max-width: 47.5rem; margin: 0 auto; }
.scan-row { display: flex; gap: .5rem; }
.scan-row input { font-size: 1.4rem; letter-spacing: .05em; text-align: center; }
.camera-box { margin-top: .75rem; text-align: center; }
.camera-box video { width: 100%; max-height: 320px; border-radius: var(--radius-sm); background: #000; }
.scan-message {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
    font-size: 1.15rem;
    font-weight: 700;
}
.scan-message.is-ok { background: #E5F5EC; color: #11734B; }
.scan-message.is-error { background: #FDECEC; color: #B42318; }
.scan-piece .route { margin: 1rem 0; }
.scan-piece.is-late { border-color: #F0B4AE; }
.scan-garment { font-size: 1.5rem; font-weight: 700; color: var(--brand); margin: .4rem 0 .2rem; }

/* ===== المراحل ===== */
.stage-dot {
    display: inline-flex;
    width: 1.875rem;
    height: 1.875rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: var(--accent);
    margin-inline-end: .4rem;
}
.stage-route { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .8rem; color: var(--brand); }
.stage-route .bi { color: var(--accent); font-size: .7rem; }

/* ===== لوحة التحكم ===== */
.stat-link { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.stat-link:hover { transform: translateY(-2px); color: inherit; }
.stat-red > .bi { background: #FDECEC; color: #B42318; }
.stage-link { display: flex; flex-direction: column; align-items: center; gap: .45rem; color: inherit; text-decoration: none; }
.stage-link .stage-icon::after { content: none; }
.stage-count {
    position: absolute;
    top: -.4rem;
    inset-inline-end: -.6rem;
    min-width: 1.9rem;
    height: 1.6rem;
    padding: 0 .45rem;
    border-radius: 999px;
    border: 2px solid var(--surface);
    background: #EEF0F3;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stage.has-items .stage-count { background: var(--accent); color: var(--brand); }

@media (max-width: 1199.98px) {
    .order-layout { grid-template-columns: 1fr; }
    .order-side { position: static; }
}
@media (max-width: 575.98px) {
    .piece-card { flex-direction: column; }
    .piece-qr { width: 3.5rem; }
    .line-piece input { width: 5.625rem; }
    .scan-row input { font-size: 1.1rem; }
}

/* =====================================================================
   المرحلة 3أ — الخياطون
   ===================================================================== */
.tailor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.tailor-card {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.tailor-card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.tailor-card.is-inactive { opacity: .6; }
.tailor-card-head { display: flex; align-items: center; gap: .75rem; }
.tailor-pay { display: flex; flex-wrap: wrap; gap: .35rem; }
.tailor-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; margin: 0; }
.tailor-stats > div { padding: .4rem; border-radius: 8px; background: #F7F5F1; text-align: center; }
.tailor-stats dt { font-size: .72rem; font-weight: 500; color: var(--muted); }
.tailor-stats dd { margin: 0; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.tailor-stats dd small { font-size: .65rem; color: var(--muted); }
.tailor-stats .is-late { background: #FDECEC; }
.tailor-stats .is-late dd { color: #B42318; }
.tailor-stats .is-due { background: #E5F5EC; }
.tailor-stats .is-due dd { color: #11734B; }
.tailor-stats .is-advance { background: #FFF4E5; }
.tailor-stats .is-advance dd { color: #B45309; }

.check-list { display: flex; flex-direction: column; gap: .25rem; max-height: 14rem; overflow-y: auto; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; }

.rate-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem 1rem; padding: .85rem 0; border-bottom: 1px dotted var(--border); }
.rate-row:last-child { border-bottom: 0; }
.rate-garment { flex: 0 0 9rem; font-weight: 700; color: var(--brand); padding-top: 1.6rem; }
.rate-cells { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; }
.rate-cell .form-label { margin-bottom: .15rem; color: var(--muted); }
.rate-any .form-label { color: var(--brand); font-weight: 700; }
.rate-any input { border-color: var(--accent); }

.ledger .restore-steps { margin: 0 0 .75rem; padding-inline-start: 1.1rem; font-size: .88rem; }
.restore-steps li { margin-bottom: .35rem; }

.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger-opening td { background: #F7F5F1; font-weight: 500; }
.ledger tfoot th { border-top: 2px solid var(--brand); color: var(--brand); }

.seg { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.seg .btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.seg .btn-check:checked + .seg-present { background: #11734B; border-color: #11734B; color: #fff; }
.seg .btn-check:checked + .seg-halfday { background: #D97706; border-color: #D97706; color: #fff; }
.seg .btn-check:checked + .seg-absent { background: #B42318; border-color: #B42318; color: #fff; }
.seg .btn-check:checked + .seg-leave { background: #6B7280; border-color: #6B7280; color: #fff; }
.seg .btn-check:checked + .seg-none { background: #EEF0F3; color: var(--text); }

.assign-form { display: inline-flex; align-items: center; gap: .35rem; }
.assign-form select { min-width: 10rem; }
.assign-form-lg { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.assign-form-lg select { flex: 1 1 14rem; }
.board-card-assign { padding: .35rem .5rem; border-top: 1px solid #EFEBE4; }
.board-card-tailor { padding: .3rem .7rem; border-top: 1px solid #EFEBE4; font-size: .8rem; color: var(--brand); }

@media (max-width: 575.98px) {
    .tailor-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rate-garment { flex-basis: 100%; padding-top: 0; }
}

/* =====================================================================
   المرحلة 3ج — نقطة البيع
   ===================================================================== */
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 24rem; gap: 1.25rem; align-items: start; }
.pos-side { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.pos-scan { margin-bottom: 1rem; }
.pos-scan .scan-row input[type=text] { font-size: 1.3rem; letter-spacing: .04em; }
.pos-qty { max-width: 6.5rem; }
.pos-price { max-width: 8rem; }

.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .5rem; }
.pos-tile {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .6rem .5rem;
    min-height: 4.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.pos-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.pos-tile-name { font-weight: 600; font-size: .88rem; }
.pos-tile-qty { font-size: .75rem; color: var(--muted); }

.pos-order-box { margin-top: .5rem; padding: .6rem; border-radius: 8px; background: var(--accent-soft); }
.pos-pay { display: grid; grid-template-columns: auto 1fr; gap: .4rem .6rem; align-items: center; }
.pos-pay .form-label { margin: 0; }

@media (max-width: 1199.98px) {
    .pos-layout { grid-template-columns: 1fr; }
    .pos-side { position: static; }
}

/* ===== المزامنة ===== */
.key-box {
    display: block;
    padding: .6rem .75rem;
    border-radius: 8px;
    background: #0F1B2E;
    color: #FFD98A;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .95rem;
    word-break: break-all;
    user-select: all;
}

/* =====================================================================
   المرحلة 5 — التقارير
   ===================================================================== */
.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }

.report-filter { padding: .85rem 1rem; }
.report-filter form { row-gap: .5rem; }
.quick-dates { display: flex; gap: .25rem; flex-wrap: wrap; }

.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.report-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.report-card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.report-card > .bi { font-size: 1.6rem; color: var(--accent); }
.report-card-title { font-weight: 700; color: var(--brand); }
.report-card-note { font-size: .82rem; color: var(--muted); }
.report-card-kpi { position: absolute; inset-inline-end: 1rem; top: 1rem; font-weight: 700; color: var(--brand); }
.report-card-kpi small { font-size: .7rem; color: var(--muted); font-weight: 400; }

.report-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }

.bar-chart { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.bar-chart li { display: grid; grid-template-columns: 7rem 1fr 7rem; align-items: center; gap: .5rem; font-size: .85rem; }
.bar-label { color: var(--muted); }
.bar-track { height: .9rem; border-radius: 999px; background: #EEF0F3; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.bar-value { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 575.98px) {
    .bar-chart li { grid-template-columns: 5rem 1fr 5.5rem; font-size: .78rem; }
}

@media print {
    .no-print { display: none !important; }
    .report-cards { display: none; }
}

/* ===================== تقليل الحركة ===================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===================== الطباعة ===================== */
@media print {
    .sidebar, .topbar, .sidebar-backdrop, .form-actions, .filter-bar, .pager-bar, .btn { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .panel { box-shadow: none; border: 0; }
}
