/* ==========================================================================
   UI POLISH — readability, semantic money colors, practical interactions
   Loaded after ocean-finance.css
   ========================================================================== */

:root {
  --ui-pnl-positive: #4ade80;
  --ui-pnl-positive-dim: #22c55e;
  --ui-pnl-negative: #f87171;
  --ui-pnl-negative-dim: #ef4444;
  --ui-pnl-neutral: #94a3b8;
  --ui-focus-ring: rgba(56, 189, 248, 0.72);
  --ui-row-hover: rgba(56, 189, 248, 0.08);
  --ui-row-hover-border: rgba(56, 189, 248, 0.22);
}

/* —— Semantic P&L (override ocean glacier/mist confusion) —— */
.val-gain,
.table .val-gain,
.data-table .val-gain,
.standard-data-table .val-gain,
.text-success:not(.badge),
.cell-pct.pct-positive,
.cell-positive,
.positive-value {
  color: var(--ui-pnl-positive) !important;
  font-variant-numeric: tabular-nums;
}

.val-loss,
.table .val-loss,
.data-table .val-loss,
.standard-data-table .val-loss,
.text-danger:not(.badge),
.cell-pct.pct-negative,
.cell-negative,
.negative-value {
  color: var(--ui-pnl-negative) !important;
  font-variant-numeric: tabular-nums;
}

.val-neutral,
.table .val-neutral,
.data-table .val-neutral,
.standard-data-table .val-neutral {
  color: var(--ui-pnl-neutral) !important;
  font-weight: 500;
}

/* —— Focus & keyboard —— */
:focus-visible {
  outline: 2px solid var(--ui-focus-ring);
  outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-input:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ui-focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

/* —— Slightly brighter secondary copy on dark glass —— */
.data-table td,
.standard-data-table td,
.page-subtitle,
.text-muted,
.text-secondary {
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 88%, #ffffff 12%);
}

.data-table th,
.standard-data-table th {
  color: color-mix(in srgb, var(--ocean-glacier, #cfe9f7) 92%, #ffffff 8%) !important;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* —— Clients list: clickable rows + calmer delete —— */
#clients-list-table tbody tr {
  cursor: pointer;
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
}

#clients-list-table tbody tr:hover td {
  background-color: var(--ui-row-hover) !important;
}

#clients-list-table tbody tr:hover {
  box-shadow: inset 3px 0 0 var(--ui-row-hover-border);
}

#clients-list-table tbody tr:focus-within {
  box-shadow: inset 3px 0 0 var(--ui-focus-ring);
}

.clients-list-actions {
  width: 96px;
  min-width: 96px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.clients-list-actions .btn-danger {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  min-height: 30px;
  border-radius: 8px;
  opacity: 0.92;
}

#clients-list-table tbody tr:hover .clients-list-actions .btn-danger {
  opacity: 1;
}

.client-cell {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.client-cell .client-name {
  font-weight: 600;
  color: var(--ocean-glacier, #cfe9f7);
}

#clients-list-table tbody tr:hover .client-cell .client-name {
  color: #ffffff;
}

/* —— Config / settings tables —— */
.config-client-mgmt .cm-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--ui-pnl-positive-dim, #22c55e);
  cursor: pointer;
}

.config-client-mgmt .action-btn {
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.config-client-mgmt .action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(145, 184, 209, 0.55);
}

.config-client-mgmt .btn-danger {
  font-size: 12px;
  padding: 5px 12px;
  min-height: 30px;
}

/* —— Collapsible settings sections —— */
.collapsible-section {
  border-color: rgba(65, 113, 154, 0.38);
  background: rgba(8, 28, 52, 0.28);
  backdrop-filter: blur(12px);
}

.collapsible-header {
  padding: 14px 20px;
  background: rgba(12, 36, 64, 0.55);
}

.collapsible-header:hover {
  background: rgba(18, 48, 82, 0.65);
}

