/* ============================================================
   Hadaya Baraka — Modern UI v2 (adapted from project_v2)
   Supports BOTH Arabic (RTL) and Turkish (LTR).
   Includes legacy BEM compatibility shims for old pages.
   ============================================================ */


/* ─── CSS Variables ───────────────────────────────────────── */
:root {
    /* Primary palette: black with a gold accent */
    --primary: #1a1a1a;
    --primary-dark: #000000;
    --primary-light: #f3f4f6;
    --secondary: #d4a017;          /* gold — used for accents */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --sidebar-bg: #0f172a;
    --sidebar-w: 270px;
    --navbar-h: 64px;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow:    0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.10), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Legacy aliases used by older pages. */
    --c-primary:        var(--primary);
    --c-primary-dark:   var(--primary-dark);
    --c-primary-light:  var(--primary-light);
    --c-accent:         var(--secondary);
    --c-bg:             var(--bg);
    --c-surface:        var(--surface);
    --c-surface-2:      var(--surface-2);
    --c-text:           var(--text-primary);
    --c-text-soft:      var(--text-secondary);
    --c-border:         var(--border);
    --c-border-strong:  var(--border);
    --c-success:        var(--success);
    --c-success-bg:     var(--success-light);
    --c-warning:        var(--warning);
    --c-warning-bg:     var(--warning-light);
    --c-danger:         var(--danger);
    --c-danger-bg:      var(--danger-light);
    --c-info:           var(--info);
    --c-info-bg:        var(--info-light);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    padding-top: var(--navbar-h);
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.6;
}
[lang="tr"] body { font-family: 'Inter', 'Segoe UI', sans-serif; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── Navbar ─────────────────────────────────────────────── */
.app-navbar {
    height: var(--navbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.navbar-toggler-custom {
    width: 40px; height: 40px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.navbar-toggler-custom:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.navbar-brand-custom {
    flex: 1;
    min-width: 0;               /* allow shrinking on narrow phones */
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-profile-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    border-radius: 999px;
    padding: 2px;
    transition: background var(--transition);
}
.navbar-profile-link:hover { background: var(--bg); }
.navbar-profile-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: none;
}

@media (min-width: 768px) {
    .user-name { display: block; }
}

.btn-logout {
    width: 36px; height: 36px;
    border: none;
    background: var(--danger-light);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--danger);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-size: 1rem;
}
.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    transform: scale(1.05);
}

.lang-switch {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.lang-switch a {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all var(--transition);
}
.lang-switch a:hover { background: var(--surface); color: var(--text-primary); }
.lang-switch a.is-active {
    background: #1a1a1a;
    color: #fff;
}

/* ─── Sidebar (offcanvas) ───────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-w) !important;
    background: var(--sidebar-bg) !important;
    border: none !important;
    color: rgba(255,255,255,.55);
}

.sidebar-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--secondary), #b8861a);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-subtitle {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.3);
}

.sidebar-body {
    padding: 0.75rem 0;
    overflow-y: auto;
    height: calc(100% - 72px);
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    padding: 0.9rem 1.25rem 0.3rem;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.22);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin: 1px 0.6rem;
    border-radius: var(--radius-sm);
    position: relative;
    border: none;
    background: transparent;
    width: calc(100% - 1.2rem);
    cursor: pointer;
}

.sidebar-link .link-icon {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    transition: all var(--transition);
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-link:hover .link-icon { background: rgba(255,255,255,.12); }

.sidebar-link.active {
    color: #fff;
    background: rgba(212, 160, 23, 0.16);
}
.sidebar-link.active .link-icon {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(212, 160, 23, 0.45);
}
.sidebar-link.active::after {
    content: '';
    position: absolute;
    inset-inline-end: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 55%;
    background: var(--secondary);
    border-radius: 0 999px 999px 0;
}
[dir="rtl"] .sidebar-link.active::after { border-radius: 999px 0 0 999px; }

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0.4rem 1.2rem;
}

.sidebar-link.link-danger { color: rgba(248, 113, 113, 0.65); }
.sidebar-link.link-danger .link-icon {
    background: rgba(239, 68, 68, 0.10);
    color: #f87171;
}
.sidebar-link.link-danger:hover { color: #fff; background: rgba(239, 68, 68, 0.15); }
.sidebar-link.link-danger:hover .link-icon { background: var(--danger); }

/* ─── Main ─────────────────────────────────────────────── */
main, .app-main {
    padding: 1.5rem 1.25rem !important;
    min-height: calc(100vh - var(--navbar-h));
}

/* ─── Page Header ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.4rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.page-header h1, .page-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    -webkit-text-fill-color: initial;
}

.page-header .breadcrumb {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
    padding: 0;
    background: none;
    list-style: none;
}

/* ─── Cards ───────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow); }

.card-header, .card__header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.25rem;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.card__title { margin: 0; font-size: 0.95rem; font-weight: 700; }
.card-body, .card__body { padding: 1.25rem; }
.card__footer {
    padding: 0.85rem 1.25rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border-light);
}

/* ─── Stat Cards ──────────────────────────────────────── */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    border: none;
    box-shadow: var(--shadow);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -25px;
    inset-inline-start: -25px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
}

.stat-card__icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    flex-shrink: 0;
    z-index: 1;
}

