:root,
html[data-theme="light"] {
  --sidebar-width: 260px;
  --sidebar-collapsed: 76px;
  --sidebar-bg: #111827;
  --sidebar-text: #e5e7eb;
  --frame-bg: #f3f4f6;
  --topbar-bg: #111827;
  --topbar-text: #fff;
  --topbar-muted: #e5e7eb;
  --card-bg: #fff;
  --card-border: #e5e7eb;
  --text: #212529;
  --muted: #6c757d;
  --accent: #2563eb;
  --table-stripe: rgba(0, 0, 0, 0.03);
  --input-bg: #fff;
  --map-border: #e5e7eb;
  color-scheme: light;
}

html[data-theme="dark"] {
  --sidebar-bg: #020617;
  --sidebar-text: #e2e8f0;
  --frame-bg: #0f172a;
  --topbar-bg: #020617;
  --topbar-text: #f8fafc;
  --topbar-muted: #cbd5e1;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --table-stripe: rgba(255, 255, 255, 0.04);
  --input-bg: #0f172a;
  --map-border: #334155;
  color-scheme: dark;
}

html[data-theme="forest"] {
  --sidebar-bg: #0c2f24;
  --sidebar-text: #e8f0ea;
  --frame-bg: #eef4ef;
  --topbar-bg: #0f3d2e;
  --topbar-text: #f8f5ea;
  --topbar-muted: #e8c872;
  --card-bg: #f7fbf7;
  --card-border: #c9d9cc;
  --text: #143226;
  --muted: #4d6b5c;
  --accent: #0f3d2e;
  --table-stripe: rgba(15, 61, 46, 0.05);
  --input-bg: #fff;
  --map-border: #c9d9cc;
  color-scheme: light;
}