.collapsible-title {
  font-size: 12px;
  color: var(--ocean-glacier, #cfe9f7);
  letter-spacing: 0.08em;
}

.collapsible-subtitle {
  font-size: 12px;
  color: rgba(189, 216, 237, 0.78);
}

/* —— Page headers —— */
.page-header h1,
.page-title {
  letter-spacing: -0.03em;
}

.page-subtitle {
  max-width: 52ch;
  line-height: 1.5;
}

.section-meta,
.section-heading-above-table .section-meta {
  font-size: 13px;
  color: rgba(189, 216, 237, 0.75);
}

/* —— Forms: clearer fields —— */
.form-control,
.form-input,
select.form-control,
input.form-input {
  min-height: 40px;
  border-radius: 10px;
}

.form-control::placeholder,
.form-input::placeholder {
  opacity: 0.72;
}

/* —— Status badges —— */
.badge-success,
.status-pill--ok,
.status-badge--connected {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #86efac !important;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.badge-danger,
.status-pill--error,
.status-badge--disconnected {
  background: rgba(239, 68, 68, 0.14) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.badge-warning,
.status-pill--warn {
  background: rgba(251, 191, 36, 0.12) !important;
  color: #fcd34d !important;
  border: 1px solid rgba(251, 191, 36, 0.32);
}

/* —— Table search toolbar —— */
.dt-table-search-wrap input,
.table-search-input {
  border-radius: 10px;
  min-height: 38px;
}

/* —— Modals —— */
.modal-box {
  border-radius: 16px;
  border: 1px solid rgba(145, 184, 209, 0.35);
}

.modal-title {
  color: var(--ocean-glacier, #cfe9f7);
  font-weight: 700;
}

/* —— Notification settings & matrix panel —— */
.notif-reason-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 960px;
}

.notif-legacy-card,
.nm-panel.section-card {
  padding: 1.25rem 1.35rem 1.35rem;
  border-radius: 14px;
  border: 1px solid rgba(120, 165, 200, 0.28);
  background: linear-gradient(165deg, rgba(12, 28, 52, 0.92) 0%, rgba(8, 18, 36, 0.96) 100%);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.notif-card-header,
.nm-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(120, 165, 200, 0.2);
}

.notif-card-title,
.nm-panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ocean-glacier, #cfe9f7);
}

.notif-card-desc,
.nm-panel-desc,
.nm-hint,
.notif-legacy-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 82%, #fff 18%);
}

.notif-legacy-note {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.18);
}

.nm-profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nm-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #e0f2fe;
}

.nm-badge-urgency.nm-badge--high {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.nm-badge-urgency.nm-badge--medium {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.nm-badge-urgency.nm-badge--low {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.3);
  color: #bbf7d0;
}

.nm-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.nm-section {
  padding: 0.85rem 0 0;
}

.nm-section--full {
  padding-top: 0.25rem;
}

.nm-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ocean-glacier, #cfe9f7) 75%, #fff 25%);
}

.nm-grid {
  display: grid;
  gap: 0.85rem 1rem;
  align-items: end;
}

.nm-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nm-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .nm-grid-2,
  .nm-grid-4 {
    grid-template-columns: 1fr;
  }
}

.nm-hint--block {
  margin: 0 0 0.85rem;
  max-width: 42rem;
}

.nm-section--hero {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(120, 165, 200, 0.2);
  background: rgba(8, 18, 36, 0.28);
}

.nm-schedule-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.nm-schedule-card {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(120, 165, 200, 0.24);
  background: linear-gradient(180deg, rgba(12, 26, 48, 0.55), rgba(8, 18, 36, 0.35));
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.nm-schedule-card--off {
  opacity: 0.55;
  border-style: dashed;
}

.nm-schedule-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.nm-schedule-card__title {
  display: block;
  font-size: 0.95rem;
  color: var(--ocean-glacier, #e8f4fc);
}

.nm-schedule-card__subtitle {
  display: block;
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 85%, #fff 15%);
  margin-top: 0.15rem;
}

.nm-switch--compact .nm-switch-label {
  font-size: 0.8125rem;
  font-weight: 600;
}

.nm-schedule-allday {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 90%, #fff 10%);
  cursor: pointer;
  user-select: none;
}

.nm-schedule-allday input {
  width: 1rem;
  height: 1rem;
  accent-color: #38bdf8;
}

.nm-time-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.65rem 0.75rem;
  align-items: end;
  max-width: 28rem;
}

.nm-time-sep {
  align-self: end;
  padding-bottom: 0.55rem;
  font-size: 1.1rem;
  color: rgba(56, 189, 248, 0.75);
}

.nm-time-input {
  font-variant-numeric: tabular-nums;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
}

.nm-phase-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.nm-phase-card {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(120, 165, 200, 0.22);
  background: rgba(8, 18, 36, 0.38);
}

.nm-phase-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.75rem;
}

.nm-phase-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #e0f2fe;
}

.nm-phase-card__hint {
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 82%, #fff 18%);
}

.nm-phase-card__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem 1rem;
  align-items: end;
}

