/* =====================================================
   WCAG 2.1 AA + GIGW 3.0 + IS 17802 Compliance
   Accessibility Layer for Login Page
   Non-invasive overlay - preserves existing light/dark mode
   ===================================================== */

/* ===== TEXT SCALING - WCAG 1.4.4 ===== */
/* Users can scale text up to 200% without loss of content or functionality */
/* IMPORTANT: Scale at HTML level only - NO em multipliers to prevent exponential growth */

html.large-text {
    font-size: 110%;
}

html.larger-text {
    font-size: 125%;
}

html.maximum-text {
    font-size: 150%;
}

/* DO NOT apply additional scaling to elements - html scaling is enough */
/* This prevents exponential/cascading text growth */

/* ===== DASHBOARD SPECIFIC SCALING ===== */
/* Remove hardcoded font-size declarations that block html-level scaling */
/* Elements will inherit from html root font-size change */
html.large-text .metric-value,
html.large-text .metric-label,
html.large-text .summary-value,
html.large-text .summary-label,
html.large-text .table td,
html.large-text .table tbody td,
html.large-text .table th,
html.large-text .table thead th,
html.large-text .stock-symbol,
html.large-text .description-text {
    font-size: inherit !important;
}

html.larger-text .metric-value,
html.larger-text .metric-label,
html.larger-text .summary-value,
html.larger-text .summary-label,
html.larger-text .table td,
html.larger-text .table tbody td,
html.larger-text .table th,
html.larger-text .table thead th,
html.larger-text .stock-symbol,
html.larger-text .description-text {
    font-size: inherit !important;
}

html.maximum-text .metric-value,
html.maximum-text .metric-label,
html.maximum-text .summary-value,
html.maximum-text .summary-label,
html.maximum-text .table td,
html.maximum-text .table tbody td,
html.maximum-text .table th,
html.maximum-text .table thead th,
html.maximum-text .stock-symbol,
html.maximum-text .description-text {
    font-size: inherit !important;
}

/* ===== HIGH CONTRAST MODE - WCAG 1.4.3 ===== */
body.high-contrast {
    background: #000000 !important;
    color: #ffffff !important;
}

body.high-contrast .row,
body.high-contrast .container {
    background: #000000 !important;
    border: 3px solid #ffffff !important;
    color: #ffffff !important;
}

/* Remove ALL gradients and colors from header/navbar */
body.high-contrast .navbar,
body.high-contrast .navbar-dark,
body.high-contrast .navbar-brand {
    background: #000000 !important;
    color: #ffffff !important;
    border-bottom: 3px solid #ffffff !important;
}

