/* ═══════════════════════════════════════════════════════════
   RMS Portal — Space-Tech Crystal Design System
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ────────────────────────────────────── */
:root {
  --accent:            #0096cc;
  --accent-hover:      #007aaa;
  --accent-bg:         rgba(0, 150, 204, 0.10);
  --accent-glow:       rgba(0, 180, 255, 0.18);

  --cyan:              #00d4ff;
  --cyan-dim:          rgba(0, 212, 255, 0.55);
  --cyan-glow:         rgba(0, 212, 255, 0.18);

  --apple-red:         #cc4444;
  --apple-green:       #2ea86a;
  --apple-orange:      #cc7a28;
  --apple-yellow:      #c0a000;
  --apple-gray:        #6a7a8a;
  --apple-indigo:      #6060cc;

  --bg:                #e8f0f8;
  --bg-card:           rgba(255, 255, 255, 0.72);
  --bg-elevated:       rgba(255, 255, 255, 0.88);
  --bg-input:          rgba(0, 120, 180, 0.06);
  --bg-sidebar:        #0a1628;
  --bg-topbar:         rgba(232, 240, 248, 0.82);

  --border:            rgba(0, 140, 200, 0.14);
  --border-strong:     rgba(0, 120, 180, 0.22);
  --border-glow:       rgba(0, 200, 255, 0.25);

  --text:              #0a1828;
  --text-muted:        #3a6080;
  --text-faint:        #7aA0b8;

  --sidebar-text:      rgba(180, 220, 255, 0.70);
  --sidebar-act-bg:    rgba(0, 200, 255, 0.14);
  --sidebar-act-text:  #a8e8ff;
  --sidebar-hover-bg:  rgba(0, 180, 255, 0.07);
  --sidebar-border:    rgba(0, 180, 255, 0.10);
  --sidebar-label:     rgba(100, 180, 255, 0.38);

  --shadow-sm:  0 1px 4px rgba(0,80,160,0.10), 0 1px 2px rgba(0,40,80,0.06);
  --shadow-md:  0 4px 20px rgba(0,80,160,0.14), 0 2px 6px rgba(0,40,80,0.08);
  --shadow-glow: 0 0 24px rgba(0,200,255,0.12), 0 0 48px rgba(0,150,255,0.06);

  --r-xs: 6px;  --r-sm: 9px;  --r-md: 13px;  --r-lg: 18px;  --r-xl: 24px;
  --r-pill: 999px;
}

[data-bs-theme="dark"] {
  --accent:            #00c8f0;
  --accent-hover:      #38d8ff;
  --accent-bg:         rgba(0, 200, 240, 0.10);
  --accent-glow:       rgba(0, 200, 255, 0.22);

  --cyan:              #00e8ff;
  --cyan-dim:          rgba(0, 232, 255, 0.55);
  --cyan-glow:         rgba(0, 232, 255, 0.20);

  --apple-red:         #ff5555;
  --apple-green:       #30d080;
  --apple-orange:      #ff9040;

  --bg:                #000000;
  --bg-card:           rgba(0, 6, 18, 0.82);
  --bg-elevated:       rgba(0, 10, 28, 0.92);
  --bg-input:          rgba(0, 140, 200, 0.06);
  --bg-sidebar:        rgba(0, 2, 8, 0.99);
  --bg-topbar:         rgba(0, 4, 14, 0.95);

  --border:            rgba(0, 200, 255, 0.12);
  --border-strong:     rgba(0, 200, 255, 0.22);
  --border-glow:       rgba(0, 220, 255, 0.35);

  --text:              #d0ecff;
  --text-muted:        #6ab0d8;
  --text-faint:        #305880;

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.55), 0 0 12px rgba(0,160,255,0.06);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.70), 0 0 30px rgba(0,160,255,0.10);
  --shadow-glow: 0 0 28px rgba(0,220,255,0.18), 0 0 60px rgba(0,160,255,0.09);
}