.stat-card .stat-label, .stat-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}
.stat-card .stat-value, .stat-card__value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* Color variants — same gradient logic as project_v2 + extra ones */
.stat-card.v-primary, .stat-card.bg-primary { background: linear-gradient(135deg, #2a2a2a, #1a1a1a) !important; }
.stat-card.v-success, .stat-card.bg-success { background: linear-gradient(135deg, #10b981, #34d399) !important; }
.stat-card.v-warning, .stat-card.bg-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24) !important; }
.stat-card.v-warn,    .stat-card.bg-warn    { background: linear-gradient(135deg, #f59e0b, #fbbf24) !important; }
.stat-card.v-danger,  .stat-card.bg-danger  { background: linear-gradient(135deg, #ef4444, #f87171) !important; }
.stat-card.v-info,    .stat-card.bg-info    { background: linear-gradient(135deg, #06b6d4, #22d3ee) !important; }
.stat-card.v-purple,  .stat-card.bg-secondary { background: linear-gradient(135deg, #475569, #64748b) !important; }
.stat-card.v-accent { background: linear-gradient(135deg, #d4a017, #b8861a) !important; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

/* ─── Tables ─────────────────────────────────────────── */
.table {
    font-size: 0.875rem;
    color: var(--text-primary);
    border-color: var(--border-light);
}
.table thead th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    white-space: nowrap;
    border-top: none;
    text-align: center;
    vertical-align: middle;
}
.table tbody td {
    padding: 0.6rem 1rem;
    border-color: var(--border-light);
    vertical-align: middle;
    text-align: center;
    height: 52px;
    box-sizing: border-box;
    white-space: nowrap;          /* keep text on one line; let the wrapper scroll */
}
.table-hover tbody tr { transition: background var(--transition); }
.table-hover tbody tr:hover { background: #f8faff; }

/* Legacy data-table (BEM style) — same look */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.875rem;
    color: var(--text-primary);
}
.data-table thead th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    white-space: nowrap;
    text-align: start;
    vertical-align: middle;
}
.data-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    text-align: start;
    white-space: nowrap;          /* one-line text; wrapper provides horizontal scroll */
}
/* Opt-out helper for truly long content (e.g. addresses) */
.data-table tbody td.cell-wrap,
.table tbody td.cell-wrap {
    white-space: normal;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #f8faff; }

/* Sticky header inside the scroll wrapper */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: 0 1px 0 var(--border);
}
.table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: 0 1px 0 var(--border);
}

/* Modern action button cluster — single row, never wraps */
.row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.row-actions form { margin: 0; padding: 0; display: inline-flex; }

.btn-icon-action {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), background var(--transition),
                border-color var(--transition), color var(--transition),
                box-shadow var(--transition);
    padding: 0;
    cursor: pointer;
    font-size: 0.92rem;
    text-decoration: none;
    flex-shrink: 0;
}
.btn-icon-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.10);
}
.btn-icon-action i { line-height: 1; }

.btn-icon-action.action-view {
    color: #0284c7;
}
.btn-icon-action.action-view:hover {
    background: var(--info-light);
    border-color: #0284c7;
    color: #0e7490;
}

.btn-icon-action.action-edit {
    color: #ca8a04;
}
.btn-icon-action.action-edit:hover {
    background: var(--warning-light);
    border-color: #ca8a04;
    color: #92400e;
}

.btn-icon-action.action-delete {
    color: var(--danger);
}
.btn-icon-action.action-delete:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.table-wrap, .table-scroll-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    border-radius: var(--radius);
}

/* ─── Badges ─────────────────────────────────────────── */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.28em 0.65em;
    border-radius: 999px;
    display: inline-block;
}
.badge-primary, .bg-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success, .bg-success { background: var(--success-light); color: #065f46; }
.badge-warning, .bg-warning { background: var(--warning-light); color: #92400e; }
.badge-danger,  .bg-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-info,    .bg-info    { background: var(--info-light);    color: #0e7490; }
.badge-muted    { background: #f3f4f6; color: var(--text-muted); }
.badge-gold     { background: #fef3c7; color: #92400e; }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    cursor: pointer;
    padding: 0.52rem 1rem;
    line-height: 1.2;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg);
}
[lang="tr"] .btn { font-family: 'Inter', sans-serif; }

.btn:active { transform: scale(0.97); }
.btn-sm  { padding: 0.32rem 0.7rem; font-size: 0.82rem; }
.btn-lg  { padding: 0.72rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon {
    width: 34px; height: 34px;
    padding: 0 !important;
    border-radius: var(--radius-sm);
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #2a2a2a, #000000);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    border: 1px solid #000;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #000000, #1a1a1a);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
    transform: translateY(-1px);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.30);
}
.btn-success:hover { box-shadow: 0 6px 18px rgba(16, 185, 129, 0.42); transform: translateY(-1px); color: #fff; }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { transform: translateY(-1px); color: #fff; box-shadow: 0 6px 18px rgba(239, 68, 68, 0.42); }

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.30);
}
.btn-warning:hover { transform: translateY(-1px); color: #fff; }

.btn-accent {
    background: linear-gradient(135deg, var(--secondary), #b8861a);
    color: #fff;
    box-shadow: 0 4px 12px rgba(212, 160, 23, 0.32);
}
.btn-accent:hover { color: #fff; transform: translateY(-1px); }

.btn-outline, .btn-outline-primary {
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    background: var(--surface);
    box-shadow: none;
}
.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--bg); color: var(--text-primary); border-color: var(--text-secondary); }
.btn-outline-primary:hover { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary-dark); }

.btn-ghost { background: transparent; box-shadow: none; }

/* ─── Forms ──────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    display: block;
}
.form-label .req { color: var(--danger); }

.form-control, .form-select {
    font-family: 'Cairo', sans-serif;
    font-size: 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--surface);
    transition: all var(--transition);
    padding: 0.52rem 0.85rem;
    width: 100%;
}
[lang="tr"] .form-control, [lang="tr"] .form-select { font-family: 'Inter', sans-serif; }

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.12);
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--surface-2); color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 88px; }

.form-help, .form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.invalid-feedback {
    color: var(--danger);
    font-size: 0.78rem;
    margin-top: 0.25rem;
}
.form-control.is-invalid { border-color: var(--danger); }

.form-group { margin-bottom: 1rem; }

/* Legacy form-row helper (used heavily by family/item forms) */
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-row.form-row--2-1 { grid-template-columns: 2fr 1fr; }

.form-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--border);
}
.form-section__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-dark);
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
}

.checkbox, .radio {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    padding: 0.3rem 0;
}
.checkbox input, .radio input {
    width: 18px; height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ─── Alerts ─────────────────────────────────────────── */
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}
.alert-success { background: var(--success-light); color: #065f46; }
.alert-danger, .alert-error { background: var(--danger-light); color: #991b1b; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info    { background: var(--info-light);    color: #0e7490; }

/* ─── Login (split-screen, black + gold) ───────────────── */
body.login-body { padding-top: 0; background: #fff; overflow-x: hidden; }

.login-split {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}

/* Brand panel — solid black with subtle dotted grid + gold halo */
.login-brand {
    background: #0a0a0a;
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0);
    background-size: 22px 22px;
    pointer-events: none;
}
.login-brand::after {
    content: '';
    position: absolute;
    width: 540px; height: 540px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 160, 23, 0.18) 0%, transparent 65%);
    inset-inline-end: -240px;
    bottom: -240px;
    animation: glowPulse 6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes glowPulse {
    0%,100% { opacity: 0.85; transform: scale(1); }
    50%     { opacity: 1;     transform: scale(1.08); }
}

.login-brand__inner {
    position: relative;
    z-index: 1;
    max-width: 520px;
    width: 100%;
    margin: auto;
    animation: slideStart 0.55s cubic-bezier(.22,.61,.36,1);
}
@keyframes slideStart { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.login-brand__logo {
    width: 76px; height: 76px;
    background: linear-gradient(135deg, var(--secondary), #b8861a);
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.1rem; color: #fff;
    margin-bottom: 1.5rem;
    box-shadow: 0 12px 32px rgba(212, 160, 23, 0.32);
    overflow: hidden;
}
.login-brand__logo img { width: 100%; height: 100%; object-fit: contain; }

.login-brand__title {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 0.6rem;
    color: #fff;
}
.login-brand__title em {
    font-style: normal;
    color: var(--secondary);
}
.login-brand__subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.7;
    margin-bottom: 2rem;
}
.login-brand__features {
    list-style: none; padding: 0; margin: 0;
    display: grid; gap: 0.85rem;
}
.login-brand__features li {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.85);
}
.login-brand__features li i {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(212, 160, 23, 0.14);
    color: var(--secondary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Form panel — clean white */
.login-form-panel {
    background: #ffffff;
    padding: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-form-card {
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.55s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.login-form-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 0.4rem;
    color: var(--text-primary);
}
.login-form-card p.lead {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}
.login-form-card .form-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.login-form-card .form-control {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
}
.login-form-card .form-control:focus {
    background: #fff;
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.btn-login {
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(135deg, #1a1a1a, #000);
    color: #fff;
    border: 1px solid #000;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.20);
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}
.btn-login::before {
    content: '';
    position: absolute;
    top: 0; inset-inline-start: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 160, 23, 0.35), transparent);
    transition: inset-inline-start 0.6s ease;
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.30);
}
.btn-login:hover::before { inset-inline-start: 100%; }

.login-meta {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem;
}
.login-meta__hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.login-meta__hint i { color: var(--secondary); margin-inline-end: 4px; }

.login-lang-switch {
    display: flex; gap: 4px;
}
.login-lang-switch a {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.login-lang-switch a:hover { background: var(--bg); color: var(--text-primary); }
.login-lang-switch a.is-active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

@media (max-width: 900px) {
    .login-split { grid-template-columns: 1fr; }
    .login-brand { padding: 2rem 1.5rem; }
    .login-brand__inner { text-align: center; max-width: 480px; }
    .login-brand__logo { margin-inline: auto; }
    .login-brand__features { display: none; }
    .login-form-panel { padding: 2rem 1.25rem; }
}
@media (max-width: 480px) {
    .login-brand { padding: 1.5rem 1rem; }
    .login-brand__title { font-size: 1.4rem; }
    .login-brand__logo { width: 60px; height: 60px; font-size: 1.6rem; }
    .login-form-card h2 { font-size: 1.2rem; }
    .login-form-card p.lead { font-size: 0.85rem; margin-bottom: 1.25rem; }
    .login-form-panel { padding: 1.5rem 1rem; }
}

/* ─── Empty State ────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: block;
}

/* ─── Pagination ─────────────────────────────────────── */
.pagination {
    display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
    padding: 1rem 0;
    list-style: none; margin: 0;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all var(--transition);
}
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Misc helpers ───────────────────────────────────── */
.color-swatch {
    display: inline-block;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border), 0 2px 4px rgba(0,0,0,.08);
    vertical-align: middle;
}
.province-dot {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    margin-inline-end: 8px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px rgba(255,255,255,.95), 0 0 0 3px rgba(0,0,0,.08);
}

.detail-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.detail-item {
    background: var(--surface-2);
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.detail-item__label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 600;
}
.detail-item__value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
}

.signature-img {
    background: var(--surface);
    border: 1px dashed var(--border);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
}
.signature-img img { max-height: 120px; max-width: 100%; }

/* Utility classes */
.text-soft     { color: var(--text-muted); }
.text-primary  { color: var(--primary) !important; }
.text-accent   { color: var(--secondary) !important; }
.text-success  { color: var(--success) !important; }
.text-warning  { color: var(--warning) !important; }
.text-danger   { color: var(--danger) !important; }
.text-info     { color: var(--info) !important; }
.text-muted    { color: var(--text-muted) !important; }
.text-end      { text-align: end; }
.text-center   { text-align: center; }
.text-start    { text-align: start; }
.fw-bold       { font-weight: 700; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.fw-800        { font-weight: 800; }
.mt-0  { margin-top: 0; }   .mt-1 { margin-top: .5rem; }   .mt-2 { margin-top: 1rem; }   .mt-3 { margin-top: 1.5rem; }
.mb-0  { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }   .gap-2 { gap: 1rem; }   .gap-3 { gap: 1.5rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

/* ─── Charts grid ────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.charts-grid--equal { grid-template-columns: 1fr 1fr; }

/* Stack vertically on tablets and below */
@media (max-width: 1024px) {
    .charts-grid,
    .charts-grid--equal { grid-template-columns: 1fr; }
}

/* Chart card uses full available card height — no idle whitespace below the canvas */
.chart-box {
    display: flex;
    flex-direction: column;
}
.chart-box .card-body,
.chart-box .card__body {
    flex: 1;
    min-height: 360px;
    padding: 1rem 1.1rem;
    position: relative;
}
.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 420px;
}

/* Tighter on mobile to avoid huge cards */
@media (max-width: 768px) {
    .chart-box .card-body,
    .chart-box .card__body { min-height: 280px; }
    .chart-box canvas { max-height: 320px; }
}

/* ─── Animations ─────────────────────────────────────── */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

/* ─── Responsive ─────────────────────────────────────── */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    main, .app-main { padding: 1rem 0.85rem !important; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding: 0.85rem 1rem;
    }
    .page-header h1, .page-header h2 {
        font-size: 1rem;
        justify-content: center;
    }
    .page-header .btn,
    .page-header a.btn { width: 100%; justify-content: center; }

    .card-header, .card__header { padding: 0.75rem 1rem; font-size: 0.84rem; }
    .card-body, .card__body { padding: 1rem; }
    .card__footer { padding: 0.75rem 1rem; }

    .form-row.cols-2,
    .form-row.cols-3,
    .form-row.cols-4,
    .form-row.form-row--2-1 { grid-template-columns: 1fr; }

    /* Detail view (families/show.php) — one field per row on tablet & below */
    .detail-grid { grid-template-columns: 1fr !important; }
    .detail-item[style*="grid-column"] { grid-column: auto !important; }

    .stat-card { padding: 0.9rem 1rem; }
    .stat-card .stat-value, .stat-card__value { font-size: 1.25rem; }
    .stat-card__icon { width: 42px; height: 42px; font-size: 1.1rem; }
}

/* Mobile (≤576px) */
@media (max-width: 576px) {
    main, .app-main { padding: 0.75rem 0.5rem !important; }

    .page-header {
        padding: 0.75rem 0.85rem;
        margin-bottom: 0.6rem;
        border-radius: var(--radius);
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 0.5rem;
    }
    .page-header > div:first-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }
    .page-header h1, .page-header h2 {
        font-size: 1rem;
        gap: 0.4rem;
        justify-content: center;
    }
    .page-header h1 i, .page-header h2 i { font-size: 1rem; }
    .page-header .breadcrumb { font-size: 0.78rem; }
    .page-header .btn,
    .page-header a.btn {
        width: 100%;
        justify-content: center;
        font-size: 0.85rem;
        padding: 0.55rem 0.8rem;
    }

    .card { border-radius: var(--radius); margin-bottom: 0.5rem; }
    .card-body, .card__body { padding: 0.75rem; }
    .card-header, .card__header { padding: 0.65rem 0.75rem; font-size: 0.82rem; }

    /* Filter bar form-row sits tighter on mobile */
    .form-row { gap: 0.6rem; }
    .form-group { margin-bottom: 0.6rem; }
    .form-group.mb-0 { margin-bottom: 0 !important; }
    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }

    /* Action buttons slightly smaller on tiny screens */
    .btn-icon-action { width: 30px; height: 30px; font-size: 0.85rem; }
    .row-actions { gap: 4px; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card {
        padding: 0.85rem;
        border-radius: var(--radius);
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        min-height: 110px;
    }
    .stat-card__icon { width: 36px; height: 36px; font-size: 1rem; border-radius: 8px; }
    .stat-card .stat-value, .stat-card__value { font-size: 1.05rem; }
    .stat-card .stat-label, .stat-card__label { font-size: 0.62rem; }

    .table { font-size: 0.78rem; }
    .data-table { font-size: 0.78rem; }
    .table thead th, .data-table thead th {
        padding: 0.55rem 0.5rem;
        font-size: 0.62rem;
        letter-spacing: 0.03em;
    }
    .table tbody td, .data-table tbody td {
        padding: 0.45rem 0.5rem;
        height: 42px;
        font-size: 0.78rem;
    }

    .btn { font-size: 0.8rem; padding: 0.4rem 0.7rem; }
    .btn-icon { width: 30px; height: 30px; }
    .btn-icon i { font-size: 0.8rem; }
    .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

    .form-control, .form-select { font-size: 0.82rem; padding: 0.42rem 0.7rem; }
    .form-label { font-size: 0.78rem; margin-bottom: 0.25rem; }

    .badge { font-size: 0.65rem; padding: 0.2em 0.5em; }
    .alert { font-size: 0.82rem; padding: 0.7rem 0.9rem; }

    .app-navbar { padding: 0 0.75rem; gap: 0.5rem; }
    .navbar-brand-custom { font-size: 0.88rem; }
    .navbar-toggler-custom { width: 36px; height: 36px; font-size: 1.05rem; }
    .user-avatar { width: 32px; height: 32px; font-size: 0.75rem; }
    .btn-logout { width: 32px; height: 32px; font-size: 0.9rem; }

    .btn-login { padding: 0.6rem; font-size: 0.88rem; }

    .charts-grid { grid-template-columns: 1fr; gap: 0.75rem; }

    .detail-grid { grid-template-columns: 1fr; }
}

/* Very small (≤400px) */
@media (max-width: 400px) {
    main, .app-main { padding: 0.5rem 0.35rem !important; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: auto; flex-direction: row; }
    .form-control, .form-select { font-size: 0.78rem; padding: 0.36rem 0.5rem; }
    .form-label { font-size: 0.72rem; }
    .btn { font-size: 0.73rem; padding: 0.3rem 0.55rem; }
    .badge { font-size: 0.6rem; padding: 0.15em 0.4em; }
    .navbar-brand-custom { font-size: 0.78rem; }
}

/* Print */
@media print {
    .app-navbar, .app-sidebar, .no-print { display: none !important; }
    body { padding-top: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc; }
}

/* =========================================================
   Additions (v1.1): deliveries, pagination, audit log
   ========================================================= */

/* Inline "record delivery" form in the needs table */
.deliver-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}
.deliver-form input[type="date"] {
    width: 9.5rem;
    min-width: 9.5rem;
    padding-block: 0.3rem;
}

/* Pagination bar (families list, audit log) */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}
.pagination-bar__info { color: var(--text-secondary); font-size: 0.85rem; }
.pagination-bar__pages { display: flex; flex-wrap: wrap; gap: 4px; }
.pg-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition);
}
a.pg-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.pg-btn.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-gap { align-self: center; padding: 0 4px; color: var(--text-secondary); }

