/* ============================================================
   eTradeLay — Design System
   Modern, professional theme built on top of Bootstrap 5.
   ============================================================ */

:root {
  /* Brand palette */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;

  /* Neutrals — validated B2B SaaS slate scale (WCAG-checked):
     text-primary #0F172A hits 18.9:1 on white (AAA), text-secondary
     #475569 hits 5.9:1 on white (AA). App background is a step
     darker than the card surface so cards visibly separate from
     the page instead of blending into it. */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;

  --success: #15803d;
  --danger:  #dc2626;
  --warning: #d97706;
  --info:    #0891b2;

  --surface: #ffffff;
  --app-bg: #f1f5f9;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.14);

  /* Bootstrap variable overrides */
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: 79, 70, 229;
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--ink-800);
  --bs-body-font-family: 'Segoe UI', Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-md);
  --bs-border-color: var(--ink-200);
  --bs-link-color: var(--brand-600);
  --bs-link-hover-color: var(--brand-700);

  /* Keep secondary text, headings, and subtle surfaces tied to the
     same neutral scale so .text-muted / headings / .bg-light etc.
     all feel like one cohesive palette instead of two mismatched
     grays. */
  --bs-secondary-color: var(--ink-600);
  --bs-tertiary-color: var(--ink-500);
  --bs-heading-color: var(--ink-900);
  --bs-emphasis-color: var(--ink-900);
  --bs-secondary-bg: var(--ink-100);
  --bs-tertiary-bg: var(--ink-50);
}

/* ============================================================
   DARK THEME
   ============================================================ */

html[data-bs-theme="dark"] {
  --ink-900: #f1f5f9;
  --ink-800: #e2e8f0;
  --ink-700: #cbd5e1;
  --ink-600: #94a3b8;
  --ink-500: #94a3b8;
  --ink-400: #64748b;
  --ink-300: #334155;
  --ink-200: #293548;
  --ink-100: #1e293b;
  --ink-50:  #172033;

  --surface: #111827;
  --app-bg: #0b1220;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

html[data-bs-theme="dark"] body { background-color: var(--app-bg); }

html[data-bs-theme="dark"] .card,
html[data-bs-theme="dark"] .smart-toolbar .st-search input,
html[data-bs-theme="dark"] .smart-toolbar .st-filter select,
html[data-bs-theme="dark"] .smart-toolbar .st-clear,
html[data-bs-theme="dark"] .smart-tfoot,
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .modal-content {
  background-color: var(--surface);
  color: var(--ink-800);
}

html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }

html[data-bs-theme="dark"] .bg-light { background-color: var(--ink-100) !important; }

html[data-bs-theme="dark"] .table thead.table-light th { background-color: var(--ink-50); }

html[data-bs-theme="dark"] .form-control::placeholder { color: var(--ink-500); }

html[data-bs-theme="dark"] .text-dark { color: var(--ink-800) !important; }

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */

.theme-toggle-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1050;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--ink-200);
  background: var(--surface);
  color: var(--ink-700);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  font-size: 1.1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.theme-toggle-btn:hover { transform: translateY(-2px) scale(1.04); box-shadow: var(--shadow-lg); }

.theme-toggle-btn .bi-moon-stars-fill { display: none; }
html[data-bs-theme="dark"] .theme-toggle-btn .bi-sun-fill { display: none; }
html[data-bs-theme="dark"] .theme-toggle-btn .bi-moon-stars-fill { display: inline-block; }

/* ============================================================
   HOME / DASHBOARD QUICK-ACCESS BUTTON
   ============================================================ */

.home-nav-btn {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 1050;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--ink-200);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  font-size: 1.15rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-nav-btn:hover {
  color: #fff;
  transform: translateY(-2px) scale(1.04);
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .app-content > .container > .card,
  .app-content > .container-fluid > .card,
  .app-content > .container-fluid > .row > .card,
  .app-content > .container-fluid > .row > div > .card,
  .app-content > .container > .row > .card,
  .app-content > .container > .row > div > .card {
    animation: fadeInUp 0.45s ease both;
  }

  .app-content > .container-fluid > .row.g-3 > div,
  .app-content > .container-fluid > .row.g-4 > div {
    animation: fadeInUp 0.45s ease both;
  }

  .app-content > .container-fluid > .row.g-3 > div:nth-child(2),
  .app-content > .container-fluid > .row.g-4 > div:nth-child(2) { animation-delay: 0.05s; }
  .app-content > .container-fluid > .row.g-3 > div:nth-child(3),
  .app-content > .container-fluid > .row.g-4 > div:nth-child(3) { animation-delay: 0.1s; }
  .app-content > .container-fluid > .row.g-3 > div:nth-child(4),
  .app-content > .container-fluid > .row.g-4 > div:nth-child(4) { animation-delay: 0.15s; }

  .smart-table-fade tbody tr { animation: fadeIn 0.3s ease both; }

  .modal.fade .modal-dialog { transition: transform 0.25s ease, opacity 0.25s ease; }
}

