

:root {
    --red-50:  #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-300: #fca5a5;
    --red-400: #f87171;
    --red-500: #dc2626;
    --red-600: #b91c1c;
    --red-700: #991b1b;
    --red-900: #450a0a;

    --green-50:  #ecfdf5;
    --green-100: #d1fae5;
    --green-200: #a7f3d0;
    --green-500: #10b981;
    --green-600: #059669;
    --green-700: #047857;

    --amber-50:  #fffbeb;
    --amber-100: #fef3c7;
    --amber-200: #fde68a;
    --amber-600: #d97706;
    --amber-700: #b45309;

    --brand-orange-50:  #fff7ed;
    --brand-orange-100: #ffedd5;
    --brand-orange-200: #fed7aa;
    --brand-orange-500: #f97316;
    --brand-orange-600: #ea580c;
    --brand-orange-700: #c2410c;
    --stat-neutral: #154940;
    --stat-neutral-soft: rgba(21, 73, 64, .10);
    --stat-orange: #c2410c;
    --stat-orange-soft: rgba(249, 115, 22, .12);

    --ink-900: #0b1220;
    --ink-700: #1f2937;
    --ink-500: #4b5563;
    --ink-400: #6b7280;
    --ink-300: #9ca3af;
    --ink-200: #e5e7eb;
    --ink-100: #f3f4f6;
    --ink-50:  #f8fafc;

    --page:    #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border:  #e6ebf3;
    --border-strong: #cfd7e6;
    --text:    #0b1220;
    --muted:   #6b7280;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow:    0 6px 20px rgba(15, 23, 42, .07);
    --shadow-lg: 0 24px 50px -16px rgba(185, 28, 28, .25), 0 8px 24px rgba(15, 23, 42, .08);
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(1100px 580px at -10% -10%, rgba(220, 38, 38, .05), transparent 60%),
        radial-gradient(900px 500px at 110% 0%, rgba(16, 185, 129, .06), transparent 60%),
        var(--page);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    font-size: 14px;
}
a { color: inherit; }

.app-shell {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    min-height: 100vh;
}
.app-shell.no-sidebar {
    grid-template-columns: minmax(0, 1fr);
}

.app-shell {
    transition: grid-template-columns .34s cubic-bezier(.4, 0, .2, 1);
}
.app-shell.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}
.app-shell > .sidebar {
    overflow-x: hidden;
    transition: opacity .26s ease, transform .34s cubic-bezier(.4, 0, .2, 1);
}
.app-shell.sidebar-collapsed > .sidebar {
    opacity: 0;
    transform: translateX(-14px);
    pointer-events: none;
}

.app-shell > .sidebar > .sidebar-brand,
.app-shell > .sidebar > .sidebar-nav,
.app-shell > .sidebar > .sidebar-footer {
    width: 240px;
    max-width: 240px;
}
.sidebar {
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex; flex-direction: column;
    gap: 6px;
}
.sidebar-brand {
    display: flex; gap: 12px; align-items: center;
    padding: 10px 10px 14px;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 6px;
}
.brand-logo {
    flex: 0 0 52px;
    width: 52px; height: 52px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--red-600), var(--red-700));
    color: #fff;
    box-shadow: 0 8px 18px rgba(185, 28, 28, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
    position: relative;
    overflow: hidden;
    padding: 0;
}
.brand-logo::after {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(60% 60% at 30% 20%, rgba(255, 255, 255, .25), transparent 60%);
    pointer-events: none;
}
.brand-logo i { font-size: 26px; position: relative; z-index: 1; }
.brand-logo img {
    width: 38px; height: 38px;
    object-fit: contain;
    position: relative; z-index: 1;
    filter: brightness(0) invert(1);
}
.brand-meta { line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; color: var(--ink-900); letter-spacing: .2px; }
.brand-subtitle, .brand-sub {
    font-size: 11px; color: var(--ink-400); margin-top: 4px;
    text-transform: uppercase; letter-spacing: .12em;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group {
    margin: 14px 8px 4px;
    color: var(--ink-300);
    font-size: 10.5px; font-weight: 800;
    letter-spacing: .14em; text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}
.nav-group::before {
    content: "";
    width: 14px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--red-500), var(--green-500));
}
.nav-item {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center; gap: 10px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--ink-700);
    text-decoration: none;
    font-size: 13.5px; font-weight: 600;
    transition: all .18s ease;
    position: relative;
    cursor: pointer;
}
.nav-item i { color: var(--ink-400); font-size: 14px; }
.nav-item:hover {
    background: var(--ink-50);
    color: var(--ink-900);
    border-color: var(--border);
}
.nav-item.active {
    background: linear-gradient(180deg, var(--red-50), #fff);
    border-color: var(--red-200);
    color: var(--red-700);
    box-shadow: inset 3px 0 0 var(--red-600), 0 1px 2px rgba(185, 28, 28, .08);
}
.nav-item.active i { color: var(--red-600); }
.nav-item.child { font-size: 12.5px; min-height: 34px; font-weight: 600; }
.nav-pill {
    font-size: 10px; font-weight: 800;
    padding: 2px 7px; border-radius: 999px;
    background: var(--green-100); color: var(--green-700);
    letter-spacing: .04em;
}
.nav-pill.red { background: var(--red-100); color: var(--red-700); }
.nav-pill.alert {
    background: #dc2626;
    color: #fff;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, .18);
}
.nav-pill.amber { background: var(--amber-100); color: var(--amber-700); }

.notification-btn {
    position: relative;
}
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: #dc2626;
    color: #fff;
    border: 2px solid var(--surface);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(220, 38, 38, .25);
}

.nav-more { margin: 4px 0; }
.nav-more > summary {
    list-style: none; cursor: pointer;
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center; gap: 10px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--ink-700);
    font-size: 13.5px; font-weight: 700;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 10px; color: var(--ink-300);
    transition: transform .2s ease;
}
.nav-more[open] > summary::after { transform: rotate(180deg); }
.nav-more > summary i { color: var(--ink-400); font-size: 14px; }
.nav-more > summary:hover { background: var(--ink-50); color: var(--ink-900); border-color: var(--border); }
.nav-more[open] > summary { color: var(--red-700); }
.nav-more[open] > summary i { color: var(--red-600); }
.nav-more-panel { padding: 4px 0 6px 8px; display: flex; flex-direction: column; gap: 2px; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px dashed var(--border);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 36px; height: 36px; border-radius: 999px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    color: #fff; font-weight: 800; font-size: 13px;
    box-shadow: 0 4px 10px rgba(5, 150, 105, .25);
    flex: 0 0 36px;
}
.user-meta { line-height: 1.1; min-width: 0; flex: 1; overflow: hidden; }
.user-name {
    font-size: 13px; font-weight: 700; color: var(--ink-900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--ink-400); margin-top: 3px; }
.pulse-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: var(--green-500);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: pulse 1.8s infinite;
    margin-left: auto;
    flex: 0 0 8px;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
    70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.main-panel { padding: 22px 28px 40px; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
    
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow .18s ease, border-radius .18s ease;
}

.topbar.is-pinned {
    border-radius: 0;
    box-shadow: 0 10px 26px -14px rgba(15, 23, 42, .5);
}
.topbar > div:first-child { min-width: 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left > .topbar-heading { min-width: 0; }
.sidebar-toggle { flex: none; }
.sidebar-toggle i {
    display: inline-block;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
.sidebar-toggle:hover i { transform: scale(1.12); }
.sidebar-toggle:active i { transform: scale(.88); }

.app-shell.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }
.app-shell.sidebar-collapsed .sidebar-toggle:hover i { transform: rotate(180deg) scale(1.12); }
.crumbs {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--ink-400); font-weight: 600;
    flex-wrap: wrap;
}
.crumbs i { color: var(--red-500); }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--red-700); }
.crumbs .current { color: var(--ink-700); }
.crumb-sep { color: var(--ink-200); }
.page-title { margin: 4px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    height: 38px;
    border-radius: 10px;
    font-size: 13px; font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--ink-700);
    text-decoration: none;
    transition: all .15s ease;
    white-space: nowrap;
    line-height: 1;
    font-family: inherit;
}
.btn:hover { border-color: var(--red-500); color: var(--red-700); background: var(--red-50); }
.btn-primary {
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    border-color: var(--red-600);
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(220, 38, 38, .6);
}
.btn-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--red-600), var(--red-700));
    border-color: var(--red-700);
}
.btn-success {
    background: linear-gradient(135deg, var(--green-500), var(--green-600));
    border-color: var(--green-600);
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(5, 150, 105, .55);
}
.btn-success:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    border-color: var(--green-700);
}
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--ink-50); color: var(--ink-900); border-color: var(--border-strong); }
.btn-danger { color: var(--red-700); border-color: var(--red-200); background: #fff; }
.btn-danger:hover { background: var(--red-50); border-color: var(--red-500); color: var(--red-700); }

.btn-outline-secondary { color: var(--ink-700); border-color: var(--border-strong); background: #fff; }
.btn-outline-secondary:hover { border-color: var(--red-500); color: var(--red-700); background: var(--red-50); }
.btn-outline-primary { color: var(--red-700); border-color: var(--red-200); background: #fff; }
.btn-outline-primary:hover { background: var(--red-50); border-color: var(--red-500); color: var(--red-700); }
.btn-outline-danger { color: var(--red-700); border-color: var(--red-200); background: #fff; }
.btn-outline-danger:hover { background: var(--red-50); border-color: var(--red-500); color: var(--red-700); }

.btn-sm { height: 32px; padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }
.btn.w-100 { width: 100%; justify-content: center; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.kpi-mini {
    background:
        radial-gradient(180px 110px at 100% -20%, rgba(249, 115, 22, .08), transparent 62%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.kpi-mini:hover {
    transform: translateY(-1px);
    border-color: rgba(249, 115, 22, .28);
    box-shadow: 0 12px 26px -18px rgba(21, 24, 35, .45), var(--shadow-sm);
}
.kpi-mini::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--brand-orange-500), var(--brand-orange-700));
}
.kpi-mini.green::before,
.kpi-mini.neutral::before,
.kpi-mini.orange::before,
.kpi-mini.amber::before,
.kpi-mini.red::before { background: linear-gradient(180deg, var(--brand-orange-500), var(--brand-orange-700)); }
.kpi-strip .kpi-mini:nth-child(even)::before {
    background: linear-gradient(180deg, #154940, #0f342e);
}
.kpi-mini-label { color: var(--ink-400); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi-mini-val   { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; color: var(--ink-900); }
.kpi-mini-val small { font-size: 12px; color: var(--ink-400); font-weight: 700; margin-left: 2px; }
.kpi-mini-foot {
    margin-top: 6px;
    color: var(--ink-500);
    font-size: 12px;
    font-weight: 700;
}
.kpi-period-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 7px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--ink-50);
    border: 1px solid var(--border);
    color: var(--ink-400);
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.7;
}
.kpi-period-tag i { font-size: 9px; opacity: .85; }
.kpi-mini-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--stat-neutral-soft); color: var(--stat-neutral);
    font-size: 15px;
    box-shadow: inset 0 0 0 1px rgba(249, 115, 22, .08);
}
.kpi-mini.neutral .kpi-mini-icon { background: var(--stat-neutral-soft); color: var(--stat-neutral); box-shadow: inset 0 0 0 1px rgba(249, 115, 22, .08); }
.kpi-mini.orange .kpi-mini-icon { background: var(--stat-orange-soft); color: var(--stat-orange); box-shadow: inset 0 0 0 1px rgba(249, 115, 22, .12); }
.kpi-mini.green .kpi-mini-icon { background: var(--green-50); color: var(--green-600); box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .12); }
.kpi-mini.amber .kpi-mini-icon { background: var(--amber-50); color: var(--amber-600); box-shadow: inset 0 0 0 1px rgba(217, 119, 6, .10); }
.kpi-mini.red .kpi-mini-icon { background: var(--red-50); color: var(--red-600); box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .10); }

