:root {
    --sanid-navy-950: #102a3a;
    --sanid-navy-900: #16384d;
    --sanid-navy-800: #1d4b63;
    --sanid-teal-700: #087f8c;
    --sanid-teal-600: #0f97a6;
    --sanid-teal-100: #dff5f5;
    --sanid-green-600: #159467;
    --sanid-blue-600: #176b87;
    --sanid-red-600: #c43d4d;
    --sanid-amber-500: #d99b16;
    --sanid-ink: #193042;
    --sanid-muted: #617587;
    --sanid-line: #d9e4eb;
    --sanid-surface: #ffffff;
    --sanid-canvas: #f3f7f9;
    --sanid-radius-sm: 10px;
    --sanid-radius: 16px;
    --sanid-radius-lg: 24px;
    --sanid-shadow-sm: 0 3px 12px rgba(16, 42, 58, .07);
    --sanid-shadow: 0 12px 32px rgba(16, 42, 58, .10);
    --sanid-focus: 0 0 0 3px rgba(15, 151, 166, .24);
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body.sanid-app-shell {
    color: var(--sanid-ink);
    background: var(--sanid-canvas);
    line-height: 1.55;
}

.sanid-skip-link {
    position: fixed;
    inset-block-start: 10px;
    inset-inline-start: 10px;
    z-index: 12000;
    padding: .7rem 1rem;
    border-radius: var(--sanid-radius-sm);
    color: #fff;
    background: var(--sanid-navy-950);
    transform: translateY(-160%);
    transition: transform .15s ease;
}

.sanid-skip-link:focus { transform: translateY(0); }

.sanid-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

body.sanid-app-shell .content-wrapper {
    background:
        radial-gradient(circle at 8% 0%, rgba(15, 151, 166, .08), transparent 28rem),
        var(--sanid-canvas);
}

body.sanid-app-shell main[role="main"] {
    width: 100%;
    max-width: 1500px;
    margin-inline: auto;
}

.sanid-page-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    font-weight: 800;
}

.sanid-page-title i { color: var(--sanid-teal-700); }

.sanid-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(8, 29, 42, .48);
    backdrop-filter: blur(2px);
}

.sanid-sidebar-backdrop.is-visible { display: block; }

body.sanid-app-shell h1,
body.sanid-app-shell h2,
body.sanid-app-shell h3,
body.sanid-app-shell h4,
body.sanid-app-shell h5 {
    color: var(--sanid-navy-950);
    letter-spacing: -.02em;
}

body.sanid-app-shell .sidebar-menu {
    background: linear-gradient(180deg, var(--sanid-navy-950), var(--sanid-navy-900));
    border-inline-start-color: rgba(63, 191, 189, .25);
    box-shadow: -10px 0 35px rgba(16, 42, 58, .22);
}

body.sanid-app-shell .sidebar-header {
    background: linear-gradient(150deg, rgba(255,255,255,.055), rgba(255,255,255,.012));
    padding-block: 24px 20px;
}

body.sanid-app-shell .nav-link-item {
    min-height: 50px;
    border-color: rgba(255,255,255,.075);
    background: rgba(255,255,255,.035);
    box-shadow: none;
}

body.sanid-app-shell .nav-link-item.active {
    background: linear-gradient(135deg, rgba(15,151,166,.32), rgba(21,148,103,.20));
    border-color: rgba(99, 226, 209, .34);
    animation: none;
}

body.sanid-app-shell .nav-link-item:not(.active):hover {
    transform: translateX(-3px);
    box-shadow: 0 7px 20px rgba(4, 20, 30, .18);
}

body.sanid-app-shell .toggle-btn,
body.sanid-app-shell .mobile-menu-btn {
    background: linear-gradient(135deg, var(--sanid-teal-600), var(--sanid-green-600));
}