.nm-duration {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.nm-duration-prefix {
  font-size: 0.8125rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 88%, #fff 12%);
  white-space: nowrap;
}

.nm-duration-value {
  width: 4.25rem;
  min-width: 3.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.5rem;
}

.nm-duration-unit {
  min-width: 6.5rem;
  flex: 1 1 6rem;
}

.nm-duration--fixed {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(120, 165, 200, 0.22);
  background: rgba(8, 18, 36, 0.28);
}

.nm-duration-fixed-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e0f2fe;
}

.nm-phase-card__schedule {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(120, 165, 200, 0.16);
}

.nm-phase-card__schedule-title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 90%, #fff 10%);
}

@media (max-width: 720px) {
  .nm-phase-card__grid,
  .nm-time-row {
    grid-template-columns: 1fr;
  }
  .nm-time-sep {
    display: none;
  }
}

.nm-hint--inline {
  font-size: 0.75rem;
  opacity: 0.85;
}

.nm-placeholder-list {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.2rem;
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 82%, #fff 18%);
}

.nm-placeholder-list code {
  font-size: 0.78rem;
}

.nm-hint--placeholders {
  padding: 0.5rem 0.65rem;
  border-left: 3px solid color-mix(in srgb, var(--ocean-mist, #91b8d1) 55%, transparent);
  background: color-mix(in srgb, var(--ocean-mist, #91b8d1) 8%, transparent);
  border-radius: 0 4px 4px 0;
}

.nm-pill--sub span {
  font-size: 0.8125rem;
}

.nm-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.nm-field--hint {
  justify-content: center;
}

.nm-field--days .nm-pill-group {
  margin-top: 0.15rem;
}

.nm-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 90%, #fff 10%);
}

.nm-control,
.nm-textarea {
  width: 100%;
  min-height: 38px;
  border-radius: 10px;
}

.nm-control--narrow {
  max-width: 10rem;
}

.nm-textarea {
  min-height: 5.5rem;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.nm-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.nm-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.nm-switch-track {
  position: relative;
  width: 2.5rem;
  height: 1.35rem;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.35);
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.nm-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #f1f5f9;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease;
}

.nm-switch input:checked + .nm-switch-track {
  background: rgba(56, 189, 248, 0.55);
  border-color: rgba(56, 189, 248, 0.65);
}

.nm-switch input:checked + .nm-switch-track::after {
  transform: translateX(1.1rem);
}

.nm-switch-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ocean-glacier, #e8f4fc);
}

.nm-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nm-pill {
  display: inline-flex;
  cursor: pointer;
}

.nm-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nm-pill span {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid rgba(120, 165, 200, 0.35);
  background: rgba(15, 30, 54, 0.65);
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 88%, #fff 12%);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nm-pill input:checked + span {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}

.nm-pill input:focus-visible + span {
  outline: 2px solid var(--ui-focus-ring);
  outline-offset: 2px;
}

.nm-phase-wrap {
  max-width: 36rem;
}

.nm-phase-table th,
.nm-phase-table td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
}

.nm-phase-table .nm-phase-label {
  width: 100%;
  min-width: 10rem;
}

.nm-phase-interval-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  white-space: nowrap;
}

.nm-phase-interval-cell .nm-phase-interval {
  width: 5.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nm-phase-unit {
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 90%, #fff 10%);
}

.nm-phase-empty {
  font-size: 0.8125rem;
  padding: 0.75rem !important;
}

.nm-footer,
.notif-legacy-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding-top: 0.5rem;
  margin-top: 0.25rem;
  border-top: 1px solid rgba(120, 165, 200, 0.16);
}

.notif-legacy-footer {
  margin-top: 1rem;
}

.notif-legacy-footer .btn {
  margin-left: auto;
}

.tg-autosave-hint {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft, #3b82f6) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-soft, #3b82f6) 35%, transparent);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ocean-mist, #91b8d1) 85%, #fff 15%);
}

.tg-autosave-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  min-width: 4.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: opacity 240ms ease;
}

.tg-autosave-status[data-state="idle"] {
  opacity: 0;
}

.tg-autosave-status[data-state="saving"] {
  opacity: 1;
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.12);
}

.tg-autosave-status[data-state="saved"] {
  opacity: 1;
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.tg-autosave-status[data-state="failed"] {
  opacity: 1;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
}

.dashboard-autosave-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  min-width: 4.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: opacity 240ms ease;
}