/* Audit log details */
.audit-details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 0.8rem; }
.audit-details pre {
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 360px;
    margin: 6px 0 0;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 0.75rem;
}

/* Admin notices (pending database updates) */
.admin-notice { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.admin-notice .btn { margin-inline-start: auto; }

/* Due-date summary on the dashboard */
.due-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.due-summary a.alert { text-decoration: none; margin-bottom: 0; }
.due-summary a.alert:hover { filter: brightness(0.97); }

/* Export buttons on the reports page */
.export-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* =========================================================
   v1.2 — centered content column + form modals
   ========================================================= */

/* Content sits in a centered column with free space on both sides
   (wide screens only; below the max width nothing changes). */
:root { --content-max: 1200px; }
main, .app-main {
    max-width: var(--content-max);
    margin-inline: auto;
}
@media (min-width: 1240px) {
    /* Navbar stays full-bleed, but its items line up with the content column */
    .app-navbar { padding-inline: calc((100% - var(--content-max)) / 2 + 1.25rem); }
}
@media print {
    main, .app-main { max-width: none; }
}

/* Form modals (add / edit happen in a popup, never on a separate page) */
.modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    padding: 0.9rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.modal-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--text-primary);
}
.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: 0.75rem 1.25rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}
.modal-footer > * { margin: 0; }
.modal-body > .alert[data-form-alert] { margin-bottom: 1rem; }
.modal-body .form-group:last-child { margin-bottom: 0; }