.btn { transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, filter 0.15s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active:not(:disabled) { transform: translateY(0); }

/* Elegant button system */
.btn {
  border-radius: 9px;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border: none;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); border: none; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3); }
.btn-danger  { background: linear-gradient(135deg, #f87171, #dc2626); border: none; box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3); }
.btn-warning { background: linear-gradient(135deg, #fbbf24, #d97706); border: none; color: #fff; box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3); }
.btn-warning:hover:not(:disabled) { color: #fff; }
.btn-secondary { background: linear-gradient(135deg, var(--ink-500), var(--ink-700)); border: none; box-shadow: 0 2px 6px rgba(51, 65, 85, 0.25); }

.btn-outline-primary, .btn-outline-warning, .btn-outline-danger,
.btn-outline-success, .btn-outline-info, .btn-outline-secondary {
  background: transparent;
  box-shadow: none;
}

.btn-outline-primary:hover, .btn-outline-warning:hover, .btn-outline-danger:hover,
.btn-outline-success:hover, .btn-outline-info:hover, .btn-outline-secondary:hover {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.btn:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }

/* ============================================================
   PAGE LOADING SCREEN
   ============================================================ */

#pageLoader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--app-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#pageLoader.pageLoader-hidden {
  opacity: 0;
  pointer-events: none;
}

#pageLoader .loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

#pageLoader .loader-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink-800);
  letter-spacing: 0.02em;
}

#pageLoader svg {
  width: 160px;
  height: 70px;
  overflow: visible;
}

#pageLoader .loader-line {
  fill: none;
  stroke: url(#loaderGradient);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: loaderDraw 1.1s ease-in-out infinite;
}

#pageLoader .loader-dot {
  fill: var(--brand-500);
  animation: loaderDotMove 1.1s ease-in-out infinite;
}

@keyframes loaderDraw {
  0%   { stroke-dashoffset: 220; }
  50%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -220; }
}