.dashboard-autosave-status[data-state="idle"] { opacity: 0; }
.dashboard-autosave-status[data-state="saving"] {
  opacity: 1;
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.12);
}
.dashboard-autosave-status[data-state="saved"] {
  opacity: 1;
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}
.dashboard-autosave-status[data-state="failed"] {
  opacity: 1;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
}

.notif-enable-row {
  margin-bottom: 0.85rem;
}

.notif-template-field {
  margin-bottom: 0.85rem;
}

.notification-matrix-table tbody tr:hover td,
.policy-matrix-table tbody tr:hover td {
  background: var(--ui-row-hover) !important;
}

.notif-hub-grid {
  margin-top: 0.25rem;
}

.broker-server-row {
  transition: border-color 0.15s ease, background 0.15s ease;
}

.broker-server-row:hover {
  border-color: rgba(56, 189, 248, 0.35) !important;
}

/* —— Skip link (accessibility) —— */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100000;
  padding: 10px 16px;
  background: #0f172a;
  color: #fff;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* —— Reduce motion —— */
@media (prefers-reduced-motion: reduce) {
  #clients-list-table tbody tr,
  .config-client-mgmt .action-btn,
  .collapsible-body {
    transition: none !important;
  }
}

/* ==========================================================================
   SELECT / DROPDOWN READABILITY — native lists + custom menus
   Fixes white OS dropdown faces with pale blue-gray text on Windows.
   ========================================================================== */

:root {
  --ui-select-bg: #0c1a30;
  --ui-select-bg-hover: #122a48;
  --ui-select-border: rgba(120, 165, 200, 0.48);
  --ui-select-text: #e8f4fc;
  --ui-select-muted: #94a3b8;
  --ui-select-option-bg: #0f1e36;
  --ui-select-option-active: #1a4a72;
}

html,
html[data-theme="dark"],
html[data-bs-theme="dark"] {
  color-scheme: dark;
}

select,
.form-select,
.form-control:not([type]):not([multiple]),
select.form-control,
select.form-input,
.filter-select,
.filter-group select,
.settings-role-select,
.settings-users-role-cell select,
.dm-category-select,
.cr-mr-select,
.cr-mr-month-input,
select.cr-reports-date-input,
.portfolio-positions-toolbar select,
.master-data-page select,
.master-data-page .md-form-control-soft,
.md-field-control,
.md-kv-table select,
.md-table select,
.mapping-form select,
.edit-mapping-form select,
.login-info-wrap select.li-input,
.filter-dropdown select,
.filter-dropdown .form-select,
.filter-dropdown .form-input,
.tab-section select,
.section-card select.form-select {
  color-scheme: dark !important;
  background-color: var(--ui-select-bg) !important;
  color: var(--ui-select-text) !important;
  border: 1px solid var(--ui-select-border) !important;
}

select:disabled,
.form-select:disabled {
  opacity: 0.62;
  color: var(--ui-select-muted) !important;
  cursor: not-allowed;
}

select:hover:not(:disabled),
.form-select:hover:not(:disabled) {
  background-color: var(--ui-select-bg-hover) !important;
  border-color: rgba(145, 184, 209, 0.58) !important;
}

select:focus,
.form-select:focus,
select.form-control:focus {
  background-color: #142d4f !important;
  color: #ffffff !important;
  border-color: rgba(56, 189, 248, 0.65) !important;
}

select option,
select optgroup,
.form-select option,
.form-select optgroup {
  background-color: var(--ui-select-option-bg) !important;
  color: var(--ui-select-text) !important;
}

select option:checked,
select option:hover {
  background-color: var(--ui-select-option-active) !important;
  color: #ffffff !important;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23bdd8ed' d='M6 8L0 0h12z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 2.25rem !important;
}

/* Table-inline selects were transparent → inherited pale text on light stripes */
.md-kv-table select,
.md-table select {
  background-color: rgba(12, 26, 48, 0.92) !important;
}

select.cr-reports-date-input {
  background-color: var(--ui-select-bg) !important;
  color: var(--ui-select-text) !important;
}

/* Custom Bootstrap-style menus */
.dropdown-menu {
  background: rgba(12, 30, 56, 0.98) !important;
  border-color: rgba(120, 165, 200, 0.45) !important;
}

.dropdown-item {
  color: var(--ui-select-text) !important;
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item.active {
  background: rgba(65, 113, 154, 0.32) !important;
  color: #ffffff !important;
}

/* Flatpickr popover stays light; only style its internal month/year controls */
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid rgba(15, 23, 42, 0.18) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months option {
  background: #ffffff !important;
  color: #0f172a !important;
}
