/**
 * Admin layout custom fixes - LTR/RTL margin, padding, icons
 * Matches Ubold 7 structure
 */

/* --------------------------------------------------------------------------
 * Corplift brand palette (https://corplift.sa)
 * Trust blue #1B365D = primary | Luxury gold #D4AF37 = accent | Deep frame #0F1419
 * -------------------------------------------------------------------------- */
:root,
[data-bs-theme="light"] {
  --corplift-blue: #1b365d;
  --corplift-blue-hover: #152a47;
  --corplift-gold: #d4af37;
  --corplift-gold-light: #f4e185;
  --corplift-black: #0f1419;
  --ins-primary: #1b365d;
  --ins-primary-rgb: 27, 54, 93;
  --ins-blue: #1b365d;
  --ins-link-color: #1b365d;
  --ins-link-hover-color: #152a47;
  --bs-primary: #1b365d;
  --bs-primary-rgb: 27, 54, 93;
  --bs-link-color: #1b365d;
  --bs-link-hover-color: #152a47;
}

[data-bs-theme="dark"] {
  --corplift-blue: #2a4d7c;
  --corplift-blue-hover: #3a62a0;
  --corplift-gold: #d4af37;
  --corplift-gold-light: #f4e185;
  --corplift-black: #0f1419;
  --ins-primary: #3d6fb8;
  --ins-primary-rgb: 61, 111, 184;
  --ins-blue: #3d6fb8;
  --ins-link-color: #7eb3ff;
  --ins-link-hover-color: #a8ccff;
  --bs-primary: #3d6fb8;
  --bs-primary-rgb: 61, 111, 184;
  --bs-link-color: #8ebfff;
  --bs-link-hover-color: #b8d6ff;
  --ins-body-bg: #0f1419;
  --ins-secondary-bg: #151c24;
  --ins-tertiary-bg: #1a232e;
}

/* Sidebar: transparent; topbar shell stays clear but menu bar gets solid backdrop */
.sidenav-menu {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-inline-end: 1px solid var(--ins-border-color);
}
header.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  isolation: isolate;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-bottom: none !important;
}
header.app-topbar .container-fluid.topbar-menu,
header.app-topbar .topbar-menu.container-fluid {
  position: relative;
  z-index: 1;
  background-color: var(--ins-body-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ins-border-color) !important;
  min-height: var(--ins-topbar-height, 70px);
}
/* Do not set z-index on .content-page — it creates a stacking context that
   traps Bootstrap .modal under body-level .modal-backdrop (blurred overlay). */
.content-page {
  position: relative;
}
.content-page > .content > .container-fluid {
  position: relative;
}

/* Ensure dialogs always sit above the backdrop across the admin panel */
.modal {
  z-index: 1055;
}
.modal-backdrop {
  z-index: 1050;
}
[data-bs-theme="dark"] .sidenav-menu {
  border-inline-end-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme="dark"] header.app-topbar .container-fluid.topbar-menu,
[data-bs-theme="dark"] header.app-topbar .topbar-menu.container-fluid {
  background-color: rgba(15, 20, 25, 0.94);
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* Gold accent: outline buttons / subtle highlights (optional use in UI) */
.btn-corplift-gold {
  --ins-btn-color: var(--corplift-black);
  --ins-btn-bg: var(--corplift-gold);
  --ins-btn-border-color: var(--corplift-gold);
  --ins-btn-hover-bg: #c19d2e;
  --ins-btn-hover-border-color: #c19d2e;
}

/* Arabic: Cairo font - override Ubold font variables so all text uses Cairo */
html[lang="ar"],
html[dir="rtl"] {
  --ins-font-sans-serif: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  --ins-font-family-secondary: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  --ins-body-font-family: "Cairo", sans-serif !important;
}
html[lang="ar"] body,
html[dir="rtl"] body {
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}
html[lang="ar"] body *, 
html[dir="rtl"] body * {
  font-family: inherit !important;
}
/* Icons must keep their icon fonts (Cairo would break them) */
html[lang="ar"] .ti, html[lang="ar"] .ti:before, html[lang="ar"] [class^="ti-"], html[lang="ar"] [class*=" ti-"],
html[dir="rtl"] .ti, html[dir="rtl"] .ti:before, html[dir="rtl"] [class^="ti-"], html[dir="rtl"] [class*=" ti-"] {
  font-family: "tabler-icons" !important;
}
html[lang="ar"] [class^="ri-"], html[lang="ar"] [class*=" ri-"],
html[dir="rtl"] [class^="ri-"], html[dir="rtl"] [class*=" ri-"] {
  font-family: "remixicon" !important;
}

/* Ensure Tabler icons display and align correctly */
.ti, .ti:before, [class^="ti-"], [class*=" ti-"] {
  font-family: "tabler-icons" !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: inline-block;
  vertical-align: middle;
}

/* Topbar: fix icon alignment in buttons */
.app-topbar .sidenav-toggle-button .ti,
.app-topbar .topnav-toggle-button .ti,
.app-topbar .topbar-link .ti {
  vertical-align: middle;
  line-height: 1;
}

/* Topbar buttons: match Ubold 7 - no extra padding/border on icon-only topbar-link */
.app-topbar .topbar-item .topbar-link:not(.dropdown-toggle) {
  padding: 0 0.5rem;
  min-width: 2.25rem;
}

/* RTL: zero margin-left (app.css sets it; app-rtl uses margin-right instead) */
[dir="rtl"] .app-topbar,
[dir="rtl"] .content-page {
  margin-left: 0;
}

/* Page title row (legacy page-title-box markup used in admin layout) */
.page-title-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 1.25rem 0 1rem;
  min-height: 0;
}
.page-title-box .page-title {
  order: 1;
  margin: 0;
  flex: 0 1 auto;
}
.page-title-box .page-title-right {
  order: 2;
  margin-inline-start: auto;
  flex: 0 1 auto;
}
.page-title-box .breadcrumb {
  padding: 0;
  margin: 0;
  justify-content: flex-end;
}

/* Card header: Ubold sets flex row — stack title row + filter row vertically */
.card-header.card-header-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem !important;
}
.card-header.card-header-stacked > * {
  width: 100%;
  max-width: 100%;
}
.card-header-stacked .card-header-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
}
.card-header-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.card-header-title-group .header-title {
  margin-inline-end: 0 !important;
}