.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.toolbar form {
    display: flex; gap: 8px; align-items: center;
    flex: 1 1 320px; min-width: 280px;
}
.toolbar form .search-input {
    flex: 1;
    display: flex; align-items: center; gap: 8px;
    background: var(--ink-50);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    height: 38px;
}
.toolbar form .search-input i { color: var(--ink-400); }
.toolbar form .search-input input {
    flex: 1; border: 0; outline: 0;
    background: transparent;
    color: var(--ink-900);
    font-size: 13px; font-weight: 500;
    font-family: inherit;
    height: 36px;
}
.toolbar .filter-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700;
    background: var(--green-50); color: var(--green-700);
    border: 1px solid var(--green-200);
}
.toolbar .filter-chip.red { background: var(--red-50); color: var(--red-700); border-color: var(--red-200); }
.toolbar .filter-chip i { font-size: 9px; }
.toolbar .filter-chip .x { cursor: pointer; opacity: .7; margin-left: 2px; text-decoration: none; }
.toolbar .spacer { flex: 1; }
.toolbar .toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table-head-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.table-title { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.table-title .count {
    display: inline-flex; align-items: center;
    padding: 2px 9px; border-radius: 999px;
    background: var(--red-50); color: var(--red-700);
    font-size: 11px; font-weight: 800;
}
.table-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.table-responsive {
    width: 100%;
    max-width: 100%;
    
    overflow-x: auto;
}
.table-responsive > table {
    width: 100% !important;
    
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
}
.table-responsive > table.tbl,
.table-responsive > table.table {
    table-layout: fixed;
}

.table-responsive > table.tbl.entity-table {
    table-layout: auto;
}
.table-responsive > table.tbl th:not(.is-column-hidden),
.table-responsive > table.tbl td:not(.is-column-hidden),
.table-responsive > table.table th:not(.is-column-hidden),
.table-responsive > table.table td:not(.is-column-hidden) {
    min-width: 0;
    max-width: 100%;
}
.is-column-hidden { display: none !important; }
col.is-column-hidden {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
}

@media (max-width: 880px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-responsive > table.tbl,
    .table-responsive > table.table {
        width: 100% !important;
        min-width: 720px !important;
        max-width: none !important;
    }
    .table-responsive > table.tbl.entity-table {
        min-width: 640px !important;
    }
    .table-responsive > table.tbl.clients-table {
        min-width: 600px !important;
    }
    
    .table-responsive > table.tbl.orders-table {
        min-width: 0 !important;
    }
}
@media (max-width: 540px) {
    .table-responsive > table.tbl,
    .table-responsive > table.table {
        min-width: 640px !important;
    }
    .table-responsive > table.tbl.orders-table {
        min-width: 0 !important;
    }
}

.column-visibility { position: relative; display: inline-block; }
.column-visibility summary {
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink-700);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.column-visibility summary::-webkit-details-marker { display: none; }
.column-visibility summary:hover {
    border-color: var(--red-300);
    background: var(--red-50);
    color: var(--red-700);
}
.column-visibility-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    width: min(260px, calc(100vw - 32px));
    max-height: 340px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.column-visibility-menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 8px;
    color: var(--ink-700);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}
.column-visibility-menu label:hover { background: var(--ink-50); }
.column-visibility-menu input { accent-color: var(--red-600); }
.column-visibility-menu .btn { width: 100%; justify-content: center; margin-top: 6px; }

table.table, table.tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    margin: 0;
}
table.table thead th, table.tbl thead th {
    background: var(--ink-50);
    padding: 11px 14px;
    font-size: 11.5px; font-weight: 800;
    color: var(--ink-500);
    letter-spacing: .04em; text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    vertical-align: middle;
    position: relative;
}
.col-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 3;
}
.col-resize-handle::after {
    content: "";
    position: absolute;
    top: 25%;
    right: 3px;
    width: 1px;
    height: 50%;
    background: var(--border-strong);
    opacity: 0;
    transition: opacity .12s ease;
}
.col-resize-handle:hover::after,
.col-resize-handle.is-active::after {
    opacity: 1;
    background: var(--red-400, var(--red-600));
}
body.col-resizing {
    cursor: col-resize;
    user-select: none;
}
table.table thead th[data-sortable="1"],
table.tbl thead th[data-sortable="1"] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}
table.table thead th[data-sortable="1"]::after,
table.tbl thead th[data-sortable="1"]::after {
    content: "↕";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--ink-400);
    opacity: .75;
}
table.table thead th[data-sort-direction="asc"]::after,
table.tbl thead th[data-sort-direction="asc"]::after { content: "↑"; color: var(--red-600); opacity: 1; }
table.table thead th[data-sort-direction="desc"]::after,
table.tbl thead th[data-sort-direction="desc"]::after { content: "↓"; color: var(--red-600); opacity: 1; }
table.table thead th[data-sortable="1"]:hover,
table.tbl thead th[data-sortable="1"]:hover {
    color: var(--ink-900);
    background: var(--ink-100);
}
table.table tbody td, table.tbl tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--ink-100);
    color: var(--ink-700);
    vertical-align: middle;
}
table.table tbody tr:hover td, table.tbl tbody tr:hover td { background: var(--ink-50); }
table.table tbody tr:last-child td, table.tbl tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr.is-selected td { background: rgba(220, 38, 38, .04); }

/* Recently-actioned / selected row — neutral gray.
   Uses !important + high specificity so it always wins over the
   status-row colour gradients in the orders & invoices tables. */
.table-responsive table tbody tr.sfm-row-active > td {
    background: rgba(100, 116, 139, .17) !important;
}
.table-responsive table tbody tr.sfm-row-active:hover > td {
    background: rgba(100, 116, 139, .24) !important;
}
.table-responsive table tbody tr.sfm-row-active > td:first-child {
    box-shadow: inset 3px 0 0 0 #64748b !important;
}
html[data-theme="dark"] .table-responsive table tbody tr.sfm-row-active > td {
    background: rgba(148, 163, 184, .22) !important;
}
html[data-theme="dark"] .table-responsive table tbody tr.sfm-row-active:hover > td {
    background: rgba(148, 163, 184, .30) !important;
}
/* Manual multi-select tick keeps a lighter neutral tint */
table.table tbody tr.is-selected > td,
table.tbl tbody tr.is-selected > td {
    background: rgba(100, 116, 139, .10);
}
@keyframes sfmRowFlash {
    0%   { background: rgba(100, 116, 139, .34) !important; }
    100% { background: rgba(100, 116, 139, .17) !important; }
}
.table-responsive table tbody tr.sfm-row-active > td {
    animation: sfmRowFlash 1.1s ease-out 1;
}

.id-col  { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: 12px; color: var(--ink-500); font-weight: 700; }