/* The big family form: sections keep their card look inside the modal */
#familyModal .modal-body { background: var(--bg); }
#familyModal .modal-body .card:last-of-type { margin-bottom: 0 !important; }
.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 220px;
    color: var(--text-secondary);
}

/* Colour picker + hex text pair used in several forms */
.color-field { display: flex; align-items: center; gap: 0.5rem; }
.color-field input[type="color"] {
    width: 52px;
    height: 42px;
    padding: 0;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.color-field input[type="text"] { font-family: monospace; direction: ltr; }

@media (max-width: 576px) {
    .modal-body { padding: 0.9rem; }
    .modal-header, .modal-footer { padding-inline: 0.9rem; }
}

/* Wide tables inside the centered column: tighter cells + two-line cells */
.data-table--dense thead th,
.data-table--dense tbody td { padding-inline: 0.6rem; }
.data-table td.cell-stack small {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
/* Long free text wraps instead of stretching the table */
.data-table tbody td.cell-wrap { min-width: 14rem; max-width: 24rem; }

/* ===== Warehouses (v1.3) ===== */
/* Product lines of a warehouse document (modal) */
.stock-line {
    margin-top: 10px;
    padding: 12px;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface-2);
}
.stock-line__grid {
    display: grid;
    grid-template-columns: minmax(200px, 3fr) minmax(90px, 1fr) minmax(110px, 1.2fr) minmax(140px, 1.4fr) auto;
    gap: 10px;
    align-items: end;
}
.stock-line__grid > [data-line-expiry][hidden] { display: none; }
.stock-line__remove { padding-bottom: 2px; }
.stock-line [data-line-hint] { margin-top: 6px; min-height: 1em; }
@media (max-width: 768px) {
    .stock-line__grid { grid-template-columns: 1fr 1fr; }
    .stock-line__grid > :first-child { grid-column: 1 / -1; }
}

/* Family delivery from a warehouse: compact controls in the needs table */
.deliver-form select.form-control-sm { max-width: 11rem; }
.deliver-form .deliver-qty { width: 5.5rem; }

/* ID card photo of the head of family */
.id-image-preview img { max-height: 160px; }
.id-image-thumb img {
    display: block;
    max-width: 220px;
    max-height: 140px;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    object-fit: contain;
    background: #fff;
}

/* Warehouse report */
.report-summary td:first-child { width: 60%; }
.report-matrix td, .report-matrix th { text-align: center; }
.report-matrix td:first-child, .report-matrix th:first-child { text-align: start; }

/* Count sheet */
.count-sheet input[type="number"] { max-width: 140px; }

@media print {
    .stock-line__remove, .deliver-form { display: none !important; }
    .report-matrix, .report-summary, .count-sheet { font-size: 11px; }
}
.deliver-form:has(select) { flex-wrap: wrap; }
