/* DyeingDaftar design system - on top of Bootstrap 5.3 RTL. Fonts and icons are served locally. */

:root {
    --dd-primary: #3f3d9e;
    --dd-primary-rgb: 63, 61, 158;
    --dd-primary-dark: #2d2b7a;
    --dd-primary-soft: #eceafb;
    --dd-accent: #e0457b;
    --dd-accent-soft: #fde8ef;
    --dd-teal: #14a3a3;
    --dd-teal-soft: #dcf5f4;
    --dd-amber: #f59e0b;
    --dd-amber-soft: #fef3d9;

    --dd-bg: #f3f4fa;
    --dd-surface: #ffffff;
    --dd-text: #1f2340;
    --dd-muted: #6b7190;
    --dd-border: #e3e5f1;

    --dd-radius: 14px;
    --dd-radius-sm: 10px;
    --dd-shadow: 0 1px 2px rgba(31, 35, 64, .05), 0 6px 20px rgba(31, 35, 64, .06);
    --dd-sidebar-w: 272px;

    /* Bootstrap variables */
    --bs-font-sans-serif: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-color: var(--dd-text);
    --bs-body-bg: var(--dd-bg);
    --bs-primary: var(--dd-primary);
    --bs-primary-rgb: var(--dd-primary-rgb);
    --bs-link-color: var(--dd-primary);
    --bs-link-color-rgb: var(--dd-primary-rgb);
    --bs-link-hover-color: var(--dd-primary-dark);
    --bs-border-color: var(--dd-border);
    --bs-border-radius: var(--dd-radius-sm);
    --bs-success-rgb: 20, 163, 100;
    --bs-danger-rgb: 214, 51, 75;
}