body.sanid-app-shell .card,
body.sanid-app-shell .form-container,
body.sanid-app-shell .review-event,
body.sanid-app-shell .financial-review-panel {
    border: 1px solid var(--sanid-line);
    border-radius: var(--sanid-radius);
    background: var(--sanid-surface);
    box-shadow: var(--sanid-shadow-sm);
}

body.sanid-app-shell .card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--sanid-line);
    border-radius: var(--sanid-radius) var(--sanid-radius) 0 0;
    background: #f8fbfc !important;
}

body.sanid-app-shell .card-body { padding: 1.25rem; }

body.sanid-app-shell .table-responsive {
    border: 1px solid var(--sanid-line);
    border-radius: var(--sanid-radius);
    background: #fff;
    box-shadow: var(--sanid-shadow-sm);
}

body.sanid-app-shell .table { margin-bottom: 0; color: var(--sanid-ink); }
body.sanid-app-shell .table > :not(caption) > * > * { padding: .8rem .7rem; border-color: #e6edf2; }
body.sanid-app-shell .table thead th {
    color: var(--sanid-navy-950);
    font-weight: 750;
    background: #eaf2f6;
    vertical-align: middle;
    white-space: nowrap;
}
body.sanid-app-shell .table tbody tr { transition: background-color .15s ease; }
body.sanid-app-shell .table tbody tr:hover { background: #f5fafb; }

body.sanid-app-shell .form-label { color: var(--sanid-navy-900); font-weight: 650; }
body.sanid-app-shell .form-control,
body.sanid-app-shell .form-select {
    min-height: 44px;
    border-color: #cddbe4;
    border-radius: var(--sanid-radius-sm);
    color: var(--sanid-ink);
    background-color: #fff;
}
body.sanid-app-shell .form-control:focus,
body.sanid-app-shell .form-select:focus {
    border-color: var(--sanid-teal-600);
    box-shadow: var(--sanid-focus);
}

body.sanid-app-shell .btn {
    min-height: 42px;
    padding: .55rem 1rem;
    border-radius: var(--sanid-radius-sm);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
}

body.sanid-app-shell .btn-primary {
    border-color: var(--sanid-blue-600);
    background: var(--sanid-blue-600);
}
body.sanid-app-shell .btn-primary:hover { border-color: #11566e; background: #11566e; }
body.sanid-app-shell .btn-success { border-color: var(--sanid-green-600); background: var(--sanid-green-600); }
body.sanid-app-shell .btn-danger { border-color: var(--sanid-red-600); background: var(--sanid-red-600); }
body.sanid-app-shell .btn-secondary { border-color: #617587; background: #617587; }

body.sanid-app-shell .alert {
    border-width: 1px;
    border-radius: var(--sanid-radius);
    box-shadow: var(--sanid-shadow-sm);
}

body.sanid-app-shell .badge { padding: .45em .7em; border-radius: 999px; font-weight: 700; }

/* App-wide identity pass — extends coverage to Bootstrap components used
   outside the invoice/return screens (reports removed, settings, users,
   templates, operations…) without touching any view markup. Colors/shape
   only: no layout, spacing-affecting, or structural properties that could
   hide/show/reorder existing fields or buttons. */
body.sanid-app-shell .btn-outline-primary {
    color: var(--sanid-blue-600);
    border-color: var(--sanid-blue-600);
}
body.sanid-app-shell .btn-outline-primary:hover {
    color: #fff;
    background: var(--sanid-blue-600);
    border-color: var(--sanid-blue-600);
}
body.sanid-app-shell .btn-outline-success { color: var(--sanid-green-600); border-color: var(--sanid-green-600); }
body.sanid-app-shell .btn-outline-success:hover { color: #fff; background: var(--sanid-green-600); border-color: var(--sanid-green-600); }
body.sanid-app-shell .btn-outline-danger { color: var(--sanid-red-600); border-color: var(--sanid-red-600); }
body.sanid-app-shell .btn-outline-danger:hover { color: #fff; background: var(--sanid-red-600); border-color: var(--sanid-red-600); }
body.sanid-app-shell .btn-outline-secondary { color: var(--sanid-muted); border-color: #cddbe4; }
body.sanid-app-shell .btn-outline-secondary:hover { color: #fff; background: var(--sanid-muted); border-color: var(--sanid-muted); }
body.sanid-app-shell .btn-outline-info,
body.sanid-app-shell .btn-info {
    color: var(--sanid-teal-700);
    border-color: var(--sanid-teal-600);
    background: transparent;
}
body.sanid-app-shell .btn-info { color: #fff; background: var(--sanid-teal-600); }
body.sanid-app-shell .btn-outline-info:hover,
body.sanid-app-shell .btn-info:hover { color: #fff; background: var(--sanid-teal-700); border-color: var(--sanid-teal-700); }
body.sanid-app-shell .btn-warning { color: #4a3200; border-color: var(--sanid-amber-500); background: var(--sanid-amber-500); }
body.sanid-app-shell .btn-warning:hover { background: #b87f0d; border-color: #b87f0d; }
body.sanid-app-shell .btn-light { border-color: var(--sanid-line); background: #fff; }
body.sanid-app-shell .btn:disabled,
body.sanid-app-shell .btn.disabled { opacity: .6; box-shadow: none; }

body.sanid-app-shell .nav-tabs { border-bottom-color: var(--sanid-line); }
body.sanid-app-shell .nav-tabs .nav-link {
    border: 0;
    border-bottom: 3px solid transparent;
    color: var(--sanid-muted);
    font-weight: 650;
}
body.sanid-app-shell .nav-tabs .nav-link.active,
body.sanid-app-shell .nav-tabs .nav-link:hover {
    color: var(--sanid-teal-700);
    background: transparent;
    border-bottom-color: var(--sanid-teal-600);
}

body.sanid-app-shell .dropdown-menu {
    border-color: var(--sanid-line);
    border-radius: var(--sanid-radius-sm);
    box-shadow: var(--sanid-shadow);
}
body.sanid-app-shell .dropdown-item:hover,
body.sanid-app-shell .dropdown-item:focus { background: var(--sanid-teal-100); color: var(--sanid-navy-950); }
body.sanid-app-shell .dropdown-item.active,
body.sanid-app-shell .dropdown-item:active { background: var(--sanid-teal-600); }

body.sanid-app-shell .modal-content {
    border: 1px solid var(--sanid-line);
    border-radius: var(--sanid-radius);
    box-shadow: var(--sanid-shadow);
}
body.sanid-app-shell .modal-header { border-bottom-color: var(--sanid-line); }
body.sanid-app-shell .modal-footer { border-top-color: var(--sanid-line); }

body.sanid-app-shell .page-link {
    color: var(--sanid-teal-700);
    border-color: var(--sanid-line);
}
body.sanid-app-shell .page-item.active .page-link {
    background: var(--sanid-teal-600);
    border-color: var(--sanid-teal-600);
}

body.sanid-app-shell .form-check-input:checked {
    background-color: var(--sanid-teal-600);
    border-color: var(--sanid-teal-600);
}
body.sanid-app-shell .form-check-input:focus {
    border-color: var(--sanid-teal-600);
    box-shadow: var(--sanid-focus);
}

body.sanid-app-shell a:not(.btn):not(.nav-link-item):not(.dropdown-item) {
    color: var(--sanid-teal-700);
}
body.sanid-app-shell a:not(.btn):not(.nav-link-item):not(.dropdown-item):hover {
    color: var(--sanid-navy-950);
}

body.sanid-app-shell :is(a, button, input, select, textarea, summary):focus-visible,
.sanid-login-page :is(a, button, input):focus-visible {
    outline: 2px solid transparent;
    box-shadow: var(--sanid-focus) !important;
}

.sanid-login-page {
    direction: rtl;
    background:
        radial-gradient(circle at 15% 12%, rgba(66, 201, 190, .25), transparent 25rem),
        radial-gradient(circle at 90% 92%, rgba(42, 109, 135, .30), transparent 30rem),
        linear-gradient(145deg, var(--sanid-navy-950), var(--sanid-navy-800));
}

.sanid-login-page::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .17;
    background-image: linear-gradient(rgba(255,255,255,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.13) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.sanid-login-page .sanid-login-card {
    position: relative;
    isolation: isolate;
    max-width: 440px;
    padding: 34px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--sanid-radius-lg);
    background: rgba(255,255,255,.96);
    box-shadow: 0 25px 70px rgba(5, 24, 36, .35);
}

.sanid-login-intro { margin: -8px 0 24px; text-align: center; }
.sanid-login-intro h1 { margin-bottom: .35rem; color: var(--sanid-navy-950); font-size: 1.55rem; }
.sanid-login-intro p { margin: 0; color: var(--sanid-muted); font-size: .95rem; line-height: 1.7; }
.sanid-login-page .form-group input { direction: rtl; padding: 14px 50px 14px 18px; }
.sanid-login-page .input-icon { right: 18px; left: auto; }
.sanid-login-page button[type="submit"] { background: linear-gradient(135deg, var(--sanid-teal-700), var(--sanid-blue-600)); }
.sanid-login-secondary {
    display: block;
    margin-top: 14px;
    padding: 12px;
    text-align: center;
    border: 1px solid var(--sanid-teal-600);
    border-radius: 12px;
    color: var(--sanid-teal-700);
    font-weight: 700;
    text-decoration: none;
    transition: color .15s ease, background .15s ease;
}
.sanid-login-secondary:hover { color: var(--sanid-navy-950); background: var(--sanid-teal-100); }
.sanid-feedback { margin-bottom: 20px; padding: 12px 16px; border-radius: 10px; text-align: center; }
.sanid-feedback-success { color: #0f5132; border: 1px solid #badbcc; background: #d1e7dd; }

@media (max-width: 991.98px) {
    body.sanid-app-shell .content-wrapper { padding: 26px 20px; }
}

/* R31.2 — compact document state and predictable row actions. */
body.sanid-app-shell .document-state-stack {
    display: inline-flex;
    min-width: 128px;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    text-align: right;
}

body.sanid-app-shell .document-state-stack .badge {
    box-shadow: none;
    font-size: .72rem;
}

body.sanid-app-shell .document-review-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #586a76;
    font-size: .72rem;
    font-weight: 750;
    line-height: 1.25;
}

body.sanid-app-shell .document-review-label.review-approved { color: #147653; }
body.sanid-app-shell .document-review-label.review-rejected { color: #aa3442; }
body.sanid-app-shell .document-review-label.review-pending { color: #8a6810; }
body.sanid-app-shell .document-storage-state { color: #84919a; font-size: .66rem; }

body.sanid-app-shell td.document-state-cell { min-width: 140px !important; }
body.sanid-app-shell td.document-actions-cell { min-width: 210px !important; }
body.sanid-app-shell .document-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

body.sanid-app-shell .document-row-actions > .btn,
body.sanid-app-shell .document-row-actions > .dropdown > .btn,
body.sanid-app-shell .document-row-actions > .document-actions-menu > .btn {
    min-height: 36px;
    margin: 0;
    padding: .4rem .68rem;
    border-radius: 8px;
    box-shadow: none;
}

body.sanid-app-shell .document-preview-action,
body.sanid-app-shell .document-more-action { width: 38px; }
body.sanid-app-shell .document-primary-action { min-width: 92px; gap: 6px; }
body.sanid-app-shell .document-actions-menu { display: inline-flex; }
body.sanid-app-shell .document-actions-menu .dropdown-menu {
    min-width: 220px;
    padding: 6px;
    border-color: var(--sanid-line);
    border-radius: 10px;
    text-align: right;
    box-shadow: 0 12px 30px rgba(16, 42, 58, .16);
}

body.sanid-app-shell .document-actions-menu .dropdown-item {
    display: flex;
    min-height: 38px;
    align-items: center;
    gap: 9px;
    padding: .5rem .65rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font-size: .84rem;
    font-weight: 650;
    text-align: right;
}

body.sanid-app-shell .document-actions-menu .dropdown-item i { width: 18px; text-align: center; }

@media (min-width: 768px) {
    body.sanid-app-shell .sidebar-menu:not(.sidebar-small) { width: 260px; overflow-x: hidden; }
    body.sanid-app-shell .content-wrapper:not(.content-small) { width: calc(100% - 260px); margin-right: 260px; }
    body.sanid-app-shell .sidebar-header { padding: 15px 16px 12px; }
    body.sanid-app-shell .logo .app-logo-wrap,
    body.sanid-app-shell .logo .app-logo-image { width: 154px; height: 46px; }
    body.sanid-app-shell .logo span { font-size: 1rem; }
    body.sanid-app-shell .nav-links {
        padding: 5px 0 10px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
    }
    body.sanid-app-shell .nav-links::-webkit-scrollbar { width: 0; height: 0; }
    body.sanid-app-shell .nav-link-item {
        min-height: 40px;
        max-width: calc(100% - 18px);
        margin: 3px 9px;
        padding: 8px 14px;
        gap: 11px;
        border-radius: 8px;
        font-size: .9rem;
    }
    body.sanid-app-shell .settings-items .nav-link-item { margin-right: 23px; padding: 7px 13px; }
    body.sanid-app-shell .nav-icon { width: 22px; font-size: 1.05rem; }
    body.sanid-app-shell .nav-divider { margin-block: 8px !important; }
    body.sanid-app-shell .sidebar-footer { padding: 8px 10px; }
    body.sanid-app-shell .sidebar-footer p { margin: 1px 0; font-size: .72rem; }
    body.sanid-app-shell .sidebar-menu form .nav-link-item { width: calc(100% - 18px) !important; }
}

@media (max-width: 767.98px) {
    body.sanid-menu-open { overflow: hidden; }
    body.sanid-app-shell .content-wrapper { padding: 78px 12px 20px; }
    body.sanid-app-shell main[role="main"] > .container,
    body.sanid-app-shell main[role="main"] > .container-md { padding-inline: 0; }
    body.sanid-app-shell h2 { font-size: 1.45rem; }
    body.sanid-app-shell .mobile-menu-btn { top: 14px; right: 14px; width: 46px; height: 46px; border-radius: 14px; }
    body.sanid-app-shell .sidebar-menu { width: min(88vw, 320px); }
    body.sanid-app-shell .card-body { padding: 1rem; }
    body.sanid-app-shell .btn { min-height: 44px; }
    body.sanid-app-shell .finance-mobile-nav {
        top: 66px;
        padding: .45rem;
        border: 1px solid var(--sanid-line);
        border-radius: 14px;
        background: rgba(243,247,249,.94);
        box-shadow: var(--sanid-shadow-sm);
        backdrop-filter: blur(10px);
    }
    body.sanid-app-shell .finance-documents-table tr {
        border-color: var(--sanid-line);
        box-shadow: var(--sanid-shadow-sm);
    }
}

@media (max-width: 480px) {
    .sanid-login-page { padding: 12px; align-items: center; }
    .sanid-login-page .sanid-login-card { margin: 0; padding: 26px 20px; }
    .sanid-login-page .brand-logo { width: min(100%, 225px); }
}

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

@media print {
    .sanid-skip-link, .sidebar-menu, .toggle-btn, .mobile-menu-btn { display: none !important; }
    body.sanid-app-shell .content-wrapper { width: 100% !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }
}