/* Filter toolbar: labels, selects, and buttons on one baseline */
.card-filter-toolbar {
  --toolbar-control-height: calc(0.775rem * 1.5 + 0.625rem + 2px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.card-filter-toolbar .form-label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
  line-height: 1.5;
  min-height: var(--toolbar-control-height);
}
.card-filter-toolbar .form-select-sm {
  line-height: 1.5;
  min-height: var(--toolbar-control-height);
}
.card-filter-toolbar .form-control-sm {
  line-height: 1.5;
  min-height: var(--toolbar-control-height);
}
.card-filter-toolbar .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.5;
  min-height: var(--toolbar-control-height);
  box-shadow: none !important;
  --ins-btn-box-shadow: none;
}
.card-filter-toolbar .form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0;
  min-height: var(--toolbar-control-height);
}
.card-filter-toolbar .form-check-label {
  margin-bottom: 0;
  line-height: 1.5;
}

/* DataTables v1.x: length + search toolbar */
.card-body div.dataTables_wrapper > .row:first-child {
  margin-bottom: 0.75rem;
  align-items: center;
  --bs-gutter-y: 0.75rem;
}
.card-body div.dataTables_wrapper > .row:first-child > [class*="col-"] {
  display: flex;
  align-items: center;
}
.card-body div.dataTables_wrapper div.dataTables_length {
  text-align: start;
  width: 100%;
}
.card-body div.dataTables_wrapper div.dataTables_filter {
  text-align: end;
  width: 100%;
}
.card-body div.dataTables_wrapper div.dataTables_length label,
.card-body div.dataTables_wrapper div.dataTables_filter label {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
}
.card-body div.dataTables_wrapper div.dataTables_length label {
  justify-content: flex-start;
}
.card-body div.dataTables_wrapper div.dataTables_filter label {
  justify-content: flex-end;
}
.card-body div.dataTables_wrapper div.dataTables_length select.form-select,
.card-body div.dataTables_wrapper div.dataTables_length select {
  width: auto;
  min-width: 5rem;
  flex: 0 0 auto;
  margin: 0 !important;
}
.card-body div.dataTables_wrapper div.dataTables_filter input.form-control,
.card-body div.dataTables_wrapper div.dataTables_filter input {
  width: auto;
  min-width: 12rem;
  max-width: 22rem;
  flex: 1 1 12rem;
  margin: 0 !important;
}
.card-body div.dataTables_wrapper > .row.dt-row {
  margin-top: 0;
  margin-bottom: 0;
}

/* Restore column padding stripped by DataTables inside table-responsive */
.card-body .table-responsive > div.dataTables_wrapper > div.row > [class*="col-"] {
  padding-inline: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

@media (max-width: 767.98px) {
  .card-body div.dataTables_wrapper div.dataTables_length,
  .card-body div.dataTables_wrapper div.dataTables_filter {
    text-align: center;
  }
  .card-body div.dataTables_wrapper div.dataTables_length label,
  .card-body div.dataTables_wrapper div.dataTables_filter label {
    justify-content: center;
  }
  .card-body div.dataTables_wrapper div.dataTables_filter input.form-control,
  .card-body div.dataTables_wrapper div.dataTables_filter input {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }
}

/* -------------------------------------------------------------------------- */
/* CRM tables — mobile: scroll the table only, keep filters usable            */
/* -------------------------------------------------------------------------- */
.admin-dt-outer.table-responsive {
  overflow: visible;
}

.admin-dt-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
}

.admin-dt-scroll > [class*="col-"] {
  min-width: 0;
}

.admin-dt-scroll table.dataTable,
.card-body .table-responsive > table,
.card-body .table-responsive table.dataTable {
  width: max-content !important;
  min-width: 100%;
  margin-bottom: 0 !important;
}

.admin-dt-scroll table.dataTable th,
.admin-dt-scroll table.dataTable td,
.card-body .table-responsive table th,
.card-body .table-responsive table td {
  white-space: nowrap;
  vertical-align: middle;
}

.admin-dt-scroll table.dataTable td .btn,
.card-body .table-responsive table td .btn {
  white-space: nowrap;
}