@keyframes loaderDotMove {
  0%   { offset-distance: 0%; opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

.card { transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease; }

/* ============================================================
   COPY-LINK CONTROL
   ============================================================ */

.copy-link-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
}

.copy-link-group .copy-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.copy-link-btn {
  border: 1px solid var(--ink-300);
  background: var(--surface);
  color: var(--ink-600);
  border-radius: 7px;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.copy-link-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.copy-link-btn.copied { background: var(--success); border-color: var(--success); color: #fff; }

/* Inside an input-group, let the copy button stretch to match the
   input's natural height instead of using its fixed small size —
   looks like a normal input-group-appended button. */
.input-group .copy-link-btn {
  width: auto;
  height: auto;
  min-width: 2.6rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0;
  align-self: stretch;
}

.input-group .copy-link-btn:last-child {
  border-top-right-radius: var(--radius-sm) !important;
  border-bottom-right-radius: var(--radius-sm) !important;
}

/* Compact, horizontally-scrollable link preview used inside table
   cells — lets the user drag/scroll sideways to read a long URL
   without blowing up the column width. */
.link-scroll-box {
  max-width: 170px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.link-scroll-box a {
  text-decoration: none;
  font-size: 0.82rem;
}

.link-scroll-box::-webkit-scrollbar { height: 5px; }

* { box-sizing: border-box; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

@media (min-width: 768px) {
  html { font-size: 15.5px; }
}

body {
  background-color: var(--app-bg);
  color: var(--ink-800);
  min-height: 100vh;
}

a { text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
  color: var(--ink-900);
  letter-spacing: -0.01em;
}

.text-muted { color: var(--ink-500) !important; }

/* ============================================================
   PAGE CONTENT SPACING
   ============================================================ */

.app-content { min-height: 100vh; padding-bottom: 2rem; }

.app-content > .container,
.app-content > .container-fluid {
  padding-top: 1.5rem;
}

/* ============================================================
   CARDS / BUTTONS / FORMS
   ============================================================ */

.card {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header { border-radius: var(--radius-md) var(--radius-md) 0 0 !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 1rem;
  transition: transform 0.05s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn-sm { padding: 0.34rem 0.65rem; font-size: 0.8rem; border-radius: 7px; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-600);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-700);
  border-color: var(--brand-700);
}

.btn-outline-secondary { color: var(--ink-700); border-color: var(--ink-300); }
.btn-outline-secondary:hover { background: var(--ink-100); color: var(--ink-900); border-color: var(--ink-300); }

.btn:active { transform: translateY(1px); }

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--ink-300);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.18);
}

.form-label { font-weight: 600; font-size: 0.85rem; color: var(--ink-700); }

.badge { font-weight: 600; border-radius: 6px; padding: 0.38em 0.65em; letter-spacing: 0.01em; }

/* ============================================================
   TABLES
   ============================================================ */

.table {
  --bs-table-hover-bg: var(--brand-50);
  font-size: 0.89rem;
  color: var(--ink-800);
}

.table thead.table-light th {
  background-color: var(--ink-50);
  color: var(--ink-600);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  font-weight: 700;
  border-bottom: 1px solid var(--ink-200);
  white-space: nowrap;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  vertical-align: middle;
}

.table td { vertical-align: middle; padding-top: 0.7rem; padding-bottom: 0.7rem; }

.table > :not(caption) > * > * { box-shadow: none; border-bottom-color: var(--ink-100); }

/* Column divider lines + resize handles for draggable-width tables */
table.st-resizable {
  table-layout: fixed;
  /* border-collapse:collapse (Bootstrap's default) breaks position:sticky
     on table cells in most browsers — separate + zero spacing keeps the
     same visual look while letting the sticky Actions column actually
     stick, in both the header and the body, during horizontal scroll. */
  border-collapse: separate;
  border-spacing: 0;
}

table.st-resizable th,
table.st-resizable td {
  border-right: 1px solid var(--ink-200);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.st-resizable th:last-child,
table.st-resizable td:last-child { border-right: none; }

table.st-resizable th { position: relative; }

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 5;
  touch-action: none;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 3px;
  width: 2px;
  border-radius: 2px;
  background: var(--ink-300);
  transition: background-color 0.15s ease;
}

.col-resize-handle:hover::after,
.col-resize-handle.resizing::after {
  background: var(--brand-500);
}

.sticky-actions {
  position: sticky;
  right: 0;
  z-index: 6;
  background-color: var(--surface) !important;
  box-shadow: -6px 0 10px -6px rgba(15, 23, 42, 0.16);
  overflow: visible !important;
  white-space: nowrap;
}

thead th.sticky-actions {
  background-color: var(--ink-50) !important;
  position: sticky;
  right: 0;
  z-index: 7;
}

/* Actions column never changes color on row hover — keep it neutral
   and always fully legible regardless of scroll position. */
tbody tr:hover .sticky-actions {
  background-color: var(--surface) !important;
}

.summary-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.summary-card:hover { transform: translateY(-2px); }

.action-button { min-width: 65px; }

/* ============================================================
   SMART TABLE TOOLBAR (AWS-console style filter bar)
   ============================================================ */

.smart-toolbar {
  border: 1px solid var(--ink-200);
  border-bottom: none;
  background: var(--ink-50);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0.9rem 1rem 0.75rem;
}

.smart-toolbar .st-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.smart-toolbar .st-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 260px;
}

.smart-toolbar .st-search i {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  font-size: 0.9rem;
}

.smart-toolbar .st-search input {
  width: 100%;
  padding: 0.48rem 0.75rem 0.48rem 2.1rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  background: var(--surface);
}

.smart-toolbar .st-search input:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.15);
}

.smart-toolbar .st-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  padding-left: 0.65rem;
  flex: 0 0 auto;
}

.smart-toolbar .st-filter-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.smart-toolbar .st-filter select {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.47rem 1.9rem 0.47rem 0.4rem;
  font-size: 0.83rem;
  background-color: transparent;
  color: var(--ink-700);
  min-width: 120px;
}