.id-col::before,
.id-col::after,
td.invoice-col-no::before, td.order-col-no::before,
td.quote-col-no::before, td.delivery-col-no::before { content: none !important; }
.num-col { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-weight: 700; color: var(--ink-900); text-align: right; white-space: nowrap; }
table.table thead th.num-col,
table.tbl thead th.num-col {
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--ink-500);
    text-align: left;
}
.quotes-table tbody td.num-col,
.invoices-table tbody td.num-col,
.deliveries-table tbody td.num-col,
.orders-table tbody td.num-col {
    text-align: left;
}
td.actions, .actions-cell {
    text-align: right;
    white-space: nowrap;
    
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

td.actions .btn, .actions-cell .btn { margin-left: 0; }
td.actions .btn-icon, .actions-cell .btn-icon { width: 24px; height: 24px; }

td.actions .btn, .actions-cell .btn { gap: 3px; padding: 3px 6px; height: 26px; font-size: 11px; }
td.actions .btn-icon, .actions-cell .btn-icon { padding: 0; font-size: 12px; }

.selection-column { width: 32px; text-align: center; }

.invoices-table th:has(> input[type="checkbox"]),
.invoices-table td:has(> input[type="checkbox"]),
.orders-table th:has(> input[type="checkbox"]),
.orders-table td:has(> input[type="checkbox"]),
.quotes-table th:has(> input[type="checkbox"]),
.quotes-table td:has(> input[type="checkbox"]),
.deliveries-table th:has(> input[type="checkbox"]),
.deliveries-table td:has(> input[type="checkbox"]) {
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
}

.client-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-avatar {
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 800; color: #fff;
    flex: 0 0 32px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.client-avatar.r1 { background: linear-gradient(135deg, var(--red-500),  var(--red-700)); }
.client-avatar.r2 { background: linear-gradient(135deg, #1f2937, #0b1220); }
.client-avatar.g1 { background: linear-gradient(135deg, var(--green-500), var(--green-700)); }
.client-avatar.g2 { background: linear-gradient(135deg, #475569, #1e293b); }
.client-avatar.a1 { background: linear-gradient(135deg, var(--amber-600), var(--amber-700)); }
.client-name { font-weight: 700; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.client-sub  { font-size: 11px; color: var(--ink-400); }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 800; letter-spacing: .02em;
    border: 1px solid transparent;
    white-space: nowrap;
}
.chip .ico { width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85; }
.chip-paid, .chip-delivered { background: #dcfce7; color: #047857; border-color: #86efac; box-shadow: inset 0 0 0 1px rgba(34, 197, 94, .14); }
.chip-partial { background: #fef3c7; color: #92400e; border-color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .14); }
.chip-pending { background: #ffedd5; color: #c2410c; border-color: #fdba74; box-shadow: inset 0 0 0 1px rgba(249, 115, 22, .16); }
.chip-overdue { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .14); }
.chip-draft { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.chip-sent  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.status-row.status-pending td   { background: linear-gradient(90deg, rgba(249, 115, 22, .055), transparent 30%); }
.status-row.status-overdue td   { background: linear-gradient(90deg, rgba(220, 38, 38, .085), transparent 38%); }
.status-row.status-partial td   { background: linear-gradient(90deg, rgba(217, 119, 6, .05), transparent 30%); }
.status-row.status-delivered td { background: linear-gradient(90deg, rgba(16, 185, 129, .05), transparent 30%); }
.status-row.status-paid td      { background: linear-gradient(90deg, rgba(16, 185, 129, .05), transparent 30%); }
.status-row.status-pending td:first-child   { box-shadow: inset 4px 0 0 #f97316; }
.status-row.status-overdue td:first-child   { box-shadow: inset 4px 0 0 #dc2626; }
.status-row.status-partial td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
.status-row.status-delivered td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
.status-row.status-paid td:first-child      { box-shadow: inset 4px 0 0 #22c55e; }

.invoices-table .status-row td,
.invoices-table .status-row.status-pending td,
.invoices-table .status-row.status-partial td,
.invoices-table .status-row.status-paid td,
.invoices-table .status-row td:first-child {
    background: transparent;
    box-shadow: none;
}
.invoices-table .status-row.status-pending td:first-child { box-shadow: inset 4px 0 0 #ef4444; }
.invoices-table .status-row.status-partial td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.invoices-table .status-row.status-paid td:first-child    { box-shadow: inset 4px 0 0 #22c55e; }
.invoices-table .chip-pending {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .16);
}
.invoices-table tbody tr.status-pending:hover > td { background: rgba(239, 68, 68, .075) !important; }
.invoices-table tbody tr.status-partial:hover > td { background: rgba(245, 158, 11, .09) !important; }
.invoices-table tbody tr.status-paid:hover > td    { background: rgba(34, 197, 94, .08) !important; }
.invoices-table tbody tr.status-pending:hover td:first-child { box-shadow: inset 4px 0 0 #ef4444; }
.invoices-table tbody tr.status-partial:hover td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.invoices-table tbody tr.status-paid:hover td:first-child    { box-shadow: inset 4px 0 0 #22c55e; }
.invoices-table {
    table-layout: fixed;
    font-size: 11.5px;
}
.invoices-table thead th {
    padding: 8px 10px;
    font-size: 10px;
    white-space: normal;
    overflow: visible;
    line-height: 1.15;
}
.invoices-table tbody td {
    padding: 8px 10px;
    vertical-align: middle;
}
.invoices-table th,
.invoices-table td {
    overflow: hidden;
    
    text-overflow: ellipsis;
}
.invoices-table .client-cell {
    max-width: 100%;
    overflow: hidden;
}
.invoices-table .client-name {
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.invoices-table .invoice-col-select { width: 3%; }
.invoices-table .invoice-col-no { width: 7%; }
.invoices-table .invoice-col-date { width: 11%; }
.invoices-table .invoice-col-client { width: 16%; }
.invoices-table .invoice-col-rate { width: 5%; }
.invoices-table .invoice-col-stamp { width: 5%; }
.invoices-table .invoice-col-discount { width: 5%; }
.invoices-table .invoice-col-amount { width: 8%; }
.invoices-table .invoice-col-status { width: 26%; }
.invoices-table .invoice-col-actions { width: 92px; }
.invoices-table td.actions {
    display: table-cell !important;
    overflow: visible;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}
.invoices-table .invoice-actions-inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
    vertical-align: middle;
}
.invoices-table td.actions .btn-sm {
    margin-left: 0;
    flex: 0 0 auto;
}

.orders-table .status-row td,
.orders-table .status-row.status-pending td,
.orders-table .status-row.status-overdue td,
.orders-table .status-row.status-partial td,
.orders-table .status-row.status-delivered td,
.orders-table .status-row td:first-child {
    background: transparent;
    box-shadow: none;
}
.orders-table .status-row.status-pending td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
.orders-table .status-row.status-overdue td:first-child   { box-shadow: inset 4px 0 0 #ef4444; }
.orders-table .status-row.status-partial td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
.orders-table .status-row.status-delivered td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
.orders-table .status-row.is-overdue td:first-child       { box-shadow: inset 4px 0 0 #ef4444; }
.orders-table tbody tr.status-pending:hover > td   { background: rgba(245, 158, 11, .09) !important; }
.orders-table tbody tr.status-overdue:hover > td   { background: rgba(239, 68, 68, .075) !important; }
.orders-table tbody tr.status-partial:hover > td   { background: rgba(245, 158, 11, .09) !important; }
.orders-table tbody tr.status-delivered:hover > td { background: rgba(34, 197, 94, .08) !important; }
.orders-table tbody tr.status-pending:hover td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
.orders-table tbody tr.status-overdue:hover td:first-child   { box-shadow: inset 4px 0 0 #ef4444; }
.orders-table tbody tr.status-partial:hover td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
.orders-table tbody tr.status-delivered:hover td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
.orders-table tbody tr.is-overdue:hover td:first-child       { box-shadow: inset 4px 0 0 #ef4444; }
.orders-table tbody tr.is-overdue:hover > td {
    background: rgba(239, 68, 68, .11) !important;
}
.orders-table {
    table-layout: fixed;
    font-size: 11.5px;
}
.orders-table thead th {
    padding: 8px 10px;
    font-size: 10px;
}
.orders-table tbody td {
    padding: 8px 10px;
    vertical-align: middle;
}
.orders-table th,
.orders-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}
.orders-table thead th {
    white-space: normal;
    overflow: visible;
    line-height: 1.15;
}
.orders-table .client-cell {
    max-width: 100%;
    overflow: hidden;
}
.orders-table .client-name {
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.orders-table td.actions {
    display: table-cell !important;
    overflow: visible;
    text-align: right;
    vertical-align: middle;
    position: relative;
    z-index: 30;
}
.table-panel:has(.row-action-menu[open]),
.table-responsive:has(.row-action-menu[open]),
.table-panel.has-row-action-menu-open,
.table-responsive.has-row-action-menu-open {
    overflow: visible;
}
.orders-table tr:has(.row-action-menu[open]) td,
.orders-table td.actions:has(.row-action-menu[open]),
.orders-table tr.has-row-action-menu-open td,
.orders-table td.actions.has-row-action-menu-open {
    position: relative;
    overflow: visible;
    z-index: 8000;
}
.orders-table .order-actions-inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    white-space: nowrap;
    vertical-align: middle;
    position: relative;
    z-index: 40;
}
.orders-table td.actions .btn-sm {
    height: 26px;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 10px;
    gap: 4px;
    margin-left: 0;
}
.orders-table td.actions .btn-icon { width: 24px; height: 24px; }
.orders-table .order-col-no {
    width: 8%;
    overflow: visible;
    text-overflow: clip;
}
.orders-table .order-col-select { width: 3%; }
.orders-table .order-col-date { width: 11%; }
.orders-table .order-col-client { width: 13%; }
.orders-table .order-col-qty { width: 6%; }
.orders-table .order-col-amount { width: 7%; }
.orders-table .order-col-status { width: 30%; }
.orders-table .status-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.orders-table .status-stack .chip {
    gap: 4px;
    padding: 2px 7px;
    font-size: 10px;
}
.orders-table .order-col-actions { width: 140px; }

.quotes-table,
.deliveries-table {
    table-layout: fixed;
    font-size: 11.5px;
}
.quotes-table thead th,
.deliveries-table thead th {
    padding: 8px 10px;
    font-size: 10px;
    white-space: normal;
    overflow: visible;
    line-height: 1.15;
}
.quotes-table tbody td,
.deliveries-table tbody td {
    padding: 8px 10px;
    vertical-align: middle;
}
.quotes-table th,
.quotes-table td,
.deliveries-table th,
.deliveries-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}
.quotes-table .client-cell,
.deliveries-table .client-cell {
    max-width: 100%;
    overflow: hidden;
}
.quotes-table .client-name,
.deliveries-table .client-name {
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.quotes-table td.actions,
.deliveries-table td.actions {
    display: table-cell !important;
    overflow: visible;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}
.quotes-table .quote-actions-inline,
.deliveries-table .delivery-actions-inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
    vertical-align: middle;
}
.quotes-table td.actions .btn-sm,
.deliveries-table td.actions .btn-sm {
    margin-left: 0;
    flex: 0 0 auto;
}

/* Fixed-content columns get exact pixel widths; Client has no width so (under
   table-layout:fixed) it absorbs all the remaining space. This keeps N° devis,
   Date, Délai… tight to their content instead of stretching on wide screens. */
.quotes-table .quote-col-select   { width: 38px; }
.quotes-table .quote-col-no       { width: 70px; }
.quotes-table .quote-col-date     { width: 100px; }
.quotes-table .quote-col-client   { width: auto; }
.quotes-table .quote-col-term     { width: 130px; }
.quotes-table .quote-col-discount { width: 140px; }
.quotes-table .quote-col-delay    { width: 64px; }
.quotes-table .quote-col-validity { width: 72px; }
.quotes-table .quote-col-amount   { width: 160px; }
.quotes-table .quote-col-actions  { width: 132px; }

/* List tables: every value stays on a single line so numbers/dates never wrap
   or clip — EXCEPT Client and Mode de paiement, which may break onto several
   lines (long names / payment terms). */
.quotes-table tbody td,
.invoices-table tbody td,
.deliveries-table tbody td,
.orders-table tbody td { white-space: nowrap; }
.quotes-table tbody td[data-export-column="client_name"],
.quotes-table tbody td[data-export-column="payment_term"],
.invoices-table tbody td[data-export-column="client_name"],
.deliveries-table tbody td[data-export-column="client_name"],
.orders-table tbody td[data-export-column="client_name"] { white-space: normal; }

.deliveries-table .delivery-col-select  { width: 3%; }
.deliveries-table .delivery-col-no      { width: 10%; }
.deliveries-table .delivery-col-date    { width: 14%; }
.deliveries-table .delivery-col-client  { width: 38%; }
.deliveries-table .delivery-col-po      { width: 20%; }
.deliveries-table .delivery-col-actions { width: 92px; }

.pager, .pagination-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12.5px; color: var(--ink-500);
    flex-wrap: wrap;
}
.pager .pages, .pagination-bar .pages { display: flex; gap: 4px; align-items: center; }
.pager .pages a, .pagination-bar .pages a {
    display: inline-grid; place-items: center;
    min-width: 32px; height: 32px;
    padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--ink-700); text-decoration: none;
    font-weight: 700; font-size: 12px;
    background: #fff;
}
.pager .pages a:hover, .pagination-bar .pages a:hover { border-color: var(--red-500); color: var(--red-700); background: var(--red-50); }
.pager .pages a.current, .pagination-bar .pages a.current { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.pagination-bar .muted { color: var(--ink-400); font-weight: 600; }

.form-control, .form-select,
input.input, select.select, textarea.textarea, textarea.form-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--ink-900);
    font-size: 13.5px;
    font-family: inherit;
    transition: all .15s ease;
}
textarea.form-control, textarea.textarea {
    height: auto;
    padding: 10px 12px;
    min-height: 84px;
    resize: vertical;
}
.form-control:focus, .form-select:focus,
input.input:focus, select.select:focus, textarea.textarea:focus, textarea.form-control:focus {
    outline: 0; border-color: var(--red-500); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}
.form-control.is-invalid, .form-select.is-invalid,
input.input.is-invalid, select.select.is-invalid, textarea.textarea.is-invalid, textarea.form-control.is-invalid {
    border-color: var(--red-500);
    background: var(--red-50);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .10);
}
.form-control[readonly]:not([type="date"]) {
    background: var(--ink-50, #f3f4f6);
    color: var(--ink-500, #6b7280);
    cursor: not-allowed;
}
.field-error {
    grid-column: 1 / -1;
    margin-top: 4px;
    color: var(--red-700);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.35;
}
.form-control-sm, .form-select-sm { height: 34px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
textarea.form-control.form-control-sm { height: auto; min-height: 68px; padding: 8px 10px; }

.form-select, .form-select-sm, select.select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 11px 8px;
}
.form-select-sm { padding-right: 30px; background-position: right 10px center; }
.form-select:focus, select.select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%23dc2626' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.form-select::-ms-expand, select.select::-ms-expand { display: none; }

.split-input .form-select, .split-input .form-select-sm,
.discount-fields .form-select, .discount-fields .form-select-sm,
.qty-fields .form-select, .qty-fields .form-select-sm,
.line-unit-select, select.line-unit-select {
    padding-right: 22px;
    background-position: right 7px center;
    background-size: 9px 7px;
}

input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.num-stepper { position: relative; display: block; width: 100%; line-height: 0; align-self: start; }
.num-stepper > input[type="number"] { display: block; width: 100%; padding-right: 30px; }
.num-stepper-btns {
    position: absolute;
    top: 1px; right: 1px; bottom: 1px;
    display: flex; flex-direction: column;
    width: 22px;
    overflow: hidden;
    border-left: 1px solid var(--border-strong);
    border-radius: 0 8px 8px 0;
    pointer-events: none;
}
.num-stepper-btn {
    flex: 1 1 0;
    min-height: 0;
    display: inline-flex; align-items: center; justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--ink-50, #f3f4f6);
    color: var(--ink-500);
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    transition: background .12s ease, color .12s ease;
}
.num-stepper-btn[data-step="up"] { border-bottom: 1px solid var(--border-strong); }
.num-stepper-btn:hover { background: var(--red-50); color: var(--red-600); }
.num-stepper-btn:active { background: var(--red-100, #fee2e2); }

.line-row .num-stepper > input[type="number"] { padding-right: 22px; }
.line-row .num-stepper-btns { width: 16px; border-radius: 0 7px 7px 0; }
.line-row .num-stepper-btn { font-size: 7px; }

@media (pointer: coarse) {
    .num-stepper > input[type="number"] { padding-right: 36px; }
    .num-stepper-btns { width: 28px; }
    .num-stepper-btn { font-size: 11px; }
    .line-row .num-stepper > input[type="number"] { padding-right: 22px; }
    .line-row .num-stepper-btns { width: 16px; }
    .line-row .num-stepper-btn { font-size: 7px; }
}

.field-label, label.field-label, label.form-label {
    display: block;
    font-size: 12px; font-weight: 800;
    color: var(--ink-500);
    margin-bottom: 6px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.form-text { font-size: 11.5px; color: var(--ink-400); margin-top: 4px; }

.input-prefix { position: relative; }
.input-prefix > input,
.input-prefix > .form-control { padding-left: 36px; }
.input-prefix > i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--ink-400);
    font-size: 13px; pointer-events: none;
}

.split-input, .discount-fields, .qty-fields {
    display: grid;
    grid-template-columns: 1fr 100px;
    gap: 6px;
}
.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.form-panel, .summary-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.form-panel { padding: 18px; }

.form-grid, .grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.form-grid .full, .grid-2 .full, .grid-3 .full { grid-column: 1 / -1; }

.grid-2:has(> .summary-panel) {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.grid-2:has(> .summary-panel) > .summary-panel {
    order: -1;            
    position: static;     
}

.grid-2:has(> .summary-panel) > .summary-panel .summary-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 28px;
}
.grid-2:has(> .summary-panel) > .summary-panel .summary-row {
    grid-template-columns: auto auto;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 0;
}

.section-title-h, .section-header {
    font-size: 14px; font-weight: 800;
    margin: 18px 0 10px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}
.section-title-h:first-of-type, .section-header:first-of-type {
    padding-top: 0; border-top: 0; margin-top: 8px;
}
.section-header h2, .section-title-h h2 { margin: 0; font-size: 16px; font-weight: 800; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-actions {
    margin-top: 18px;
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.document-lines { margin-top: 14px; }
.line-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 4.2fr) minmax(140px, 1fr) minmax(170px, 1.15fr) minmax(140px, 1fr) 38px;
    gap: 8px;
    align-items: start;
    padding: 10px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.line-row:hover { border-color: var(--red-200); box-shadow: 0 4px 14px rgba(185, 28, 28, .06); }
.line-row > * { min-width: 0; }
.line-row .form-control, .line-row .form-select,
.line-row .input, .line-row .select { height: 36px; font-size: 12.5px; border-radius: 8px; }
.line-row .article-id-picker { grid-column: 1; grid-row: 1; }
.line-row .article-picker { grid-column: 2 / 4; grid-row: 1; }
.line-row .qty-fields { grid-column: 4; grid-row: 1; }
.line-row input[name="line_price[]"] { grid-column: 5; grid-row: 1; }
.line-row textarea.form-control.article-details {
    grid-column: 1 / 3;
    grid-row: 2;
    min-height: 38px;
    height: 38px;
    padding: 8px 10px;
    line-height: 1.25;
    resize: vertical;
    background: var(--surface-soft);
}
.line-row textarea.form-control.article-details::placeholder { color: var(--ink-400); opacity: 1; }
.line-row .form-control::placeholder { opacity: 1; }
.line-row .qty-fields { grid-template-columns: minmax(78px, 1fr) 74px; }
.line-row .discount-fields { grid-template-columns: minmax(90px, 1fr) 52px; }
.line-row .discount-fields {
    grid-column: 3 / 4;
    grid-row: 2;
}
.line-row .article-picker { font-weight: 700; color: var(--ink-700); background-color: var(--surface-soft); }
.line-row .article-id-picker { font-weight: 700; color: var(--ink-700); background-color: var(--surface-soft); }
.line-row .line-total {
    grid-column: 4 / 5;
    grid-row: 2;
    min-width: 128px;
}
.line-row .line-actions {
    grid-column: 5 / 6;
    grid-row: 2;
}
.article-combobox {
    position: relative;
    min-width: 0;
    z-index: 5;
}
.article-combobox > .form-control {
    width: 100%;
    font-weight: 700;
    color: var(--ink-700);
    background-color: var(--surface-soft);
}
.article-combobox:focus-within {
    z-index: 80;
}

.line-row .article-picker textarea.form-control.article-designation {
    height: auto;
    min-height: 36px;
    max-height: 240px;
    line-height: 1.4;
    padding: 8px 12px;
    resize: vertical;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    field-sizing: content;
}
.line-row .article-id-picker { align-self: start; }
.article-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1200;
    max-height: min(280px, calc(100vh - 120px));
    overflow-x: hidden;
    overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
    overscroll-behavior: contain;
    animation: articleSuggestIn .12s ease-out;
    scrollbar-width: thin;
}
.article-suggestions.open-up {
    top: auto;
    bottom: calc(100% + 6px);
    box-shadow: 0 -18px 38px rgba(15, 23, 42, .14);
}

.article-id-picker .article-suggestions {
    right: auto;
    width: max-content;
    min-width: min(280px, calc(100vw - 32px));
    max-width: min(440px, calc(100vw - 32px));
}
.article-suggestions[hidden] {
    display: none !important;
}
.article-suggestions.is-floating {
    position: fixed;
    right: auto;
    z-index: 3001;
}
/* Transparent full-screen layer above page content but below the list + the
   active field. It blocks hover/click on everything underneath, while a wheel/
   touch over it still scrolls the whole page (we never preventDefault scroll),
   so page scroll + list scroll both work but nothing underneath is interactive
   until the user picks an item, clicks away, or scrolls the field off-screen. */
#sfm-suggest-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2990;
    background: transparent;
    cursor: default;
}
/* The field being typed into stays above the backdrop so it remains usable. */
.article-combobox.suggest-active {
    position: relative;
    z-index: 3000 !important;
}
.article-suggestion {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-700);
    text-align: left;
    font-size: 13px;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color .14s ease, color .14s ease, transform .12s ease;
}
.article-suggestion[hidden],
.article-suggestion.is-hidden {
    display: none !important;
}
.article-suggestion:hover,
.article-suggestion:focus {
    background: var(--surface-soft);
    transform: translateX(2px);
    outline: none;
}
.article-suggestion .article-suggestion-name {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-suggestion .article-suggestion-ref {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 96px;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--brand-orange-700);
    background: var(--brand-orange-50);
    border: 1px solid var(--brand-orange-200);
    white-space: nowrap;
}
.article-suggestion .article-suggestion-ref small {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .75;
}

.article-suggestion .article-suggestion-ref.is-id {
    min-width: 0;
    color: var(--ink-500);
    background: var(--surface-soft);
    border-color: var(--border-strong);
}
.article-suggestion-message {
    padding: 8px 10px;
    color: var(--ink-500);
    font-size: 13px;
}
@keyframes articleSuggestIn {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}
.article-suggestions.open-up {
    animation-name: articleSuggestInUp;
}
@keyframes articleSuggestInUp {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

.advanced-panel { position: relative; }
.advanced-panel:focus-within { z-index: 50; }
.filter-combobox { z-index: 40; }
.filter-combobox:focus-within { z-index: 1600; }
.filter-combobox .article-suggestions { z-index: 1600; }
.line-row.bl { grid-template-columns: 76px minmax(0, 4.2fr) minmax(170px, 1.15fr) 38px; }
.line-row.bl .article-picker { grid-column: 2; }
.line-row.bl .qty-fields { grid-column: 3; }
.line-row.bl textarea.form-control.article-details { grid-column: 1 / 3; grid-row: 2; }
.line-row.no-discount { grid-template-columns: 76px minmax(0, 4.2fr) minmax(140px, 1fr) minmax(170px, 1.15fr) minmax(140px, 1fr) 38px; }
.line-row.no-discount textarea.form-control.article-details { grid-column: 1 / 3; grid-row: 2; }
.line-row.no-discount .line-total { grid-column: 3 / 5; grid-row: 2; }
.line-row.order-line { grid-template-columns: 76px minmax(0, 4.2fr) minmax(140px, 1fr) minmax(170px, 1.15fr) minmax(140px, 1fr) minmax(150px, 1fr) 38px; }
.line-row.order-line .article-picker { grid-column: 2 / 4; grid-row: 1; }
.line-row.order-line .qty-fields { grid-column: 4; grid-row: 1; }
.line-row.order-line input[name="shipped_qty[]"] { grid-column: 5; grid-row: 1; }
.line-row.order-line input[name="shipping_date[]"] { grid-column: 6; grid-row: 1; }
.line-row.order-line textarea.form-control.article-details { grid-column: 1 / 4; grid-row: 2; }
.line-row.order-line .line-actions { grid-column: 6; }
.line-total {
    height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink-500);
    font-size: 11px;
    line-height: 1.1;
}
.line-total strong { color: var(--ink-900); font-size: 13px; font-weight: 800; }
.line-actions { display: grid; place-items: center; grid-column: 5 / 6; grid-row: 2; }
.line-actions .btn-outline-danger,
.line-remove {
    width: 36px; height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink-400);
    cursor: pointer;
    display: grid; place-items: center;
    transition: all .15s ease;
    padding: 0;
    font-family: inherit;
    font-size: 14px;
}
.line-actions .btn-outline-danger:hover,
.line-remove:hover {
    background: var(--red-50);
    border-color: var(--red-500);
    color: var(--red-700);
}
.add-line, button[data-add-line] {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px; height: 36px;
    border-radius: 9px;
    border: 1px dashed var(--border-strong);
    background: #fff;
    color: var(--ink-500);
    font-weight: 700; font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.add-line:hover, button[data-add-line]:hover {
    border-color: var(--green-500);
    color: var(--green-700);
    background: var(--green-50);
}

.summary-panel {
    padding: 16px;
    position: sticky;
    
    top: 88px;
    height: fit-content;
    background: linear-gradient(180deg, var(--surface), var(--surface-soft));
}
.summary-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.summary-title {
    font-size: 14px;
    font-weight: 800;
    display: flex;
    gap: 9px;
    align-items: center;
    color: var(--ink-900);
}
.summary-title .ico {
    width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--green-50);
    border: 1px solid var(--green-200);
    color: var(--green-700);
    font-size: 13px;
}
.summary-list { display: flex; flex-direction: column; gap: 6px; }
.summary-row {
    display: grid;
    grid-template-columns: minmax(100px, .85fr) minmax(0, 1.15fr);
    gap: 10px;
    align-items: start;
    font-size: 13px;
    line-height: 1.35;
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.summary-row:last-child { border-bottom: 0; }
.summary-row .lbl { color: var(--ink-500); font-weight: 700; }
.summary-row .val {
    font-family: inherit;
    font-weight: 700;
    color: var(--ink-900);
    text-align: right;
    overflow-wrap: anywhere;
}
.summary-row.muted .val    { color: var(--ink-500); font-weight: 600; }
.summary-row.discount .val { color: var(--green-700); }
.summary-row.tax      .val { color: var(--amber-700); }
.summary-divider { height: 1px; background: var(--border); margin: 8px 0; }
.summary-total {
    margin-top: 6px;
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--ink-900), #1a1d2b);
    color: #fff;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: relative; overflow: hidden;
}
.summary-total::before {
    content: "";
    position: absolute; right: -30px; top: -30px;
    width: 120px; height: 120px; border-radius: 999px;
    background: radial-gradient(circle, rgba(220, 38, 38, .5), transparent 60%);
}
.summary-total .lbl { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: rgba(255, 255, 255, .65); letter-spacing: .06em; }
.summary-total .val { font-size: 22px; font-weight: 800; font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; letter-spacing: -.01em; }
.summary-meta { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11.5px; color: var(--ink-500); }
.summary-meta .pill {
    padding: 6px 8px; border-radius: 8px;
    background: var(--ink-50);
    border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 2px;
}
.summary-meta .pill strong { color: var(--ink-900); font-weight: 700; font-size: 12.5px; }

.document-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}
.document-summary .muted { color: var(--ink-400); }

.alert {
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px 16px;
    font-size: 13px; font-weight: 600;
    margin-bottom: 14px;
}
.alert-success { background: var(--green-50); color: var(--green-700); border-color: var(--green-200); }
.alert-danger,
.alert-error   { background: var(--red-50);   color: var(--red-700);   border-color: var(--red-200); }
.alert-warning { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-200); }
.alert-info    { background: #eff6ff;         color: #1d4ed8;          border-color: #bfdbfe; }

.hero {
    position: relative;
    background:
        radial-gradient(420px 220px at 90% -20%, rgba(16, 185, 129, .18), transparent 60%),
        linear-gradient(135deg, #1a1d2b 0%, #0e1018 60%, #1a0a0a 100%);
    color: #fff;
    border-radius: 18px;
    padding: 26px 28px;
    overflow: hidden;
    box-shadow: 0 18px 40px -12px rgba(11, 18, 32, .35);
    margin-bottom: 22px;
}
.hero::before {
    content: ""; position: absolute; right: -60px; top: -60px;
    width: 280px; height: 280px; border-radius: 999px;
    background: radial-gradient(circle, rgba(220, 38, 38, .45), transparent 60%);
    filter: blur(2px);
}
.hero::after {
    content: ""; position: absolute; left: -40px; bottom: -80px;
    width: 220px; height: 220px; border-radius: 999px;
    background: radial-gradient(circle, rgba(16, 185, 129, .4), transparent 65%);
    filter: blur(2px);
}
.hero-row {
    display: grid; grid-template-columns: 1.4fr 1fr;
    gap: 24px; align-items: center;
    position: relative; z-index: 1;
}
.hero h1, .hero .hero-title { margin: 0 0 6px; font-size: 28px; font-weight: 800; letter-spacing: -0.015em; color: #fff; }
.hero .accent { color: var(--green-200); }
.hero p, .hero-sub { margin: 0; color: rgba(255, 255, 255, .78); font-size: 14px; max-width: 60ch; line-height: 1.55; }
.hero-meta {
    display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap;
    font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
    font-size: 12px; color: rgba(255, 255, 255, .7);
}
.hero-meta .dot {
    width: 6px; height: 6px; border-radius: 999px;
    background: var(--green-500);
    display: inline-block; margin-right: 6px; vertical-align: middle;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: pulse 1.8s infinite;
}
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.cta-primary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    color: #fff; border-radius: 12px; border: 0;
    font-weight: 700; font-size: 13px; text-decoration: none;
    box-shadow: 0 14px 28px -10px rgba(220, 38, 38, .6);
    transition: transform .15s ease, box-shadow .15s ease;
}
.cta-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 30px -10px rgba(220, 38, 38, .7); color: #fff; }
.cta-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 16px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 12px;
    font-weight: 600; font-size: 13px;
    text-decoration: none;
}
.cta-secondary:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .28); color: #fff; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi {
    position: relative;
    background:
        radial-gradient(190px 120px at 100% -20%, rgba(249, 115, 22, .08), transparent 64%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.kpi:hover {
    transform: translateY(-1px);
    border-color: rgba(249, 115, 22, .28);
    box-shadow: 0 14px 30px -20px rgba(21, 24, 35, .5), var(--shadow-sm);
}
.kpi::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--brand-orange-500), var(--brand-orange-700));
}
.kpi.green::before { background: linear-gradient(180deg, var(--brand-orange-500), var(--brand-orange-700)); }
.kpi-grid .kpi:nth-child(even)::before {
    background: linear-gradient(180deg, #154940, #0f342e);
}
.kpi-label { color: var(--ink-400); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; font-feature-settings: "tnum" 1; color: var(--ink-900); }
.kpi-value small { font-size: 14px; color: var(--ink-400); font-weight: 700; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--ink-500); font-weight: 600; }
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.delta.up   { color: var(--green-700); background: var(--green-50); border: 1px solid var(--green-200); }
.delta.down { color: var(--red-700); background: var(--red-50); border: 1px solid var(--red-200); }
.kpi-spark { position: absolute; right: 14px; top: 14px; width: 64px; height: 28px; pointer-events: none; }

.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 6px 2px 14px;
}
.section-title { font-size: 16px; font-weight: 800; letter-spacing: -0.005em; margin: 0; }
.section-sub { font-size: 12.5px; color: var(--ink-400); font-weight: 500; }

.module-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.module-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    min-height: 210px;
    display: flex; flex-direction: column;
    text-decoration: none; color: inherit;
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
    overflow: hidden;
}
.module-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.module-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--red-500), var(--red-700));
    color: #fff; font-size: 22px;
    box-shadow: 0 10px 20px -6px rgba(185, 28, 28, .45), inset 0 1px 0 rgba(255, 255, 255, .18);
    position: relative; z-index: 1;
}
.module-card h3 { margin: 18px 0 4px; font-size: 18px; font-weight: 800; color: var(--ink-900); letter-spacing: -0.01em; }
.module-desc { font-size: 13px; color: var(--ink-500); line-height: 1.5; margin: 0; }
.module-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 800; letter-spacing: .03em;
    background: var(--green-50); color: var(--green-700);
    border: 1px solid var(--green-200);
}
.module-status .ico {
    width: 6px; height: 6px; border-radius: 999px;
    background: var(--green-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .18);
}
.module-status.soon { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.module-status.soon .ico { background: var(--ink-300); box-shadow: none; }
.module-foot {
    margin-top: auto;
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
    font-size: 12.5px; color: var(--ink-400); font-weight: 600;
}
.module-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.module-tag {
    font-size: 10.5px; font-weight: 700;
    padding: 3px 8px; border-radius: 6px;
    background: var(--ink-50); color: var(--ink-500);
    border: 1px solid var(--border);
}
.module-enter { display: inline-flex; align-items: center; gap: 8px; color: var(--red-700); font-weight: 800; font-size: 13px; }
.module-enter i { transition: transform .2s ease; }
.module-card-active {
    background:
        radial-gradient(220px 130px at 110% -10%, rgba(16, 185, 129, .16), transparent 70%),
        linear-gradient(180deg, #fff, #fff);
    border-color: var(--red-200);
}
.module-card-active:hover {
    transform: translateY(-2px);
    border-color: var(--red-500);
    box-shadow: var(--shadow-lg);
}
.module-card-active:hover .module-enter i { transform: translateX(4px); }
.module-card-active::after {
    content: "";
    position: absolute; right: -40px; top: -40px;
    width: 140px; height: 140px; border-radius: 999px;
    background: var(--red-500);
    opacity: .12;
    transition: opacity .22s ease, transform .22s ease;
    pointer-events: none;
}
.module-card-active:hover::after { transform: scale(1.15); opacity: .18; }
.module-card-active::before {
    content: "";
    position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    background: linear-gradient(90deg, var(--red-500) 0%, var(--red-500) 50%, var(--green-500) 50%, var(--green-500) 100%);
    border-radius: 0 0 16px 16px;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}
.module-card-active:hover::before { opacity: 1; }
.module-card-soon {
    background: linear-gradient(180deg, #fcfcfd, #fafbfc);
    border-style: dashed;
    border-color: var(--border-strong);
    color: var(--ink-500);
    cursor: not-allowed;
}
.module-card-soon h3 { color: var(--ink-700); }
.module-card-soon .module-icon { background: var(--ink-100); color: var(--ink-400); box-shadow: none; }
.module-lock { color: var(--ink-300); }

.permission-grid {
    display: flex; flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
}
.permission-row {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 10px; align-items: center;
    padding: 8px 10px; background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.permission-row.permission-head {
    background: var(--ink-50); color: var(--ink-500);
    font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
.permission-module { font-weight: 700; color: var(--ink-900); font-size: 13px; }

.advanced-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
}
.advanced-panel > summary {
    list-style: none;
    cursor: pointer;
    font-size: 13px; font-weight: 700; color: var(--ink-700);
    display: flex; align-items: center; gap: 8px;
}
.advanced-panel > summary::-webkit-details-marker { display: none; }
.advanced-panel > summary::before {
    content: "\f0b0"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    font-size: 12px; color: var(--red-500);
}
.advanced-panel[open] > summary { color: var(--red-700); margin-bottom: 12px; }
.advanced-panel form .actions { margin-top: 12px; }

.advanced-panel > summary::before { transition: transform .18s ease; }
.advanced-panel[open] > summary::before { transform: rotate(90deg); }
.advanced-panel[open]:not(.is-closing) > form {
    animation: filterPanelReveal .17s ease both;
    will-change: opacity, transform;
}
.advanced-panel.is-closing > form {
    animation: filterPanelClose .15s ease both;
    will-change: opacity, transform;
}
@keyframes filterPanelReveal {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes filterPanelClose {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
    .advanced-panel > form { animation: none !important; }
    .advanced-panel > summary::before { transition: none; }
}

.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-panel {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: #fff; border: 1px solid var(--border);
    border-radius: 10px; padding: 6px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 4px;
    min-width: 140px;
    z-index: 20;
}
.row-action-menu {
    position: relative;
    display: inline-block;
    order: 10;
    z-index: 5000;
}
.row-action-menu[open] { z-index: 6000; }
.row-action-menu.is-open { z-index: 6000; }
.row-action-menu > summary { list-style: none; cursor: pointer; }
.row-action-menu > summary::-webkit-details-marker { display: none; }
.row-action-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 150px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 7000;
}
.row-action-menu[open] .row-action-menu-panel,
.row-action-menu.is-open .row-action-menu-panel { z-index: 99999; }
.floating-row-action-menu {
    position: absolute;
    right: auto;
    min-width: 170px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 2147483000;
}
.floating-row-action-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink-700);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.floating-row-action-menu a:hover { background: var(--ink-50); color: var(--ink-900); }
.floating-row-action-menu a.danger { color: var(--red-700); }
.floating-row-action-menu a.danger:hover { background: rgba(220, 38, 38, .08); }
.row-action-menu-panel a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink-700);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}
.row-action-menu-panel a:hover { background: var(--ink-50); color: var(--ink-900); }
.row-action-menu-panel a.danger { color: var(--red-700); }
.row-action-menu-panel a.danger:hover { background: rgba(220, 38, 38, .08); }

tr.active-row td { background: rgba(220, 38, 38, .04); }
.entity-table-layout, .entity-form-layout { display: block; }
.entity-grid { grid-template-columns: minmax(0, 1.5fr) minmax(320px, .55fr); }
.client-form-panel .grid-2 { grid-template-columns: 1fr 1fr; }
.compact-fields > * { min-width: 0; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 14px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.h5 { font-size: 16px; font-weight: 800; margin: 0; }
.fw-semibold { font-weight: 700; }
.muted, .text-muted { color: var(--ink-400); }
.d-flex { display: flex; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 14px; }
.justify-content-between { justify-content: space-between; }
.align-middle { vertical-align: middle; }
.text-end { text-align: right; }
.hidden { display: none !important; }
.w-100 { width: 100%; }

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes softPop {
    0%   { opacity: 0; transform: scale(.985); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes rowReveal {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}

.topbar,
.hero,
.toolbar,
.table-panel,
.form-panel,
.summary-panel,
.document-summary,
.advanced-panel,
.login-card {
    animation: fadeSlideUp .34s ease both;
}
.kpi,
.kpi-mini,
.module-card {
    animation: softPop .32s ease both;
}
.kpi-strip .kpi-mini:nth-child(2),
.kpi-grid .kpi:nth-child(2),
.module-grid .module-card:nth-child(2) { animation-delay: .035s; }
.kpi-strip .kpi-mini:nth-child(3),
.kpi-grid .kpi:nth-child(3),
.module-grid .module-card:nth-child(3) { animation-delay: .07s; }
.kpi-strip .kpi-mini:nth-child(4),
.kpi-grid .kpi:nth-child(4),
.module-grid .module-card:nth-child(4) { animation-delay: .105s; }
.kpi-strip .kpi-mini:nth-child(5),
.kpi-grid .kpi:nth-child(5) { animation-delay: .14s; }

.nav-item,
.nav-more > summary,
.btn,
.filter-chip,
.chip,
.pager .pages a,
.pagination-bar .pages a,
.column-visibility-menu label,
.add-line,
button[data-add-line],
.line-remove,
.line-actions .btn-outline-danger {
    transition:
        background-color .18s ease,
        border-color .18s ease,
        color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}
.btn:hover,
.add-line:hover,
button[data-add-line]:hover,
.pager .pages a:hover,
.pagination-bar .pages a:hover {
    transform: translateY(-1px);
}
.btn:active,
.add-line:active,
button[data-add-line]:active {
    transform: translateY(0) scale(.985);
}
.nav-item:hover,
.nav-more > summary:hover {
    transform: translateX(2px);
}
.toolbar .filter-chip:hover,
.chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -14px rgba(15, 23, 42, .45);
}

table.table tbody tr,
table.tbl tbody tr {
    animation: rowReveal .22s ease both;
}
table.table tbody tr:hover td,
table.tbl tbody tr:hover td {
    transition: background-color .16s ease, box-shadow .16s ease;
}
table.table tbody td,
table.tbl tbody td {
    transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.form-control,
.form-select,
input.input,
select.select,
textarea.textarea,
textarea.form-control {
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        background-color .18s ease,
        color .18s ease;
}
.line-row {
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}
.line-row:hover {
    transform: translateY(-1px);
}
.column-visibility-menu,
.advanced-panel[open],
.nav-more[open] .nav-children {
    animation: fadeSlideUp .22s ease both;
}
.notification-badge,
.nav-pill.alert {
    animation: softPop .25s ease both;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

.login-shell {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
    background:
        radial-gradient(720px 420px at -10% 110%, rgba(220, 38, 38, .12), transparent 60%),
        radial-gradient(680px 420px at 110% -10%, rgba(16, 185, 129, .14), transparent 60%),
        var(--page);
}
.login-card {
    width: 100%; max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 18px 40px -12px rgba(11, 18, 32, .15);
    position: relative;
}
.login-actions { position: absolute; right: 14px; top: 14px; }
.login-logo-wrap { display: grid; place-items: center; margin-bottom: 6px; }
.login-logo {
    width: 80px; height: 80px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--red-600), var(--red-700));
    padding: 14px;
    object-fit: contain;
    box-shadow: 0 14px 28px -10px rgba(185, 28, 28, .35);
    filter: brightness(0) invert(1);
}
.login-subtitle {
    text-align: center;
    font-size: 11px; color: var(--ink-400);
    margin: 10px 0 18px;
    text-transform: uppercase; letter-spacing: .14em; font-weight: 800;
}
.login-card form .mb-3 { margin-bottom: 14px; }

@media (max-width: 1180px) {
    .kpi-strip   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-grid    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero-row    { grid-template-columns: 1fr; }
    .hero-cta    { justify-content: flex-start; }
    .main-panel > .grid-2 { grid-template-columns: 1fr; }
    .summary-panel { position: static; }
    .line-row, .line-row.bl, .line-row.no-discount, .line-row.order-line {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .line-row textarea.form-control.article-details { grid-column: 1 / -1; }
    .line-actions { grid-column: auto; grid-row: auto; }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {

    .app-shell,
    .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
    .app-shell > .sidebar {
        position: fixed;
        top: 0; left: 0;
        z-index: 1200;
        width: 286px; max-width: 86vw;
        height: 100vh; height: 100dvh;
        opacity: 1;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.4, 0, .2, 1);
        box-shadow: var(--shadow-lg);
        will-change: transform;
    }
    
    .app-shell.sidebar-collapsed > .sidebar {
        opacity: 1;
        transform: translateX(-100%);
        pointer-events: none;
    }
    .app-shell.sidebar-open > .sidebar,
    .app-shell.sidebar-open.sidebar-collapsed > .sidebar {
        transform: translateX(0);
        pointer-events: auto;
    }
    
    .app-shell > .sidebar > .sidebar-brand,
    .app-shell > .sidebar > .sidebar-nav,
    .app-shell > .sidebar > .sidebar-footer {
        width: 100%; max-width: 100%;
    }
    
    .sidebar-backdrop {
        position: fixed; inset: 0;
        z-index: 1100;
        background: rgba(8, 12, 22, .46);
        opacity: 0; visibility: hidden;
        transition: opacity .3s ease, visibility .3s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1; visibility: visible;
    }
    
    body.sidebar-drawer-open { overflow: hidden; }
    .form-grid, .grid-2, .grid-3, .kpi-strip, .kpi-grid, .module-grid {
        grid-template-columns: 1fr;
    }
    .main-panel { padding: 16px; }
    .topbar { gap: 12px; }
    .client-name { max-width: 140px; }
}

@media (min-width: 601px) and (max-width: 760px) {
    .table-responsive > table.tbl.orders-table {
        min-width: 760px !important;
    }
}

@media (min-width: 761px) {
    .sidebar-backdrop { display: none; }
}
@media (max-width: 480px) {
    .main-panel { padding: 12px; }
    .topbar { padding: 12px 14px; }
    .page-title { font-size: 18px; }
    
    .btn, .btn-sm { min-height: 38px; }
    .btn-icon { width: 38px; height: 38px; }
    .topbar-actions { gap: 8px; }
    .nav-item { min-height: 44px; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 600px) {
    
    .topbar-actions .btn span:not(.notification-badge) { display: none !important; }
    .topbar-actions .btn {
        padding-left: 0;
        padding-right: 0;
        min-width: 38px;
        justify-content: center;
        gap: 0;
    }
    
    .login-actions .theme-toggle span { display: none !important; }
    .login-actions .theme-toggle {
        padding-left: 0;
        padding-right: 0;
        min-width: 38px;
        justify-content: center;
        gap: 0;
    }
}

@media (max-width: 600px) {
    .table-responsive { overflow-x: visible; }
    .table-responsive > table.tbl,
    .table-responsive > table.table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }
    
    .table-responsive > table.tbl.entity-table,
    .table-responsive > table.tbl.clients-table,
    .table-responsive > table.tbl.orders-table {
        min-width: 0 !important;
    }
    .table-responsive > table > colgroup { display: none; }
    .table-responsive > table > thead { display: none; }
    .table-responsive > table > tbody { display: block; }
    .table-responsive td.mobile-hide,
    .table-responsive th.mobile-hide { display: none !important; }

    .table-responsive > table > tbody > tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: 12px 14px;
        margin-bottom: 12px;
        box-shadow: var(--shadow-sm);
    }
    
    .table-responsive > table > tbody > tr > td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        padding: 7px 0;
        border: none;
        text-align: right;
        white-space: normal;
    }
    .table-responsive > table > tbody > tr > td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 10.5px; font-weight: 800;
        letter-spacing: .05em; text-transform: uppercase;
        color: var(--ink-400);
        text-align: left;
    }
    
    .table-responsive > table > tbody > tr > td.id-col {
        font-size: 15px; font-weight: 800;
        color: var(--ink-900);
        justify-content: flex-start;
        text-align: left;
        padding: 2px 0 10px;
        margin-bottom: 4px;
        border-bottom: 1px dashed var(--border);
    }
    .table-responsive > table > tbody > tr > td.id-col::before { display: none; }
    
    .table-responsive > table > tbody > tr > td .client-cell,
    .table-responsive > table > tbody > tr > td .client-avatar-cell {
        justify-content: flex-end;
    }
    
    .table-responsive > table > tbody > tr > td.actions {
        justify-content: flex-end;
        padding: 12px 0 2px;
        margin-top: 4px;
        border-top: 1px dashed var(--border);
    }
    .table-responsive > table > tbody > tr > td.actions::before { display: none; }
    .table-responsive > table > tbody > tr > td.actions .order-actions-inline,
    .table-responsive > table > tbody > tr > td.actions .invoice-actions-inline,
    .table-responsive > table > tbody > tr > td.actions .quote-actions-inline {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    
    .table-responsive > table > tbody > tr > td[colspan] {
        display: block;
        text-align: center;
    }
    .table-responsive > table > tbody > tr > td[colspan]::before { display: none; }
}

html[data-theme="dark"] {
    --page:    #0b1220;
    --surface: #131a2b;
    --surface-soft: #1a2238;
    --border:  #1f2a44;
    --border-strong: #2c3a5a;
    --text:    #e5e7eb;
    --muted:   #9ca3af;
    --ink-900: #f3f4f6;
    --ink-700: #e5e7eb;
    --ink-500: #cbd5e1;
    --ink-400: #9ca3af;
    --ink-300: #6b7280;
    --ink-200: #374151;
    --ink-100: #1f2a44;
    --ink-50:  #1a2238;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, .6);
}
html[data-theme="dark"] body {
    background:
        radial-gradient(1100px 580px at -10% -10%, rgba(220, 38, 38, .08), transparent 60%),
        radial-gradient(900px 500px at 110% 0%, rgba(16, 185, 129, .08), transparent 60%),
        var(--page);
    color: var(--text);
}
html[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #131a2b 0%, #0e152a 100%);
    border-right-color: var(--border);
}
html[data-theme="dark"] .nav-item.active {
    background: linear-gradient(180deg, rgba(220, 38, 38, .18), rgba(255, 255, 255, .02));
    border-color: rgba(220, 38, 38, .35);
    color: #fecaca;
    box-shadow: inset 3px 0 0 var(--red-500);
}
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .table-panel,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .form-panel,
html[data-theme="dark"] .summary-panel,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .kpi-mini,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .advanced-panel,
html[data-theme="dark"] .document-summary {
    background: var(--surface);
    border-color: var(--border);
}
html[data-theme="dark"] .module-card-soon {
    background: linear-gradient(180deg, #131a2b, #0e152a);
}
html[data-theme="dark"] .form-control.is-invalid,
html[data-theme="dark"] .form-select.is-invalid,
html[data-theme="dark"] input.input.is-invalid,
html[data-theme="dark"] select.select.is-invalid,
html[data-theme="dark"] textarea.textarea.is-invalid,
html[data-theme="dark"] textarea.form-control.is-invalid {
    background: rgba(220, 38, 38, .12);
    border-color: var(--red-500);
    color: var(--ink-900);
}
html[data-theme="dark"] table.table thead th,
html[data-theme="dark"] table.tbl thead th {
    background: var(--surface-soft); color: var(--ink-500);
    border-bottom-color: var(--border-strong);
}
html[data-theme="dark"] table.table tbody td,
html[data-theme="dark"] table.tbl tbody td {
    color: var(--ink-700);
    border-bottom-color: var(--border);
}
html[data-theme="dark"] table.table tbody tr:hover td,
html[data-theme="dark"] table.tbl tbody tr:hover td { background: var(--surface-soft); }
html[data-theme="dark"] .invoices-table tbody tr.status-pending:hover td { background: rgba(239, 68, 68, .16); }
html[data-theme="dark"] .invoices-table tbody tr.status-partial:hover td { background: rgba(245, 158, 11, .16); }
html[data-theme="dark"] .invoices-table tbody tr.status-paid:hover td    { background: rgba(34, 197, 94, .14); }
html[data-theme="dark"] .invoices-table .chip-pending {
    background: rgba(239, 68, 68, .22);
    color: #fecaca;
    border-color: rgba(248, 113, 113, .65);
}
html[data-theme="dark"] .invoices-table tbody tr.status-pending:hover td:first-child { box-shadow: inset 4px 0 0 #ef4444; }
html[data-theme="dark"] .invoices-table tbody tr.status-partial:hover td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
html[data-theme="dark"] .invoices-table tbody tr.status-paid:hover td:first-child    { box-shadow: inset 4px 0 0 #22c55e; }
html[data-theme="dark"] .orders-table tbody tr.status-pending:hover td   { background: rgba(245, 158, 11, .16); }
html[data-theme="dark"] .orders-table tbody tr.status-overdue:hover td   { background: rgba(239, 68, 68, .16); }
html[data-theme="dark"] .orders-table tbody tr.status-partial:hover td   { background: rgba(245, 158, 11, .16); }
html[data-theme="dark"] .orders-table tbody tr.status-delivered:hover td { background: rgba(34, 197, 94, .14); }
html[data-theme="dark"] .orders-table tbody tr.status-pending:hover td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
html[data-theme="dark"] .orders-table tbody tr.status-overdue:hover td:first-child   { box-shadow: inset 4px 0 0 #ef4444; }
html[data-theme="dark"] .orders-table tbody tr.status-partial:hover td:first-child   { box-shadow: inset 4px 0 0 #f59e0b; }
html[data-theme="dark"] .orders-table tbody tr.status-delivered:hover td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
html[data-theme="dark"] .orders-table tbody tr.is-overdue:hover td:first-child       { box-shadow: inset 4px 0 0 #ef4444; }
html[data-theme="dark"] .orders-table tbody tr.is-overdue:hover > td {
    background: rgba(239, 68, 68, .18) !important;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea.form-control,
html[data-theme="dark"] input.input,
html[data-theme="dark"] select.select,
html[data-theme="dark"] textarea.textarea {
    background: var(--surface-soft);
    color: var(--ink-700);
    border-color: var(--border-strong);
}

html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-select-sm,
html[data-theme="dark"] select.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%23cbd5e1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 11px 8px;
}
html[data-theme="dark"] .form-select-sm { background-position: right 10px center; }
html[data-theme="dark"] .num-stepper-btns { border-left-color: var(--border-strong); }
html[data-theme="dark"] .num-stepper-btn {
    background: var(--surface);
    color: var(--ink-500);
}
html[data-theme="dark"] .num-stepper-btn[data-step="up"] { border-bottom-color: var(--border-strong); }
html[data-theme="dark"] .num-stepper-btn:hover {
    background: rgba(220, 38, 38, .18);
    color: #fecaca;
}
html[data-theme="dark"] .toolbar form .search-input { background: var(--surface-soft); }
html[data-theme="dark"] .toolbar form .search-input input { color: var(--ink-700); }
html[data-theme="dark"] .btn { background: var(--surface); color: var(--ink-700); border-color: var(--border-strong); }
html[data-theme="dark"] .btn:hover { background: rgba(220, 38, 38, .15); border-color: var(--red-500); color: #fecaca; }
html[data-theme="dark"] .btn-ghost { background: transparent; }
html[data-theme="dark"] .export-menu > summary.btn,
html[data-theme="dark"] .table-tools .export-menu > summary.btn {
    background: var(--surface-soft);
    color: var(--ink-700);
    border-color: var(--border-strong);
}
html[data-theme="dark"] .export-menu[open] > summary.btn,
html[data-theme="dark"] .export-menu > summary.btn:hover {
    background: rgba(249, 115, 22, .16);
    color: #fed7aa;
    border-color: rgba(249, 115, 22, .45);
}
html[data-theme="dark"] .export-menu-panel {
    background: #11182a;
    border-color: var(--border-strong);
    box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .85);
}
html[data-theme="dark"] .export-menu-panel .btn {
    background: transparent;
    color: var(--ink-700);
    border-color: transparent;
}
html[data-theme="dark"] .export-menu-panel .btn:hover {
    background: rgba(249, 115, 22, .14);
    color: #fed7aa;
    border-color: rgba(249, 115, 22, .35);
}
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-danger { background: var(--surface); color: var(--ink-700); }
html[data-theme="dark"] .module-card h3,
html[data-theme="dark"] .kpi-value,
html[data-theme="dark"] .kpi-mini-val,
html[data-theme="dark"] .client-name,
html[data-theme="dark"] .page-title { color: var(--ink-700); }
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .kpi-mini {
    background:
        radial-gradient(190px 120px at 100% -20%, rgba(249, 115, 22, .14), transparent 64%),
        linear-gradient(180deg, #151d31, #11182a);
    border-color: rgba(148, 163, 184, .18);
    box-shadow: 0 10px 28px -22px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .035);
}
html[data-theme="dark"] .kpi:hover,
html[data-theme="dark"] .kpi-mini:hover {
    border-color: rgba(249, 115, 22, .38);
    box-shadow: 0 16px 34px -24px rgba(249, 115, 22, .38), inset 0 1px 0 rgba(255, 255, 255, .045);
}
html[data-theme="dark"] .kpi-label,
html[data-theme="dark"] .kpi-mini-label {
    color: #a8b3c7;
}
html[data-theme="dark"] .kpi-period-tag {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .12);
    color: #9aa6ba;
}
html[data-theme="dark"] .kpi-foot,
html[data-theme="dark"] .kpi-mini-foot,
html[data-theme="dark"] .kpi-value small,
html[data-theme="dark"] .kpi-mini-val small {
    color: #c4ccda;
}
html[data-theme="dark"] .kpi-mini.neutral .kpi-mini-icon,
html[data-theme="dark"] .kpi-mini .kpi-mini-icon {
    background: rgba(21, 73, 64, .34);
    color: #5eead4;
    box-shadow: inset 0 0 0 1px rgba(94, 234, 212, .12);
}
html[data-theme="dark"] .kpi-mini.orange .kpi-mini-icon {
    background: rgba(249, 115, 22, .18);
    color: #fdba74;
    box-shadow: inset 0 0 0 1px rgba(253, 186, 116, .14);
}
html[data-theme="dark"] .kpi-mini.green .kpi-mini-icon {
    background: rgba(16, 185, 129, .18);
    color: #86efac;
    box-shadow: inset 0 0 0 1px rgba(134, 239, 172, .14);
}
html[data-theme="dark"] .kpi-mini.amber .kpi-mini-icon {
    background: rgba(217, 119, 6, .2);
    color: #fcd34d;
    box-shadow: inset 0 0 0 1px rgba(252, 211, 77, .14);
}
html[data-theme="dark"] .kpi-mini.red .kpi-mini-icon {
    background: rgba(220, 38, 38, .2);
    color: #fca5a5;
    box-shadow: inset 0 0 0 1px rgba(252, 165, 165, .14);
}
html[data-theme="dark"] .delta.up {
    color: #86efac;
    background: rgba(16, 185, 129, .16);
    border-color: rgba(134, 239, 172, .22);
}
html[data-theme="dark"] .delta.down {
    color: #fca5a5;
    background: rgba(220, 38, 38, .16);
    border-color: rgba(252, 165, 165, .22);
}
html[data-theme="dark"] .pager .pages a,
html[data-theme="dark"] .pagination-bar .pages a {
    background: var(--surface-soft); color: var(--ink-700); border-color: var(--border);
}
html[data-theme="dark"] .summary-meta .pill { background: var(--surface-soft); border-color: var(--border); }
html[data-theme="dark"] .summary-meta .pill strong { color: var(--ink-700); }
html[data-theme="dark"] .module-tag { background: var(--surface-soft); color: var(--ink-500); border-color: var(--border); }
html[data-theme="dark"] tr.active-row td { background: rgba(220, 38, 38, .12); }
html[data-theme="dark"] .line-row { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .add-line, html[data-theme="dark"] button[data-add-line] {
    background: var(--surface); border-color: var(--border-strong); color: var(--ink-500);
}
html[data-theme="dark"] .line-actions .btn-outline-danger,
html[data-theme="dark"] .line-remove {
    background: var(--surface); border-color: var(--border); color: var(--ink-400);
}

.stats-period-control {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 6px;
    margin: -4px 0 8px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.stats-period-control label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0;
}

.stats-period-control label span {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
}

.stats-period-control .form-select,
.stats-period-control .form-control {
    min-height: 30px;
    height: 30px;
    padding: 3px 28px 3px 8px;
    font-size: .78rem;
    border-radius: 8px;
}

.stats-period-dates {
    display: none;
    align-items: center;
    gap: 6px;
}

.stats-period-dates.is-visible {
    display: flex;
}

.stats-period-dates .form-control {
    width: 132px;
    min-width: 132px;
    padding-right: 6px;
}

html[data-theme="dark"] .stats-period-control {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

@media (max-width: 760px) {
    .stats-period-control,
    .stats-period-dates {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-period-control label,
    .stats-period-dates .form-control,
    .stats-period-dates .btn {
        width: 100%;
    }
}

.stats-settings-panel {
    max-width: 560px;
    padding: 16px;
}

.stats-settings-panel .table-head-bar {
    min-height: auto;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.stats-settings-panel .table-title {
    font-size: 15px;
    font-weight: 800;
}

.stats-settings-form {
    display: grid;
    gap: 14px;
}

.stats-settings-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr);
    gap: 12px;
}

.stats-settings-form .field-label {
    margin-bottom: 6px;
}

.stats-settings-form .form-control,
.stats-settings-form .form-select {
    height: 38px;
    border-radius: 10px;
}

.stats-custom-dates {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.stats-custom-dates.is-visible {
    display: grid;
}

.stats-settings-form .actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0 !important;
}

@media (max-width: 760px) {
    .stats-settings-panel {
        max-width: none;
    }

    .stats-custom-dates {
        grid-template-columns: 1fr;
    }
}

body.page-dashboard .app-shell.no-sidebar {
    display: block;
    width: 100%;
    min-height: 100vh;
}

body.page-dashboard .app-shell.no-sidebar .main-panel {
    width: 100%;
    max-width: none;
    margin: 0;
}

.invoices-table tr.status-pending .chip-pending,
.invoices-table .invoice-col-status .chip-pending,
html[data-theme="dark"] .invoices-table tr.status-pending .chip-pending,
html[data-theme="dark"] .invoices-table .invoice-col-status .chip-pending {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #ef4444 !important;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .18) !important;
}

.orders-table tbody tr.is-overdue:hover > td { background: rgba(239, 68, 68, .11) !important; }
html[data-theme="dark"] .orders-table tbody tr.is-overdue:hover > td { background: rgba(239, 68, 68, .18) !important; }

.line-row,
.line-row.bl,
.line-row.no-discount,
.line-row.order-line {
    grid-template-columns: 70px minmax(0, 1fr) !important;
    grid-template-areas:
        "id designation"
        "bottom bottom" !important;
    gap: 8px;
}
.line-row > * { min-width: 0; }
.line-row .article-id-picker { grid-area: id !important; }
.line-row .article-picker { grid-area: designation !important; }
.line-row > .line-row-bottom { grid-area: bottom !important; }

.line-row > .line-row-bottom {
    display: grid !important;
    grid-template-columns: minmax(0, 170px) minmax(0, 130px) minmax(0, 168px) minmax(0, 130px) minmax(0, 230px) minmax(0, 1fr) 40px;
    gap: 8px;
    align-items: start;
    min-width: 0;
}
.line-row.no-discount > .line-row-bottom {
    grid-template-columns: minmax(0, 170px) minmax(0, 130px) minmax(0, 130px) minmax(0, 230px) minmax(0, 1fr) 40px;
}
.line-row.bl > .line-row-bottom {
    grid-template-columns: minmax(0, 170px) minmax(0, 280px) minmax(0, 1fr) 40px;
}
.line-row.order-line > .line-row-bottom {
    grid-template-columns: minmax(0, 170px) minmax(0, 120px) minmax(0, 130px) minmax(0, 168px) minmax(0, 110px) minmax(0, 1fr) 40px;
}

.line-row > .line-row-bottom > .qty-fields,
.line-row > .line-row-bottom > input[name="line_price[]"],
.line-row > .line-row-bottom > input[name="order_price[]"],
.line-row > .line-row-bottom > input[name="shipped_qty[]"],
.line-row > .line-row-bottom > input[name="shipping_date[]"],
.line-row > .line-row-bottom > .discount-fields,
.line-row > .line-row-bottom > .line-total,
.line-row > .line-row-bottom > textarea.article-details {
    grid-area: auto !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-width: 0;
}
.line-row > .line-row-bottom > .line-actions {
    grid-area: auto !important;
    grid-row: auto !important;
    grid-column: -2 / -1 !important;
    align-self: stretch;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

@media (max-width: 1100px) {
    .line-row,
    .line-row.bl,
    .line-row.no-discount,
    .line-row.order-line {
        grid-template-columns: 70px minmax(0, 1fr) !important;
        grid-template-areas:
            "id designation"
            "bottom bottom" !important;
    }
    
    .line-row > .line-row-bottom,
    .line-row.no-discount > .line-row-bottom,
    .line-row.bl > .line-row-bottom,
    .line-row.order-line > .line-row-bottom {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .line-row > .line-row-bottom > .line-actions {
        grid-column: 1 / -1 !important;
        justify-content: flex-end !important;
    }
    
    .line-row > .line-row-bottom > textarea.article-details {
        grid-column: 1 / -1 !important;
    }
}

.line-row > .line-row-bottom > .line-actions {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.line-row > .line-row-bottom > .line-total {
    display: flex !important;
    flex-direction: column;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    gap: 2px;
    padding-inline: 8px;
}

.line-row > .line-row-bottom > .line-total span,
.line-row > .line-row-bottom > .line-total strong {
    display: block;
    width: 100%;
    text-align: center;
}

.line-total {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.line-total span,
.line-total strong {
    display: block !important;
    width: 100%;
    text-align: center !important;
}

#sfm-toasts {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 36px));
    pointer-events: none;
}
.sfm-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--red-200);
    background: var(--red-50);
    color: var(--red-700);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 12px 30px -10px rgba(11, 18, 32, .35);
    animation: sfmToastIn .22s ease both;
}
.sfm-toast-success { background: var(--green-50); color: var(--green-700); border-color: var(--green-200); }
.sfm-toast-warning { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-200); }
.sfm-toast span { flex: 1; line-height: 1.4; padding-top: 1px; }
.sfm-toast i { padding-top: 2px; }
.sfm-toast-close {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    opacity: .7;
}
.sfm-toast-close:hover { opacity: 1; }
.sfm-toast-out { animation: sfmToastOut .2s ease both; }
@keyframes sfmToastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes sfmToastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(16px); } }

/* Navigation progress bar — instant feedback while a page loads */
#sfm-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 9999;
    background: linear-gradient(90deg, var(--accent, #4f46e5), #8b5cf6);
    box-shadow: 0 0 8px rgba(79, 70, 229, .5);
    opacity: 0;
    pointer-events: none;
    border-radius: 0 2px 2px 0;
}
#sfm-progress.active {
    opacity: 1;
    width: 82%;
    transition: width 8s cubic-bezier(.1, .7, .3, 1), opacity .1s ease;
}
#sfm-progress.done {
    opacity: 0;
    width: 100%;
    transition: width .2s ease, opacity .4s ease .1s;
}
