/* FaktuLink Design System — MASTER.md compliant */

/* ── CSS Variables ── */
:root {
  --color-primary: #6366F1;
  --color-on-primary: #FFFFFF;
  --color-secondary: #818CF8;
  --color-accent: #059669;
  --color-background: #F5F3FF;
  --color-foreground: #1E1B4B;
  --color-muted: #EBEFF9;
  --color-border: #E0E7FF;
  --color-destructive: #DC2626;
  --color-ring: #6366F1;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* ── Typography ── */
/* Font loaded via <link> in HTML for performance */

html, body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--color-foreground);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  color: var(--color-foreground);
}

/* ── Buttons ── */
.btn-primary {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
  color: white !important;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-primary:hover, .btn-primary:focus {
  background: #047857 !important;
  border-color: #047857 !important;
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-outline-primary {
  color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  border-width: 2px;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
  background: var(--color-primary) !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent !important;
  color: var(--color-primary) !important;
  border: 2px solid var(--color-primary) !important;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-secondary:hover, .btn-secondary:focus {
  background: var(--color-primary) !important;
  color: white !important;
  transform: translateY(-1px);
}

.btn-outline-secondary {
  color: var(--color-primary) !important;
  border-color: var(--color-border) !important;
  border-width: 2px;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-outline-secondary:hover {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
  transform: translateY(-1px);
}

.btn-outline-success {
  color: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
  border-width: 2px;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-outline-success:hover {
  background: var(--color-accent) !important;
  color: white !important;
  transform: translateY(-1px);
}

.btn-outline-danger {
  color: var(--color-destructive) !important;
  border-color: var(--color-destructive) !important;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-outline-danger:hover {
  background: var(--color-destructive) !important;
  color: white !important;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-destructive) !important;
  border-color: var(--color-destructive) !important;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 200ms ease;
  cursor: pointer;
}
.btn-danger:hover {
  background: #B91C1C !important;
  border-color: #B91C1C !important;
  transform: translateY(-1px);
}

/* All clickable elements must have cursor:pointer */
a, button, [role="button"], .nav-link, .btn, .card[onclick], [hx-post], [hx-get] {
  cursor: pointer;
}

/* btn-sm override — uniform sizing for action button groups */
.btn-sm {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.8rem !important;
  border-radius: var(--radius-sm) !important;
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius-lg) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: var(--shadow-md);
  transition: all 200ms ease;
}
.card:hover {
  box-shadow: var(--shadow-lg);
}
.card-header {
  background: var(--color-muted) !important;
  border-bottom: 1px solid var(--color-border) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  font-weight: 600;
  color: var(--color-foreground);
}

/* ── Inputs ── */
.form-control, .form-select {
  padding: 0.65rem 1rem;
  border: 1px solid #E2E8F0;
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary) !important;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}

/* ── Tables ── */
.table {
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th {
  font-weight: 600;
  color: var(--color-foreground);
  background: var(--color-muted);
  border-color: var(--color-border);
}
.table td {
  border-color: var(--color-border);
  vertical-align: middle;
}
.table-hover tbody tr {
  transition: background-color 200ms ease;
}
.table-hover tbody tr:hover {
  background-color: rgba(99, 102, 241, 0.04) !important;
}

/* ── Badges ── */
.badge {
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 0.35em 0.65em;
  transition: all 200ms ease;
}
.badge.bg-primary, .bg-primary {
  background-color: var(--color-primary) !important;
}
.badge.bg-success, .bg-success {
  background-color: var(--color-accent) !important;
}
.badge.bg-danger, .bg-danger {
  background-color: var(--color-destructive) !important;
}

/* ── Alerts ── */
.alert {
  border-radius: var(--radius-md);
  border: none;
  font-weight: 500;
}
.alert-warning {
  background: #FEF3C7;
  color: #92400E;
}
.alert-danger {
  background: #FEE2E2;
  color: #991B1B;
}
.alert-success {
  background: #D1FAE5;
  color: #065F46;
}

/* ── Modals ── */
.modal-backdrop {
  backdrop-filter: blur(4px);
}
.modal-content {
  background: white;
  border-radius: var(--radius-xl) !important;
  padding: 0;
  box-shadow: var(--shadow-xl);
  border: none !important;
}
.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-lg);
}
.modal-body {
  padding: var(--space-lg);
}
.modal-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
}

/* ── Focus states (a11y) ── */
:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}
.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35) !important;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Scrollbar styling ── */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-muted);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ── Status colors override ── */
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-accent) !important; }
.text-danger { color: var(--color-destructive) !important; }
.text-info { color: var(--color-secondary) !important; }
.text-warning { color: #D97706 !important; }

/* ── Links ── */
a {
  color: var(--color-primary);
  transition: color 200ms ease;
}
a:hover {
  color: #4F46E5;
}


/* ══════════ Layout (moved from base.html) ══════════ */
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--color-background, #F5F3FF); }
.app-wrapper { display: flex; height: 100vh; background: var(--color-background, #F5F3FF); }

/* ── Sidebar ── */
.sidebar {
  width: 280px; min-width: 280px; height: 100vh;
  background: linear-gradient(180deg, #1E1B4B 0%, #312E81 100%);
  position: fixed; top: 0; left: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  /* Reserve scrollbar space so content never shifts when the sidebar starts to overflow */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
  border-right: none;
  border-radius: 0 16px 16px 0;
}
.main-content {
  margin-left: 280px; flex: 1; overflow-y: auto; height: 100vh;
  background: var(--color-background, #F5F3FF);
  padding: var(--space-lg, 1.5rem);
}

/* Sidebar nav */
.sidebar .nav-link {
  color: rgba(255,255,255,0.65);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md, 8px);
  margin: 2px 0;
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.sidebar .nav-link:hover {
  color: #fff;
  background: rgba(99, 102, 241, 0.2);
}
.sidebar .nav-link.active {
  color: #fff;
  background: var(--color-primary, #6366F1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.sidebar .nav-link i { margin-right: 0.5rem; width: 20px; text-align: center; }

/* Status colors */
.status-success, .status-completed { color: var(--color-accent, #059669); }
.status-error, .status-failed { color: var(--color-destructive, #DC2626); }
.status-partial { color: #D97706; }
.status-running { color: var(--color-primary, #6366F1); }
.badge-synced { background: var(--color-accent, #059669); }

/* ── Animations ── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.anim-slide-in { animation: fadeSlideIn 0.35s ease-out; }

@keyframes rowFlash {
    0%   { background-color: rgba(99, 102, 241, 0.12); }
    100% { background-color: transparent; }
}
tr.row-updated > td { animation: rowFlash 0.8s ease-out; }

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.status-running { animation: statusPulse 1.5s ease-in-out infinite; }

/* Theme toggle */
.theme-toggle .btn {
  padding: 0.4rem 0.65rem; font-size: 1.1rem;
  border-color: var(--color-border);
  transition: all 200ms ease;
}
.theme-toggle .btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Dark mode overrides */
[data-bs-theme="dark"] .main-content { background: #1a1625; }
[data-bs-theme="dark"] .app-wrapper, [data-bs-theme="dark"] body { background: #1a1625; }
[data-bs-theme="dark"] .sidebar { background: linear-gradient(180deg, #0f0d1a 0%, #1a1625 100%); }
[data-bs-theme="dark"] .card { background: #252033; border-color: #3d3556 !important; }
[data-bs-theme="dark"] .card-header { background: #2d2740 !important; color: #E0E7FF; border-color: #3d3556 !important; }
[data-bs-theme="dark"] .table { --bs-table-bg: #252033; --bs-table-striped-bg: #2d2740; --bs-table-hover-bg: #352f48; }
[data-bs-theme="dark"] .table-light { --bs-table-bg: #2d2740; --bs-table-color: #E0E7FF; }
[data-bs-theme="dark"] .table th { background: #2d2740; color: #E0E7FF; }
[data-bs-theme="dark"] .ss-search { background: #252033; border-color: #3d3556; }
[data-bs-theme="dark"] .ss-search input { background: #252033; color: #E0E7FF; border-color: #3d3556; }
[data-bs-theme="dark"] .ss-options div:hover, [data-bs-theme="dark"] .ss-options div.highlighted { background: #352f48; }
[data-bs-theme="dark"] a.text-dark, [data-bs-theme="dark"] .text-dark { color: #E0E7FF !important; }
[data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] .form-control { background-color: #252033; color: #E0E7FF; border-color: #3d3556; }
[data-bs-theme="dark"] .form-select option { background-color: #252033; color: #E0E7FF; }
[data-bs-theme="dark"] .ss-options div { color: #E0E7FF; }
[data-bs-theme="dark"] .ss-options div.selected { background: var(--color-primary); color: #fff; }
[data-bs-theme="dark"] .modal-content { background: #252033; }
[data-bs-theme="dark"] h1, [data-bs-theme="dark"] h2, [data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] h5, [data-bs-theme="dark"] h6 { color: #E0E7FF; }
/* Dark mode text visibility fixes */
[data-bs-theme="dark"] .form-check-label { color: #E0E7FF; }
[data-bs-theme="dark"] .text-muted { color: #A5B4FC !important; }
[data-bs-theme="dark"] label { color: #E0E7FF; }
[data-bs-theme="dark"] p, [data-bs-theme="dark"] span, [data-bs-theme="dark"] small { color: #C7D2FE; }
[data-bs-theme="dark"] .form-check-inline .form-check-label { color: #E0E7FF; }
[data-bs-theme="dark"] .card-body { color: #E0E7FF; }
[data-bs-theme="dark"] td, [data-bs-theme="dark"] .table td { color: #E0E7FF; }
[data-bs-theme="dark"] .nav-tabs .nav-link { color: #A5B4FC; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { color: #fff; background: #352f48; border-color: #3d3556; }
/* Dark mode buttons — no white borders */
[data-bs-theme="dark"] .btn-outline-secondary { border-color: #6366F1 !important; color: #A5B4FC !important; }
[data-bs-theme="dark"] .btn-outline-secondary:hover { background: #6366F1 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-outline-primary { border-color: #818CF8 !important; color: #A5B4FC !important; }
[data-bs-theme="dark"] .btn-outline-primary:hover { background: #6366F1 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-outline-success { border-color: #059669 !important; color: #6EE7B7 !important; }
[data-bs-theme="dark"] .btn-outline-success:hover { background: #059669 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-outline-info { border-color: #818CF8 !important; color: #A5B4FC !important; }
[data-bs-theme="dark"] .btn-outline-info:hover { background: #6366F1 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-outline-warning { border-color: #D97706 !important; color: #FCD34D !important; }
[data-bs-theme="dark"] .btn-outline-warning:hover { background: #D97706 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-outline-danger { border-color: #DC2626 !important; color: #FCA5A5 !important; }
[data-bs-theme="dark"] .btn-outline-danger:hover { background: #DC2626 !important; color: #fff !important; }
[data-bs-theme="dark"] .btn-secondary { border-color: #6366F1 !important; color: #A5B4FC !important; }
[data-bs-theme="dark"] .btn-secondary:hover { background: #6366F1 !important; color: #fff !important; }
/* Dark mode alerts */
[data-bs-theme="dark"] .alert-warning { background: rgba(217, 119, 6, 0.15); color: #FCD34D; border: 1px solid rgba(217, 119, 6, 0.3); }
[data-bs-theme="dark"] .alert-danger { background: rgba(220, 38, 38, 0.15); color: #FCA5A5; border: 1px solid rgba(220, 38, 38, 0.3); }
[data-bs-theme="dark"] .alert-success { background: rgba(5, 150, 105, 0.15); color: #6EE7B7; border: 1px solid rgba(5, 150, 105, 0.3); }
[data-bs-theme="dark"] .alert-info { background: rgba(99, 102, 241, 0.15); color: #A5B4FC; border: 1px solid rgba(99, 102, 241, 0.3); }

/* Sidebar logo area */
.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0 16px 0 0;
  margin: -1rem -1rem 0 -1rem;
  padding: 1.25rem 1rem;
}
.sidebar-brand img {
  height: 36px;
  width: auto;
}
.sidebar-office {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  padding: 0.75rem 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

/* Disk usage bar */
.disk-bar {
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.disk-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms ease;
}

/* ── Mobile top bar ── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
  z-index: 1040;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
}
.mobile-topbar img { height: 28px; }
.mobile-topbar .hamburger {
  background: none; border: none; color: white;
  font-size: 1.5rem; padding: 0.25rem; cursor: pointer;
  transition: transform 200ms ease;
}
.mobile-topbar .hamburger:active { transform: scale(0.9); }

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1049;
  opacity: 0;
  transition: opacity 300ms ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ── Mobile responsive table cards ── */
.mobile-card-list { display: none; }

/* ── Mobile breakpoint ── */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 300ms ease;
    z-index: 1050;
    border-radius: 0 16px 16px 0;
    width: 280px; min-width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(56px + 1rem);
  }
  /* Hide desktop tables, show mobile cards */
  .table-responsive, .table-desktop { display: none !important; }
  .mobile-card-list { display: block !important; }
  /* Stack form columns */
  .row.g-3 > [class*="col-md"], .row.g-4 > [class*="col-md"],
  .row.g-3 > [class*="col-lg"], .row.g-4 > [class*="col-lg"] {
    width: 100% !important;
    flex: 0 0 100% !important;
  }
  /* Dashboard stat cards — 2 columns */
  .row.g-4 > .col-6 { width: 50% !important; flex: 0 0 50% !important; }
  /* Smaller headings */
  h2 { font-size: 1.25rem; }
  /* Card adjustments */
  .card-body { padding: 1rem; }
  /* Button groups wrap */
  .d-flex.gap-2 { flex-wrap: wrap; }
  .d-flex.gap-2 .btn { flex: 1 1 auto; min-width: 120px; }
  /* Bottom padding for browser navbar */
  .main-content { padding-bottom: 5rem !important; }
}

/* ══════════ Searchable select ══════════ */
.searchable-select-wrapper { position: relative; }
.searchable-select-wrapper .ss-search { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1050; background: var(--bs-body-bg, #fff); border: 1px solid var(--color-border, #E0E7FF); border-top: none; border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px); box-shadow: var(--shadow-lg); max-height: 280px; overflow: hidden; }
.searchable-select-wrapper.open .ss-search { display: block; }
.searchable-select-wrapper.open .form-select { border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0; border-color: var(--color-primary, #6366F1); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.card:has(.searchable-select-wrapper.open) { overflow: visible !important; z-index: 1060 !important; position: relative; }
.card-body:has(.searchable-select-wrapper.open) { overflow: visible !important; }
.ss-search input { width: 100%; border: none; border-bottom: 1px solid var(--color-border, #E0E7FF); padding: .5rem .75rem; outline: none; font-size: .875rem; background: transparent; color: var(--bs-body-color); font-family: 'Plus Jakarta Sans', sans-serif; }
.ss-search input::placeholder { color: #adb5bd; }
.ss-options { max-height: 220px; overflow-y: auto; }
.ss-options div { padding: .4rem .75rem; cursor: pointer; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--bs-body-color); transition: background-color 150ms ease; }
.ss-options div:hover, .ss-options div.highlighted { background: var(--color-muted, #EBEFF9); }
.ss-options div.selected { background: var(--color-primary, #6366F1); color: #fff; }
.ss-options div.hidden { display: none; }

/* ══════════ Sidebar sections, account menu, preview switch ══════════ */
.sidebar .nav-section {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4); padding: 0.9rem 1rem 0.3rem;
}
.sidebar .nav-link.nav-link-sm { padding: 0.45rem 1rem; font-size: 0.875rem; }
.sidebar-sync { font-size: 0.75rem; color: rgba(255,255,255,0.6); padding: 0 0.5rem 0.5rem; }
.sidebar-account .account-link {
  display: block; color: rgba(255,255,255,0.6); text-decoration: none;
  font-size: 0.8rem; padding: 0.3rem 0.5rem; border-radius: 6px; background: none; border: 0; width: 100%; text-align: left;
}
.sidebar-account .account-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar-account .account-link i { width: 18px; display: inline-block; }

.view-as-bar {
  display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem;
  margin: calc(-1 * var(--space-lg, 1.5rem)) calc(-1 * var(--space-lg, 1.5rem)) 1rem;
  padding: 0.4rem var(--space-lg, 1.5rem);
  background: var(--color-background, #F5F3FF);
  border-bottom: 1px solid var(--color-border, #E0E7FF);
  font-size: 0.85rem;
}
.view-as-bar.active { background: #FEF3C7; border-bottom-color: #F59E0B; }
[data-bs-theme="dark"] .view-as-bar { background: #1a1625; border-bottom-color: #3d3556; }
[data-bs-theme="dark"] .view-as-bar.active { background: rgba(217,119,6,0.18); border-bottom-color: #D97706; }
.view-as-bar .form-select { width: auto; min-width: 160px; }
.view-as-bar .form-switch .form-check-input { width: 2.4em; height: 1.25em; cursor: pointer; }
@media (max-width: 768px) {
  .view-as-bar { margin: -1rem -1rem 1rem; padding: 0.4rem 1rem; }
  .view-as-bar .form-select { min-width: 0; max-width: 45vw; }
}

/* ══════════ Tables ══════════ */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; }
tr.row-link { cursor: pointer; }
.export-mark { color: var(--color-accent, #059669); }

/* Admin office switcher in the sidebar */
.sidebar .office-switch {
    font-size: 0.75rem;
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}
.sidebar .office-switch option { color: #000; }

/* Terms of service / privacy policy */
.legal-doc h6 { margin-top: 1.1rem; font-weight: 700; }
.legal-doc ol, .legal-doc ul { padding-left: 1.3rem; }
.legal-doc li { margin-bottom: 0.25rem; }

/* Invoice list: stacked cells */
.inv-table td.inv-stack > div { line-height: 1.25; }
.inv-table td.inv-stack code { font-size: 0.72rem; }
.inv-table .th-sub { font-size: 0.68rem; font-weight: 400; color: var(--bs-secondary-color); white-space: nowrap; }
.inv-table .inv-contractor { max-width: 260px; }
.inv-type-switch .btn { padding: 0.45rem 1.1rem !important; font-weight: 600; min-width: 120px;
    background: var(--bs-body-bg) !important; border: 1px solid #CBD5E1 !important; color: #334155 !important; }
.inv-type-switch .btn:hover { background: #F1F5F9 !important; }
.inv-type-switch .btn-check:checked + .btn { color: #fff !important; }
.inv-type-switch .btn-check:checked + .type-all { background: #475569 !important; border-color: #475569 !important; }
.inv-type-switch .btn-check:checked + .type-sales { background: #2563EB !important; border-color: #2563EB !important; }
.inv-type-switch .btn-check:checked + .type-purchases { background: #0891B2 !important; border-color: #0891B2 !important; }
[data-bs-theme="dark"] .inv-type-switch .btn { border-color: #334155 !important; color: #CBD5E1 !important; }
[data-bs-theme="dark"] .inv-type-switch .btn:hover { background: #1E293B !important; }
[data-bs-theme="dark"] .inv-type-switch .btn-check:checked + .btn { color: #fff !important; }
.export-status-line { min-height: 1.4rem; }
/* Sales / purchase badges — same colours as the Sprzedaż / Zakup switch */
.badge.badge-sales { background-color: #2563EB !important; color: #fff !important; }
.badge.badge-purchases { background-color: #0891B2 !important; color: #fff !important; }
/* Currency badges: dark text on a light background in both themes */
.badge.badge-cur-pln { background-color: #F1F5F9 !important; color: #0F172A !important; border: 1px solid #CBD5E1; }
.badge.badge-cur-fx { background-color: #FBBF24 !important; color: #1F2937 !important; }

/* Terms acceptance gate: blurred, inert app shell behind a non-dismissable dialog */
.terms-gate-backdrop { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); background-color: rgba(15, 23, 42, 0.45) !important; opacity: 1 !important; }
.terms-gate { z-index: 1060; }
.terms-gate-docs { max-height: 46vh; overflow-y: auto; }
.terms-gate-bg { pointer-events: none; user-select: none; }
.inv-table .th-sub a { color: inherit; text-decoration: none; }
.inv-table .th-sub a:hover { color: var(--bs-primary); }
.inv-table .th-sub .bi { font-size: 0.6rem !important; }

/* Certificate page: method switch */
.cert-methods .nav-link { border: 1px solid var(--bs-border-color); margin: 0 0.25rem; text-align: left; }
.cert-methods .nav-link small { opacity: 0.8; }
.cert-steps li { margin-bottom: 0.35rem; }

/* Auto-width selects: keep the text clear of the dropdown arrow */
.form-select.w-auto { padding-right: 2.4rem; }
.form-select-sm.w-auto { padding-right: 2.2rem; background-position: right 0.6rem center; }