.smart-toolbar .st-filter select:focus { outline: none; }

.smart-toolbar .st-clear {
  border: 1px solid var(--ink-300);
  background: var(--surface);
  color: var(--ink-600);
  border-radius: var(--radius-sm);
  padding: 0.47rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}

.smart-toolbar .st-clear:hover { background: var(--ink-100); color: var(--ink-900); }

.smart-toolbar .st-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--ink-500);
}

.smart-toolbar .st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.smart-toolbar .st-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--brand-100);
  color: var(--brand-800);
  border-radius: 999px;
  padding: 0.22rem 0.55rem 0.22rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.smart-toolbar .st-chip button {
  border: none;
  background: transparent;
  color: var(--brand-700);
  line-height: 1;
  padding: 0;
  font-size: 0.95rem;
}

.smart-toolbar .st-chip button:hover { color: var(--brand-900); }

/* Sortable column headers */
th.st-sortable { cursor: pointer; user-select: none; }

th.st-sortable .st-sort-icon {
  display: inline-block;
  margin-left: 0.3rem;
  opacity: 0.35;
  font-size: 0.7rem;
}

th.st-sortable.st-sort-asc .st-sort-icon,
th.st-sortable.st-sort-desc .st-sort-icon { opacity: 1; color: var(--brand-600); }

/* Smart table footer (pagination) */
.smart-tfoot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--ink-200);
  border-top: none;
  padding: 0.65rem 1rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--surface);
  font-size: 0.82rem;
  color: var(--ink-500);
}

.smart-tfoot .st-pagesize select {
  border: 1px solid var(--ink-300);
  border-radius: 6px;
  padding: 0.25rem 1.6rem 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.smart-tfoot .st-pager { display: flex; align-items: center; gap: 0.3rem; }

.smart-tfoot .st-pager button {
  border: 1px solid var(--ink-300);
  background: var(--surface);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
  color: var(--ink-600);
}

.smart-tfoot .st-pager button:hover:not(:disabled) { background: var(--ink-100); }
.smart-tfoot .st-pager button:disabled { opacity: 0.4; }
.smart-tfoot .st-pager .st-page-indicator { font-size: 0.8rem; color: var(--ink-600); padding: 0 0.3rem; white-space: nowrap; }

.st-row-hidden { display: none !important; }

.st-empty-row td {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-500);
}

/* ============================================================
   MISC
   ============================================================ */

.dashboard-card { transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.dashboard-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg) !important; border-color: var(--brand-200); }
.dashboard-card .bg-opacity-10 { transition: transform 0.25s ease; }
.dashboard-card:hover .bg-opacity-10 { transform: scale(1.08) rotate(-4deg); }

/* ============================================================
   PAGE TITLE CARD — decorates the header of every page
   ============================================================ */

.page-header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--brand-50) 130%);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.6rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-700));
}