html { font-size: 16px; }
body { font-family: var(--bs-body-font-family); background: var(--dd-bg); color: var(--dd-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: 0; }

/* numbers, dates, codes always read left-to-right even inside Arabic text */
.num, input[type=number], input[type=date], .form-control.num { direction: ltr; unicode-bidi: plaintext; text-align: start; }
td.num, th.num { white-space: nowrap; }
/* A header is Arabic text: with `.num` (direction:ltr + plaintext) the browser resolved "end" to the LEFT for it. Headers always hug the right edge, like the numbers below them. */
th.num { direction: rtl; unicode-bidi: normal; text-align: right; }
/* Same trap in a cell: `plaintext` takes the direction from the first LETTER, so "78 سطر" or "535802311 البنك الأهلي" is right-to-left and `end` meant the LEFT
   (products «الاستخدام»), while a pure number (no letters) stayed on the right. A cell always hugs the right edge, like its header. */
td.num { text-align: right; }
/* Same for a block-level number/date under an Arabic label (dashboard tiles, opening-balance dates, phone lines): `text-align:start` on an ltr box is the LEFT,
   so the digits sat on the opposite side of the label above them. Inputs keep `start`; Bootstrap `text-end/text-start` utilities still win. */
div.num, p.num, dd.num { text-align: right; }

/* ---------- buttons / forms ---------- */
.btn { font-weight: 600; border-radius: var(--dd-radius-sm); padding: .55rem 1.1rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { padding: .3rem .7rem; }
.btn-lg { padding: .75rem 1.4rem; }
.btn-primary {
    --bs-btn-bg: var(--dd-primary); --bs-btn-border-color: var(--dd-primary);
    --bs-btn-hover-bg: var(--dd-primary-dark); --bs-btn-hover-border-color: var(--dd-primary-dark);
    --bs-btn-active-bg: var(--dd-primary-dark); --bs-btn-active-border-color: var(--dd-primary-dark);
    --bs-btn-disabled-bg: var(--dd-primary); --bs-btn-disabled-border-color: var(--dd-primary);
    --bs-btn-focus-shadow-rgb: var(--dd-primary-rgb);
    box-shadow: 0 2px 8px rgba(var(--dd-primary-rgb), .25);
}
.btn-outline-primary {
    --bs-btn-color: var(--dd-primary); --bs-btn-border-color: var(--dd-primary);
    --bs-btn-hover-bg: var(--dd-primary); --bs-btn-hover-border-color: var(--dd-primary);
    --bs-btn-active-bg: var(--dd-primary); --bs-btn-active-border-color: var(--dd-primary);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--dd-border); }

.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: var(--dd-radius-sm); border-color: var(--dd-border); padding: .6rem .85rem; background-color: #fff;
}
.form-control:focus, .form-select:focus { border-color: var(--dd-primary); box-shadow: 0 0 0 .22rem rgba(var(--dd-primary-rgb), .15); }
.form-control[readonly] { background: #f6f7fb; }
.form-text { color: var(--dd-muted); }
.form-check-input:checked { background-color: var(--dd-primary); border-color: var(--dd-primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.35em; cursor: pointer; }
.input-icon { position: relative; }
.input-icon > .bi { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .9rem; color: var(--dd-muted); pointer-events: none; }
.input-icon > .form-control { padding-inline-start: 2.6rem; }

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

.sidebar {
    --bs-offcanvas-width: var(--dd-sidebar-w);
    background: linear-gradient(180deg, #2a2866 0%, #1b1a48 100%);
    color: #c9cbea;
    border: 0;
}
.sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: 1.25rem 1.25rem 1rem; text-decoration: none; color: #fff; flex: none; }
.sidebar-brand img { width: 42px; height: 42px; object-fit: contain; flex: none; }
.sidebar-brand .name { font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.sidebar-brand .tag { font-size: .75rem; color: #a9acdc; font-weight: 400; }

/* only the link list scrolls - the brand above and the user card/logout below always stay in view */
.sidebar-nav { padding: .5rem .85rem 1rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* In a right-to-left page the browser puts a scrollbar on the LEFT, i.e. on the inner edge of a right-hand sidebar.
   Scrolling container is direction:ltr so the bar sits on the outer (right) edge; its children switch back to rtl. */
.sidebar-nav { direction: ltr; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .28) transparent; }
.sidebar-nav > * { direction: rtl; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .45); }

/* collapsible sections: native <details>/<summary>, no JS. The section holding the current page opens itself
   (computed from the URL on every render); others start closed. Nothing is remembered between page loads. */
.nav-group { border: 0; margin: 0; }
.nav-group > summary {
    list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: .45rem;
    font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: #8f92c9; padding: 1rem .75rem .4rem;
}
.nav-group > summary::-webkit-details-marker { display: none; }
/* arrow first (= right edge in RTL); closed it points left (towards the content in RTL), open it points down */
.nav-group > summary .chev { order: -1; font-size: .8rem; transition: transform .15s ease; transform: rotate(90deg); }
.nav-group[open] > summary .chev { transform: rotate(0deg); }
.nav-group > summary:hover { color: #c9cbea; }

.side-link {
    display: flex; align-items: center; gap: .8rem; padding: .62rem .8rem; margin-bottom: 2px;
    color: #d2d4f0; text-decoration: none; border-radius: var(--dd-radius-sm); font-weight: 600; font-size: .95rem;
    border-inline-start: 3px solid transparent;
}
.side-link .bi { font-size: 1.15rem; opacity: .9; width: 1.4rem; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, .13); color: #fff; border-inline-start-color: var(--dd-accent); }

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .09); flex: none; }
.user-card { display: flex; align-items: center; gap: .75rem; }
.user-card .who { min-width: 0; flex: 1; }
.user-card .who .n { color: #fff; font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who .r { font-size: .75rem; color: #a9acdc; }
.btn-logout { color: #d2d4f0; background: rgba(255, 255, 255, .08); border: 0; width: 38px; height: 38px; border-radius: 10px; padding: 0; }
.btn-logout:hover { background: rgba(224, 69, 123, .35); color: #fff; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem; color: #fff; background: linear-gradient(135deg, var(--dd-primary), var(--dd-accent));
}
.avatar.sm { width: 34px; height: 34px; font-size: .78rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; height: 64px; 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(--dd-border);
}
.topbar .page-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.topbar .date { color: var(--dd-muted); font-size: .85rem; }
/* right-hand tools of the header: date, future tool buttons (.topbar-tool), then the user menu */
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-tool { position: relative; }
.user-toggle {
    display: flex; align-items: center; gap: .6rem; background: none; border: 1px solid transparent; border-radius: 12px;
    padding: .25rem .5rem; color: var(--dd-text); text-align: start;
}
.user-toggle:hover, .user-toggle[aria-expanded="true"] { background: #fff; border-color: var(--dd-border); }
.user-toggle .who, .user-menu-head .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-toggle .n, .user-menu-head .n { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-toggle .r, .user-menu-head .r { font-size: .75rem; color: var(--dd-muted); }
.user-toggle .caret { font-size: .7rem; color: var(--dd-muted); }
.user-menu .dropdown-menu { min-width: 230px; padding: .4rem; border-radius: 14px; border-color: var(--dd-border); box-shadow: 0 10px 30px rgba(27, 26, 72, .15); margin-top: .5rem !important; }
.user-menu-head { display: flex; align-items: center; gap: .75rem; padding: .5rem .6rem; }
.user-menu .dropdown-item { display: flex; align-items: center; gap: .6rem; border-radius: 8px; padding: .5rem .6rem; font-weight: 600; font-size: .92rem; }
.user-menu .dropdown-item .bi { font-size: 1.05rem; width: 1.3rem; text-align: center; }
.user-menu form { margin: 0; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 12px; border: 1px solid var(--dd-border); background: #fff; color: var(--dd-text); }
.content { padding: 1.5rem; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
.app-footer { color: var(--dd-muted); font-size: .8rem; text-align: center; padding: 1rem; }

@media (min-width: 992px) {
    .sidebar.offcanvas {
        position: sticky; top: 0; height: 100vh; flex: 0 0 var(--dd-sidebar-w); width: var(--dd-sidebar-w);
        visibility: visible !important; transform: none !important; transition: none;
    }
    .sidebar .offcanvas-header { display: none; }
}
@media (max-width: 991.98px) {
    .topbar { padding: 0 1rem; }
    .content { padding: 1rem; }
    .sidebar .offcanvas-header { padding: 1rem 1.25rem 0; }
}

/* ---------- page pieces ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h2 { margin: 0; font-size: 1.35rem; }
.page-head .sub { color: var(--dd-muted); margin: .15rem 0 0; font-size: .92rem; }

.card { border: 1px solid var(--dd-border); border-radius: var(--dd-radius); box-shadow: var(--dd-shadow); background: var(--dd-surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--dd-border); font-weight: 700; padding: 1rem 1.25rem; }
.card-body { padding: 1.25rem; }

.hero {
    position: relative; overflow: hidden; border-radius: var(--dd-radius); padding: 1.75rem 1.75rem; color: #fff;
    background: linear-gradient(120deg, #3f3d9e 0%, #5b3fae 45%, #c2417b 100%); box-shadow: var(--dd-shadow);
}
.hero::after { content: ""; position: absolute; inset-inline-end: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.hero::before { content: ""; position: absolute; inset-inline-end: 110px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.hero h2 { color: #fff; font-size: 1.6rem; margin-bottom: .25rem; position: relative; z-index: 1; }
.hero p { color: rgba(255, 255, 255, .85); margin: 0; position: relative; z-index: 1; }
.hero .chip { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .4rem; background: rgba(255, 255, 255, .16); border-radius: 999px; padding: .25rem .8rem; font-size: .85rem; margin-top: .9rem; margin-inline-end: .5rem; }

.stat { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat .ico { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex: none; }
.stat .lbl { color: var(--dd-muted); font-size: .85rem; font-weight: 600; }
.stat .val { font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.ico-primary { background: var(--dd-primary-soft); color: var(--dd-primary); }
.ico-accent { background: var(--dd-accent-soft); color: var(--dd-accent); }
.ico-teal { background: var(--dd-teal-soft); color: var(--dd-teal); }
.ico-amber { background: var(--dd-amber-soft); color: #b7791f; }

.tile {
    flex-direction: row;
    display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border: 1px dashed #cfd2e6; border-radius: var(--dd-radius);
    background: rgba(255, 255, 255, .6); color: var(--dd-muted); height: 100%;
}
.tile .ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; background: #eef0f8; color: #8b90b0; flex: none; }
.tile .t { font-weight: 700; color: var(--dd-text); font-size: .95rem; }
.tile .s { font-size: .78rem; }

.quick { display: flex; flex-direction: row; align-items: center; gap: .85rem; padding: .9rem 1.1rem; text-decoration: none; color: var(--dd-text); border-radius: var(--dd-radius); border: 1px solid var(--dd-border); background: #fff; height: 100%; transition: .15s; }
.quick:hover { border-color: var(--dd-primary); box-shadow: 0 4px 14px rgba(var(--dd-primary-rgb), .12); transform: translateY(-1px); color: var(--dd-text); }
.quick .ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex: none; }
.quick .t { font-weight: 700; }
.quick .s { font-size: .8rem; color: var(--dd-muted); }

/* tables */
.table-modern { margin: 0; --bs-table-bg: transparent; }
.table-modern thead th { background: #f7f8fc; color: var(--dd-muted); font-size: .8rem; font-weight: 700; border-bottom: 1px solid var(--dd-border); padding: .8rem 1rem; white-space: nowrap; }
.table-modern td { padding: .85rem 1rem; vertical-align: middle; border-color: #eef0f7; }
.table-modern tbody tr:hover { background: #fafbff; }
.table-modern tbody tr:last-child td { border-bottom: 0; }

.badge-soft { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-soft.primary { background: var(--dd-primary-soft); color: var(--dd-primary); }
.badge-soft.accent { background: var(--dd-accent-soft); color: #b8265c; }
.badge-soft.teal { background: var(--dd-teal-soft); color: #0d7f7f; }
.badge-soft.gray { background: #eceef6; color: #5c6183; }
.badge-soft.green { background: #dcf6e8; color: #147a4a; }
.badge-soft.red { background: #fde3e7; color: #b42a3f; }

.alert { border: 0; border-radius: var(--dd-radius-sm); box-shadow: var(--dd-shadow); }
.alert-success { background: #dcf6e8; color: #0f6a3f; }
.alert-danger { background: #fde3e7; color: #a12336; }

/* permission form */
.perm-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.segmented { display: inline-flex; background: #e9ebf5; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented a { padding: .45rem 1.1rem; border-radius: 9px; text-decoration: none; color: var(--dd-muted); font-weight: 700; font-size: .92rem; }
.segmented a.active { background: #fff; color: var(--dd-primary); box-shadow: 0 1px 4px rgba(31, 35, 64, .12); }
.perm-card { height: 100%; }
.perm-card .card-header { display: flex; align-items: center; gap: .6rem; padding: .85rem 1.1rem; font-size: .95rem; }
.perm-card .card-body { padding: .6rem 1.1rem 1rem; }
.perm-row { display: flex; align-items: center; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid #f0f1f8; gap: 1rem; }
.perm-row:last-child { border-bottom: 0; }
.perm-row label { cursor: pointer; flex: 1; margin: 0; font-size: .92rem; }
.action-bar { position: sticky; bottom: 0; z-index: 10; margin-top: 1.25rem; padding: .9rem 1.25rem; background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px); border: 1px solid var(--dd-border); border-radius: var(--dd-radius); box-shadow: 0 -4px 20px rgba(31, 35, 64, .08); display: flex; gap: .6rem; flex-wrap: wrap; }

/* «delete the selected rows»: the checkbox column, the select-all line and the bar that sticks to the bottom of the screen while something is ticked */
.bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-bottom: .6rem; }
.bulk-cell { width: 2rem; }
.bulk-cell .form-check-input { margin: 0; cursor: pointer; }
.bulk-bar { align-items: center; z-index: 20; }
.bulk-bar[hidden] { display: none; }
.table-modern tbody tr:has(.bulk-pick:checked) { background: var(--dd-primary-soft); }
@media (max-width: 767.98px) { .table-stack td.bulk-cell:empty { display: none; } }   /* a ledger line that cannot be ticked: no empty strip in its card */
@media print { .bulk-cell, .bulk-toolbar, .bulk-bar { display: none !important; } }

/* site switch */
.switch-card { max-width: 720px; }
.switch-state { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; border-radius: var(--dd-radius); }
.switch-state.on { background: #e4f8ee; color: #0f6a3f; }
.switch-state.off { background: #fde8ec; color: #a12336; }
.switch-state .big { width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; background: #fff; flex: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.switch-state .t { font-size: 1.35rem; font-weight: 800; line-height: 1.2; }

/* ---------- login / setup / error pages ---------- */
body.auth { background: radial-gradient(1100px 600px at 90% -10%, #e2defa 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #fbdbe7 0%, transparent 55%), var(--dd-bg); }
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.auth-card { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr; background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px rgba(31, 35, 64, .16); }
.auth-brand {
    position: relative; overflow: hidden; color: #fff; padding: 1.5rem; display: flex; align-items: center; gap: 1rem;
    background: linear-gradient(135deg, #34328a 0%, #5a3fae 55%, #c2417b 100%);
}
.auth-brand::after { content: ""; position: absolute; inset-inline-end: -70px; bottom: -70px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.auth-brand img { width: 54px; height: 54px; background: #fff; border-radius: 16px; padding: 8px; flex: none; position: relative; z-index: 1; }
.auth-brand h1 { font-size: 1.25rem; color: #fff; margin: 0; position: relative; z-index: 1; }
.auth-brand p { margin: .15rem 0 0; color: rgba(255, 255, 255, .85); font-size: .85rem; position: relative; z-index: 1; }
.auth-brand .points { display: none; }
.auth-body { padding: 1.75rem 1.5rem 2rem; }
.auth-body h2 { font-size: 1.5rem; margin-bottom: .25rem; }
.auth-body .lead-sm { color: var(--dd-muted); margin-bottom: 1.5rem; }
@media (min-width: 768px) {
    .auth-card { grid-template-columns: 5fr 6fr; }
    .auth-brand { flex-direction: column; align-items: flex-start; justify-content: center; padding: 2.5rem 2.25rem; gap: 1.25rem; }
    .auth-brand img { width: 84px; height: 84px; border-radius: 22px; padding: 12px; }
    .auth-brand h1 { font-size: 1.8rem; }
    .auth-brand p { font-size: 1rem; }
    .auth-brand .points { display: block; list-style: none; padding: 0; margin: .5rem 0 0; position: relative; z-index: 1; }
    .auth-brand .points li { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; color: rgba(255, 255, 255, .92); font-size: .95rem; }
    .auth-body { padding: 3rem 2.75rem; }
}

/* ---------- phones ---------- */
@media (max-width: 767.98px) {
    .btn, .form-control, .form-select { min-height: 46px; }
    .hero { padding: 1.35rem 1.25rem; }
    .hero h2 { font-size: 1.3rem; }
    .table-stack thead { display: none; }
    .table-stack tbody tr { display: block; margin: .75rem; border: 1px solid var(--dd-border); border-radius: var(--dd-radius); background: #fff; overflow: hidden; }
    /* A row is label (right) + value (left) on one line. When the value does not fit beside its label (a long name, bank, number) it drops to a second line under
       the label (flex-wrap), right-aligned and itself wrapping if it is still too long. `white-space: normal` matters: the `.num` cells are nowrap on desktop,
       and one long nowrap cell made the WHOLE table wider than the phone, so every card was cut off on the left (bounced checks list, 2026-10-10). */
    .table-stack td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .15rem 1rem; border: 0; border-bottom: 1px solid #f0f1f8; padding: .65rem 1rem; text-align: start; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
    .table-stack td:last-child { border-bottom: 0; background: #fafbff; justify-content: flex-end; }
    .table-stack td::before { content: attr(data-label); font-weight: 700; color: var(--dd-muted); font-size: .8rem; text-align: start; flex: none; }
    .table-stack td.no-label::before { content: none; }
    /* numeric/date cells are direction:ltr (for the digits) which also flipped the card row: label on the LEFT, value on the right.
       In a card the row itself must be RTL like the text rows (label right, value left); the digits still read normally. */
    .table-stack td.num { direction: rtl; unicode-bidi: normal; }
    .table-stack tbody tr:hover { background: #fff; }
    .action-bar { margin-inline: -.25rem; }
}

@media print {
    .sidebar, .topbar, .app-footer, .action-bar, .btn { display: none !important; }
    body { background: #fff; }
    .content { max-width: none; padding: 0; }
    .card { box-shadow: none; }
}

@media (max-width: 767.98px) {
    /* the rows already are cards on phones - drop the outer frame so it is not a card inside a card */
    .table-card { border: 0; box-shadow: none; background: transparent; }
    .table-card .table-responsive { overflow: visible; }
    .table-card .table-stack tbody tr { margin: 0 0 .75rem; box-shadow: var(--dd-shadow); }
}

/* ---------- step 2: parties (clients / vendors) ---------- */
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }

.balance { font-weight: 800; white-space: nowrap; }
.balance small { font-weight: 700; font-size: .72rem; margin-inline-start: .35rem; padding: .1rem .5rem; border-radius: 999px; }
.balance.due { color: #b4233c; }
.balance.due small { background: #fde3e7; }
.balance.credit { color: #0d7f7f; }
.balance.credit small { background: #dcf5f4; }
.balance.zero { color: var(--dd-muted); font-weight: 600; }
.stat .val .balance { font-size: 1.35rem; }

.filter-bar .card-body { padding: 1rem 1.1rem; }
.filter-bar .form-label { font-size: .8rem; color: var(--dd-muted); }
/* search + clear buttons: never wider than their column (a narrow column used to push the clear button out of the card) */
.filter-bar .filter-actions { min-width: 6.5rem; flex-wrap: nowrap; }
.filter-bar .filter-actions .btn { min-width: 0; padding-inline: .6rem; }
.filter-bar .filter-actions .btn-primary { flex: 1 1 0; }
.filter-bar .filter-actions .btn-light { flex: 0 0 auto; }
.pager-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.page-size .dropdown-menu { min-width: 8.5rem; font-size: .9rem; }
/* «أدوات» menu in a page header (secondary actions of a busy page; same look as the user menu) */
.tools-menu .dropdown-menu { min-width: 210px; padding: .4rem; border-radius: 14px; border-color: var(--dd-border); box-shadow: 0 10px 30px rgba(27, 26, 72, .15); }
.tools-menu .dropdown-item { display: flex; align-items: center; gap: .6rem; border-radius: 8px; padding: .5rem .6rem; font-weight: 600; font-size: .92rem; }
.tools-menu .dropdown-item .bi { font-size: 1.05rem; width: 1.3rem; text-align: center; }
.page-size .dropdown-item.active, .page-size .dropdown-item:active { background-color: var(--dd-primary); color: #fff; }
.pagination { --bs-pagination-active-bg: var(--dd-primary); --bs-pagination-active-border-color: var(--dd-primary); --bs-pagination-color: var(--dd-primary); }
.pagination .page-link { min-width: 36px; text-align: center; border-radius: 8px; margin-inline: 2px; border-color: var(--dd-border); }

.row-inactive { opacity: .62; }
.table-modern tbody tr.no-cards:hover { background: transparent; }

.info-list { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; margin: 0; }
.info-list dt { color: var(--dd-muted); font-weight: 600; font-size: .9rem; }
.info-list dd { margin: 0; overflow-wrap: anywhere; }

.list-rows .list-row { display: flex; align-items: center; padding: .8rem 1.1rem; border-bottom: 1px solid #f0f1f8; }
.list-rows .list-row:last-child { border-bottom: 0; }

@media (max-width: 767.98px) {
    .table-stack tbody tr.no-cards { display: table-row; border: 0; box-shadow: none; background: transparent; margin: 0; }
    .table-stack tbody tr.no-cards td { display: table-cell; text-align: center; }
    .table-stack tbody tr.no-cards td::before { content: none; }
    .info-list { grid-template-columns: 1fr; gap: .1rem; }
    .info-list dd { margin-bottom: .6rem; }
}

/* ---------- step 2 layout fixes (found on phone screenshots) ---------- */
.stat > div { min-width: 0; }
.info-list dd.num { text-align: right; }          /* numbers/dates align with the other values in the RTL card */

.list-rows .form-switch { display: flex; align-items: center; gap: .45rem; padding: 0; margin: 0; }
.list-rows .form-switch .form-check-input { float: none; margin: 0; flex: none; }

@media (max-width: 767.98px) {
    .stat { padding: .85rem 1rem; gap: .75rem; }
    .stat .ico { width: 42px; height: 42px; font-size: 1.25rem; border-radius: 12px; }
    .stat .val { font-size: 1.3rem; }
    .stat .val .balance { font-size: 1.15rem; }
    .balance { white-space: normal; }
}

/* A stat card measures ITSELF (container query), not the screen: the same card sits in a full-width column on a phone, in a half-width one, and in a quarter-width one
   beside the sidebar on a tablet or small laptop. Wide enough = icon | label over amount. Narrower than 13rem (was 22rem until 2026-10-02: it stacked the dashboard month cards for no need; shoot18 SWEEP_STEP=40 and shoot21 check 13) = icon + label on the first row and the amount
   on its own row with the whole card width, sized to fit (a number is never broken over lines and never runs under the icon). `display: contents` on the
   text block lets its label / amount take part in the card's own wrapping row. */
.stat .val.num { white-space: nowrap; }
.stat { container-type: inline-size; container-name: stat; flex-wrap: wrap; }
@container stat (max-width: 13rem) {
    .stat { row-gap: .3rem; column-gap: .6rem; }
    .stat > div { display: contents; }
    .stat .ico { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
    .stat .lbl { flex: 1 1 0; min-width: 0; }
    .stat .val, .stat > div > .small { flex: 0 0 100%; }
    .stat .val.num { font-size: clamp(.85rem, calc((100cqw - 2.2rem) / 9.5), 1.55rem); }
}

/* ---------- step 3: type-ahead picker, document lines, printing ---------- */
.ta { position: relative; }
.ta.ta-picked .ta-text { border-color: #b7e4d2; background: #f4fbf8; }
.ta-menu { position: absolute; z-index: 1050; top: 100%; inset-inline: 0; margin-top: 4px; background: #fff; border: 1px solid var(--dd-border);
           border-radius: var(--dd-radius-sm); box-shadow: 0 10px 30px rgba(31, 35, 64, .16); max-height: 280px; overflow-y: auto; }
.ta-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem .85rem; cursor: pointer; }
.ta-item small { color: var(--dd-muted); }
.ta-item:hover, .ta-item.active { background: var(--dd-primary-soft); }
.ta-empty { padding: .7rem .9rem; color: var(--dd-muted); }

.lines-table td { vertical-align: top; }
.lines-table td.col-product { min-width: 240px; }
.lines-table td .unit-select { font-size: .8rem; }   /* the unit of this line (meter / kg), under the quantity */
.lines-table .form-control, .lines-table .form-select { min-width: 84px; }
.lines-table td.col-product .form-control { min-width: 200px; }
.totals-row td { background: #f7f8fc; border-top: 1px solid var(--dd-border); }
.line-no { color: var(--dd-muted); font-weight: 700; }

.print-only { display: none; }
.print-head { align-items: center; gap: 1rem; border-bottom: 2px solid #000; padding-bottom: .75rem; margin-bottom: 1rem; }
.print-head img { width: 56px; height: 56px; object-fit: contain; }

@media (max-width: 991.98px) {
    /* the line grid becomes one card per line */
    .lines-table thead { display: none; }
    .lines-table, .lines-table tbody, .lines-table tfoot { display: block; }
    .lines-table tr.line { display: block; margin: .75rem; padding: .25rem 0; border: 1px solid var(--dd-border); border-radius: var(--dd-radius); background: #fff; }
    .lines-table tr.line td { display: block; border: 0; padding: .4rem .9rem; }
    .lines-table tr.line td::before { content: attr(data-label); display: block; font-size: .75rem; font-weight: 700; color: var(--dd-muted); margin-bottom: .15rem; }
    .lines-table tr.line td.no-label-mobile::before { content: none; }
    .lines-table tr.line td.text-end { text-align: end; }
    .lines-table tr.totals-row { display: flex; justify-content: space-between; padding: .6rem 1rem; }
    .lines-table tr.totals-row td { display: block; background: transparent; border: 0; padding: 0; }
}

@media print {
    .print-only { display: block !important; }
    .print-head { display: flex !important; }
    .no-print { display: none !important; }
    .table-modern thead th { background: #eee !important; color: #000; }
    .badge-soft { border: 1px solid #999; background: transparent !important; color: #000 !important; }
}

.statement-table .row-opening td { background: #f7f8fc; font-weight: 700; }
@media (max-width: 767.98px) {
    .statement-table td[data-label="الصنف"]:empty, .statement-table td:empty { display: none; }
}

/* payment form: one block per check */
.check-item { border: 1px solid var(--dd-border); border-radius: var(--dd-radius); padding: .85rem 1rem; background: #fbfbfe; }
.check-item.locked { background: #f4f5fa; }

/* icon tile used outside a .stat card (cash box / bank account headers) */
.stat-ico { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex: none; }

/* dashboard: six-month bars (no chart library) */
.mini-chart { display: flex; align-items: flex-end; justify-content: space-around; gap: .5rem; height: 190px; padding-top: .5rem; }
.mini-chart .grp { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.mini-chart .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.mini-chart .bar { display: block; width: 38%; max-width: 26px; min-height: 2px; border-radius: 6px 6px 0 0; }
.mini-chart .bar.sales, .dot.sales { background: var(--dd-primary); }
.mini-chart .bar.paid, .dot.paid { background: var(--dd-teal); }
.mini-chart .lbl { font-size: .72rem; color: var(--dd-muted); margin-top: .3rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: .25rem; }

/* user guide */
.guide-tabs .nav-link { border-radius: 999px; font-weight: 700; color: var(--dd-muted); }
.guide-tabs .nav-link.active { background: var(--dd-primary); color: #fff; }
.guide-toc { position: sticky; top: 76px; background: #fff; border: 1px solid var(--dd-border); border-radius: var(--dd-radius); padding: 1rem; font-size: .9rem; max-height: calc(100vh - 100px); overflow: auto; }
.guide-toc a { display: block; padding: .28rem 0; text-decoration: none; color: var(--dd-text); }
.guide-toc a:hover { color: var(--dd-primary); }
.guide-section { background: #fff; border: 1px solid var(--dd-border); border-radius: var(--dd-radius); padding: 1.25rem 1.4rem; margin-bottom: 1rem; scroll-margin-top: 80px; }
.guide-section[hidden] { display: none; }
.guide-section h3 { font-size: 1.15rem; margin-bottom: .75rem; color: var(--dd-primary); }
.guide-section h4 { font-size: 1rem; margin: 1rem 0 .4rem; font-weight: 800; }
.guide-section p, .guide-section li { line-height: 1.9; }
.guide-steps { padding-inline-start: 1.4rem; }
.guide-steps li { margin-bottom: .35rem; }
.guide-section .callout { border-inline-start: 4px solid var(--dd-primary); background: var(--dd-primary-soft); border-radius: 10px; padding: .6rem .9rem; margin: .8rem 0; }
.guide-section .callout.warn { border-color: #d9822b; background: #fff4e5; }
.guide-section .callout.ok { border-color: #147a4a; background: #e6f7ee; }
.guide-section kbd, .guide-section .ui { background: #eef0fb; color: var(--dd-primary); padding: .05rem .45rem; border-radius: 6px; font-family: inherit; font-weight: 700; font-size: .92em; white-space: nowrap; }
.guide-section table { font-size: .93rem; }
.guide-section .table-modern thead th { white-space: normal; }          /* the shared header rule is nowrap: too wide for a phone */
@media (max-width: 575.98px) { .guide-section .table-modern th, .guide-section .table-modern td { padding: .6rem .5rem; } }
.guide-part-title { font-size: 1.35rem; font-weight: 800; margin: 0 0 1rem; padding-bottom: .5rem; border-bottom: 3px solid var(--dd-primary-soft); }
.guide-part + .guide-part { margin-top: 2rem; }
.guide-part.no-match { display: none; }
.guide-toc .toc-group { font-weight: 800; color: var(--dd-primary); font-size: .85rem; margin: .8rem 0 .2rem; padding-top: .5rem; border-top: 1px solid var(--dd-border); }
.guide-toc .toc-group:first-of-type { margin-top: .2rem; border-top: 0; padding-top: 0; }
.guide .tab-pane.no-match { display: none !important; }
.guide.searching .tab-pane { display: block !important; opacity: 1 !important; }
.guide-print-title { font-size: 1.4rem; font-weight: 800; margin: 1rem 0; }
@media print {
    .guide .tab-pane { display: block !important; opacity: 1 !important; }
    .guide-part + .guide-part { page-break-before: always; margin-top: 0; }
    .guide-section { border: 0; padding: 0; page-break-inside: avoid; }
    .guide-toc { display: none; }
}

/* ---- loading overlay (wwwroot/js/loading.js): shown when a page or a file takes more than a moment ---- */
.page-loading {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(31, 35, 64, .28);
    cursor: progress;
}
.page-loading[hidden] { display: none; }
.page-loading-box {
    display: flex; align-items: center; gap: .75rem;
    background: var(--dd-surface); color: var(--dd-text);
    border-radius: var(--dd-radius); box-shadow: var(--dd-shadow);
    padding: 1rem 1.5rem; font-weight: 600; max-width: 100%;
}
.page-loading-box .spinner-border { color: var(--dd-primary); width: 1.6rem; height: 1.6rem; border-width: .2rem; flex: none; }
@media print { .page-loading { display: none !important; } }

/* ---- sortable table headers (SortHeaderTagHelper): the whole list is sorted on the server ---- */
th.sortable { white-space: nowrap; }
th.sortable .sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
th.sortable .sort-link:hover, th.sortable .sort-link:focus-visible { color: var(--dd-primary); }
th.sortable .sort-link.active { color: var(--dd-primary); }
th.sortable .sort-ico { font-size: .7rem; }
th.sortable .sort-idle { opacity: .35; }
th.sortable .sort-link:hover .sort-idle { opacity: .8; }
/* phone «ترتيب القائمة» dropdown above a list (_PhoneSort): phones only, where the table header row is hidden */
.phone-sort .form-label { color: var(--dd-muted); font-weight: 600; }
/* change history: the record column can hold a long composite id («3|History.View» = a user's own permission, patch 09); `.num` is nowrap, which made the whole
   table wider than a 768 px screen (cut off on the left). The id may now wrap; the time column keeps its own `text-nowrap`. */
.history-table td[data-label="السجل"] { white-space: normal; overflow-wrap: anywhere; }
