/* ============================================================
       Dark Mode — layered, comfortable contrast
       bg #1c1e28 → surface #252836 → elevated #303344
       ============================================================ */
    html.theme-dark { background: #1c1e28; }
    /* --- Header --- */
    html.theme-dark .main-header .logo { background: #252836 !important; border-bottom: 1px solid #36394a; }
    html.theme-dark .main-header .navbar { background: #252836 !important; border-bottom: 1px solid #36394a; }
    html.theme-dark .main-header .navbar .nav > li > a { color: rgba(255,255,255,0.7); }
    /* --- Sidebar --- */
    html.theme-dark .main-sidebar { background: #1c1e28; border-right: 1px solid #2a2d3a; }
    html.theme-dark .sidebar-menu > li.header { color: #7e8294; background: transparent; }
    html.theme-dark .sidebar-menu > li > a { color: #b0b4c2; }
    html.theme-dark .sidebar-menu > li:hover > a { color: #e8eaf2; background: #232530; }
    html.theme-dark .sidebar-menu > li.active > a { color: #fff; background: #4f5596; border-left: 3px solid #7c84f0; }
    /* --- Content area --- */
    html.theme-dark .content-wrapper { background: #1c1e28; }
    html.theme-dark .content-header { color: #e1e4f0; }
    html.theme-dark .content-header small { color: #82889a; }
    html.theme-dark .breadcrumb { background: transparent; }
    html.theme-dark .breadcrumb > li { color: #82889a; }
    html.theme-dark .breadcrumb > .active { color: #b0b4c2; }
    html.theme-dark .breadcrumb a { color: #7c84f0; }
    /* --- Box / Card --- */
    html.theme-dark .box { background: #252836; border: 1px solid #36394a; color: #c0c4d2; border-radius: 4px; }
    html.theme-dark .box-header { color: #d8dce8; }
    html.theme-dark .box-header.with-border { border-bottom-color: #36394a; }
    html.theme-dark .box-body { background: #252836; }
    html.theme-dark .box-footer { background: #20222e; border-top-color: #36394a; }
    html.theme-dark .box.box-primary { border-top: 3px solid #7c84f0; }
    html.theme-dark .box.box-warning { border-top: 3px solid #d2991d; }
    html.theme-dark .box.box-danger  { border-top: 3px solid #e5534b; }
    html.theme-dark .box.box-success { border-top: 3px solid #3fb950; }
    html.theme-dark .box.box-info    { border-top: 3px solid #58a6ff; }
    html.theme-dark .box-tools .btn-box-tool { color: #82889a; }
    html.theme-dark .box-tools .btn-box-tool:hover { color: #d8dce8; }
    /* --- Tables --- */
    html.theme-dark .table > thead > tr > th { border-bottom: 2px solid #36394a; color: #9094a6; }
    html.theme-dark .table > tbody > tr > td { border-top: 1px solid #2a2d3a; color: #c0c4d2; }
    html.theme-dark .table-striped > tbody > tr:nth-of-type(odd) { background: #20222e; }
    html.theme-dark .table-hover > tbody > tr:hover { background: #2a2d3c; }
    /* Fix hardcoded #f9f9f9 row background in budgets */
    html.theme-dark tr[style*="background-color: #f9f9f9"],
    html.theme-dark tr[style*="background:#f9f9f9"] { background-color: #2a2d3c !important; }
    /* --- Forms --- */
    html.theme-dark .form-control { background: #171922; border-color: #36394a; color: #d8dce8; }
    html.theme-dark .form-control:focus { border-color: #7c84f0; box-shadow: 0 0 0 3px rgba(124,132,240,0.12); outline: none; }
    html.theme-dark .form-control::placeholder { color: #5e6278; }
    html.theme-dark .input-group-addon { background: #171922; border-color: #36394a; color: #9094a6; }
    html.theme-dark textarea.form-control, html.theme-dark select.form-control { background: #171922; }
    html.theme-dark select.form-control option { background: #252836; color: #d8dce8; }
    /* --- Buttons --- */
    html.theme-dark .btn-default { background: #2a2d3c; border-color: #3e4258; color: #c0c4d2; }
    html.theme-dark .btn-default:hover { background: #36394a; color: #d8dce8; border-color: #505470; }
    html.theme-dark .btn-primary { background: #4f5596; border-color: #4f5596; color: #fff; }
    html.theme-dark .btn-primary:hover { background: #5d64a8; }
    html.theme-dark .btn-warning { background: #a4750b; border-color: #a4750b; color: #fff; }
    html.theme-dark .btn-danger  { background: #c93c38; border-color: #c93c38; }
    html.theme-dark .btn-success { background: #2a8440; border-color: #2a8440; }
    html.theme-dark .btn-info    { background: #256cc4; border-color: #256cc4; }
    html.theme-dark .btn-xs { }
    /* --- Labels / Badges --- */
    html.theme-dark .badge { background: #36394a; color: #c0c4d2; }
    html.theme-dark .label-default { background: #36394a; color: #c0c4d2; }
    html.theme-dark .label-success { background: #1f3a24; color: #3fb950; }
    html.theme-dark .label-danger  { background: #3a1e20; color: #f85149; }
    html.theme-dark .label-warning { background: #3a2e10; color: #d2991d; }
    html.theme-dark .label-info    { background: #0d2d44; color: #58a6ff; }
    /* Fix AdminLTE badge background classes */
    html.theme-dark .bg-light-blue { background: #2a3a6e !important; color: #9dbbff; }
    html.theme-dark .bg-blue { background: #2a3570 !important; }
    html.theme-dark .bg-aqua { background: #1a506e !important; }
    html.theme-dark .bg-yellow { background: #5c4c10 !important; color: #f5d061; }
    html.theme-dark .bg-green { background: #1a4024 !important; }
    html.theme-dark .bg-red { background: #5c1e1e !important; }
    html.theme-dark .bg-purple { background: #3d2e6e !important; }
    /* --- Dropdowns --- */
    html.theme-dark .dropdown-menu { background: #303344; border: 1px solid #3e4258; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
    html.theme-dark .dropdown-menu > li > a { color: #c0c4d2; }
    html.theme-dark .dropdown-menu > li > a:hover, html.theme-dark .dropdown-menu > li > a:focus { background: #3a3e52; color: #e1e4f0; }
    html.theme-dark .dropdown-menu > .active > a { background: #4f5596; color: #fff; }
    html.theme-dark .dropdown-menu .divider { background-color: #3e4258; }
    @media (max-width: 767px) {
      html.theme-dark .main-header .navbar .dropdown-menu { background: #303344 !important; }
      html.theme-dark .main-header .navbar .dropdown-menu li a { color: #c0c4d2 !important; }
      html.theme-dark .main-header .navbar .dropdown-menu li a:hover { background: #3a3e52; color: #e1e4f0 !important; }
      html.theme-dark .main-header .navbar .dropdown-menu .active > a { background: #4f5596; color: #fff !important; }
      html.theme-dark .main-header .navbar .dropdown-menu .divider { background-color: #3e4258; }
    }
    html.theme-dark .dropdown-header { color: #82889a; }
    html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-header { background: #303344; }
    html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-header p { color: #c0c4d2; }
    html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-footer { background: #252836; }
    html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn-default { background: #2a2d3c; border-color: #3e4258; color: #c0c4d2; }
    /* --- Nav Tabs --- */
    html.theme-dark .nav > li > a:hover, html.theme-dark .nav > li > a:focus { background: #2a2d3c; }
    html.theme-dark .nav-tabs { border-bottom-color: #36394a; }
    html.theme-dark .nav-tabs > li > a { background: transparent; color: #9094a6; }
    html.theme-dark .nav-tabs > li > a:hover { color: #d8dce8; background: #252836; border-color: #36394a; }
    html.theme-dark .nav-tabs > li.active > a, html.theme-dark .nav-tabs > li.active > a:hover { background: #252836; border-color: #36394a #36394a transparent; color: #e1e4f0; }
    html.theme-dark .nav-tabs-custom { background: #252836; }
    html.theme-dark .nav-tabs-custom > .nav-tabs { border-bottom-color: #36394a; }
    /* --- Pagination --- */
    html.theme-dark .pagination > li > a, html.theme-dark .pagination > li > span { background: #252836; border-color: #36394a; color: #c0c4d2; }
    html.theme-dark .pagination > li > a:hover { background: #303344; color: #e1e4f0; border-color: #505470; }
    html.theme-dark .pagination > .active > a, html.theme-dark .pagination > .active > span { background: #4f5596; border-color: #4f5596; color: #fff; }
    html.theme-dark .pagination > .disabled > span, html.theme-dark .pagination > .disabled > a { background: #1c1e28; border-color: #2a2d3a; color: #5e6278; }
    /* --- Callouts --- */
    html.theme-dark .callout { background: #252836; border-left: 4px solid #36394a; color: #c0c4d2; }
    html.theme-dark .callout-warning { background: #2a2412; border-left-color: #d2991d; }
    html.theme-dark .callout-danger  { background: #2a1e1e; border-left-color: #e5534b; }
    html.theme-dark .callout-info    { background: #162230; border-left-color: #58a6ff; }
    html.theme-dark .callout-success { background: #16281c; border-left-color: #3fb950; }
    /* --- Info boxes --- */
    html.theme-dark .info-box { background: #252836; border: 1px solid #36394a; color: #c0c4d2; }
    html.theme-dark .info-box-content .info-box-text { color: #82889a; }
    html.theme-dark .info-box-content .info-box-number { color: #e1e4f0; }
    html.theme-dark .info-box-icon { opacity: 0.9; }
    /* --- Small box --- */
    html.theme-dark .small-box { border-radius: 4px; }
    html.theme-dark .small-box .icon { opacity: 0.15; }
    html.theme-dark .small-box .inner h3 { color: #fff; }
    html.theme-dark .small-box .inner p { color: rgba(255,255,255,0.75); }
    /* --- Footer --- */
    html.theme-dark .main-footer { background: #1c1e28; border-top-color: #2a2d3a; color: #6e7282; }
    html.theme-dark .main-footer a { color: #82889a; }
    html.theme-dark .main-footer a:hover { color: #b0b4c2; }
    /* --- Select2 --- */
    html.theme-dark .select2-container--default .select2-selection--single { background: #171922; border-color: #36394a; color: #d8dce8; }
    html.theme-dark .select2-container--default .select2-selection--single .select2-selection__rendered { color: #d8dce8; }
    html.theme-dark .select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: #9094a6; }
    html.theme-dark .select2-dropdown { background: #303344; border-color: #3e4258; }
    html.theme-dark .select2-container--default .select2-results__option { color: #c0c4d2; }
    html.theme-dark .select2-container--default .select2-results__option--highlighted { background: #4f5596; color: #fff; }
    html.theme-dark .select2-container--default .select2-search--dropdown .select2-search__field { background: #171922; border-color: #36394a; color: #d8dce8; }
    html.theme-dark .select2-container--default .select2-results__option[aria-selected=true] { background: #252836; }
    /* --- Datepicker --- */
    html.theme-dark .datepicker { background: #303344; border: 1px solid #3e4258; color: #c0c4d2; padding: 8px; }
    html.theme-dark .datepicker table tr td span { color: #c0c4d2; }
    html.theme-dark .datepicker table tr td.day { color: #c0c4d2; border-radius: 4px; }
    html.theme-dark .datepicker table tr td.day:hover, html.theme-dark .datepicker table tr td span:hover { background: #3a3e52; }
    html.theme-dark .datepicker table tr td.old, html.theme-dark .datepicker table tr td.new { color: #5e6278; }
    html.theme-dark .datepicker table tr td.active, html.theme-dark .datepicker table tr td span.active { background: #4f5596 !important; color: #fff; }
    html.theme-dark .datepicker .datepicker-switch, html.theme-dark .datepicker .prev, html.theme-dark .datepicker .next { color: #c0c4d2; }
    html.theme-dark .datepicker .datepicker-switch:hover, html.theme-dark .datepicker .prev:hover, html.theme-dark .datepicker .next:hover { background: #3a3e52; }
    html.theme-dark .datepicker table tr td.today { background: rgba(124,132,240,0.15); color: #e1e4f0; }
    /* --- Modal --- */
    html.theme-dark .modal-content { background: #303344; border: 1px solid #3e4258; box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
    html.theme-dark .modal-header { border-bottom-color: #36394a; }
    html.theme-dark .modal-footer { border-top-color: #36394a; background: #252836; }
    html.theme-dark .modal-title { color: #e1e4f0; }
    html.theme-dark .close { color: #82889a; text-shadow: none; opacity: 0.7; }
    html.theme-dark .close:hover { color: #e1e4f0; opacity: 1; }
    /* --- DataTables --- */
    html.theme-dark .dataTables_wrapper .dataTables_length, html.theme-dark .dataTables_wrapper .dataTables_filter,
    html.theme-dark .dataTables_wrapper .dataTables_info, html.theme-dark .dataTables_wrapper .dataTables_paginate { color: #82889a; }
    html.theme-dark table.dataTable thead th, html.theme-dark table.dataTable thead td { border-bottom-color: #36394a; }
    html.theme-dark table.dataTable tbody td { border-top-color: #2a2d3a; }
    /* --- Ticket detail messages --- */
    html.theme-dark .message-body { background: #252836 !important; color: #c0c4d2; }
    html.theme-dark .message-body.admin-msg { background: #2a2816 !important; }
    html.theme-dark .reply-box { background: #252836 !important; }
    html.theme-dark .message-avatar { opacity: 0.9; }
    /* --- Category icon picker --- */
    html.theme-dark .icon-option { background: #2a2d3c !important; color: #9094a6 !important; }
    html.theme-dark .icon-option:hover { background: #36394a !important; color: #e1e4f0 !important; }
    /* --- Ledger items --- */
    html.theme-dark .ledger-item:hover { background-color: #2a2d3c !important; }
    html.theme-dark .ledger-item.active { border-left: 3px solid #7c84f0 !important; }
    [dir="rtl"] html.theme-dark .ledger-item.active { border-right: 3px solid #7c84f0 !important; border-left: none !important; }
    /* --- Misc --- */
    html.theme-dark .text-muted { color: #82889a !important; }
    html.theme-dark hr { border-top-color: #36394a; }
    html.theme-dark code, html.theme-dark pre { background: #171922; color: #d8dce8; border: 1px solid #2a2d3a; }
    html.theme-dark .well { background: #252836; border-color: #36394a; }
    html.theme-dark .panel { background: #252836; border-color: #36394a; }
    html.theme-dark .panel-default > .panel-heading { background: #20222e; border-bottom-color: #36394a; color: #b0b4c2; }
    /* --- Alerts --- */
    html.theme-dark .alert { color: #c0c4d2; }
    html.theme-dark .alert-success { background: #16281c; border-color: #2a4a32; color: #8ecf9a; }
    html.theme-dark .alert-danger  { background: #2a1e1e; border-color: #4a2a2a; color: #f5a8a6; }
    html.theme-dark .alert-warning { background: #2a2412; border-color: #4a3e1a; color: #f5d88a; }
    html.theme-dark .alert-info    { background: #162230; border-color: #2a3a4a; color: #9dc8f5; }
    /* --- Chart.js fix --- */
    html.theme-dark canvas { background: transparent; }
    /* --- FullCalendar --- */
    html.theme-dark .fc-toolbar h2 { color: #d8dce8; }
    html.theme-dark .fc-button { background: #2a2d3c; border-color: #3e4258; color: #c0c4d2; text-shadow: none; box-shadow: none; }
    html.theme-dark .fc-button:hover { background: #36394a; color: #e1e4f0; }
    html.theme-dark .fc-button.fc-state-active { background: #4f5596; border-color: #4f5596; color: #fff; }
    html.theme-dark .fc-head-container, html.theme-dark .fc-head { background: #252836; border-color: #36394a !important; }
    html.theme-dark .fc-widget-header { background: #252836; border-color: #36394a; }
    html.theme-dark .fc-widget-header span, html.theme-dark .fc-day-header span,
    html.theme-dark .fc-widget-header a, html.theme-dark .fc-day-header a { color: #9094a6 !important; }
    html.theme-dark .fc-body { background: #1c1e28; }
    html.theme-dark .fc-widget-content { border-color: #2a2d3a !important; }
    html.theme-dark .fc-day { background: #1c1e28; border-color: #2a2d3a !important; }
    html.theme-dark .fc-day:hover { background: #252836; }
    html.theme-dark .fc-day-number { color: #c0c4d2; }
    html.theme-dark .fc-other-month .fc-day-number { color: #5e6278; opacity: 0.6; }
    html.theme-dark .fc-today { background: #1e2840 !important; }
    html.theme-dark .fc-today .fc-day-number { color: #fff; font-weight: bold; }
    html.theme-dark .fc-popover { background: #303344; border-color: #3e4258; }
    html.theme-dark .fc-popover .fc-header { background: #252836; }
    html.theme-dark .fc-more { color: #7c84f0; }
    html.theme-dark .fc-event { border: none; }
    html.theme-dark .fc-divider { border-color: #36394a; }
    html.theme-dark .fc-unthemed .fc-today { background: #1e2840 !important; }
    /* --- Cookie banner --- */
    html.theme-dark #cookie-banner { background: #252836; color: #c0c4d2; border-top: 1px solid #36394a; box-shadow: 0 -4px 24px rgba(0,0,0,0.5); }
    html.theme-dark #cookie-banner p { color: #82889a !important; }
    html.theme-dark #cookie-banner a { color: #7c84f0; }
    html.theme-dark #cookie-banner button[style*="background:#f0f0f0"] { background: #2a2d3c !important; color: #c0c4d2 !important; border-color: #3e4258 !important; }
    /* --- Theme toggle --- */
    .theme-toggle-btn { background: transparent; border: none; color: rgba(255,255,255,0.7); padding: 10px 12px; cursor: pointer; font-size: 15px; line-height: 1; outline: none; }
    .theme-toggle-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
    html.theme-dark .theme-toggle-btn { color: #82889a; }
    html.theme-dark .theme-toggle-btn:hover { color: #d8dce8; background: #2a2d3c; }
  
    /* === Force ledger active row dark background (max priority) === */
    html.theme-dark .ledger-item.active,
    html.theme-dark tr.ledger-item.active,
    html.theme-dark .table tr.ledger-item.active,
    html.theme-dark .table-striped tr.ledger-item.active,
    html.theme-dark .table-striped>tbody>tr.ledger-item.active,
    html.theme-dark .table-striped>tbody>tr:nth-of-type(odd).ledger-item.active,
    html.theme-dark .table-striped>tbody>tr:nth-of-type(even).ledger-item.active { background: #2a3050 !important; }
    /* Keep td transparent so buttons show their own colors */
    html.theme-dark .ledger-item.active td,
    html.theme-dark tr.ledger-item.active td { background: transparent !important; }
    /* --- Mobile touch optimizations --- */
    html.theme-dark { -webkit-tap-highlight-color: transparent; }
    html.theme-dark .content-wrapper { -webkit-overflow-scrolling: touch; }
    html.theme-dark .sidebar-menu > li > a,
    html.theme-dark .dropdown-menu > li > a { touch-action: manipulation; }
    @media (max-width: 767px) {
      html.theme-dark .main-header .navbar { background: #252836 !important; }
      html.theme-dark .main-header .logo { background: #1c1e28 !important; }
      html.theme-dark .navbar-nav > .user-menu > .dropdown-menu { background: #303344; border-color: #3e4258; }
      html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-header { background: #252836; }
      html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-footer { background: #1c1e28; border-top-color: #36394a; }
      html.theme-dark .navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn-default { background: #2a2d3c; color: #c0c4d2; border-color: #3e4258; }
      html.theme-dark .navbar-nav .open .dropdown-menu { background: #303344; border: 1px solid #3e4258; }
      html.theme-dark .navbar-nav .open .dropdown-menu > li > a { color: #c0c4d2; }
      html.theme-dark .navbar-nav .open .dropdown-menu > li > a:hover { background: #252836; color: #fff; }
      html.theme-dark .navbar-nav .open .dropdown-menu > .active > a { background: #4f5596; color: #fff; }
      html.theme-dark .navbar-nav .open .dropdown-menu .divider { background-color: #36394a; }
      html.theme-dark .sidebar { -webkit-overflow-scrolling: touch; }
      html.theme-dark .icon-picker { background: #1c1e28; border-color: #3e4258; }
      html.theme-dark .icon-option { background: #2a2d3c !important; color: #b0b4c2 !important; }
    }
    @media (hover: none) {
      html.theme-dark .btn:hover { opacity: 0.85; }
      html.theme-dark .sidebar-menu > li > a:active { background: #303344; }
    }