body.high-contrast .nav-link,
body.high-contrast .navbar-toggler {
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

/* Navbar dropdown menu */
body.high-contrast .dropdown-menu {
    background: #ffffff !important;
    border: 3px solid #000000 !important;
}

body.high-contrast .dropdown-item {
    background: #ffffff !important;
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
    font-weight: 600 !important;
}

body.high-contrast .dropdown-item:hover {
    background: #000000 !important;
    color: #ffffff !important;
}

body.high-contrast .dropdown-divider {
    border-color: #000000 !important;
    border-width: 2px !important;
}

/* Sidebar header */
body.high-contrast .sidebar-header {
    background: #000000 !important;
    color: #ffffff !important;
    border-bottom: 3px solid #ffffff !important;
}

body.high-contrast .sidebar-header h5 {
    color: #ffffff !important;
}

/* Remove gradients from filter boxes and card headers */
body.high-contrast .filter-box-title,
body.high-contrast .ibox-title {
    background: #000000 !important;
    color: #ffffff !important;
    border: 3px solid #ffffff !important;
}

body.high-contrast .filter-box-title h5,
body.high-contrast .ibox-title h5 {
    color: #ffffff !important;
}

body.high-contrast input,
body.high-contrast .form-control {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

body.high-contrast input::placeholder {
    color: #cccccc !important;
}

body.high-contrast button,
body.high-contrast .btn,
body.high-contrast .btn-primary,
body.high-contrast .btn-success,
body.high-contrast .btn-danger,
body.high-contrast .btn-default,
body.high-contrast .btn-secondary {
    background: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
    font-weight: 700 !important;
}

body.high-contrast button:hover,
body.high-contrast .btn:hover {
    background: #000000 !important;
    color: #ffffff !important;
    border: 3px solid #ffffff !important;
}

body.high-contrast button:focus,
body.high-contrast .btn:focus {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
}

body.high-contrast a {
    color: #ffffff !important;
    text-decoration: underline !important;
}

body.high-contrast label {
    color: #ffffff !important;
}

body.high-contrast .external-link-item {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #ffffff !important;
}

/* ===== DASHBOARD HIGH CONTRAST MODE ===== */
/* Override all colored elements for accessibility */

/* Portfolio cards - white background, black text, white border */
body.high-contrast .portfolio-card-multi {
    background: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
}

/* Card headers - remove ALL gradients, use solid black with white text */
body.high-contrast .multi-header,
body.high-contrast .export-card-header,
body.high-contrast .dashboard-header {
    background: #000000 !important;
    color: #ffffff !important;
    border: 3px solid #ffffff !important;
}

body.high-contrast .dashboard-title,
body.high-contrast .multi-header span {
    color: #ffffff !important;
}

/* Export section */
body.high-contrast .export-card,
body.high-contrast .export-section {
    background: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
}

/* All text in cards - black on white */
body.high-contrast .metric-value,
body.high-contrast .metric-label,
body.high-contrast .summary-value,
body.high-contrast .summary-label {
    color: #000000 !important;
}

/* Remove ALL color coding - profit/loss indicators */
body.high-contrast .metric-value.positive,
body.high-contrast .metric-value.negative,
body.high-contrast .text-red,
body.high-contrast .text-green {
    color: #000000 !important;
}

/* Badges - white background, BLACK TEXT, black border */
body.high-contrast .badge,
body.high-contrast .badge.bg-success,
body.high-contrast .badge.bg-danger,
body.high-contrast .badge.bg-warning,
body.high-contrast .badge.bg-info,
body.high-contrast .badge.bg-primary,
body.high-contrast span.badge,
body.high-contrast span.bg-success,
body.high-contrast span.bg-danger {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    font-weight: 700 !important;
}

/* Force text color on badge content */
body.high-contrast .badge *,
body.high-contrast .badge::before,
body.high-contrast .badge::after {
    color: #000000 !important;
}

/* Tables - white background, black text */
body.high-contrast .table {
    background: #ffffff !important;
    color: #000000 !important;
}

body.high-contrast .table thead th {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

body.high-contrast .table tbody td {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
}

body.high-contrast .table tbody tr {
    background: #ffffff !important;
}

body.high-contrast .table-footer-light {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

/* Remove colored text in tables */
body.high-contrast .table td.text-red,
body.high-contrast .table td.text-green {
    color: #000000 !important;
}

/* Scrollable containers */
body.high-contrast .table-container,
body.high-contrast .scrollable-table {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
}

/* Export section */
body.high-contrast .export-card-content {
    background: #ffffff !important;
    color: #000000 !important;
}

body.high-contrast .description-text {
    color: #000000 !important;
}

/* Icons */
body.high-contrast .fas,
body.high-contrast .fa {
    color: inherit !important;
}

/* ===== RESPONSIVE LAYOUT FOR TEXT SCALING ===== */
/* Prevent content cutoff at large text sizes - from WebGroup2 best practices */

/* Stack columns to full width in large text modes */
html.large-text .col-lg-4,
html.large-text .col-lg-6,
html.large-text .col-lg-3,
html.large-text .col-md-6,
html.large-text .col-md-4 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

html.larger-text .col-lg-4,
html.larger-text .col-lg-6,
html.larger-text .col-lg-3,
html.larger-text .col-md-6,
html.larger-text .col-md-4 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

html.maximum-text .col-lg-4,
html.maximum-text .col-lg-6,
html.maximum-text .col-lg-3,
html.maximum-text .col-md-6,
html.maximum-text .col-md-4 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

/* Allow content boxes to grow with text size */
html.large-text .portfolio-card-multi,
html.large-text .ibox,
html.large-text .ibox-content,
html.large-text .card {
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
}

html.larger-text .portfolio-card-multi,
html.larger-text .ibox,
html.larger-text .ibox-content,
html.larger-text .card {
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
}

html.maximum-text .portfolio-card-multi,
html.maximum-text .ibox,
html.maximum-text .ibox-content,
html.maximum-text .card {
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
}

/* Adjust grid layouts for readability */
html.large-text .portfolio-summary-multi,
html.larger-text .portfolio-summary-multi,
html.maximum-text .portfolio-summary-multi {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
}

/* ===== FOCUS INDICATORS - WCAG 2.4.7 ===== */
*:focus,
*:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
}

body.high-contrast *:focus,
body.high-contrast *:focus-visible {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
}

/* ===== NAVIGATION FOCUS STYLES ===== */
.sidebar-link:focus,
.sidebar-link:focus-visible {
    outline: 3px solid #0d6efd !important;
    outline-offset: 2px !important;
    background: rgba(13, 110, 253, 0.1) !important;
}

[data-bs-theme="dark"] .sidebar-link:focus,
[data-bs-theme="dark"] .sidebar-link:focus-visible {
    outline: 3px solid #80bdff !important;
    background: rgba(128, 189, 255, 0.1) !important;
}

body.high-contrast .sidebar-link:focus,
body.high-contrast .sidebar-link:focus-visible {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
    background: transparent !important;
}

/* Sidebar button styling for accessibility */
.sidebar-link.w-100 {
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
}

.sidebar-link.w-100:hover {
    background: rgba(13, 110, 253, 0.05);
}

[data-bs-theme="dark"] .sidebar-link.w-100 {
    color: inherit;
}

[data-bs-theme="dark"] .sidebar-link.w-100:hover {
    background: rgba(128, 189, 255, 0.05);
}

/* High contrast sidebar - ALL menu items consistent styling */
body.high-contrast .sidebar,
body.high-contrast .sidebar-content,
body.high-contrast .sidebar-menu {
    background: #000000 !important;
}

body.high-contrast .sidebar-link,
body.high-contrast .sidebar-link.w-100,
body.high-contrast .sidebar-item a {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    margin-bottom: 2px !important;
}

body.high-contrast .sidebar-link:hover,
body.high-contrast .sidebar-link.w-100:hover {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

body.high-contrast .sidebar-item.active .sidebar-link,
body.high-contrast .sidebar-link.active {
    background: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
}

/* Submenu items in high contrast */
body.high-contrast .collapse a,
body.high-contrast .sidebar-menu .collapse li a {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #ffffff !important;
}

body.high-contrast .collapse a:hover {
    background: #ffffff !important;
    color: #000000 !important;
}

/* ===== ACCESSIBILITY TOOLBAR ===== */
.accessibility-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.accessibility-button {
    /* BAC-53146: was rgba(13,110,253,0.75) over white (~#64A1FD, 2.61:1 for the
       white icon). Solid darker blue at full opacity clears the 3:1 minimum. */
    background: #0b57c2;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    color: #ffffff;
    font-size: 18px;
    opacity: 1;
    outline: none;
}

.accessibility-button:hover,
.accessibility-button:focus {
    background: rgba(10, 88, 202, 0.95);
    color: #ffffff;
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
    opacity: 1;
}

.accessibility-button:focus {
    outline: 3px solid #ffc107;
    outline-offset: 2px;
}

.accessibility-panel {
    position: absolute;
    bottom: 50px;
    right: 0;
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: none;
}

.accessibility-panel.show {
    display: block;
}

.accessibility-panel h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #212529;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 8px;
}

.accessibility-option {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.accessibility-option:hover {
    background: #f8f9fa;
}

.accessibility-option input[type="checkbox"],
.accessibility-option input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

.accessibility-option label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    font-size: 14px;
    color: #495057;
}

/* Settings sections */
.settings-section {
    margin-bottom: 15px;
}

.section-heading {
    font-size: 14px;
    font-weight: 700;
    color: #0d6efd;
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid #e9ecef;
}

/* Theme mode section */
.theme-mode-section {
    margin-bottom: 10px;
}

.theme-mode-title {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 5px 0;
}

.accessibility-divider {
    height: 2px;
    background: #dee2e6;
    margin: 12px 0;
}

.accessibility-reset {
    width: 100%;
    margin-top: 12px;
    padding: 9px;
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.accessibility-reset:hover {
    background: #c82333;
}

/* Dark mode compatibility */
[data-bs-theme="dark"] .accessibility-panel {
    background: #2d3338;
    border-color: #495057;
}

[data-bs-theme="dark"] .accessibility-panel h3 {
    color: #e9ecef;
    border-color: #495057;
}

[data-bs-theme="dark"] .accessibility-option:hover {
    background: #3a4046;
}

[data-bs-theme="dark"] .accessibility-option label {
    color: #e9ecef;
}

[data-bs-theme="dark"] .section-heading {
    color: #80bdff;
    border-color: #495057;
}

[data-bs-theme="dark"] .theme-mode-title {
    color: #e9ecef;
}

[data-bs-theme="dark"] .accessibility-divider {
    background: #495057;
}

[data-bs-theme="dark"] .accessibility-button {
    background: rgba(13, 110, 253, 0.75);
    border-color: rgba(26, 29, 32, 0.8);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .accessibility-button:hover,
[data-bs-theme="dark"] .accessibility-button:focus {
    background: rgba(10, 88, 202, 0.95);
    box-shadow: 0 3px 12px rgba(255, 255, 255, 0.15);
}

/* ===== HIGH CONTRAST MODE - ACCESSIBILITY PANEL ===== */
body.high-contrast .accessibility-panel {
    background: #ffffff !important;
    border: 3px solid #000000 !important;
    color: #000000 !important;
}

body.high-contrast .accessibility-panel h3,
body.high-contrast .section-heading,
body.high-contrast .theme-mode-title,
body.high-contrast .accessibility-option label {
    color: #000000 !important;
}

body.high-contrast .section-heading {
    border-color: #000000 !important;
}

body.high-contrast .accessibility-button {
    background: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
    opacity: 1 !important;
}

body.high-contrast .accessibility-button:hover,
body.high-contrast .accessibility-button:focus {
    background: #000000 !important;
    color: #ffffff !important;
    border: 3px solid #000000 !important;
}

body.high-contrast .accessibility-divider {
    background: #000000 !important;
}

/* High contrast focus indicators - WCAG 2.4.7 */
body.high-contrast *:focus,
body.high-contrast *:focus-visible {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
}

/* High contrast reset button - must be clearly actionable */
body.high-contrast .accessibility-reset {
    background: transparent !important;
    color: #000000 !important;
    border: 3px solid #000000 !important;
    font-weight: 700 !important;
}

body.high-contrast .accessibility-reset:hover,
body.high-contrast .accessibility-reset:focus {
    background: #000000 !important;
    color: #ffffff !important;
    outline: 3px solid #FFD700 !important;
}

/* ===== CAPTCHA ACCESSIBILITY ===== */
.captcha-audio-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: #0d6efd;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.captcha-audio-btn:hover {
    background: #0b5ed7;
}

.captcha-audio-btn:focus {
    outline: 3px solid #80bdff;
    outline-offset: 2px;
}

body.high-contrast .captcha-audio-btn {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #ffffff !important;
}

body.high-contrast .captcha-audio-btn:hover {
    background: #000000 !important;
    color: #ffffff !important;
}

/* ===== SCREEN READER ONLY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ===== ARIA LIVE REGION ===== */
.aria-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ===== TARGET SIZE - WCAG 2.5.5 / 2.5.8 ===== */
/* Interactive controls must be at least 44x44 CSS px (E-09).
   Scoped to the login/auth pages via .container to avoid affecting dashboards. */
.container input.form-control,
.container select.form-control,
.container .btn,
.container button {
    min-height: 44px;
}

/* The password show/hide toggle is an icon button - give it a full tap area */
#togglePassword {
    min-width: 44px;
    min-height: 44px;
}

.captcha-audio-btn {
    min-height: 44px;
}

/* Inline text links (footer, "Change / Forgot Password", external links):
   add vertical padding so the tap target reaches ~44px without breaking layout */
.container .page-footer a,
.page-footer a,
.container nav a,
.external-link-item,
.external-links-toggle {
    display: inline-block;
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: 1.5;
}

/* ===== SKIP LINK ===== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #0d6efd;
    color: #ffffff;
    padding: 10px 20px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #80bdff;
    outline-offset: 2px;
}

/* =========================================================================
   COLOR CONTRAST FIXES  (WCAG 1.4.3 / 1.4.11 - GWC audit, 2026)
   Consolidated overrides for the color-contrast findings that had no
   inline code fix. Scoped and given dark-mode equivalents so they do not
   regress the dark theme.
   Covers: BAC-43164, BAC-49160, BAC-54613, BAC-54750, BAC-43440,
           BAC-49211, BAC-54780, BAC-43357, BAC-43116.
   ========================================================================= */

/* --- Form control & checkbox borders: #DEE2E6/#DCE0E4 gave only 1.26:1 vs
       the #FAFBFC field background. #6c757d clears the 3:1 non-text minimum.
       (BAC-49211 Ledger, BAC-54780 Portfolio) --- */
.form-control,
.form-select,
.date-input,
.form-check-input {
    border-color: #6c757d;
}
.form-check-input {
    border-width: 1px;
}
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .date-input,
[data-bs-theme="dark"] .form-check-input {
    border-color: #8a919a;
}

/* --- Focus indicator on coloured / gradient chrome: the #005FCC ring had
       only 1.31:1 on the #6C6ACE header. A white ring + dark halo stays
       visible on any background. (BAC-43357) --- */
.navbar-modern .btn:focus-visible,
.navbar-modern a:focus-visible,
.navbar-modern button:focus-visible,
.dashboard-tabs .tab-button:focus-visible,
.portfolio-tabs .tab-button:focus-visible,
.offcanvas .btn:focus-visible,
.sidebar .sidebar-link:focus-visible {
    outline: 3px solid #ffffff !important;
    outline-offset: 0 !important;
    box-shadow: 0 0 0 6px #003a75 !important;
}

/* --- "Home" breadcrumb / nav link: #667EEA gave 3.47:1 on #F8F9FA.
       (BAC-43164, BAC-49160, BAC-54613, BAC-54750, BAC-43440) --- */
.breadcrumb a,
.breadcrumb-item a {
    color: #3f4fbf !important;
}
[data-bs-theme="dark"] .breadcrumb a,
[data-bs-theme="dark"] .breadcrumb-item a {
    color: #aeb8ff !important;
}

/* --- Profit/Loss figures: green #1AB394/#28A745 (2.65-3.13:1) and
       red #ED5565 (3.45:1) on white. Darkened to >=4.5:1; the !important
       also lifts the inline-styled grid numbers (num-pos/num-neg). --- */
.text-success,
.num-pos,
.text-green {
    color: #157347 !important;
}
.text-danger,
.num-neg,
.text-red {
    color: #c62828 !important;
}
[data-bs-theme="dark"] .text-success,
[data-bs-theme="dark"] .num-pos,
[data-bs-theme="dark"] .text-green {
    color: #4ade80 !important;
}
[data-bs-theme="dark"] .text-danger,
[data-bs-theme="dark"] .num-neg,
[data-bs-theme="dark"] .text-red {
    color: #f87171 !important;
}

/* --- Gradient "Sign in" and action buttons: white text sat at 4.42-4.48:1
       on the #6B6CD1/#6C6DD2 brand gradient. Darkening the gradient endpoints
       lifts the button label past 4.5:1 while keeping the brand hue.
       (BAC-43116 Sign in; contributes to BAC-54613 / BAC-54750 View/Add) --- */
.form-signin .btn-primary,
.btn-gradient-primary {
    background: linear-gradient(135deg, #4f46b8 0%, #5f3f8f 100%) !important;
    border-color: #4f46b8 !important;
    color: #ffffff !important;
}

/* --- Company name truncated in the header / offcanvas title: allow the text
       to wrap so it is fully visible by default. (BAC-54838, BAC-52785) --- */
.navbar-modern .navbar-brand,
.offcanvas-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
}

/* --- "Share"/detail icon-link inside the purple card headers (Ledger Balance
       etc.): the default link-blue icon sat at 1.19:1 on the #667eea/#764ba2
       gradient. Inherit the header's white and drop the muted opacity so the
       icon clears the 3:1 non-text minimum. (BAC-43192) --- */
.multi-header a {
    color: #ffffff !important;
}
.multi-header a .icon-muted,
.multi-header .icon-muted {
    opacity: 1 !important;
    color: #ffffff !important;
}

/* --- Reflow at ~320px without horizontal scroll (WCAG 1.4.10).
       BAC-54727 (Bills), BAC-54832 (Dashboard). The main culprit is flex
       items whose default min-width:auto refuses to shrink below their
       content (long search placeholders), forcing 2-D scrolling. --- */
@media (max-width: 480px) {
    .container,
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
        max-width: 100%;
    }
    /* Let search inputs shrink inside their group instead of overflowing */
    .input-group { flex-wrap: nowrap; }
    .input-group > .form-control,
    .input-group > .form-select,
    .input-group > input {
        min-width: 0;
    }
    .form-control,
    .form-select,
    .date-input {
        max-width: 100%;
    }
    /* Stack multi-column filter and metric grids so nothing is clipped */
    .filter-grid { grid-template-columns: 1fr !important; }
    .metric-row,
    .metric-row.combined-row { grid-template-columns: 1fr !important; }
    /* Tab strips wrap rather than pushing the page wider than the viewport */
    .dashboard-tabs,
    .portfolio-tabs { flex-wrap: wrap; }
    img { max-width: 100%; height: auto; }
}