/* ── 2. Base & Typography ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont,
               'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 0.9375rem;
}

/* Space grid — dark mode only */
[data-bs-theme="dark"] body {
  background-color: #000000;
  background-image:
    linear-gradient(rgba(0, 160, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 160, 255, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
}

/* Light mode — subtle blue tint gradient */
body:not([data-bs-theme="dark"]) {
  background: linear-gradient(160deg, #e8f2fa 0%, #f0f6ff 50%, #e4eef8 100%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont,
               'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code {
  font-size: 0.85em;
  padding: 0.15em 0.45em;
  border-radius: var(--r-xs);
  background: var(--bg-input);
  color: var(--apple-indigo);
}
[data-bs-theme="dark"] code {
  color: #a0d8ff;
  background: rgba(0, 150, 220, 0.12);
}


/* ── 3. Layout ───────────────────────────────────────────── */
.rms-layout   { display: flex; min-height: 100vh; }
.rms-shell    { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rms-main     { flex: 1; padding: 1.75rem 2rem; background: transparent; }


/* ── 4. Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: 228px;
  min-width: 228px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}

[data-bs-theme="dark"] .sidebar {
  box-shadow: inset -1px 0 0 rgba(0, 200, 255, 0.08), 4px 0 20px rgba(0, 0, 0, 0.4);
}

.sidebar .brand {
  padding: 1.35rem 1.1rem 1.1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.sidebar .brand i { color: var(--cyan); font-size: 1.2rem; }
[data-bs-theme="dark"] .sidebar .brand i {
  filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.sidebar .section-label {
  padding: 1rem 1.1rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sidebar-label);
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 0.48rem 0.8rem;
  margin: 0.1rem 0.55rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 450;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar .nav-link i { font-size: 1rem; flex-shrink: 0; opacity: 0.8; }
.sidebar .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
.sidebar .nav-link.active {
  background: var(--sidebar-act-bg);
  color: var(--sidebar-act-text);
  font-weight: 550;
}
.sidebar .nav-link.active i {
  opacity: 1;
  color: var(--cyan);
}
[data-bs-theme="dark"] .sidebar .nav-link.active i {
  filter: drop-shadow(0 0 5px var(--cyan-glow));
}

/* ── Dongle sidebar widget ───────────────────────────────── */
.dongle-sidebar-widget {
  margin: 0 0.7rem 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  background: var(--sidebar-hover-bg);
  border: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
}
.dongle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #6c757d;
  transition: background 0.3s, box-shadow 0.3s;
}
.dongle-dot.connected {
  background: #30d080;
  box-shadow: 0 0 6px #30d08066, 0 0 12px #30d08033;
}
.dongle-dot.offline { background: #ff5555; box-shadow: 0 0 6px #ff555544; }
.dongle-info { display: flex; flex-direction: column; min-width: 0; }
.dongle-info span { font-size: 0.72rem; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dongle-clicks { color: var(--sidebar-label) !important; font-size: 0.66rem !important; }

.sidebar-footer {
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-footer .username {
  font-size: 0.78rem;
  color: var(--sidebar-label);
  margin-bottom: 0.55rem;
  display: block;
}
.sidebar-footer .btn-logout {
  width: 100%;
  font-size: 0.8rem;
  color: var(--sidebar-text);
  background: var(--sidebar-hover-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--r-sm);
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sidebar-footer .btn-logout:hover {
  background: rgba(0, 180, 255, 0.10);
  border-color: rgba(0, 200, 255, 0.25);
  color: #fff;
}

.sidebar .partner-logo {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar .partner-logo img {
  max-height: 40px;
  max-width: 130px;
  object-fit: contain;
}


/* ── 5. Topbar ───────────────────────────────────────────── */
.topbar {
  background: var(--bg-topbar);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
[data-bs-theme="dark"] .topbar {
  box-shadow: 0 1px 0 rgba(0, 200, 255, 0.08), 0 4px 20px rgba(0, 0, 0, 0.4);
}
.topbar .page-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.balance-badge {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a6040;
  background: rgba(40, 180, 120, 0.14);
  border: 1px solid rgba(40, 180, 120, 0.22);
  padding: 0.28rem 0.75rem;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.balance-badge.low {
  color: #cc3030;
  background: rgba(220, 60, 60, 0.12);
  border-color: rgba(220, 60, 60, 0.22);
}
[data-bs-theme="dark"] .balance-badge {
  color: #30d080;
  background: rgba(40, 200, 120, 0.10);
  border-color: rgba(40, 200, 120, 0.22);
}
[data-bs-theme="dark"] .balance-badge.low {
  color: #ff7070;
  background: rgba(220, 60, 60, 0.12);
  border-color: rgba(220, 60, 60, 0.22);
}

.btn-theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.85rem;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.btn-theme-toggle:hover {
  background: var(--accent-bg);
  border-color: var(--border-glow);
  color: var(--accent);
}


/* ── 6. Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}
[data-bs-theme="dark"] .card {
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.9rem 1.15rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}
.card-body { color: var(--text); }
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--border) !important;
}


/* ── 6b. Partner Cards ────────────────────────────────────── */
.partner-card {
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
  position: relative;
}
.partner-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  background: linear-gradient(135deg,
    rgba(0, 200, 255, 0.04) 0%,
    transparent 50%,
    rgba(0, 100, 200, 0.04) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.partner-card:hover::before { opacity: 1; }

.partner-card:hover {
  box-shadow: var(--shadow-glow), var(--shadow-md) !important;
  border-color: var(--border-glow) !important;
  transform: translateY(-2px);
}
.partner-card .card-body {
  display: flex;
  flex-direction: column;
}

/* Balance row */
.balance-hover-wrap { cursor: default; }

/* Logo slot */
.card-logo-slot {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 130px;
  padding: 0.5rem 0.75rem;
  cursor: default;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
[data-bs-theme="dark"] .card-logo-slot {
  background: rgba(0, 150, 220, 0.05);
  border-color: rgba(0, 180, 255, 0.10);
}
.card-logo-slot .card-logo-img {
  max-height: 110px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
}
[data-bs-theme="dark"] .card-logo-slot .card-logo-img {
  filter: drop-shadow(0 2px 12px rgba(0, 180, 255, 0.20)) brightness(1.05);
}

/* Placeholder shown when partner has no logo */
.card-logo-placeholder {
  position: relative;
  z-index: 1;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  opacity: 0.25;
  user-select: none;
  font-family: 'SF Mono', ui-monospace, monospace;
}

/* Glass tooltip — overlays logo slot on hover */
.card-logo-slot .totals-tip {
  position: absolute;
  inset: 0;
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
  z-index: 2;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(220, 240, 255, 0.55);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(0, 180, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.40);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
[data-bs-theme="dark"] .card-logo-slot .totals-tip {
  background: rgba(2, 18, 48, 0.65);
  backdrop-filter: blur(18px) saturate(220%);
  -webkit-backdrop-filter: blur(18px) saturate(220%);
  border: 1px solid rgba(0, 200, 255, 0.20);
  box-shadow: inset 0 1px 0 rgba(0, 200, 255, 0.10),
              0 0 20px rgba(0, 180, 255, 0.10);
}
.card-logo-slot:hover .totals-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.totals-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.22rem 0;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.totals-tip-row:last-child { border-bottom: none; }
.totals-tip-row .tip-label { font-weight: 500; color: var(--text-muted); }
.totals-tip-row .tip-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
[data-bs-theme="dark"] .totals-tip-row .tip-value { color: var(--cyan); }
.totals-tip-header {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
[data-bs-theme="dark"] .totals-tip-header {
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
}

.badge-active {
  background: rgba(40, 180, 120, 0.14);
  color: #1a6040;
  border: 1px solid rgba(40, 180, 120, 0.22);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 0.22em 0.65em;
}
[data-bs-theme="dark"] .badge-active {
  background: rgba(40, 200, 120, 0.12);
  color: #30d080;
  border-color: rgba(40, 200, 120, 0.28);
}

.partner-financials {
  display: flex;
  align-items: stretch;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  padding: 0.65rem 0;
  border: 1px solid var(--border);
}
.fin-item {
  flex: 1;
  text-align: center;
  padding: 0 0.5rem;
}
.fin-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.fin-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fin-currency {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  margin-top: 0.08rem;
}
.fin-positive { color: #1a7a4a !important; }
.fin-negative { color: #aa3030 !important; }
[data-bs-theme="dark"] .fin-positive { color: #30d080 !important; }
[data-bs-theme="dark"] .fin-negative { color: #ff7070 !important; }

.fin-divider {
  width: 1px;
  background: var(--border);
  margin: 0.25rem 0;
  flex-shrink: 0;
}

/* Annual breakdown rows */
.annual-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}
.annual-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  gap: 0.5rem;
}
.annual-row > *:not(:first-child) { text-align: right; }
.annual-yr {
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.annual-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}


/* ── 7. Tables ───────────────────────────────────────────── */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  font-size: 0.875rem;
  color: var(--text);
}
.table thead tr {
  border-bottom: 1px solid var(--border-strong);
}
.table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.65rem 0.85rem;
  background: transparent;
  border-bottom: none;
}
[data-bs-theme="dark"] .table th { color: var(--accent); }
.table td {
  padding: 0.65rem 0.85rem;
  border-color: var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table-hover tbody tr:hover > * {
  background: var(--accent-bg);
}
[data-bs-theme="dark"] .table-hover tbody tr:hover > * {
  background: rgba(0, 180, 255, 0.06);
}
.table-sm th, .table-sm td { padding: 0.45rem 0.85rem; }


/* ── 8. Buttons ──────────────────────────────────────────── */
.btn {
  border-radius: var(--r-sm);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  transition: all 0.15s ease;
  border-width: 1px;
}
.btn-sm  { border-radius: var(--r-xs); font-size: 0.8rem; padding: 0.28rem 0.7rem; }
.btn-lg  { border-radius: var(--r-md); font-size: 1rem;   padding: 0.65rem 1.4rem; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 6px var(--accent-glow);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:active { transform: scale(0.98); }

.btn-success {
  background: #1f9060;
  border-color: #1f9060;
  color: #fff;
  box-shadow: 0 1px 6px rgba(30, 160, 100, 0.25);
}
.btn-success:hover {
  background: #187a50;
  border-color: #187a50;
  color: #fff;
  box-shadow: 0 2px 10px rgba(30, 160, 100, 0.35);
}

.btn-danger {
  background: #b03030;
  border-color: #b03030;
  color: #fff;
  box-shadow: 0 1px 6px rgba(200, 60, 60, 0.25);
}
.btn-danger:hover {
  background: #952828;
  border-color: #952828;
  color: #fff;
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--accent-bg);
  border-color: var(--border-glow);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border-strong);
  background: transparent;
}
.btn-outline-secondary:hover {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border-glow);
}

.btn-outline-danger {
  color: #b03030;
  border-color: rgba(180, 60, 60, 0.45);
  background: transparent;
}
.btn-outline-danger:hover {
  background: rgba(200, 60, 60, 0.08);
  color: #901010;
  border-color: rgba(180, 60, 60, 0.65);
}
[data-bs-theme="dark"] .btn-outline-danger {
  color: #ff7070;
  border-color: rgba(255, 80, 80, 0.30);
}
[data-bs-theme="dark"] .btn-outline-danger:hover {
  background: rgba(255, 60, 60, 0.10);
  color: #ffaaaa;
  border-color: rgba(255, 80, 80, 0.55);
}


/* ── 9. Form Controls ────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  backdrop-filter: blur(8px);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg), 0 0 12px var(--accent-glow);
  color: var(--text);
  outline: none;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:disabled, .form-select:disabled {
  background: var(--bg-input);
  color: var(--text-muted);
  opacity: 0.7;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.form-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.input-group .form-control:not(:last-child)  { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .form-control:not(:first-child) { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; }


/* ── 10. Alerts ──────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  border: none;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  backdrop-filter: blur(10px);
}
.alert-success {
  background: rgba(40, 180, 100, 0.12);
  color: #165c38;
  border-left: 3px solid #30a060;
  border: 1px solid rgba(40, 180, 100, 0.20);
  border-left: 3px solid #30a060;
}
[data-bs-theme="dark"] .alert-success {
  background: rgba(30, 180, 100, 0.10);
  color: #30d080;
  border-color: rgba(40, 200, 100, 0.20);
  border-left-color: #28c070;
}
.alert-danger {
  background: rgba(200, 60, 60, 0.10);
  color: #7a1a1a;
  border: 1px solid rgba(200, 60, 60, 0.20);
  border-left: 3px solid #c04040;
}
[data-bs-theme="dark"] .alert-danger {
  background: rgba(220, 60, 60, 0.10);
  color: #ff7070;
  border-color: rgba(220, 60, 60, 0.22);
  border-left-color: #dd5050;
}
.alert-warning {
  background: rgba(200, 150, 30, 0.10);
  color: #7a4800;
  border: 1px solid rgba(200, 150, 30, 0.20);
  border-left: 3px solid #c09030;
}
[data-bs-theme="dark"] .alert-warning {
  background: rgba(220, 160, 40, 0.10);
  color: #ffcc60;
  border-color: rgba(220, 160, 40, 0.22);
  border-left-color: #ddaa30;
}
.alert-info {
  background: rgba(0, 180, 240, 0.10);
  color: #0a4060;
  border: 1px solid rgba(0, 180, 240, 0.20);
  border-left: 3px solid #0090c0;
}
[data-bs-theme="dark"] .alert-info {
  background: rgba(0, 200, 255, 0.08);
  color: #70d8ff;
  border-color: rgba(0, 200, 255, 0.18);
  border-left-color: #00c8f0;
}
.alert-secondary {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-close { opacity: 0.5; }
.btn-close:hover { opacity: 1; }


/* ── 11. Badges ──────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: 0.72rem;
  border-radius: var(--r-pill);
  padding: 0.28em 0.65em;
}

.bg-primary   { background: rgba(0, 140, 220, 0.14) !important; color: #005888 !important; border: 1px solid rgba(0, 140, 220, 0.22) !important; }
.bg-success   { background: rgba(30, 160, 90, 0.12) !important; color: #155c38 !important; border: 1px solid rgba(30, 160, 90, 0.22) !important; }
.bg-danger    { background: rgba(200, 50, 50, 0.12) !important; color: #7a1a1a !important; border: 1px solid rgba(200, 50, 50, 0.22) !important; }
.bg-warning   { background: rgba(200, 140, 20, 0.12) !important; color: #7a4800 !important; border: 1px solid rgba(200, 140, 20, 0.22) !important; }
.bg-secondary { background: rgba(80, 100, 130, 0.12) !important; color: #3a5070 !important; border: 1px solid rgba(80, 100, 130, 0.20) !important; }
.bg-info      { background: rgba(0, 180, 240, 0.12) !important; color: #005070 !important; border: 1px solid rgba(0, 180, 240, 0.22) !important; }

[data-bs-theme="dark"] .bg-primary   { background: rgba(0, 180, 255, 0.12) !important; color: #70c8ff !important; border-color: rgba(0, 180, 255, 0.22) !important; }
[data-bs-theme="dark"] .bg-success   { background: rgba(30, 200, 100, 0.10) !important; color: #30d080 !important; border-color: rgba(30, 200, 100, 0.22) !important; }
[data-bs-theme="dark"] .bg-danger    { background: rgba(220, 60, 60, 0.12) !important;  color: #ff7070 !important; border-color: rgba(220, 60, 60, 0.22) !important; }
[data-bs-theme="dark"] .bg-warning   { background: rgba(220, 160, 30, 0.10) !important; color: #ffcc60 !important; border-color: rgba(220, 160, 30, 0.22) !important; }
[data-bs-theme="dark"] .bg-secondary { background: rgba(60, 100, 150, 0.14) !important; color: #88b0d8 !important; border-color: rgba(60, 100, 150, 0.22) !important; }
[data-bs-theme="dark"] .bg-info      { background: rgba(0, 200, 255, 0.10) !important;  color: #60d8ff !important; border-color: rgba(0, 200, 255, 0.22) !important; }


/* ── 12. Nav Tabs ────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid var(--border);
  gap: 0.1rem;
}
.nav-tabs .nav-link {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.6rem 0.9rem;
  margin-bottom: -1px;
  transition: color 0.15s ease;
  background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--text); }
.nav-tabs .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
  font-weight: 600;
}
[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
}
.tab-content.border {
  border-color: var(--border) !important;
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
}


/* ── 13. Pagination ──────────────────────────────────────── */
.pagination { gap: 0.15rem; }
.page-link {
  border-radius: var(--r-xs) !important;
  border: 1px solid var(--border);
  color: var(--accent);
  background: var(--bg-card);
  padding: 0.3rem 0.65rem;
  font-size: 0.84rem;
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
}
.page-link:hover {
  background: var(--accent-bg);
  border-color: var(--border-glow);
  color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}
.page-item.disabled .page-link {
  color: var(--text-faint);
  background: transparent;
  border-color: var(--border);
}


/* ── 14. Modals ──────────────────────────────────────────── */
.modal-content {
  border-radius: var(--r-lg);
  border: 1px solid var(--border-glow);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.3rem;
}
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 0.9rem 1.3rem;
}
.modal-backdrop { backdrop-filter: blur(6px); }


/* ── 15. Dropdowns ───────────────────────────────────────── */
.dropdown-menu {
  border-radius: var(--r-md);
  border: 1px solid var(--border-glow);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  padding: 0.4rem;
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
}
.dropdown-item {
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.42rem 0.75rem;
}
.dropdown-item:hover {
  background: var(--accent-bg);
  color: var(--accent);
}
.dropdown-divider { border-color: var(--border); margin: 0.3rem 0; }


/* ── 16. Background Sections ─────────────────────────────── */
.bg-light  { background: var(--bg-input) !important; }
.bg-white  { background: var(--bg-card)  !important; }
.border    { border-color: var(--border) !important; }
.border-top    { border-top-color: var(--border) !important; }
.border-bottom { border-bottom-color: var(--border) !important; }

.rounded       { border-radius: var(--r-sm) !important; }
.rounded-2     { border-radius: var(--r-md) !important; }
.rounded-3     { border-radius: var(--r-lg) !important; }
.rounded-pill  { border-radius: var(--r-pill) !important; }


/* ── 17. Font Monospace ──────────────────────────────────── */
.font-monospace {
  font-family: 'SF Mono', ui-monospace, 'Cascadia Code',
               'Menlo', 'Consolas', monospace;
  font-size: 0.85em;
}


/* ── 18. Logo Display ────────────────────────────────────── */
.logo-img {
  display: block;
  margin: 0 auto;
  max-height: 48px;
  max-width: 160px;
  object-fit: contain;
}

.logo-display-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 90px;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  padding: 1rem;
  border: 1px solid var(--border);
}
.logo-display-img {
  display: block;
  max-height: 72px;
  max-width: 220px;
  object-fit: contain;
}
.logo-placeholder { text-align: center; }

.sidebar .partner-logo {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  justify-content: center;
  align-items: center;
}
.sidebar .partner-logo img {
  display: block;
  max-height: 44px;
  max-width: 140px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 4px 8px;
}

.card-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.25rem;
  min-height: 28px;
}
.card-logo img {
  display: block;
  max-height: 28px;
  max-width: 100px;
  object-fit: contain;
}


/* ── 19. Login Page ──────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 2rem;
}
[data-bs-theme="dark"] .login-wrap {
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 100, 200, 0.15) 0%, transparent 60%), #010b18;
  background-attachment: fixed;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.login-card .login-logo i {
  color: var(--accent);
  margin-right: 0.4rem;
}
[data-bs-theme="dark"] .login-card .login-logo i {
  filter: drop-shadow(0 0 8px var(--cyan-glow));
}


/* ── 20. Sortable Table Headers ──────────────────────────── */
.sort-th {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  transition: color 0.15s ease;
}
.sort-th:hover { color: var(--accent); }
.sort-th.sort-active { color: var(--accent); }
.sort-icon { font-size: 0.65em; opacity: 0.7; }
.sort-icon-idle { opacity: 0.3; }
.sort-th:hover .sort-icon-idle { opacity: 0.6; }
.sort-th.sort-active .sort-icon { opacity: 1; }


/* ── 21. Utility Overrides ───────────────────────────────── */
.fw-semibold { font-weight: 580; }

.text-success   { color: #1a7a4a !important; }
.text-danger    { color: #aa3030 !important; }
.text-warning   { color: #7a4800 !important; }
.text-primary   { color: var(--accent) !important; }
.text-secondary { color: var(--text-muted) !important; }
[data-bs-theme="dark"] .text-success { color: #30d080 !important; }
[data-bs-theme="dark"] .text-danger  { color: #ff7070 !important; }
[data-bs-theme="dark"] .text-warning { color: #ffcc60 !important; }

hr { border-color: var(--border); opacity: 1; }


/* ── 22. Scanline / HUD overlay (dark mode only) ─────────── */
[data-bs-theme="dark"] .rms-main::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 180, 255, 0.012) 2px,
    rgba(0, 180, 255, 0.012) 4px
  );
  mix-blend-mode: screen;
}
[data-bs-theme="dark"] .rms-main > * { position: relative; z-index: 1; }

/* Corner accent on partner cards (dark mode) */
[data-bs-theme="dark"] .partner-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 40px; height: 40px;
  background: linear-gradient(225deg, rgba(0, 200, 255, 0.12) 0%, transparent 60%);
  border-radius: 0 var(--r-md) 0 0;
  pointer-events: none;
}


/* ── 23. Smooth transitions ──────────────────────────────── */
*, *::before, *::after {
  transition: background-color 0.2s ease, border-color 0.2s ease,
              color 0.1s ease, box-shadow 0.18s ease;
}
.btn, a, .nav-link, .form-control, .form-select { transition: none; }
.btn {
  transition: background-color 0.12s ease, border-color 0.12s ease,
              box-shadow 0.12s ease, transform 0.08s ease;
}
.nav-link { transition: background 0.15s ease, color 0.15s ease; }
.form-control, .form-select {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card-logo-slot .totals-tip {
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
.partner-card {
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

/* Spin animation for refresh button */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.6s linear infinite; }

/* Pulse glow for active dongle status */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 6px #30d08066; }
  50%       { box-shadow: 0 0 12px #30d08099, 0 0 20px #30d08033; }
}
.dongle-dot.connected { animation: pulse-glow 2.4s ease-in-out infinite; }