html {
  font-size: 14px;
  height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body.app-body {
  margin: 0;
  min-height: 100%;
  background: var(--frame-bg);
  color: var(--text);
}

.hero {
  padding: 0.5rem 0 0.75rem;
}

.area-card {
  border-radius: 0.75rem;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.sidebar-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: #2563eb;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: none;
}

.sidebar-brand-text {
  font-weight: 650;
  white-space: nowrap;
}

.sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-role {
  font-size: 0.7rem;
  font-weight: 500;
  color: #9ca3af;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-label,
.app-sidebar.collapsed .sidebar-section,
.app-sidebar.collapsed .sidebar-role {
  display: none;
}

.sidebar-toggle {
  border: 0;
  background: transparent;
  color: #9ca3af;
  width: 2rem;
  height: 2rem;
  border-radius: 0.4rem;
  display: grid;
  place-items: center;
  padding: 0;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-toggle-icon,
.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
  display: block;
  width: 14px;
  height: 2px;
  background: currentColor;
  position: relative;
}

.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.sidebar-toggle-icon::before { top: -5px; }
.sidebar-toggle-icon::after { top: 5px; }

.sidebar-nav {
  padding: 0.75rem 0.6rem 1.5rem;
  overflow: auto;
  flex: 1;
}

.sidebar-section {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 0.85rem 0.7rem 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #d1d5db;
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.28);
  color: #fff;
}

.sidebar-ico {
  width: 1.25rem;
  text-align: center;
  flex: none;
}

.sidebar-group {
  margin-bottom: 0.15rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.sidebar-item .sidebar-link {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.sidebar-group-head {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.sidebar-plus {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: #9ca3af;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

.sidebar-plus::before {
  content: "+";
  font-size: 1.15rem;
  font-weight: 600;
}

.sidebar-plus:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-group.open > .sidebar-item .sidebar-plus::before {
  content: "−";
}

.sidebar-group-items {
  display: none;
  padding: 0.15rem 0 0.25rem 0.55rem;
  margin: 0.1rem 0 0.2rem 0.55rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-group.open > .sidebar-group-items {
  display: block;
}

.sidebar-group-items .sidebar-link {
  padding: 0.42rem 0.55rem;
  font-size: 0.92em;
}

.app-sidebar.collapsed .sidebar-plus,
.app-sidebar.collapsed .sidebar-group-items {
  display: none;
}

.app-frame {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.app-sidebar.collapsed ~ .app-frame {
  margin-left: var(--sidebar-collapsed);
}

.app-body.no-sidebar .app-frame {
  margin-left: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--topbar-text);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-brand:hover {
  color: var(--topbar-text);
}

.topbar-user {
  margin-left: auto;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.5rem 1.25rem;
  background: var(--topbar-bg);
  color: var(--topbar-text);
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.page-nav-page {
  margin: 0 0 1rem;
}

.topbar-title {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-link {
  color: var(--topbar-muted);
  text-decoration: none;
}

.topbar-link:hover {
  color: var(--topbar-text);
}

.theme-form {
  margin: 0;
}

.theme-select {
  width: auto;
  min-width: 7.5rem;
  background: rgba(255, 255, 255, 0.12);
  color: var(--topbar-text);
  border-color: rgba(255, 255, 255, 0.28);
}

.theme-select option {
  color: #111827;
}

.app-content {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
}

.app-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
}

.app-footer a {
  color: inherit;
  text-underline-offset: 0.15em;
}

.footer-sep {
  opacity: 0.55;
}

.card,
.activation-card,
.activation-fleet,
.activation-ops {
  background: var(--card-bg);
  border-color: var(--card-border);
  color: var(--text);
}

.text-muted {
  color: var(--muted) !important;
}

.table {
  --bs-table-bg: var(--card-bg);
  --bs-table-color: var(--text);
  --bs-table-striped-bg: var(--table-stripe);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: var(--table-stripe);
  --bs-table-hover-color: var(--text);
  --bs-table-border-color: var(--card-border);
}

.form-control,
.form-select {
  background-color: var(--input-bg);
  color: var(--text);
  border-color: var(--card-border);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--input-bg);
  color: var(--text);
}

.sale-map {
  height: 320px;
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--map-border);
  z-index: 1;
}

.sale-map-capture {
  height: 420px;
}

.sale-map-full {
  height: calc(100vh - 14rem);
  min-height: 480px;
}

.sale-map-popup {
  min-width: 180px;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-toggle-mobile {
  display: grid;
  color: #fff;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-frame,
  .app-sidebar.collapsed ~ .app-frame {
    margin-left: 0;
  }

  .sidebar-toggle-mobile {
    display: grid;
  }

  .app-sidebar .sidebar-toggle {
    display: none;
  }

  .app-sidebar.mobile-open ~ .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1030;
  }

  .app-sidebar.collapsed .sidebar-brand-text,
  .app-sidebar.collapsed .sidebar-label,
  .app-sidebar.collapsed .sidebar-section {
    display: inline;
  }

  .app-sidebar.collapsed .sidebar-label,
  .app-sidebar.collapsed .sidebar-brand-text,
  .app-sidebar.collapsed .sidebar-section {
    display: revert;
  }

  .app-sidebar.collapsed .sidebar-brand-text,
  .app-sidebar.collapsed .sidebar-label {
    display: inline;
  }

  .app-sidebar.collapsed .sidebar-section {
    display: block;
  }

  .app-sidebar.collapsed .sidebar-plus {
    display: grid;
  }

  .app-sidebar.collapsed .sidebar-group.open > .sidebar-group-items {
    display: block;
  }
}

@media print {
  .app-sidebar,
  .app-topbar,
  .page-nav,
  .app-footer,
  .sidebar-toggle,
  .d-flex.gap-2 {
    display: none !important;
  }

  .app-frame {
    margin-left: 0 !important;
  }

  .invoice-sheet {
    border: 0;
    box-shadow: none;
  }
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.activation-hero {
  background: linear-gradient(135deg, #0f3d2e 0%, #163a5f 58%, #111827 100%);
  color: #fff;
  border-radius: 1rem;
  padding: 1.75rem 1.5rem 1.5rem;
  margin-bottom: 1.75rem;
}

.activation-kicker {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 0.35rem;
}

.activation-title {
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.activation-lead {
  max-width: 42rem;
  opacity: 0.92;
  margin-bottom: 1.25rem;
}

.activation-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.activation-stats div {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 0.7rem;
  padding: 0.7rem 0.85rem;
}

.activation-stats strong {
  display: block;
  font-size: 1.45rem;
  color: #e8c872;
}

.activation-stats span {
  font-size: 0.8rem;
  opacity: 0.85;
}

.activation-card,
.activation-fleet {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.85rem;
  padding: 1.1rem 1.15rem;
}

.activation-card-tag {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #0f3d2e;
  color: #e8c872;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-bottom: 0.55rem;
}

.activation-fleet-count {
  font-size: 2rem;
  font-weight: 700;
  color: #0f3d2e;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.activation-table {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
}

.activation-ops {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.85rem;
  padding: 0.85rem 1.1rem;
}

.activation-ops summary {
  cursor: pointer;
  font-weight: 600;
}

@media (max-width: 767.98px) {
  .activation-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activation-hero {
    padding: 1.25rem 1rem 1.15rem;
  }

  .activation-table {
    max-height: 220px;
  }
}

body.auth-shell {
  background: #07111f;
  color: #e2e8f0;
}

body.auth-shell .app-frame {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  background: transparent;
}

body.auth-shell .app-footer {
  position: relative;
  z-index: 3;
  justify-content: center;
  color: #94a3b8;
  text-align: center;
}

body.auth-shell .app-footer a {
  color: #cbd5e1;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.35), transparent 55%),
    radial-gradient(900px 500px at 90% 110%, rgba(14, 165, 233, 0.22), transparent 50%),
    linear-gradient(160deg, #07111f 0%, #0b1b33 45%, #10243f 100%);
}

.auth-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 78%);
}

.auth-dash {
  position: absolute;
  inset: 4vh 5vw;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.25rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  padding: 1.25rem 1.4rem 1.5rem;
  color: #cbd5e1;
  pointer-events: none;
}

.auth-dash-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 1rem;
}

.auth-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auth-kpis article {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
}

.auth-kpis span,
.auth-table li span,
.auth-chart-title {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.auth-kpis strong {
  display: block;
  font-size: 1.45rem;
  color: #f8fafc;
  margin: 0.2rem 0;
}

.auth-kpis em {
  font-style: normal;
  color: #34d399;
  font-size: 0.8rem;
}

.auth-panels {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 0.85rem;
  min-height: 42vh;
}

.auth-chart,
.auth-table {
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 0.9rem;
  padding: 1rem;
}

.auth-chart svg {
  width: 100%;
  height: 110px;
  margin: 0.5rem 0;
}

.auth-chart polyline {
  fill: none;
  stroke: #60a5fa;
  stroke-width: 3;
}

.auth-chart .auth-chart-fill {
  stroke: none;
  fill: url(#none);
  fill: rgba(37, 99, 235, 0.2);
}

.auth-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  height: 72px;
}

.auth-bars span {
  flex: 1;
  height: var(--h);
  border-radius: 0.3rem 0.3rem 0 0;
  background: linear-gradient(180deg, #38bdf8, #1d4ed8);
  opacity: 0.85;
}

.auth-table ul {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}

.auth-table li {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
}

.auth-stage {
  min-height: calc(100vh - 5.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-radius: 1.15rem;
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
  padding: 1.75rem 1.65rem 1.85rem;
  position: relative;
  z-index: 3;
}

html[data-theme="dark"] .auth-card {
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  margin-bottom: 1.25rem;
}

.auth-brand strong {
  display: block;
  line-height: 1.1;
}

.auth-brand small {
  display: block;
  color: #64748b;
  font-size: 0.78rem;
}

.auth-card .btn-dark {
  padding: 0.6rem 1rem;
}

@media (max-width: 767.98px) {
  .auth-kpis,
  .auth-panels {
    grid-template-columns: 1fr 1fr;
  }

  .auth-dash {
    inset: 1rem;
    padding: 0.75rem;
  }

  .auth-table,
  .auth-kpis article:nth-child(n + 3) {
    display: none;
  }
}

.app-toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(26rem, calc(100vw - 1.5rem));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 0.35rem 1fr auto;
  align-items: start;
  gap: 0.7rem;
  padding: 0.85rem 0.85rem 0.85rem 0;
  border-radius: 0.85rem;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
  animation: app-toast-in 0.22s ease-out;
}

html[data-theme="dark"] .app-toast {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

.app-toast-bar {
  align-self: stretch;
  border-radius: 0.85rem 0 0 0.85rem;
}

.app-toast.success .app-toast-bar { background: #16a34a; }
.app-toast.error .app-toast-bar,
.app-toast.failed .app-toast-bar { background: #dc2626; }
.app-toast.warning .app-toast-bar { background: #d97706; }
.app-toast.info .app-toast-bar { background: #2563eb; }

.app-toast-copy {
  min-width: 0;
  padding: 0.05rem 0;
}

.app-toast-title {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.app-toast.success .app-toast-title { color: #15803d; }
.app-toast.error .app-toast-title,
.app-toast.failed .app-toast-title { color: #b91c1c; }
.app-toast.warning .app-toast-title { color: #b45309; }
.app-toast.info .app-toast-title { color: #1d4ed8; }

.app-toast-text {
  font-size: 0.92rem;
  line-height: 1.35;
  word-break: break-word;
}

.app-toast-close {
  border: 0;
  background: transparent;
  color: #64748b;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.4rem;
  line-height: 1;
  font-size: 1.1rem;
}

.app-toast-close:hover {
  background: var(--table-stripe);
  color: var(--text);
}

@keyframes app-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

body.auth-shell .app-toast-host {
  top: 1.25rem;
}

.brochure-hero .brochure-actions .btn-light {
  color: #0f3d2e;
}

@media print {
  .app-topbar,
  .app-footer,
  .brochure-actions,
  .sidebar-backdrop {
    display: none !important;
  }

  .brochure-hero,
  .activation-hero {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .activation-card {
    break-inside: avoid;
  }
}
