/* TexCiti – shared styles */

:root {
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: rgba(29, 78, 216, 0.12);
  --text: #0b1220;
  --text-muted: #5b667a;
  --text-soft: #7b8798;
  --border: #dbe3ee;
  --border-subtle: #e8edf4;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --bg: #f5f7fb;
  --sidebar-bg: #f6f8fb;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --max: 1120px;
  --saas-sidebar-w: 260px;
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(circle at 0 0, #ffffff 0%, var(--bg) 45%);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-nav {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.top-nav__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.user-chip strong {
  color: var(--text);
  font-weight: 600;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.main-wrap {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.page-title {
  margin-bottom: 0.35rem;
}

.page-sub {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.card + .card {
  margin-top: 1rem;
}

.card--flat {
  box-shadow: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.input,
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  background: var(--surface-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--primary-soft);
}

.btn:disabled,
.input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 34px;
}

.btn.is-loading {
  position: relative;
  pointer-events: none;
}

.btn.is-loading::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  display: inline-block;
  animation: btn-spin 0.75s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.search-bar {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-bar .input {
  padding-left: 2.5rem;
}

.search-bar svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-muted {
  background: var(--bg);
  color: var(--text-muted);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.qr-box {
  display: inline-flex;
  padding: 1rem;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.profile-hero {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 700px) {
  .profile-hero {
    flex-direction: row;
    align-items: flex-start;
  }
}

.profile-meta {
  flex: 1;
}

.profile-overview {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 700px) {
  .profile-overview {
    grid-template-columns: 1fr;
  }
}

.products-heading {
  margin: 1rem 0 0.65rem;
}

.products-list {
  margin-top: 0.65rem;
}

.products-list--grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.product-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: var(--surface);
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.product-card h4 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.product-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.image-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.image-grid__item {
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
}

.image-grid__item img {
  transition: transform 0.16s ease;
}

.image-grid__item:hover img {
  transform: scale(1.02);
}

.products-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.product-editor-list {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.product-editor-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-editor-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.product-editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.product-editor-title h4 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.field-hint-error {
  color: #b91c1c;
}

.editor-preview-grid {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.editor-image-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: hidden;
}

.editor-image-preview__open {
  border: none;
  background: none;
  padding: 0;
  width: 100%;
  cursor: zoom-in;
}

.editor-image-preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.editor-image-preview__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
}

.editor-image-preview__actions .btn {
  width: 100%;
  min-height: 36px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
}

.editor-image-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  background: var(--surface-muted);
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.5rem;
}

.editor-image-empty p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

body.viewer-open {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  z-index: 1500;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
}

.image-viewer[hidden] {
  display: none !important;
}

.image-viewer__stage {
  margin: 0;
  max-width: min(92vw, 1100px);
  width: 100%;
  justify-self: center;
}

.image-viewer__stage img {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.image-viewer__caption {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.image-viewer__counter {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.82rem;
  color: #e2e8f0;
}

.image-viewer__close,
.image-viewer__nav {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
}

.image-viewer__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  line-height: 1;
}

.image-viewer__nav {
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
}

@media (max-width: 760px) {
  .image-viewer {
    grid-template-columns: 1fr;
    gap: 1rem;
    justify-items: center;
    padding-top: 3.5rem;
  }

  .image-viewer__nav {
    position: absolute;
    top: calc(50% - 22px);
  }

  .image-viewer__nav--prev {
    left: 0.5rem;
  }

  .image-viewer__nav--next {
    right: 0.5rem;
  }
}

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 1rem;
}

.scanner-region {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f172a;
  min-height: 280px;
}

.admin-gate {
  max-width: 400px;
  margin: 3rem auto;
}

.admin-gate__error {
  margin-top: 1rem;
}

.admin-panel-section {
  margin-top: 1rem;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* —— SaaS dashboard shell (Stripe / Notion–inspired) —— */

body.saas-body {
  background: var(--bg);
}

.saas-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.saas-sidebar {
  width: var(--saas-sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  z-index: 20;
}

.saas-sidebar__brand {
  padding: 0 0.5rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
}

.brand--sidebar {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand--sidebar .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.6875rem;
}

.saas-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
}

.saas-nav__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.saas-nav__link:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
  text-decoration: none;
}

.saas-nav__link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.22);
}

.saas-nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.saas-nav__link.is-active .saas-nav__icon {
  opacity: 1;
}

.saas-nav__btn {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.saas-sidebar__signout {
  width: 100%;
  justify-content: flex-start;
}

.saas-sidebar__footer {
  padding-top: 0.75rem;
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
}

.saas-sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
}

.saas-sidebar__user .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.8125rem;
}

.saas-sidebar__user-meta {
  min-width: 0;
  flex: 1;
}

.saas-sidebar__user-name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saas-sidebar__user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.saas-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.saas-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1.5rem 1.5rem 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
}

.saas-page-intro .page-title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.saas-page-intro .page-sub {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.saas-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.saas-content {
  flex: 1;
  padding: 1.35rem 1.5rem 2.5rem;
  max-width: 1080px;
  width: 100%;
}

.saas-kpi-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 520px) {
  .saas-kpi-row {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

.saas-kpi {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.saas-kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.saas-kpi__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.saas-kpi__value {
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
}

.saas-panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.saas-panel:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.saas-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.saas-panel__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.saas-panel__hint {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.saas-panel__body {
  padding: 1.25rem;
}

.saas-panel__body .search-bar {
  margin-bottom: 0;
}

.saas-panel__body .search-bar + .connection-list {
  margin-top: 1rem;
}

.search-bar--flush .input {
  border-radius: var(--radius-sm);
  border-color: var(--border-subtle);
  background: var(--sidebar-bg);
}

.search-bar--flush .input:focus {
  background: var(--surface);
}

.connection-list {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sidebar-bg);
}

.connection-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  transition: background 0.2s ease;
}

.connection-row:last-child {
  border-bottom: none;
}

.connection-row:hover {
  background: var(--surface-muted);
}

.connection-row__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.connection-row__company {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.connection-row__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}

.connection-row__actions .btn {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .connection-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .connection-row__actions .btn {
    width: 100%;
  }
}

.empty-state--panel {
  padding: 2.5rem 1.25rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-top: 1rem;
}

@media (max-width: 1023px) {
  .saas-shell {
    flex-direction: column;
  }

  .saas-sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .saas-sidebar__brand {
    padding: 0;
    margin: 0;
    border: none;
    flex: 1;
    min-width: 140px;
  }

  .saas-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    order: 3;
    gap: 0.3rem;
  }

  .saas-nav__link {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    min-height: 40px;
  }

  .saas-sidebar__footer {
    display: contents;
  }

  .saas-sidebar__user {
    order: 2;
    margin: 0;
    padding: 0.35rem 0.5rem;
    max-width: 160px;
  }

  .saas-sidebar__footer .btn-ghost {
    order: 4;
    margin-left: auto;
  }
}

@media (max-width: 767px) {
  .main-wrap {
    padding: 1rem 0.9rem 2rem;
  }

  .top-nav__inner {
    padding: 0.8rem 0.9rem;
  }

  .card,
  .saas-panel__body {
    padding: 1rem;
  }

  .saas-topbar {
    padding: 1rem 1rem 0.85rem;
    align-items: stretch;
  }

  .saas-topbar__actions {
    width: 100%;
  }

  .saas-topbar__actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .saas-content {
    padding: 1rem 1rem 2rem;
  }

  .saas-kpi-row {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .products-list--grid {
    grid-template-columns: 1fr;
  }

  .products-editor-head,
  .product-editor-title {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .products-editor-head .btn,
  .product-editor-title .btn {
    min-height: 40px;
  }

  .editor-preview-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    min-height: 44px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .main-wrap {
    padding: 1.25rem 1.1rem 2.2rem;
  }

  .saas-topbar {
    padding: 1.25rem 1.25rem 1rem;
  }

  .saas-content {
    padding: 1.15rem 1.25rem 2.25rem;
  }

  .saas-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .products-list--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .saas-kpi-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .products-list--grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.26);
    --text: #e5ecf7;
    --text-muted: #9aabc4;
    --text-soft: #8395b3;
    --border: #273246;
    --border-subtle: #1e293b;
    --surface: #0f172a;
    --surface-muted: #111b30;
    --bg: #090f1f;
    --sidebar-bg: #0c1427;
    --shadow: 0 1px 2px rgba(2, 6, 23, 0.35), 0 4px 14px rgba(2, 6, 23, 0.45);
    --shadow-lg: 0 12px 32px rgba(2, 6, 23, 0.55);
  }

  body {
    background: radial-gradient(circle at 0 0, #111b32 0%, var(--bg) 45%);
    color: var(--text);
  }

  .brand,
  .saas-panel__title,
  .connection-row__name,
  .saas-kpi__value,
  .stat-card__value {
    color: var(--text);
  }

  .btn {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
  }

  .btn:hover {
    background: #16233f;
  }

  .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #f8fbff;
  }

  .btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
  }

  .badge-success {
    background: rgba(22, 101, 52, 0.36);
    color: #86efac;
  }

  .badge-muted {
    background: #172338;
    color: #b7c6dc;
  }

  .alert-error {
    background: rgba(127, 29, 29, 0.4);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
  }

  .alert-success {
    background: rgba(20, 83, 45, 0.34);
    border-color: rgba(74, 222, 128, 0.34);
    color: #86efac;
  }

  th {
    background: #111c31;
    color: #a7bad6;
  }

  .connection-row:hover {
    background: #12203a;
  }

  .product-card {
    border-color: #26344d;
    background: #111d33;
  }

  .image-grid img {
    border-color: #2b3a54;
  }

  .product-editor-item {
    border-color: #26344d;
    background: #111d33;
  }

  .products-editor-head {
    border-bottom-color: #223149;
  }

  .editor-image-empty {
    border-color: #2c3a52;
    background: #0f1a2f;
  }

  .field-hint-error {
    color: #fca5a5;
  }

  .top-nav,
  .saas-topbar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
  }

  .search-bar svg {
    color: #8fa4c7;
  }

  .image-viewer__stage img {
    background: rgba(15, 23, 42, 0.55);
  }
}