@media (max-width: 767.98px) {
  .content-page,
  .content-page .content,
  .content-page .container-fluid {
    max-width: 100%;
    overflow-x: clip;
  }

  .page-title-box {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .page-title-box .page-title-right {
    margin-inline-start: 0;
    width: 100%;
  }

  .page-title-box .breadcrumb {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .card-header-stacked .card-header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .card-header-stacked .card-header-top > .d-flex {
    flex-wrap: wrap;
    width: 100%;
  }

  .card-header-stacked .card-header-top .btn {
    flex: 1 1 auto;
  }

  .card-filter-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .card-filter-toolbar .form-label {
    min-height: 0;
    margin-bottom: 0.15rem;
  }

  .card-filter-toolbar .form-select-sm,
  .card-filter-toolbar .form-control-sm,
  .card-filter-toolbar select,
  .card-filter-toolbar input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .card-filter-toolbar .btn {
    width: 100%;
  }

  .card-filter-toolbar .form-check {
    width: 100%;
  }

  .card-body:has(.admin-dt-ready),
  .card-body:has(> .table-responsive) {
    padding-inline: 0.75rem;
  }

  .admin-dt-scroll {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
  }

  /* Keep the last column (usually Actions) visible while scrolling */
  .admin-dt-scroll table.dataTable thead th:last-child,
  .admin-dt-scroll table.dataTable tbody td:last-child {
    position: sticky;
    inset-inline-end: 0;
    z-index: 3;
    background-color: var(--ins-secondary-bg, var(--bs-body-bg, #fff)) !important;
    box-shadow: -8px 0 12px -8px rgba(15, 23, 42, 0.22);
  }

  html[dir="rtl"] .admin-dt-scroll table.dataTable thead th:last-child,
  html[dir="rtl"] .admin-dt-scroll table.dataTable tbody td:last-child {
    box-shadow: 8px 0 12px -8px rgba(15, 23, 42, 0.22);
  }

  .admin-dt-scroll table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > td:last-child {
    background-color: var(--ins-tertiary-bg, #f8fafc) !important;
  }

  .admin-dt-scroll table.dataTable.table-hover > tbody > tr:hover > td:last-child {
    background-color: var(--ins-tertiary-bg, #f1f5f9) !important;
  }

  .card-body div.dataTables_wrapper > .row:last-child {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .card-body div.dataTables_wrapper .dataTables_paginate .pagination {
    flex-wrap: wrap;
    justify-content: center !important;
  }

  .card-body div.dataTables_wrapper .page-item .page-link {
    min-width: 2.25rem;
    padding: 0.35rem 0.55rem;
  }
}

[data-bs-theme="dark"] .admin-dt-scroll table.dataTable thead th:last-child,
[data-bs-theme="dark"] .admin-dt-scroll table.dataTable tbody td:last-child {
  background-color: var(--ins-secondary-bg) !important;
}

[data-bs-theme="dark"] .admin-dt-scroll table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > td:last-child,
[data-bs-theme="dark"] .admin-dt-scroll table.dataTable.table-hover > tbody > tr:hover > td:last-child {
  background-color: var(--ins-tertiary-bg) !important;
}

/* DataTables v1.x footer: separate pagination from last table row */
.card-body div.dataTables_wrapper table.dataTable {
  margin-bottom: 0 !important;
  margin-top: 0 !important;
}
.card-body div.dataTables_wrapper > .row:last-child {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ins-border-color);
  align-items: center;
}
.card-body div.dataTables_wrapper div.dataTables_info,
.card-body div.dataTables_wrapper div.dataTables_paginate {
  padding-top: 0;
  margin-top: 0;
}
.card-body div.dataTables_wrapper .dataTables_paginate .pagination {
  margin-bottom: 0;
  gap: 0.25rem;
}
.card-body div.dataTables_wrapper .page-item .page-link {
  line-height: 1.5;
}
@media (max-width: 767.98px) {
  .card-body div.dataTables_wrapper div.dataTables_info,
  .card-body div.dataTables_wrapper div.dataTables_paginate {
    text-align: center;
  }
  .card-body div.dataTables_wrapper .dataTables_paginate .pagination {
    justify-content: center !important;
  }
}

/* Card titles beside action buttons */
.card-header:not(.card-header-stacked) .header-title,
.card-header:not(.card-header-stacked) .card-title,
.card-header:not(.card-header-stacked) > h4,
.card-header:not(.card-header-stacked) > h5 {
  margin-inline-end: 0.75rem;
}
.header-title,
.card-title {
  margin-inline-end: 0.75rem;
}

/* Permission Matrix & cards: dark mode coloring (Ubold 7) */
[data-bs-theme=dark] .table thead.table-light th,
[data-bs-theme=dark] .table thead.table-light td {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-body-color);
  border-color: rgba(131, 145, 162, 0.4) !important;
}
[data-bs-theme=dark] tr.table-secondary td {
  background-color: var(--ins-secondary-bg);
  color: var(--ins-body-color);
  border-color: rgba(131, 145, 162, 0.4) !important;
}
[data-bs-theme=dark] .card .card-header.bg-light,
[data-bs-theme=dark] .card .card-footer.bg-light {
  background-color: var(--ins-secondary-bg) !important;
  border-color: var(--ins-border-color);
  color: var(--ins-body-color);
}
[data-bs-theme=dark] .list-group-item {
  background-color: var(--ins-secondary-bg);
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}
[data-bs-theme=dark] .table.table-bordered {
  --ins-table-bg: var(--ins-secondary-bg);
  --ins-table-color: var(--ins-body-color);
  --ins-table-border-color: rgba(131, 145, 162, 0.4);
}
[data-bs-theme=dark] .table.table-bordered,
[data-bs-theme=dark] .table.table-bordered th,
[data-bs-theme=dark] .table.table-bordered td {
  border-color: rgba(131, 145, 162, 0.4) !important;
  background-color: var(--ins-secondary-bg);
  color: var(--ins-body-color);
}
[data-bs-theme=dark] .table.table-bordered thead th {
  background-color: var(--ins-tertiary-bg) !important;
  border-color: rgba(131, 145, 162, 0.4) !important;
}
[data-bs-theme=dark] .table.table-bordered tbody tr td {
  border-color: rgba(131, 145, 162, 0.4) !important;
}
[data-bs-theme=dark] .table.table-bordered tbody tr {
  --ins-table-bg: var(--ins-secondary-bg);
}
[data-bs-theme=dark] .table-responsive {
  border-color: rgba(131, 145, 162, 0.2);
}

/* Permissions page: matrix table style (close to Ubold 7 in light/dark) */
.permission-matrix-table-wrap {
  border: 1px solid var(--ins-border-color);
  border-radius: 0.5rem;
}
.permission-matrix-table {
  --ins-table-bg: transparent;
}
.permission-matrix-table thead.permission-matrix-head th {
  background-color: var(--ins-light);
  color: var(--ins-emphasis-color);
  font-weight: 600;
  white-space: nowrap;
}
.permission-matrix-table .permission-matrix-group-row td {
  background-color: var(--ins-light-bg-subtle);
  color: var(--ins-emphasis-color);
  font-weight: 600;
}
.permission-matrix-table td,
.permission-matrix-table th {
  vertical-align: middle;
}

[data-bs-theme=dark] .permission-matrix-table-wrap {
  border-color: rgba(131, 145, 162, 0.35);
}
[data-bs-theme=dark] .permission-matrix-table.table-bordered,
[data-bs-theme=dark] .permission-matrix-table.table-bordered th,
[data-bs-theme=dark] .permission-matrix-table.table-bordered td {
  border-color: rgba(131, 145, 162, 0.35) !important;
}
[data-bs-theme=dark] .permission-matrix-table tbody tr td {
  background-color: var(--ins-secondary-bg);
  color: var(--ins-body-color);
}
[data-bs-theme=dark] .permission-matrix-table thead.permission-matrix-head th {
  background-color: var(--ins-tertiary-bg) !important;
  color: var(--ins-emphasis-color);
}
[data-bs-theme=dark] .permission-matrix-table .permission-matrix-group-row td {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-emphasis-color);
}

/* Dashboard stat cards (widget-flat): dark mode fixes */
[data-bs-theme=dark] .card.widget-flat.text-bg-primary,
[data-bs-theme=dark] .card.widget-flat.text-bg-success,
[data-bs-theme=dark] .card.widget-flat.text-bg-info,
[data-bs-theme=dark] .card.widget-flat.text-bg-warning {
  border-color: rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
[data-bs-theme=dark] .card.widget-flat .card-body,
[data-bs-theme=dark] .card.widget-flat .card-body h6,
[data-bs-theme=dark] .card.widget-flat .card-body h2,
[data-bs-theme=dark] .card.widget-flat .card-body p,
[data-bs-theme=dark] .card.widget-flat .card-body span,
[data-bs-theme=dark] .card.widget-flat .card-body .widget-icon,
[data-bs-theme=dark] .card.widget-flat .card-body i {
  color: #fff !important;
}
[data-bs-theme=dark] .card.widget-flat .badge.bg-white.bg-opacity-10 {
  background-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
}

/* Dashboard page: dark mode */
[data-bs-theme="dark"] .dashboard-page .card {
  background-color: var(--ins-secondary-bg);
  border-color: var(--ins-border-color);
}
[data-bs-theme="dark"] .dashboard-page .card-header {
  background-color: var(--ins-tertiary-bg);
  border-color: var(--ins-border-color);
  color: var(--ins-body-color);
}
[data-bs-theme="dark"] .dashboard-page .card-body {
  color: var(--ins-body-color);
}
[data-bs-theme="dark"] .dashboard-page h3,
[data-bs-theme="dark"] .dashboard-page h4,
[data-bs-theme="dark"] .dashboard-page h5,
[data-bs-theme="dark"] .dashboard-page .header-title {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .dashboard-page .table thead.table-light th {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}
[data-bs-theme="dark"] .dashboard-page .table tbody td,
[data-bs-theme="dark"] .dashboard-page .table tbody th {
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}
[data-bs-theme="dark"] .dashboard-page .table-hover tbody tr:hover > * {
  --ins-table-bg-state: var(--ins-tertiary-bg);
  color: var(--ins-body-color);
}
[data-bs-theme="dark"] .dashboard-page .table a.fw-medium {
  color: var(--ins-link-color);
}
[data-bs-theme="dark"] .dashboard-page .text-success {
  color: #4ade80 !important;
}
[data-bs-theme="dark"] .dashboard-page .text-danger {
  color: #f87171 !important;
}
[data-bs-theme="dark"] .dashboard-page .text-warning {
  color: #fbbf24 !important;
}

/* Invoice amount summary (top of invoice show) */
.invoice-amount-summary-box {
  background: var(--ins-secondary-bg, #fff);
  border-color: rgba(15, 20, 25, 0.14) !important;
}

.invoice-amount-summary-box strong {
  color: var(--ins-emphasis-color);
}

[data-bs-theme="dark"] .invoice-amount-summary-box {
  background: var(--ins-tertiary-bg);
  border-color: rgba(255, 255, 255, 0.15) !important;
}

[data-bs-theme="dark"] .invoice-amount-summary .text-success {
  color: #4ade80 !important;
}

[data-bs-theme="dark"] .invoice-amount-summary .text-warning {
  color: #fbbf24 !important;
}

.invoice-collected-breakdown {
  background: var(--ins-secondary-bg, #f8f9fa);
  border-color: rgba(15, 20, 25, 0.12) !important;
}

.invoice-collected-breakdown-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
}

.invoice-collected-breakdown-item {
  white-space: nowrap;
}

[data-bs-theme="dark"] .invoice-collected-breakdown {
  background: var(--ins-tertiary-bg);
  border-color: rgba(255, 255, 255, 0.12) !important;
}

[data-bs-theme="dark"] .invoice-collected-breakdown a.text-primary {
  color: #93c5fd !important;
}

/* Invoice items & totals (show / edit / supplement) */
.invoice-display-section {
  margin-bottom: 1.5rem;
}

.invoice-display-panel {
  border: 1.5px solid rgba(15, 20, 25, 0.24);
  border-radius: 0.5rem;
  background: var(--ins-body-bg, #fff);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 20, 25, 0.04);
}

.invoice-display-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(15, 20, 25, 0.12);
  background: var(--ins-light, #f8f9fa);
}

.invoice-display-panel-header h5 {
  color: var(--ins-emphasis-color);
}

.invoice-display-panel-body .table-responsive {
  border-bottom: 1px solid rgba(15, 20, 25, 0.08);
}

.invoice-display-panel .invoice-items-table {
  margin-bottom: 0;
  border: 0;
}

.invoice-display-panel .invoice-items-table > :not(caption) > * > * {
  border-color: rgba(15, 20, 25, 0.1);
}

.invoice-totals-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1rem 1rem;
  margin-top: 0;
}

.invoice-totals-card {
  width: min(100%, 22rem);
  padding: 0;
  background: transparent;
}

.invoice-totals-table td {
  padding: 0.45rem 0.85rem;
  border: none;
  vertical-align: middle;
}

.invoice-totals-label {
  color: var(--ins-secondary-color);
  font-weight: 500;
  white-space: nowrap;
}

.invoice-totals-value {
  font-weight: 600;
  text-align: end;
  width: 8.5rem;
  color: var(--ins-body-color);
}

.invoice-totals-table tr.invoice-totals-grand .invoice-totals-label,
.invoice-totals-table tr.invoice-totals-grand .invoice-totals-value {
  font-weight: 700;
  font-size: 1.02rem;
}

.invoice-totals-table tr.invoice-totals-grand .invoice-totals-value {
  border-top: 1px solid var(--ins-border-color);
  padding-top: 0.65rem;
}

.invoice-totals-table tr.invoice-totals-grand .invoice-totals-label {
  padding-top: 0.65rem;
}

.invoice-items-table .invoice-col-qty {
  width: 6rem;
}

.invoice-items-table .invoice-col-money {
  width: 8rem;
}

.invoice-totals-form-row {
  display: grid;
  grid-template-columns: 1fr min(45%, 9rem);
  gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0.85rem;
}

.invoice-totals-form-row.invoice-totals-grand {
  font-weight: 700;
  padding-top: 0.65rem;
  border-top: 1px solid var(--ins-border-color);
  margin-top: 0.25rem;
}

.invoice-totals-input {
  text-align: end;
}

.invoice-totals-divider {
  border-color: var(--ins-border-color);
  opacity: 1;
  margin-inline: 0.85rem;
}

[data-bs-theme="dark"] .invoice-display-panel {
  border-color: rgba(255, 255, 255, 0.22);
  background: var(--ins-secondary-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .invoice-display-panel-header {
  border-bottom-color: rgba(255, 255, 255, 0.12);
  background: var(--ins-tertiary-bg);
}

[data-bs-theme="dark"] .invoice-display-panel-body .table-responsive {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .invoice-display-panel .invoice-items-table > :not(caption) > * > * {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .invoice-display-section .invoice-items-table thead.table-light th,
[data-bs-theme="dark"] .invoice-totals-card {
  background-color: transparent;
  border-color: transparent !important;
}

[data-bs-theme="dark"] .invoice-display-section .invoice-items-table thead.table-light th {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .invoice-display-section .invoice-items-table tbody td {
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}

[data-bs-theme="dark"] .invoice-totals-label {
  color: var(--ins-secondary-color);
}

[data-bs-theme="dark"] .invoice-totals-value {
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .invoice-display-section .text-success,
[data-bs-theme="dark"] .invoice-totals-form .text-success {
  color: #4ade80 !important;
}

[data-bs-theme="dark"] .invoice-display-section .text-danger {
  color: #f87171 !important;
}

[data-bs-theme="dark"] .invoice-display-section .text-warning,
[data-bs-theme="dark"] .invoice-totals-form .text-warning {
  color: #fbbf24 !important;
}

/* Choices.js (form-select): selected value text follows theme (if plugin choices.min.css is ever loaded, it won’t wash out dark mode) */
.choices__inner .choices__list--single .choices__item {
  color: var(--ins-body-color);
}

/* Brand logos — Future Waves (sidebar / topbar / auth) */
.sidenav-menu > a.logo {
  min-height: var(--ins-topbar-height, 70px);
  height: var(--ins-topbar-height, 70px);
  padding: 0.55rem 12px 0.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: none;
  background: transparent !important;
}
/* Ubold also styles inner span.logo wrappers — strip sticky/padding/bg so no gray box shows */
.sidenav-menu > a.logo > span.logo.logo-light,
.sidenav-menu > a.logo > span.logo.logo-dark {
  position: static !important;
  top: auto !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0;
  background: transparent !important;
  box-shadow: none !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu .logo,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) .logo {
  background: transparent !important;
  box-shadow: none !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu > a.logo,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) > a.logo {
  min-height: var(--ins-topbar-height, 70px) !important;
  height: var(--ins-topbar-height, 70px) !important;
  padding: 0.55rem 8px 0.3rem !important;
  background: transparent !important;
}
/* Keep menu vertical position when sidebar collapses (titles hide but keep their slot) */
html[data-sidenav-size="condensed"] .sidenav-menu .side-nav-title,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) .side-nav-title {
  display: block !important;
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  margin: 0 !important;
  padding: var(--ins-sidenav-item-padding-y, 0.625rem) calc(var(--ins-sidenav-item-padding-x, 1.25rem) * 2) !important;
  font-size: calc(var(--ins-sidenav-item-font-size, 0.875rem) * 0.7) !important;
  line-height: 1.25 !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 0;
}
html[data-sidenav-size="condensed"] .sidenav-menu .side-nav > .side-nav-title.mt-2,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) .side-nav > .side-nav-title.mt-2 {
  margin-top: 0.5rem !important;
}
/* Smooth width-only sidebar animation; avoid link layout jumps */
.sidenav-menu {
  transition: width 0.25s ease-in-out !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu .side-nav .side-nav-item .side-nav-link,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) .side-nav .side-nav-item .side-nav-link {
  transition: background-color 0.2s ease, color 0.2s ease !important;
}
.sidenav-menu > a.logo span.logo-lg {
  display: block !important;
}
.sidenav-menu > a.logo span.logo-sm {
  display: none !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu > a.logo span.logo-lg,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) > a.logo span.logo-lg {
  display: none !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu > a.logo span.logo-sm,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) > a.logo span.logo-sm {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0 !important;
  line-height: 1 !important;
  background: transparent !important;
}
.sidenav-menu .logo img.admin-brand-logo-sidebar {
  height: auto;
  max-height: 40px;
  width: auto;
  max-width: min(220px, 90%);
  object-fit: contain;
  display: block;
}
.sidenav-menu .logo img.admin-brand-logo-sidebar-sm {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
  object-position: center;
  display: block;
  flex-shrink: 0;
  background: transparent !important;
}
html[data-sidenav-size="condensed"] .sidenav-menu .logo img.admin-brand-logo-sidebar-sm,
html[data-sidenav-size="on-hover"] .sidenav-menu:not(:hover) .logo img.admin-brand-logo-sidebar-sm {
  width: 40px !important;
  height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
}
.logo-topbar {
  padding-top: 0.35rem;
  padding-bottom: 0.15rem;
  line-height: 1.2;
  box-sizing: border-box;
}
.logo-topbar img.admin-brand-logo-topbar {
  height: auto !important;
  max-height: 34px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
}
.logo-topbar img.admin-brand-logo-topbar-sm {
  height: auto !important;
  max-height: 28px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}
.auth-brand .auth-login-logo,
.auth-login-logo {
  height: auto;
  max-height: 40px;
  width: auto;
  max-width: min(240px, 100%);
  object-fit: contain;
}
/* Auth / welcome logos: Bootstrap d-inline-block overrides Ubold theme toggle */
.auth-brand .logo-dark,
.auth-brand a.logo-dark,
.welcome-logo .logo-dark {
  display: inline-block !important;
}
.auth-brand .logo-light,
.auth-brand a.logo-light,
.welcome-logo .logo-light {
  display: none !important;
}
html[data-bs-theme="dark"] .auth-brand .logo-light,
html[data-bs-theme="dark"] .auth-brand a.logo-light,
html[data-bs-theme="dark"] .welcome-logo .logo-light {
  display: inline-block !important;
}
html[data-bs-theme="dark"] .auth-brand .logo-dark,
html[data-bs-theme="dark"] .auth-brand a.logo-dark,
html[data-bs-theme="dark"] .welcome-logo .logo-dark {
  display: none !important;
}

/* RTL: table columns align right (whole admin panel; preserve explicit center columns e.g. actions) */
html[dir="rtl"] .table thead th,
html[dir="rtl"] .table tbody td {
  text-align: right;
}
html[dir="rtl"] .table thead th.text-center,
html[dir="rtl"] .table tbody td.text-center,
html[dir="rtl"] .table .text-center {
  text-align: center !important;
}
html[dir="rtl"] table.dataTable thead th,
html[dir="rtl"] table.dataTable tbody td {
  text-align: right !important;
}
html[dir="rtl"] table.dataTable thead th.text-center,
html[dir="rtl"] table.dataTable tbody td.text-center {
  text-align: center !important;
}
html[dir="rtl"] div.dt-container table.dataTable thead th,
html[dir="rtl"] div.dt-container table.dataTable tbody td {
  text-align: right !important;
}
html[dir="rtl"] div.dt-container table.dataTable thead th.text-center,
html[dir="rtl"] div.dt-container table.dataTable tbody td.text-center {
  text-align: center !important;
}

/* Finance overview (/admin/finance) */
.finance-flow-card,
.finance-stat-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
}
.finance-stat-card-plus { border-right: 3px solid #22c55e; }
.finance-stat-card-minus { border-right: 3px solid #ef4444; }
html[dir="rtl"] .finance-stat-card-plus { border-right: none; border-left: 3px solid #22c55e; }
html[dir="rtl"] .finance-stat-card-minus { border-right: none; border-left: 3px solid #ef4444; }

.finance-flow-equation { min-height: 3.5rem; }
.finance-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
}
.finance-pill-plus {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
}
.finance-pill-minus {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
}
.finance-pill-result { transform: scale(1.03); }
.finance-pill-label {
  display: block;
  font-size: 0.7rem;
  color: #6c757d;
  line-height: 1.2;
}
.finance-pill-value,
.finance-stat-value {
  display: block;
  font-size: 1.05rem;
  color: var(--ins-emphasis-color, #212529);
  line-height: 1.3;
}
.finance-stat-card h2.finance-stat-value,
.finance-stat-card h3.finance-stat-value {
  font-size: inherit;
}
.finance-sign {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.finance-pill-plus .finance-sign {
  background: #22c55e;
  color: #fff;
}
.finance-pill-minus .finance-sign {
  background: #ef4444;
  color: #fff;
}

.finance-amount-plus { color: #16a34a !important; font-weight: 600; }
.finance-amount-minus { color: #dc2626 !important; font-weight: 600; }

.finance-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  font-size: 1.1rem;
}
.finance-icon-plus { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.finance-icon-minus { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
.finance-icon-neutral { background: rgba(27, 54, 93, 0.08); color: #1b365d; }

.finance-net-display {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}
.finance-net-sign {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.finance-net-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}
.finance-net-positive .finance-net-sign,
.finance-net-positive .finance-net-value { color: #16a34a; }
.finance-net-negative .finance-net-sign,
.finance-net-negative .finance-net-value { color: #dc2626; }

.finance-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}
.finance-chip-plus {
  color: #15803d;
  background: rgba(34, 197, 94, 0.12);
}
.finance-chip-minus {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.finance-table-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  vertical-align: middle;
}
.finance-table-badge-plus { background: #22c55e; color: #fff; }
.finance-table-badge-minus { background: #ef4444; color: #fff; }

.finance-card-header {
  background: transparent;
}
.finance-table-head th {
  background-color: var(--ins-tertiary-bg, #f8f9fa);
  color: var(--ins-emphasis-color, inherit);
  border-bottom-color: var(--ins-border-color, #dee2e6);
}

/* Finance overview — dark mode */
[data-bs-theme="dark"] .finance-overview .finance-flow-card,
[data-bs-theme="dark"] .finance-overview .finance-stat-card {
  background: var(--ins-secondary-bg);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] .finance-overview .finance-pill-plus {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(74, 222, 128, 0.35);
}
[data-bs-theme="dark"] .finance-overview .finance-pill-minus {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
}
[data-bs-theme="dark"] .finance-overview .finance-pill-label {
  color: rgba(255, 255, 255, 0.55);
}
[data-bs-theme="dark"] .finance-overview .finance-pill-value,
[data-bs-theme="dark"] .finance-overview .finance-stat-value {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .finance-overview .finance-amount-plus { color: #4ade80 !important; }
[data-bs-theme="dark"] .finance-overview .finance-amount-minus { color: #f87171 !important; }
[data-bs-theme="dark"] .finance-overview .finance-icon-plus {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
}
[data-bs-theme="dark"] .finance-overview .finance-icon-minus {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
}
[data-bs-theme="dark"] .finance-overview .finance-icon-neutral {
  background: rgba(126, 179, 255, 0.15);
  color: #7eb3ff;
}
[data-bs-theme="dark"] .finance-overview .finance-net-positive .finance-net-sign,
[data-bs-theme="dark"] .finance-overview .finance-net-positive .finance-net-value { color: #4ade80; }
[data-bs-theme="dark"] .finance-overview .finance-net-negative .finance-net-sign,
[data-bs-theme="dark"] .finance-overview .finance-net-negative .finance-net-value { color: #f87171; }
[data-bs-theme="dark"] .finance-overview .finance-chip-plus {
  color: #86efac;
  background: rgba(34, 197, 94, 0.2);
}
[data-bs-theme="dark"] .finance-overview .finance-chip-minus {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.2);
}
[data-bs-theme="dark"] .finance-overview .finance-card-header {
  background: var(--ins-secondary-bg);
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}
[data-bs-theme="dark"] .finance-overview .finance-card-header .header-title {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .finance-overview .finance-table-head th {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-emphasis-color);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] .finance-overview .card .table tbody td {
  color: var(--ins-body-color);
  border-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme="dark"] .finance-overview .text-warning {
  color: #fbbf24 !important;
}
[data-bs-theme="dark"] .finance-overview .text-info {
  color: #67e8f9 !important;
}
[data-bs-theme="dark"] .finance-overview .text-success {
  color: #4ade80 !important;
}

/* Expenses — quick add bar */
.expense-quick-card {
  background: #fff;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-inline-start: 3px solid #ef4444;
  box-shadow: none;
}
.expense-quick-title {
  color: var(--ins-emphasis-color, #212529);
}
.expense-quick-badge {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.45rem 0.65rem;
}
.expense-quick-badge-code {
  background: rgba(27, 54, 93, 0.08);
  color: #1b365d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}
.expense-quick-form .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ins-emphasis-color, #212529);
}
[data-bs-theme="dark"] .expense-quick-card {
  background: var(--ins-secondary-bg);
  border-color: rgba(248, 113, 113, 0.25);
  border-inline-start-color: #f87171;
}
[data-bs-theme="dark"] .expense-quick-title {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .expense-quick-badge {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}
[data-bs-theme="dark"] .expense-quick-badge-code {
  background: rgba(126, 179, 255, 0.15);
  color: #7eb3ff;
}
[data-bs-theme="dark"] .expense-quick-form .form-label {
  color: var(--ins-emphasis-color);
}

/* Internal notes — quick upload bar */
.note-quick-card {
  background: #fff;
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-inline-start: 3px solid #0ea5e9;
  box-shadow: none;
}
.note-quick-title {
  color: var(--ins-emphasis-color, #212529);
}
.note-quick-form .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ins-emphasis-color, #212529);
}
.note-quick-dropzone {
  position: relative;
  min-height: calc(0.775rem * 1.5 + 0.875rem * 2 + 2px);
  border: 1.5px dashed rgba(14, 165, 233, 0.45);
  border-radius: 0.5rem;
  background: rgba(14, 165, 233, 0.04);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.note-quick-dropzone:hover,
.note-quick-dropzone:focus-visible {
  border-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.08);
  outline: none;
}
.note-quick-dropzone.is-dragover {
  border-color: #0284c7;
  background: rgba(14, 165, 233, 0.14);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.note-quick-dropzone.has-file {
  border-style: solid;
  border-color: rgba(14, 165, 233, 0.55);
  background: rgba(14, 165, 233, 0.07);
}
.note-quick-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: calc(0.775rem * 1.5 + 0.875rem * 2 + 2px);
  padding: 0.65rem 0.75rem;
}
.note-quick-dropzone-icon {
  font-size: 1.35rem;
  color: #0284c7;
  line-height: 1;
}
.note-quick-dropzone-label {
  font-size: 0.8125rem;
  color: var(--ins-secondary-color, #6c757d);
}
.note-quick-file-name {
  color: var(--ins-emphasis-color, #212529) !important;
  font-weight: 600;
  word-break: break-all;
}
[data-bs-theme="dark"] .note-quick-card {
  background: var(--ins-secondary-bg);
  border-color: rgba(56, 189, 248, 0.28);
  border-inline-start-color: #38bdf8;
}
[data-bs-theme="dark"] .note-quick-title,
[data-bs-theme="dark"] .note-quick-form .form-label {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .note-quick-dropzone {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
}
[data-bs-theme="dark"] .note-quick-dropzone.is-dragover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}
[data-bs-theme="dark"] .note-quick-dropzone-icon {
  color: #7dd3fc;
}
[data-bs-theme="dark"] .note-quick-file-name {
  color: var(--ins-emphasis-color) !important;
}

.expense-amount-minus {
  display: inline-block;
  color: #dc2626;
  font-weight: 700;
  white-space: nowrap;
}
.expense-amount-input-group .expense-amount-prefix {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
  font-size: 1.15rem;
  font-weight: 800;
  min-width: 2.5rem;
  justify-content: center;
}
.expense-amount-input-group .expense-amount-input {
  font-weight: 600;
  color: #dc2626;
}
.expense-amount-input-group .expense-amount-input::placeholder {
  color: rgba(220, 38, 38, 0.45);
}
[data-bs-theme="dark"] .expense-amount-minus {
  color: #f87171;
}
[data-bs-theme="dark"] .expense-amount-input-group .expense-amount-prefix {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}
[data-bs-theme="dark"] .expense-amount-input-group .expense-amount-input {
  color: #f87171;
}
[data-bs-theme="dark"] .expense-amount-input-group .expense-amount-input::placeholder {
  color: rgba(248, 113, 113, 0.45);
}

/* Client show page */
.client-show-page .client-panel-box,
.client-show-page .client-section-box {
  background: #fff;
}
.client-show-page .client-section-box {
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  overflow: visible;
}
.client-show-page .client-dropzone {
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.client-show-page .client-dropzone-empty {
  cursor: pointer;
}
.client-show-page .client-dropzone-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 12;
  align-items: center;
  justify-content: center;
  background: rgba(27, 54, 93, 0.08);
  border-radius: inherit;
  pointer-events: none;
}
.client-show-page .client-dropzone.is-dragover {
  border-color: var(--ins-primary, #1b365d);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(27, 54, 93, 0.12);
}
.client-show-page .client-dropzone.is-dragover .client-dropzone-overlay {
  display: flex;
}
.client-show-page .client-dropzone-overlay-inner {
  padding: 1.5rem;
  color: var(--ins-primary, #1b365d);
}
.client-show-page .client-dropzone .client-upload-form,
.client-show-page .client-dropzone .table-responsive,
.client-show-page .client-dropzone .client-empty-state {
  position: relative;
  z-index: 1;
}
[data-bs-theme="dark"] .client-show-page .client-dropzone.is-dragover {
  border-color: #7eb3ff;
  box-shadow: 0 0 0 3px rgba(126, 179, 255, 0.18);
}
[data-bs-theme="dark"] .client-show-page .client-dropzone-overlay {
  background: rgba(126, 179, 255, 0.12);
}
[data-bs-theme="dark"] .client-show-page .client-dropzone-overlay-inner {
  color: #7eb3ff;
}
.client-show-page .client-empty-state {
  background: #fff;
}
.client-show-page .client-upload-form {
  background: #f8f9fa;
}
.client-show-page .client-table-head th {
  background-color: var(--ins-tertiary-bg, #f8f9fa);
  color: var(--ins-emphasis-color, inherit);
}
.client-show-page .client-code-badge {
  background: rgba(27, 54, 93, 0.08);
  color: #1b365d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}
.client-show-page .client-contract-code {
  color: #1b365d;
  font-size: 0.85rem;
}
.client-show-page .client-notes-feed {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.client-show-page .client-note-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.5rem;
  background: #fff;
}
.client-show-page .client-note-avatar {
  width: 42px;
  height: 42px;
  object-fit: cover;
  flex-shrink: 0;
}
.client-show-page .client-note-body {
  flex: 1;
  min-width: 0;
}
.client-show-page .client-note-author {
  color: var(--ins-emphasis-color, #212529);
}
.client-show-page .client-note-text {
  white-space: pre-wrap;
  color: var(--ins-body-color, #495057);
  line-height: 1.5;
}
[data-bs-theme="dark"] .client-show-page .client-panel-box,
[data-bs-theme="dark"] .client-show-page .client-section-box,
[data-bs-theme="dark"] .client-show-page .client-empty-state,
[data-bs-theme="dark"] .client-show-page .client-note-item {
  background: var(--ins-secondary-bg);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] .client-show-page .client-upload-form {
  background: var(--ins-tertiary-bg);
  border-color: rgba(255, 255, 255, 0.1) !important;
}
[data-bs-theme="dark"] .client-show-page .client-code-badge {
  background: rgba(126, 179, 255, 0.15);
  color: #7eb3ff;
}
[data-bs-theme="dark"] .client-show-page .client-contract-code {
  color: #7eb3ff;
}
[data-bs-theme="dark"] .client-show-page .client-note-author {
  color: var(--ins-emphasis-color);
}
[data-bs-theme="dark"] .client-show-page .client-note-text {
  color: var(--ins-body-color);
}
[data-bs-theme="dark"] .client-show-page .text-success {
  color: #4ade80 !important;
}
[data-bs-theme="dark"] .client-show-page .text-warning {
  color: #fbbf24 !important;
}

/* Accounting archive — transactions table */
.accounting-archive-page .archive-index-table .archive-index-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.accounting-archive-page .archive-index-table .archive-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.accounting-archive-page .archive-summary-card h3 {
  font-size: 1.35rem;
  margin-bottom: 0;
}

.accounting-archive-page .archive-readonly-banner {
  border: 1px solid rgba(27, 54, 93, 0.15);
  background: rgba(27, 54, 93, 0.05);
  color: var(--ins-body-color);
}

.accounting-archive-page .archive-transactions-table {
  --archive-pending-border: #e8a317;
}

.accounting-archive-page .archive-table-head th {
  background: var(--ins-tertiary-bg, #f6f8fa);
  color: var(--ins-body-color);
  font-weight: 600;
  white-space: nowrap;
}

.accounting-archive-page .archive-txn-row td {
  vertical-align: middle;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.accounting-archive-page .archive-txn-row--pending {
  box-shadow: inset 3px 0 0 var(--archive-pending-border);
}

.accounting-archive-page .archive-txn-row--pending td {
  background: transparent;
}

.accounting-archive-page .archive-col-no { width: 2.5rem; }
.accounting-archive-page .archive-col-date { width: 6.5rem; }
.accounting-archive-page .archive-col-type { width: 5.5rem; }
.accounting-archive-page .archive-col-amount { width: 5.5rem; }
.accounting-archive-page .archive-col-party { min-width: 11rem; max-width: 16rem; }
.accounting-archive-page .archive-col-desc { min-width: 10rem; max-width: 14rem; }
.accounting-archive-page .archive-col-ref { max-width: 8rem; }
.accounting-archive-page .archive-col-invoice { min-width: 11rem; max-width: 14rem; }
.accounting-archive-page .archive-col-note { min-width: 11rem; max-width: 14rem; }
.accounting-archive-page .archive-col-review { width: 6.5rem; }
.accounting-archive-page .archive-col-action { width: 3rem; }

.accounting-archive-page .archive-party,
.accounting-archive-page .archive-ref {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.accounting-archive-page .archive-desc-summary {
  font-size: 0.8125rem;
  color: var(--ins-secondary-color, #5f6b7a);
  line-height: 1.4;
}

.accounting-archive-page .archive-desc-details {
  margin-top: 0.2rem;
}

.accounting-archive-page .archive-desc-details summary {
  font-size: 0.75rem;
  color: var(--ins-link-color, #1b365d);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.accounting-archive-page .archive-desc-details summary::-webkit-details-marker {
  display: none;
}

.accounting-archive-page .archive-desc-details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.accounting-archive-page .archive-desc-details[open] summary::before {
  transform: rotate(90deg);
}

.accounting-archive-page .archive-desc-full {
  margin-top: 0.35rem;
  padding: 0.45rem 0.55rem;
  max-height: 7rem;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-line;
  border-radius: 0.35rem;
  background: var(--ins-tertiary-bg, #f3f6f9);
  color: var(--ins-body-color);
  border: 1px solid var(--ins-border-color, #e8edf2);
}

.accounting-archive-page .archive-note-input {
  min-height: 2.5rem;
  max-height: 4.5rem;
  resize: vertical;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.accounting-archive-page .archive-invoice-select {
  font-size: 0.8125rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.accounting-archive-page .archive-note-readonly {
  font-size: 0.8125rem;
  line-height: 1.4;
}

.accounting-archive-page .archive-save-btn {
  padding: 0.25rem 0.45rem;
  line-height: 1;
}

.accounting-archive-page .archive-amount {
  font-variant-numeric: tabular-nums;
}

.accounting-archive-page .archive-amount-in {
  color: #198754;
}

.accounting-archive-page .archive-amount-out {
  color: #dc3545;
}

[data-bs-theme="dark"] .accounting-archive-page .archive-readonly-banner {
  border-color: rgba(126, 179, 255, 0.2);
  background: rgba(61, 111, 184, 0.12);
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-transactions-table {
  --archive-pending-border: #fbbf24;
}

[data-bs-theme="dark"] .accounting-archive-page .archive-table-head th {
  background: var(--ins-tertiary-bg, #1a232e);
  color: var(--ins-body-color);
  border-color: var(--ins-border-color, #2a3544);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-txn-row td {
  border-color: var(--ins-border-color, #2a3544);
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-desc-summary {
  color: var(--ins-secondary-color, #9aa3af);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-desc-full {
  background: var(--ins-secondary-bg, #151c24);
  border-color: var(--ins-border-color, #2a3544);
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-desc-details summary {
  color: var(--ins-link-color, #8ebfff);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-note-input,
[data-bs-theme="dark"] .accounting-archive-page .archive-invoice-select {
  background-color: var(--ins-secondary-bg, #151c24);
  border-color: var(--ins-border-color, #2a3544);
  color: var(--ins-body-color);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-note-input::placeholder {
  color: var(--ins-secondary-color, #9aa3af);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-amount-in {
  color: #4ade80;
}

[data-bs-theme="dark"] .accounting-archive-page .archive-amount-out {
  color: #f87171;
}

[data-bs-theme="dark"] .accounting-archive-page .archive-index-table tbody td {
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}

[data-bs-theme="dark"] .accounting-archive-page .archive-index-table thead th {
  background-color: var(--ins-tertiary-bg);
  color: var(--ins-body-color);
  border-color: var(--ins-border-color);
}

/* CRM Tags */
.crm-tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.crm-tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  background: var(--tag-color, #3b82f6);
  border: 1px solid color-mix(in srgb, var(--tag-color, #3b82f6) 75%, #000 25%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  white-space: nowrap;
}

.crm-tagged-row {
  box-shadow: inset 3px 0 0 #f59e0b;
  background: rgba(245, 158, 11, 0.06) !important;
}

.crm-tag-color-presets .crm-tag-color-preset {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
  background: var(--preset-color);
  padding: 0;
  cursor: pointer;
}

.crm-tag-preview-wrap {
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(15, 23, 42, 0.12);
  border-radius: 0.5rem;
  background: #f8fafc;
}

.tag-it-modal-content {
  background: #fff;
}

.tag-it-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 18rem;
  overflow: auto;
}

.tag-it-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 0.5rem;
  background: #fff;
  cursor: pointer;
  margin: 0;
}

.tag-it-option:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.04);
}

.tag-it-option-desc {
  flex: 1;
  min-width: 0;
}

[data-bs-theme="dark"] .crm-tagged-row {
  background: rgba(245, 158, 11, 0.1) !important;
}

[data-bs-theme="dark"] .crm-tag-preview-wrap,
[data-bs-theme="dark"] .tag-it-modal-content,
[data-bs-theme="dark"] .tag-it-option {
  background: var(--ins-secondary-bg);
  border-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .tag-it-modal-content .modal-title {
  color: var(--ins-emphasis-color);
}