html[data-bs-theme="dark"] .page-header {
  background: linear-gradient(135deg, var(--surface) 0%, #1b2338 130%);
}

.page-header h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
  background: linear-gradient(135deg, var(--ink-900), var(--brand-700));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

html[data-bs-theme="dark"] .page-header h1 {
  background: linear-gradient(135deg, #f8fafc, var(--brand-300));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header p { margin-bottom: 0; }

/* Keep the title from squishing/growing the action button(s) when it
   contains long dynamic text (e.g. a long product name). The title
   block shrinks and wraps first; the button(s) never resize. */
.page-header > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.page-header > div:first-child h1,
.page-header > div:first-child p {
  overflow-wrap: break-word;
  word-break: break-word;
}

.page-header > div:last-child {
  flex-shrink: 0;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder { color: var(--ink-500); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 360px;
}

.app-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--surface);
  color: var(--ink-800);
  border: 1px solid var(--ink-200);
  border-left: 4px solid var(--brand-500);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.8rem 0.9rem;
  font-size: 0.87rem;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.show { opacity: 1; transform: translateX(0); }

.app-toast i { font-size: 1.1rem; margin-top: 0.05rem; flex-shrink: 0; }

.app-toast-success { border-left-color: var(--success); }
.app-toast-success i { color: var(--success); }

.app-toast-error { border-left-color: var(--danger); }
.app-toast-error i { color: var(--danger); }

.app-toast-info { border-left-color: var(--info); }
.app-toast-info i { color: var(--info); }

.app-toast-msg { flex: 1; line-height: 1.4; }

.app-toast-close {
  border: none;
  background: transparent;
  color: var(--ink-400);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.app-toast-close:hover { color: var(--ink-700); }

/* ============================================================
   PROFIT / LOSS SEMANTIC COLORS
   ============================================================ */

.text-profit { color: var(--success) !important; }
.text-profit-high { color: #15803d !important; font-weight: 700; }
.text-caution { color: var(--warning) !important; }
.text-loss { color: var(--danger) !important; }

.bg-profit-subtle { background-color: rgba(21, 128, 61, 0.1) !important; color: #15803d !important; }
.bg-caution-subtle { background-color: rgba(217, 119, 6, 0.12) !important; color: #b45309 !important; }
.bg-loss-subtle { background-color: rgba(220, 38, 38, 0.1) !important; color: #b91c1c !important; }

/* ============================================================
   SOURCE / PRODUCT SECTION BACKGROUNDS (Add & Edit Product forms)
   ============================================================ */

.source-section {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.14) 0%, rgba(8, 145, 178, 0.03) 55%, var(--surface) 100%);
  border: 1px solid rgba(8, 145, 178, 0.28) !important;
  box-shadow: 0 6px 20px -8px rgba(8, 145, 178, 0.35), var(--shadow-sm);
}

.source-section::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #22d3ee, #0e7490);
}

.source-section .card-header,
.source-section .section-icon {
  color: #0e7490;
}

.source-section .section-icon {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.28), rgba(8, 145, 178, 0.18));
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.product-section {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.14) 0%, rgba(79, 70, 229, 0.03) 55%, var(--surface) 100%);
  border: 1px solid rgba(79, 70, 229, 0.28) !important;
  box-shadow: 0 6px 20px -8px rgba(79, 70, 229, 0.35), var(--shadow-sm);
}

.product-section::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-700));
}

.product-section .card-header,
.product-section .section-icon {
  color: var(--brand-700);
}

.product-section .section-icon {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.3), rgba(79, 70, 229, 0.18));
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

html[data-bs-theme="dark"] .source-section {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2) 0%, rgba(8, 145, 178, 0.06) 55%, var(--surface) 100%);
  border-color: rgba(34, 211, 238, 0.35) !important;
  box-shadow: 0 6px 24px -8px rgba(34, 211, 238, 0.25), var(--shadow-sm);
}

html[data-bs-theme="dark"] .source-section .card-header,
html[data-bs-theme="dark"] .source-section .section-icon {
  color: #67e8f9;
}

html[data-bs-theme="dark"] .source-section .section-icon {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.35), rgba(8, 145, 178, 0.2));
  box-shadow: 0 2px 10px rgba(34, 211, 238, 0.3);
}

html[data-bs-theme="dark"] .product-section {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.22) 0%, rgba(99, 102, 241, 0.07) 55%, var(--surface) 100%);
  border-color: rgba(129, 140, 248, 0.4) !important;
  box-shadow: 0 6px 24px -8px rgba(129, 140, 248, 0.3), var(--shadow-sm);
}

html[data-bs-theme="dark"] .product-section .card-header,
html[data-bs-theme="dark"] .product-section .section-icon {
  color: #c7d2fe;
}

html[data-bs-theme="dark"] .product-section .section-icon {
  background: linear-gradient(135deg, rgba(165, 180, 252, 0.4), rgba(99, 102, 241, 0.22));
  box-shadow: 0 2px 10px rgba(129, 140, 248, 0.35);
}

.section-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Inline "product name" readout that doubles as an editable field */
.inline-feedback-input {
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.15rem 0.3rem;
  border-bottom: 1px dashed var(--ink-300);
  width: 100%;
  color: var(--brand-700);
}

html[data-bs-theme="dark"] .inline-feedback-input { color: #a5b4fc; }

.inline-feedback-input:focus {
  outline: none;
  border-bottom-color: var(--brand-500);
  background: rgba(79, 70, 229, 0.06);
}

.inline-feedback-input::placeholder { color: var(--ink-400); font-weight: 400; }

/* "Open site" adornment on link inputs */
.link-input-group .btn-open-link {
  color: var(--brand-600);
}

html[data-bs-theme="dark"] .link-input-group .btn-open-link { color: #a5b4fc; }
