/* ==========================================================================
   Rede Neutra — Modern Design System (Dark & Light Theme)
   ========================================================================== */

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #090f1d;
  --bg-surface: #0e172a;
  --bg-surface-elevated: #132238;
  --bg-surface-hover: #182a44;
  --bg-sidebar: #0a1222;
  --bg-topbar: #0c1628;
  --bg-input: #091222;
  --border: #1e2e46;
  --border-focus: #14b8a6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --teal: #0d9488;
  --teal-light: #14b8a6;
  --teal-dark: #0f766e;
  --teal-glow: rgba(20, 184, 166, 0.22);

  --cyan: #06b6d4;
  --blue: #3b82f6;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.14);
  --success-border: rgba(16, 185, 129, 0.35);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.35);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-border: rgba(239, 68, 68, 0.35);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);

  --sidebar-w: 250px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --bg-input: #ffffff;
  --border: #e2e8f0;
  --border-focus: #0d9488;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --teal: #0d9488;
  --teal-light: #0f766e;
  --teal-dark: #115e59;
  --teal-glow: rgba(13, 148, 136, 0.15);

  --cyan: #0891b2;
  --blue: #2563eb;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --sidebar-w: 250px;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-canvas);
  color: var(--text-main);
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-main);
  font: 14.5px/1.55 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--teal-light);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--cyan);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-main);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

h1 { font-size: clamp(22px, 2.5vw, 28px); }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 6px 0 12px; color: var(--text-muted); }

/* ==========================================================================
   App Shell Layout (Desktop Sidebar + Topbar + Main)
   ========================================================================== */

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  background: var(--bg-canvas);
}

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  overflow-y: auto;
}

.brand {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 6px;
  padding: 4px 6px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal-light), var(--teal-dark));
  color: white;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 4px 14px var(--teal-glow);
}

.brand-logo {
  display: block;
  max-width: 175px;
  max-height: 46px;
  width: auto;
  height: auto;
  border-radius: 6px;
  object-fit: contain;
  object-position: left center;
}

.brand-details {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-details strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-details small {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-section-label {
  margin: 26px 8px 10px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.sidebar-nav a:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.sidebar-nav a.active {
  border-color: var(--border);
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
  box-shadow: inset 3px 0 var(--teal-light);
}

.nav-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  stroke-width: 2;
  color: currentColor;
}

.sidebar-bottom {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-bottom-link {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.sidebar-bottom-link:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.sidebar-bottom-link.active {
  border-color: var(--border);
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
  box-shadow: inset 3px 0 var(--teal-light);
}

.sidebar-bottom-link .nav-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  stroke-width: 2;
  color: currentColor;
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
  font-weight: 800;
  font-size: 13px;
}

.account-meta {
  display: grid;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.35;
}

.account-meta strong {
  overflow: hidden;
  color: var(--text-main);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta small {
  color: var(--text-dim);
}

.sidebar-logout {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-logout:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
  transform: none;
  box-shadow: none;
}

.sidebar-logout .logout-icon {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.app-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 clamp(18px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-page-title {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-context-badge {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.topbar-role-badge {
  padding: 4px 10px;
  border: 1px solid var(--teal-glow);
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.1);
  color: var(--teal-light);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.theme-toggle {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  transform: none;
  box-shadow: none;
}

.theme-icon {
  font-size: 14px;
}

.mobile-navigation {
  display: none;
}

/* ==========================================================================
   Main Workspace
   ========================================================================== */

.app-main {
  width: min(1440px, calc(100% - 40px));
  min-height: calc(100vh - 58px);
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-heading p {
  margin: 6px 0 0;
  font-size: 14px;
}

.heading-actions {
  display: flex;
  gap: 10px;
}

.dashboard-kicker,
.panel-kicker {
  display: inline-block;
  color: var(--teal-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ==========================================================================
   Cards, Metrics & Panels
   ========================================================================== */

.card,
.dashboard-panel,
.tenant-workspace {
  margin-bottom: 20px;
  padding: clamp(18px, 2vw, 24px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.card-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.card-heading p,
.panel-heading p {
  margin: 4px 0 0;
  font-size: 13px;
}

/* Metrics Row */
.dashboard-metrics,
.tenant-dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card,
.tenant-metric-card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.metric-card:hover,
.tenant-metric-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.metric-card-heading,
.tenant-metric-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-icon,
.tenant-metric-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
  font-size: 12px;
  font-weight: 750;
}

.metric-card > strong,
.tenant-metric-card > strong {
  display: block;
  margin: 12px 0 4px;
  color: var(--text-main);
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.tenant-status-value {
  color: var(--success) !important;
}

.metric-card > small,
.tenant-metric-card > small {
  color: var(--text-muted);
  font-size: 12px;
}

.positive-text {
  color: var(--success);
  font-weight: 700;
}

.metric-warning {
  border-color: var(--warning-border);
}

.metric-warning .metric-icon {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.report-summary .stat-card {
  display: flex;
  min-width: 0;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 18px 20px;
}

.report-summary .eyebrow {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.report-summary .stat-title {
  color: var(--text-main);
  font-size: clamp(24px, 2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.report-summary .stat-copy {
  margin: 5px 0 0;
  font-size: 12px;
}

.report-contract-table {
  min-width: 760px;
}

.report-contract-table th,
.report-contract-table td {
  padding: 13px 15px;
}

.report-contract-table td:nth-child(n + 3) {
  white-space: nowrap;
}

.report-contract-table td:first-child {
  min-width: 180px;
}

/* Dashboard Columns */
.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: flex-start;
  gap: 18px;
}

.dashboard-rail {
  display: grid;
  gap: 14px;
}

.quick-panel {
  border-color: var(--teal-glow);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-elevated));
}

.quick-panel .button {
  margin-top: 14px;
  width: 100%;
}

.rail-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--teal-light);
  font-size: 13px;
  font-weight: 700;
}

/* ==========================================================================
   Tenant Partner Dashboard
   ========================================================================== */

.tenant-dashboard {
  display: grid;
  gap: 20px;
}

.tenant-dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-elevated));
  box-shadow: var(--shadow-sm);
}

.tenant-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.tenant-hero-meta i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.tenant-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.tenant-action-card {
  display: flex;
  min-height: 170px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  transition: all 0.15s ease;
}

.tenant-action-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tenant-action-primary {
  border-color: var(--teal-glow);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-elevated));
}

.tenant-action-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
}

.tenant-action-card h3 {
  margin: 4px 0 6px;
  color: var(--text-main);
  font-size: 14.5px;
}

.tenant-action-card p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.tenant-action-card > a {
  margin-top: auto;
  color: var(--teal-light);
  font-size: 13px;
  font-weight: 750;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-main);
  font-size: 13.5px;
  text-align: left;
}

th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--bg-surface-hover);
}

.provider-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.provider-list-card {
  padding: clamp(18px, 2.4vw, 28px);
}

.provider-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.provider-list-heading h2 {
  font-size: 19px;
}

.provider-list-heading p {
  margin: 5px 0 0;
  font-size: 13px;
}

.provider-count-badge {
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.managed-provider-table {
  min-width: 1040px;
  table-layout: fixed;
}

.managed-provider-table th,
.managed-provider-table td {
  padding: 14px 16px;
}

.managed-provider-table th:nth-child(1) { width: 21%; }
.managed-provider-table th:nth-child(2) { width: 22%; }
.managed-provider-table th:nth-child(3) { width: 17%; }
.managed-provider-table th:nth-child(4) { width: 9%; }
.managed-provider-table th:nth-child(5) { width: 9%; }
.managed-provider-table th:nth-child(6) { width: 22%; }

.managed-provider-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.managed-provider-identity > span:last-child {
  min-width: 0;
}

.managed-provider-identity strong,
.managed-provider-identity small,
.managed-provider-table .provider-cell-secondary {
  display: block;
  overflow-wrap: anywhere;
}

.managed-provider-identity strong,
.managed-provider-table td > strong {
  color: var(--text-main);
  font-size: 13px;
  font-weight: 750;
}

.managed-provider-identity small,
.managed-provider-table .provider-cell-secondary {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.managed-provider-table td:nth-child(4),
.managed-provider-table td:nth-child(5) {
  text-align: center;
}

.managed-provider-table td:nth-child(4) {
  font-size: 14px;
  font-weight: 750;
}

.managed-provider-logo,
.managed-provider-logo-fallback {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 10px;
}

.provider-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 7px;
}

.provider-row-actions > .button {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 12px;
}

.provider-more-actions {
  min-width: 0;
}

.provider-more-actions[open] {
  flex: 1 0 100%;
}

.provider-more-actions > summary {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.provider-more-actions > summary::-webkit-details-marker,
.provider-files > summary::-webkit-details-marker {
  display: none;
}

.provider-more-actions > summary:hover {
  border-color: var(--border-focus);
  color: var(--text-main);
}

.provider-more-menu {
  display: grid;
  width: min(420px, 100%);
  gap: 9px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-sm);
}

.provider-more-menu > form button,
.provider-files > summary {
  width: 100%;
}

.provider-more-menu > form button {
  justify-content: flex-start;
  text-align: left;
}

.provider-files > summary {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.tenant-documents {
  display: grid;
  gap: 9px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
}

.tenant-documents > a:not(.tenant-logo-preview) {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.tenant-documents > .muted {
  margin: 0;
  font-size: 11px;
}

.tenant-documents .document-upload-form,
.tenant-documents .document-delete-form {
  display: grid;
  gap: 8px;
}

.tenant-documents label {
  font-size: 11.5px;
}

.tenant-documents button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.provider-logo,
.provider-logo-fallback,
.managed-provider-logo,
.managed-provider-logo-fallback {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-surface-elevated);
  color: var(--teal-light);
  font-size: 12px;
  font-weight: 800;
  object-fit: contain;
}

.tenant-logo-preview img,
.provider-edit-logo-current img,
.logo-preview img,
.branding-current-logo img {
  max-width: 120px;
  max-height: 44px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  vertical-align: middle;
}

.provider-identity strong {
  display: block;
  color: var(--text-main);
  font-size: 13.5px;
}

.provider-identity small {
  color: var(--text-dim);
  font-size: 11.5px;
}

.amount-cell {
  color: var(--teal-light);
  font-weight: 750;
  white-space: nowrap;
}

.action-sep {
  margin: 0 4px;
  color: var(--text-dim);
}

.table-action {
  color: var(--teal-light);
  font-weight: 700;
  font-size: 12.5px;
}

.table-action:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Badges and Status Pills
   ========================================================================== */

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.success,
.status-pill:not(.suspended):not(.disabled) {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.badge.danger,
.status-pill.suspended,
.status-pill.disabled {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.info {
  border-color: rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
}

.badge.muted {
  border-color: var(--border);
  background: var(--bg-surface-elevated);
  color: var(--text-dim);
}

/* ==========================================================================
   Forms & Controls
   ========================================================================== */

label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-main);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--teal-light);
}

.check-option {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  line-height: 1.4;
  cursor: pointer;
}

.check-option input[type="checkbox"] {
  flex: 0 0 18px;
  margin: 0;
}

.provider-registration-card {
  padding: clamp(20px, 3vw, 34px);
}

.provider-form-heading,
.provider-form-heading-copy {
  display: flex;
  align-items: center;
}

.provider-form-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.provider-form-heading-copy {
  min-width: 0;
  gap: 13px;
}

.provider-section-marker {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--teal-glow);
  border-radius: 12px;
  background: rgba(20, 184, 166, 0.1);
  color: var(--teal-light);
  font-size: 14px;
}

.provider-form-heading h2 {
  font-size: 20px;
}

.provider-form-heading p {
  margin: 5px 0 0;
  font-size: 13px;
}

.provider-form-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.provider-create-form {
  display: grid;
  gap: 22px;
}

.provider-form-section {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-surface-elevated);
}

.provider-form-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 17px;
  font-size: 14px;
}

.provider-form-section h3 > span {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-light);
  font-size: 11px;
  font-weight: 800;
}

.provider-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.provider-field-grid > label {
  min-width: 0;
}

.provider-field-grid input:not([type="checkbox"]) {
  min-width: 0;
}

.provider-commercial-fields .check-option {
  align-self: end;
}

.provider-commercial-fields > label > small {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
}

.provider-form-bottom {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.provider-form-help {
  margin: 13px 0 0;
  font-size: 12px;
}

.provider-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.provider-form-footer > span {
  color: var(--text-muted);
  font-size: 12px;
}

.provider-form-footer button {
  flex: 0 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.provider-edit-card {
  margin-bottom: 24px;
}

.provider-logo-edit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.provider-current-logo-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

.provider-current-logo-card .provider-sublabel {
  display: block;
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.provider-current-logo-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.provider-current-logo-body img {
  max-width: 140px;
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-elevated);
}

.provider-current-logo-meta strong {
  display: block;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
}

.provider-current-logo-meta small {
  color: var(--teal-light);
  font-size: 11px;
  font-weight: 600;
}

.provider-no-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.provider-upload-box {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

.provider-upload-box label {
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
}

.user-create-card,
.user-list-card {
  padding: clamp(18px, 2.4vw, 28px);
}

.user-create-card .card-heading,
.user-list-card .card-heading {
  margin-bottom: 18px;
}

.user-create-card .card-heading p,
.user-list-card .card-heading p {
  max-width: 720px;
  line-height: 1.5;
}

.user-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.user-create-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(130px, 0.8fr);
  gap: 14px;
}

.user-create-fields > label {
  min-width: 0;
}

.user-create-form > button {
  min-height: 42px;
  white-space: nowrap;
}

.user-management-table {
  min-width: 840px;
}

.user-management-table th,
.user-management-table td {
  padding: 13px 15px;
}

.user-management-table th:last-child {
  width: 320px;
}

.user-management-table td:nth-child(1) {
  font-weight: 700;
}

.user-management-table td:nth-child(2) {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.user-management-table td:last-child {
  white-space: nowrap;
}

.user-management-table td:last-child > .actions,
.user-management-table td:last-child > .user-action-dropdown,
.user-management-table td:last-child > .user-edit-details {
  display: inline-block;
  margin: 0 5px 0 0;
  vertical-align: middle;
}

.user-management-table .user-edit-details > summary,
.user-management-table .user-action-dropdown > summary {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 12px;
  list-style: none;
  cursor: pointer;
}

.user-management-table .user-edit-details > summary::-webkit-details-marker,
.user-management-table .user-action-dropdown > summary::-webkit-details-marker {
  display: none;
}

.user-management-table .user-edit-details[open],
.user-management-table .user-action-dropdown[open] {
  position: relative;
  z-index: 50;
  white-space: normal;
}

.user-management-table .user-edit-details > form,
.user-management-table .user-dropdown-form {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  display: grid;
  width: min(340px, 85vw);
  gap: 11px;
  margin-top: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  white-space: normal;
  z-index: 60;
}

.user-dropdown-form .dropdown-header {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-form .dropdown-header strong {
  font-size: 13.5px;
  color: var(--text-main);
}

.user-dropdown-form .dropdown-header span {
  font-size: 11.5px;
}

.user-management-table .user-edit-details > form label,
.user-dropdown-form label {
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.user-reset-actions-row {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.user-reset-actions-row button {
  width: 100%;
  font-size: 12.5px;
}

.button-reset-summary {
  border-color: rgba(37, 211, 102, 0.5) !important;
  color: #25d366 !important;
  font-weight: 700 !important;
}

.button-reset-summary:hover {
  background: rgba(37, 211, 102, 0.15) !important;
}

.user-phone-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-main);
}

.user-wa-badge {
  font-size: 14px;
}

.user-management-table .user-edit-details > form button,
.user-management-table td:last-child > .actions button,
.user-management-table td:last-child > a.button-sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

button.button-whatsapp,
.button.button-whatsapp,
a.button-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #25d366;
  border: 1px solid #20ba5a;
  color: #ffffff !important;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.18s ease;
  cursor: pointer;
}

button.button-whatsapp:hover,
.button.button-whatsapp:hover,
a.button-whatsapp:hover {
  background: #1ebe5d;
  border-color: #1a9e4e;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
  color: #ffffff !important;
}

button.button-whatsapp:active,
.button.button-whatsapp:active,
a.button-whatsapp:active {
  background: #128c7e;
  border-color: #0d7065;
}

button.button-telegram,
.button.button-telegram,
a.button-telegram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #229ed9;
  border: 1px solid #1a8cc4;
  color: #ffffff !important;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.18s ease;
  cursor: pointer;
}

button.button-telegram:hover,
.button.button-telegram:hover,
a.button-telegram:hover {
  background: #1e8ec5;
  border-color: #177cb0;
  box-shadow: 0 4px 14px rgba(34, 158, 217, 0.4);
  color: #ffffff !important;
}

button.button-telegram:active,
.button.button-telegram:active,
a.button-telegram:active {
  background: #1877a5;
  border-color: #136289;
}

.password-reset-notice {
  border: 1px solid rgba(37, 211, 102, 0.35);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.08) 0%, rgba(13, 148, 136, 0.06) 100%);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 22px;
}

.password-reset-notice-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.password-notice-icon {
  font-size: 28px;
  line-height: 1;
}

.password-reset-notice-header h2 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
}

.password-reset-notice-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.password-reset-card-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.password-reveal-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.password-reveal {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 8px 16px;
  background: var(--bg-surface-elevated);
  border: 1px dashed var(--teal);
  border-radius: 7px;
  color: var(--teal-light, var(--teal));
  user-select: all;
}

.button-copy {
  padding: 8px 14px;
  font-size: 12.5px;
}

.password-actions-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.password-actions-container a.button-whatsapp {
  padding: 9px 18px;
  font-size: 13.5px;
}

.user-empty-state {
  padding: 28px 16px;
  color: var(--text-muted);
  text-align: center;
}

.customer-reservation-list {
  display: grid;
  min-width: 120px;
  gap: 7px;
}

.customer-reservation-list > span {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-size: 12px;
}

.customer-reservation-list small {
  color: var(--text-muted);
  font-size: 10.5px;
}

.customer-registration-card {
  margin-bottom: 24px;
}

.customer-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.customer-form-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.customer-form-grid .customer-address-field {
  grid-column: 1 / -1;
}

.customer-optional-label {
  font-weight: normal;
  color: var(--text-muted);
  font-size: 11.5px;
}

.customer-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.customer-form-footer span {
  font-size: 12.5px;
  color: var(--text-muted);
}

.billing-report {
  padding: clamp(18px, 2.5vw, 30px);
}

.billing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface-elevated);
}

.billing-filter-field {
  display: grid;
  min-width: min(230px, 100%);
  flex: 1 1 230px;
  gap: 6px;
}

.billing-filter-field label {
  font-size: 12px;
}

.billing-toolbar > button {
  min-height: 42px;
}

.billing-report-header {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface-elevated);
}

.billing-report-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.billing-report-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--teal);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.billing-report-brand > div {
  display: grid;
  gap: 3px;
}

.billing-report-brand strong {
  color: var(--text-main);
  font-size: 15px;
}

.billing-report-brand > div > span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.billing-report-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.billing-report-eyebrow {
  color: var(--teal-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.billing-report-title h1 {
  margin-top: 5px;
  font-size: clamp(22px, 3vw, 30px);
}

.billing-report-period {
  display: grid;
  gap: 3px;
  text-align: right;
}

.billing-report-period span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.billing-report-period strong {
  color: var(--text-main);
  font-size: 20px;
}

.billing-report-parties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px 22px;
  margin: 20px 0 0;
}

.billing-report-parties > div {
  min-width: 0;
}

.billing-report-parties dt {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.billing-report-parties dd {
  margin: 0;
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.billing-summary-heading {
  margin: 24px 0 12px;
}

.billing-report-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-focus);
  border-radius: 9px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 12px;
}

.billing-report-notice strong {
  color: var(--text-main);
}

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 12px;
  margin: 18px 0 26px;
}

.billing-kpis article {
  display: grid;
  min-height: 94px;
  align-content: space-between;
  gap: 12px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

.billing-kpis article span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.billing-kpis article strong {
  color: var(--text-main);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.billing-detail-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 12px;
}

.billing-detail-heading h2 {
  margin-top: 4px;
}

.billing-detail-heading p {
  margin: 0;
  font-size: 12px;
}

.billing-report .table-wrap {
  margin-top: 10px;
}

.billing-report table {
  min-width: 850px;
}

.billing-report th,
.billing-report td {
  padding: 12px 14px;
}

.billing-report td strong {
  white-space: nowrap;
}

.billing-empty-state {
  margin: 0;
  padding: 24px 16px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  color: var(--text-muted);
  text-align: center;
}

.billing-report-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.billing-report-footer p {
  max-width: 760px;
  margin: 0;
  font-size: 11px;
}

.billing-report-footer > span {
  color: var(--text-dim);
  font-size: 10px;
  text-align: right;
}

input::placeholder {
  color: var(--text-dim);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--teal-glow);
  outline: 0;
}

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover,
.button:hover {
  background: var(--teal-dark);
  box-shadow: 0 4px 14px var(--teal-glow);
}

button.secondary,
.button.secondary {
  border-color: var(--border);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--bg-surface-hover);
  box-shadow: none;
}

button.danger,
.button.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

button.danger:hover,
.button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.provider-search {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.provider-search input {
  height: 38px;
  min-height: 38px;
}

.provider-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px 0;
  color: var(--text-dim);
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
}

/* Notices */
.notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  font-size: 13px;
}

.notice.success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.notice.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.notice.warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.notice h2 {
  font-size: 15px;
  margin-bottom: 4px;
}

.empty-state {
  padding: 32px 16px;
  color: var(--text-dim);
  text-align: center;
  font-size: 13.5px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ==========================================================================
   Viability Tool Specific Layout & Styles
   ========================================================================== */

.viability-body {
  overflow: hidden;
}

.viability-layout {
  display: grid;
  height: 100vh;
  grid-template-columns: minmax(380px, 440px) minmax(0, 1fr);
  background: var(--bg-canvas);
}

.viability-sidebar {
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 20px 22px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  overflow-y: auto;
}

.viability-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.viability-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-link {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.sidebar-title h1 {
  font-size: 20px;
  margin-bottom: 4px;
}

.sidebar-title p {
  font-size: 12.5px;
  margin-bottom: 16px;
}

/* Search Tabs */
.search-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-input);
}

.tab-btn {
  min-height: 34px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.viability-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.gps-detect-btn {
  margin-top: 6px;
  width: 100%;
  font-size: 12px;
  min-height: 34px;
}

.search-button {
  width: 100%;
  min-height: 42px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Results in Sidebar */
.viability-results {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.results-summary-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
}

.summary-label {
  display: block;
  color: var(--teal-light);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.summary-point strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-main);
}

.summary-point small {
  color: var(--text-dim);
  font-size: 11.5px;
}

.summary-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.summary-kpi strong {
  color: var(--text-main);
  font-size: 15px;
}

.summary-radius {
  color: var(--text-dim);
}

/* CTO Cards List */
.cto-cards-list {
  display: grid;
  gap: 10px;
}

.cto-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  transition: all 0.15s ease;
}

.cto-card:hover {
  border-color: var(--border-focus);
}

.cto-card-available {
  border-left: 3px solid var(--success);
}

.cto-card-full {
  border-left: 3px solid var(--danger);
}

.cto-card-unknown {
  border-left: 3px solid var(--text-dim);
}

.cto-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cto-code-badge {
  color: var(--text-main);
  font-weight: 800;
  font-size: 13.5px;
}

.cto-distance-badge {
  margin-left: 6px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

/* Capacity Bar */
.cto-capacity-bar {
  margin: 8px 0 10px;
}

.capacity-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-surface-elevated);
}

.capacity-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.fill-available {
  background: linear-gradient(90deg, var(--teal-light), var(--success));
}

.fill-full {
  background: var(--danger);
}

.capacity-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 11px;
}

.cto-card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.btn-focus-cto,
.btn-copy-coords {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

/* Map area */
#map {
  width: 100%;
  height: 100vh;
  background: #0f172a;
}

.map-popup-card {
  color: #0f172a;
  font-size: 12.5px;
  line-height: 1.45;
}

.map-popup-card strong {
  font-size: 14px;
}

/* ==========================================================================
   Login / Auth Layout
   ========================================================================== */

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  color: var(--text-main);
}

.auth-topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.auth-brand-logo {
  display: block;
  max-height: 34px;
  max-width: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.auth-brand-name {
  display: grid;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.auth-brand-name small {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.auth-topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-security-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.auth-security-label::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.auth-layout {
  display: grid;
  width: min(1200px, calc(100% - 40px));
  margin: auto;
  padding: 48px 0;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: clamp(32px, 5vw, 64px);
}

.auth-intro {
  max-width: 580px;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin-bottom: 16px;
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.08);
  color: var(--teal-light);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.auth-intro h1 {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(32px, 4vw, 44px);
  letter-spacing: -0.035em;
  line-height: 1.15;
  font-weight: 800;
}

.auth-intro h1 span {
  color: var(--teal-light);
}

.auth-intro-copy {
  margin: 14px 0 24px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.auth-feature-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
}

.auth-feature-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 700;
}

.auth-feature-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(20, 184, 166, 0.15);
  color: var(--teal-light);
  font-size: 13px;
  font-weight: 800;
}

.auth-network-visual {
  position: relative;
  height: 44px;
  margin: 14px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-network-caption {
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.auth-network-caption span {
  color: var(--teal-light);
  margin: 0 4px;
}

.auth-feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.auth-feature-list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-feature-list b {
  color: var(--success);
  font-weight: 800;
}

.auth-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.auth-notice-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  font-style: italic;
}

.auth-notice p {
  margin: 0;
}

.auth-notice strong {
  color: var(--text-main);
  font-size: 12.5px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: clamp(24px, 3.5vw, 36px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  justify-self: center;
}

.auth-card-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.auth-card-brand .auth-brand-logo {
  max-height: 42px;
  max-width: 175px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.auth-card-brand span {
  display: grid;
  gap: 2px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.auth-card-brand span small {
  color: var(--text-dim);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.auth-card-heading {
  margin-bottom: 20px;
}

.auth-card-heading h2 {
  margin: 0;
  color: var(--text-main);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
}

.auth-form button {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  font-size: 14.5px;
  font-weight: 750;
}

.auth-help {
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.5;
}

.auth-error {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 4vw, 48px);
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}

/* Password setup page */
.auth-password-main {
  width: min(480px, calc(100% - 40px));
  margin: auto;
  padding: 48px 0;
}

.auth-password-card {
  max-width: 480px;
  margin: 0 auto;
}

.auth-password-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-light);
  font-size: 20px;
  margin-bottom: 16px;
}

.auth-password-kicker {
  display: inline-block;
  color: var(--teal-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.auth-password-requirement {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 18px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1024px) {
  .app-shell {
    --sidebar-w: 220px;
  }

  .dashboard-columns {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
  }

  .settings-grid-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-sidebar {
    display: none;
  }

  .mobile-navigation {
    position: relative;
    display: block;
  }

  .mobile-navigation summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: all 0.15s ease;
  }

  .mobile-navigation summary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-focus);
  }

  .mobile-navigation summary::-webkit-details-marker {
    display: none;
  }

  /* Slide-over drawer on mobile */
  .mobile-nav-content {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: min(320px, 86vw);
    height: calc(100vh - 58px);
    max-height: calc(100vh - 58px);
    padding: 16px 14px 20px;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0 16px 16px 0;
    background: var(--bg-sidebar);
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.45);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: drawerSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes drawerSlide {
    from {
      transform: translateX(-100%);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  /* Fixed backdrop */
  .mobile-navigation[open]::before {
    content: '';
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 10, 20, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
  }

  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-nav-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .mobile-nav-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all 0.15s ease;
  }

  .mobile-nav-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
  }

  .mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
  }

  .mobile-nav-links a {
    display: flex;
    min-height: 40px;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
  }

  .mobile-nav-links a:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
  }

  .mobile-nav-links a.active {
    border-color: var(--border);
    background: var(--bg-surface-elevated);
    color: var(--teal-light);
    box-shadow: inset 3px 0 var(--teal-light);
  }

  .mobile-nav-bottom {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 10px;
  }

  .mobile-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .dashboard-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .viability-layout {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(50vh, 60vh);
    overflow: auto;
  }

  .viability-sidebar {
    height: auto;
    max-height: 70vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  #map {
    height: 60vh;
  }

  .auth-layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px 0;
  }

  .provider-form-bottom,
  .provider-logo-edit-layout,
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-wrap table {
    min-width: 650px;
  }
}

@media (max-width: 768px) {
  /* Prevent iOS Safari from auto-zooming on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .app-topbar {
    padding: 0 14px;
    gap: 10px;
    min-height: 54px;
  }

  .topbar-context-badge,
  .topbar-role-badge {
    display: none !important;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
  }

  .topbar-page-title {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }

  .app-main {
    width: calc(100% - 24px);
    padding: 16px 0 36px;
  }

  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .heading-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .heading-actions .button,
  .heading-actions a {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }

  .card,
  .dashboard-panel,
  .tenant-workspace,
  .provider-registration-card,
  .provider-list-card,
  .settings-card {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .card-heading,
  .panel-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .card-heading > div:last-child,
  .panel-heading > a,
  .panel-heading > button {
    width: 100%;
  }

  .panel-heading .button,
  .card-heading .button {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .dashboard-metrics,
  .tenant-dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
  }

  .metric-card,
  .tenant-metric-card {
    padding: 12px 14px;
  }

  .metric-card > strong,
  .tenant-metric-card > strong {
    font-size: 20px;
    margin: 8px 0 2px;
  }

  .metric-card > small,
  .tenant-metric-card > small {
    font-size: 11px;
    line-height: 1.35;
  }

  .metric-card-heading,
  .tenant-metric-heading {
    font-size: 9.5px;
  }

  .metric-icon,
  .tenant-metric-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .provider-field-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .provider-form-section {
    padding: 14px 16px;
  }

  .provider-form-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .provider-form-footer {
    flex-direction: column-reverse;
    gap: 10px;
    width: 100%;
  }

  .provider-form-footer button,
  .provider-form-footer a {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .provider-modal-sections {
    grid-template-columns: 1fr;
  }

  .provider-documents-row {
    grid-template-columns: 1fr;
  }

  .provider-modal-footer {
    flex-direction: column;
    gap: 0.85rem;
    align-items: stretch;
  }

  .provider-modal-footer-actions {
    flex-direction: column;
  }

  .provider-modal-footer-actions button,
  .provider-modal-footer-actions a {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .theme-toggle .theme-label {
    display: none;
  }

  .theme-toggle {
    padding: 6px 9px;
    min-height: 32px;
  }

  .settings-tab-link {
    padding: 8px 13px;
    font-size: 12.5px;
  }

  .password-reset-notice {
    padding: 14px 16px;
  }

  .password-reset-notice-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .password-reset-card-body {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .password-reveal-container {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .password-reveal {
    text-align: center;
    font-size: 14px;
    padding: 8px 10px;
    word-break: break-all;
  }

  .button-copy {
    width: 100%;
    justify-content: center;
  }

  .password-actions-container {
    width: 100%;
  }

  .password-actions-container a {
    width: 100%;
    justify-content: center;
  }

  .app-modal-dialog {
    width: 95vw;
    max-width: 95vw;
    margin: 12px auto;
    max-height: 92vh;
    border-radius: 14px;
  }

  .app-modal-header {
    padding: 1rem 1.15rem;
  }

  .app-modal-header h3 {
    font-size: 1.05rem;
  }

  .app-modal-body {
    padding: 1rem 1.15rem;
    gap: 12px;
  }

  .app-modal-footer {
    padding: 0.85rem 1.15rem;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
  }

  .app-modal-footer button,
  .app-modal-footer a.button {
    width: 100%;
    text-align: center;
    justify-content: center;
    min-height: 42px;
  }

  .app-modal-footer-subrow {
    flex-direction: column-reverse;
    width: 100%;
    gap: 8px;
  }

  .provider-list-heading,
  .provider-form-heading,
  .provider-form-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-search {
    flex-direction: column;
    gap: 8px;
  }

  .provider-search input {
    width: 100%;
  }

  .provider-search button,
  .provider-search a {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .provider-table-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .pagination {
    width: 100%;
    justify-content: space-between;
  }

  .user-create-form,
  .user-create-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-create-form > button {
    width: 100%;
  }

  .billing-toolbar > button {
    width: 100%;
  }

  .billing-report-title,
  .billing-detail-heading,
  .billing-report-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-report-period,
  .billing-report-footer > span {
    text-align: left;
  }
}

@media (max-width: 440px) {
  .dashboard-metrics,
  .tenant-dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .topbar-page-title {
    max-width: 130px;
    font-size: 12.5px;
  }

  .provider-modal-highlights {
    grid-template-columns: 1fr;
  }
}

@media print {
  :root,
  html[data-theme="dark"],
  html[data-theme="light"] {
    color-scheme: light;
    --bg-canvas: #fff;
    --bg-surface: #fff;
    --bg-surface-elevated: #fff;
    --border: #cbd5e1;
    --text-main: #111827;
    --text-muted: #475569;
    --text-dim: #64748b;
  }

  body,
  .app-shell,
  .app-content {
    display: block;
    min-height: 0;
    background: #fff;
    color: #111827;
  }

  .app-sidebar,
  .app-topbar,
  .no-print,
  .fin-summary-table-row {
    display: none !important;
  }

  .fin-print-only-row {
    display: table-row !important;
  }

  .app-main {
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .billing-report {
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .billing-report-header,
  .billing-kpis article,
  .billing-report .table-wrap {
    break-inside: avoid;
    background: #fff;
    box-shadow: none;
  }

  .billing-report .table-wrap {
    overflow: visible;
  }

  .billing-report table {
    min-width: 0;
    font-size: 9pt;
  }

  .billing-report th,
  .billing-report td {
    padding: 7px;
    color: #111827;
  }

  .billing-report th {
    background: #f1f5f9;
  }

  .billing-report .billing-report-mark {
    border: 1px solid #0f766e;
    background: #fff;
    color: #0f766e;
  }

  .billing-report .billing-kpis {
    grid-template-columns: repeat(3, 1fr);
  }

  .billing-report .billing-report-parties {
    grid-template-columns: repeat(3, 1fr);
  }

  .table-wrap {
    overflow: visible !important;
  }

  /* Relatório de Clientes Cadastrados */
  .print-report-header {
    display: block !important;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #0f766e;
    break-inside: avoid;
  }

  .print-report-header .print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
  }

  .print-report-header .print-brand-kicker {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #0f766e;
    margin-bottom: 3px;
  }

  .print-report-header .print-title {
    font-size: 14pt;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 4px 0;
    line-height: 1.2;
  }

  .print-report-header .print-subtitle {
    font-size: 9pt;
    color: #475569;
    margin: 0;
  }

  .print-report-header .print-meta-box {
    text-align: right;
    font-size: 8pt;
    color: #334155;
    line-height: 1.4;
    white-space: nowrap;
  }

  .customer-list-card {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .customer-list-card .card-heading {
    display: none !important;
  }

  .customer-table {
    width: 100% !important;
    font-size: 8pt !important;
    border-collapse: collapse !important;
    min-width: 0 !important;
  }

  .customer-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .customer-table th,
  .customer-table td {
    padding: 6px 7px !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    background: #fff !important;
    vertical-align: top !important;
    text-align: left !important;
  }

  .customer-table th {
    background: #f1f5f9 !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 7pt !important;
    letter-spacing: 0.04em !important;
    color: #1e293b !important;
  }

  .customer-table .status-pill {
    display: inline-block !important;
    border: 1px solid #94a3b8 !important;
    background: #f8fafc !important;
    color: #0f172a !important;
    font-size: 7pt !important;
    padding: 2px 5px !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
  }

  .customer-table small,
  .customer-table .muted {
    color: #64748b !important;
    font-size: 7.5pt !important;
  }
}

.print-report-header {
  display: none;
}

/* ==========================================================================
   Provider Details Modal Dialog
   ========================================================================== */

.provider-modal-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-width: 960px;
  width: 94vw;
  max-height: 90vh;
  margin: auto;
  overflow: hidden;
}

.provider-modal-dialog::backdrop {
  background: rgba(5, 10, 20, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.provider-modal-wrap {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.provider-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-elevated);
}

.provider-modal-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.provider-modal-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.provider-modal-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.provider-modal-logo-fallback {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--teal-light);
}

.provider-modal-badge-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.provider-modal-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.1rem 0;
  color: var(--text-main);
}

.provider-modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.provider-modal-close {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 1.1rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.provider-modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.provider-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.provider-modal-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.provider-highlight-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.provider-highlight-card.highlight-accent {
  border-color: rgba(20, 184, 166, 0.45);
  background: rgba(20, 184, 166, 0.08);
}

.provider-highlight-card strong {
  font-size: 1.25rem;
  color: var(--text-main);
  font-weight: 700;
}

.provider-highlight-card small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.highlight-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.provider-modal-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

.provider-modal-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.provider-modal-card.full-width {
  grid-column: 1 / -1;
}

.modal-card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
}

.modal-card-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.modal-card-header p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.modal-card-header .provider-count-badge {
  margin-left: auto;
}

.modal-section-icon {
  font-size: 1.15rem;
}

.provider-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin: 0;
  font-size: 0.83rem;
}

.provider-info-grid dt {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}

.provider-info-grid dd {
  color: var(--text-main);
  margin: 0;
  font-weight: 500;
  word-break: break-word;
}

.provider-info-highlight-item {
  grid-column: 1 / -1;
  background: var(--bg-input);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.provider-documents-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.provider-doc-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.provider-doc-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.provider-customers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.provider-customers-table th {
  background: var(--bg-input);
  text-align: left;
  padding: 0.55rem 0.7rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.provider-customers-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.provider-customers-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

.provider-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-elevated);
}

.provider-modal-footer-actions {
  display: flex;
  gap: 0.6rem;
}

@media (max-width: 768px) {
  .provider-modal-sections {
    grid-template-columns: 1fr;
  }
  .provider-documents-row {
    grid-template-columns: 1fr;
  }
  .provider-modal-footer {
    flex-direction: column;
    gap: 0.85rem;
    align-items: stretch;
  }
  .provider-modal-footer-actions {
    flex-direction: column;
  }
}

/* ==========================================================================
   Master Settings & WhatsApp API Gateway Styles
   ========================================================================== */

.settings-tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
}

.settings-tabs-nav::-webkit-scrollbar {
  display: none;
}

.settings-tab-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  border-radius: 8px 8px 0 0;
}

.settings-tab-link:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.settings-tab-link.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  background: var(--bg-surface-elevated);
}

.settings-grid-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
}

.settings-main-col,
.settings-side-col {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.settings-card {
  padding: clamp(20px, 2.5vw, 28px);
}

.settings-form-section {
  padding: 16px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
}

.toggle-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.toggle-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-box {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: background 0.25s ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.toggle-box::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox-label input:checked + .toggle-box {
  background: #25d366;
}

.toggle-checkbox-label.toggle-telegram input:checked + .toggle-box {
  background: #229ed9;
}

.toggle-checkbox-label input:checked + .toggle-box::after {
  transform: translateX(20px);
}

.toggle-text {
  display: grid;
  gap: 3px;
}

.toggle-text strong {
  font-size: 14px;
  color: var(--text-main);
}

.toggle-text small {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-form-grid {
  display: grid;
  gap: 16px;
}

.settings-form-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  padding-right: 44px;
  width: 100%;
}

.btn-toggle-secret {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  border-radius: 6px;
}

.btn-toggle-secret:hover {
  background: var(--bg-surface-hover);
  box-shadow: none;
}

.field-hint {
  font-size: 11.5px;
  font-weight: normal;
  color: var(--text-muted);
  line-height: 1.35;
}

.required-asterisk {
  color: #ef4444;
}

.form-actions-bar {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.test-card {
  border-left: 4px solid #25d366;
}

.test-card.telegram-card {
  border-left-color: #229ed9;
}

.test-card form {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.test-card label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.test-btn {
  width: 100%;
  padding: 12px !important;
  font-size: 13.5px !important;
}

.api-status-summary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.status-indicator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
}

.provider-guide-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.provider-guide-list code {
  font-size: 11.5px;
  padding: 2px 6px;
  background: var(--bg-surface-hover);
  border-radius: 4px;
  color: var(--teal-light, var(--teal));
}

.wa-api-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}

.wa-api-status-badge.success {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: #10b981;
}

.wa-api-status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

@media (max-width: 1100px) {
  .settings-grid-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Universal Modal Dialogs (User Create, Edit, Password Reset, Status, Delete)
   ========================================================================== */

.app-modal-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 0;
  max-width: 500px;
  width: 92vw;
  margin: auto;
  overflow: hidden;
}

.app-modal-dialog::backdrop {
  background: rgba(5, 10, 20, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.app-modal-wrap {
  display: flex;
  flex-direction: column;
}

.app-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-elevated);
}

.app-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.app-modal-close-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  box-shadow: none;
}

.app-modal-body {
  padding: 1.4rem;
  display: grid;
  gap: 14px;
}

.app-modal-body label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.app-modal-body label input,
.app-modal-body label select {
  width: 100%;
}

.app-modal-user-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.app-modal-user-summary .user-icon {
  font-size: 22px;
}

.app-modal-user-summary div {
  display: grid;
  gap: 2px;
}

.app-modal-user-summary strong {
  font-size: 14px;
  color: var(--text-main);
}

.app-modal-user-summary span {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-info-note {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.2);
  font-size: 12px;
  color: var(--teal-light, var(--teal));
  line-height: 1.4;
}

.modal-confirm-text {
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.5;
  margin: 0;
}

.app-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-elevated);
}

.app-modal-footer button {
  min-height: 38px;
}

.app-modal-footer-stacked {
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.app-modal-footer-subrow {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.user-list-card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.user-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.user-actions-cell .button-sm {
  min-height: 32px;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
}

/* ==========================================================================
   Financial Panel (Painel Financeiro & Locação de Portas)
   ========================================================================== */

.fin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.fin-header-title h1 {
  font-size: clamp(20px, 2.4vw, 26px);
  margin: 0;
  color: var(--text-main);
  font-weight: 800;
}

.fin-header-title p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.fin-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.fin-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fin-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.fin-kpi-title {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.fin-kpi-value {
  color: var(--text-main);
  font-size: clamp(24px, 2.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 6px 0 4px;
}

.fin-kpi-subtitle {
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 500;
}

.fin-grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.fin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.fin-card-heading {
  display: grid;
  gap: 2px;
}

.fin-card-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  color: var(--text-main);
}

.fin-card-heading p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.fin-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}

.fin-card-actions a,
.fin-card-actions button {
  color: var(--text-dim);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fin-card-actions a:hover,
.fin-card-actions button:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.fin-card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fin-bar-item {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) minmax(56px, auto);
  align-items: center;
  gap: 14px;
}

.fin-bar-label {
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.fin-bar-track {
  height: 18px;
  background: rgba(125, 140, 165, 0.12);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.fin-bar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 6px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fin-bar-fill.blue {
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
}

.fin-bar-fill.green {
  background: linear-gradient(90deg, #059669, #10b981);
}

.fin-bar-fill.summary {
  background: linear-gradient(90deg, #475569, #64748b);
}

.fin-bar-value {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fin-summary-bar {
  cursor: pointer;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  border: 1px dashed rgba(45, 212, 191, 0.35);
  background: rgba(15, 23, 42, 0.25);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fin-summary-bar:hover,
.fin-summary-bar:focus-visible {
  background: rgba(13, 148, 136, 0.14);
  border-color: var(--teal);
  outline: none;
}

.fin-summary-bar .fin-bar-label {
  color: var(--teal);
  text-transform: none;
}

.fin-summary-table-row {
  cursor: pointer;
  background: rgba(13, 148, 136, 0.06);
  transition: background 0.15s ease;
}

.fin-summary-table-row:hover,
.fin-summary-table-row:focus-visible {
  background: rgba(13, 148, 136, 0.16);
  outline: none;
}

.fin-summary-table-row td {
  color: var(--teal);
  font-weight: 700;
}

.fin-print-only-row {
  display: none;
}

.fin-view-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: var(--teal) !important;
  background: rgba(13, 148, 136, 0.12) !important;
  border: 1px solid rgba(45, 212, 191, 0.35) !important;
  border-radius: 999px !important;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fin-view-all-btn:hover {
  background: rgba(13, 148, 136, 0.24) !important;
  border-color: var(--teal) !important;
}

.fin-card-clickable {
  cursor: pointer;
}

.fin-modal-dialog {
  max-width: 820px;
  width: 94vw;
}

.fin-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fin-modal-search {
  flex: 1;
  min-width: 220px;
}

.fin-modal-count-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  background: rgba(13, 148, 136, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.fin-modal-scroll {
  max-height: 58vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface-elevated);
}

.fin-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-elevated);
}

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fin-table th {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.fin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.fin-table tr:last-child td {
  border-bottom: none;
}

.fin-table-partner {
  font-weight: 700;
  color: var(--text-main);
}

.fin-table-amount {
  font-weight: 800;
  color: var(--text-main);
  text-align: right;
  white-space: nowrap;
}

.fin-table-count {
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
}

.fin-empty-state {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: auto;
}

@media (max-width: 1100px) {
  .fin-kpis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fin-grid-2x2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .fin-kpis-grid {
    grid-template-columns: 1fr;
  }
  .fin-bar-item {
    grid-template-columns: minmax(80px, 120px) minmax(0, 1fr) 30px;
    gap: 8px;
  }
}




/* ==========================================================================
   Order Timeline Modal & Technical Parameters Dialog
   ========================================================================== */

.order-timeline-dialog {
  border: 1px solid #1e293b;
  border-radius: 16px;
  background: #0c1019;
  color: #f1f5f9;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  width: 1100px;
  max-width: 95vw;
  max-height: 90vh;
  margin: auto;
  overflow: hidden;
  padding: 0;
}

.order-timeline-dialog::backdrop {
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.order-timeline-modal-container {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  background: #0c1019;
}

.order-timeline-header {
  background: #0f1422;
  border-bottom: 1px solid #1e293b;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.otm-header-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.otm-pulse-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #141d2e;
  border: 1px solid #24334a;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.otm-title-block {
  min-width: 0;
}

.otm-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.otm-title {
  font-size: 19px;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  letter-spacing: -0.3px;
}

.otm-status-badge {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 999px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
}

.otm-badge-executed {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.otm-badge-approved {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.otm-badge-pending,
.otm-badge-processing {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.otm-badge-denied {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.otm-badge-deactivated {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid #475569;
}

.otm-meta-row {
  display: flex;
  gap: 18px;
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
  align-items: center;
  flex-wrap: wrap;
}

.otm-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.otm-meta-item strong {
  color: #cbd5e1;
}

.otm-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.otm-close-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.order-timeline-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  padding: 24px;
  max-height: calc(90vh - 145px);
  overflow-y: auto;
}

.otm-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.otm-tech-card {
  background: #111624;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.otm-tech-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.otm-tech-label {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.otm-tech-value {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  word-break: break-word;
}

.otm-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  color: #38bdf8;
}

.otm-teal {
  color: #2dd4bf;
  font-weight: 700;
}

.otm-highlight {
  color: #f8fafc;
  font-weight: 700;
}

.otm-timeline-wrapper {
  position: relative;
  padding-left: 28px;
}

.otm-timeline-rail {
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: 24px;
  width: 2px;
  background: linear-gradient(180deg, #38bdf8 0%, #1e293b 85%);
}

.otm-timeline-events {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.otm-timeline-card {
  position: relative;
}

.otm-bullet-node {
  position: absolute;
  left: -28px;
  top: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0c1019;
  border: 2px solid #64748b;
  z-index: 2;
  box-sizing: border-box;
}

.otm-node-executed {
  border-color: #10b981;
  background: #064e3b;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.otm-node-approved {
  border-color: #38bdf8;
  background: #075985;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.otm-node-denied {
  border-color: #ef4444;
  background: #7f1d1d;
}

.otm-node-waiting {
  border-color: #f59e0b;
  border-style: dashed;
}

.otm-card-content {
  background: #131929;
  border: 1px solid #202c40;
  border-radius: 10px;
  padding: 14px 18px;
  transition: border-color 0.2s, background 0.2s;
}

.otm-card-content:hover {
  border-color: #334460;
  background: #162033;
}

.otm-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 4px;
  line-height: 1.4;
}

.otm-card-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.45;
  margin-bottom: 8px;
}

.otm-card-meta {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: #64748b;
  align-items: center;
  flex-wrap: wrap;
}

.otm-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.otm-badge-wait {
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.order-timeline-footer {
  background: #0f1422;
  border-top: 1px solid #1e293b;
  padding: 14px 24px;
  display: flex;
  justify-content: flex-end;
}

.otm-footer-close-btn {
  padding: 8px 18px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .order-timeline-body {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   CEP Search & Structured Address Fields
   ========================================================================== */

.customer-address-fieldset {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 18px 20px;
  margin-top: 6px;
}

.customer-address-legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--teal, #14b8a6);
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cep-search-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.cep-input-group {
  flex: 0 0 180px;
  max-width: 200px;
}

.cep-input-group label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.cep-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.cep-field-wrapper input {
  padding-right: 36px;
  width: 100%;
}

.cep-spinner {
  position: absolute;
  right: 10px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(20, 184, 166, 0.2);
  border-top-color: var(--teal, #14b8a6);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.cep-actions-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

.cep-help-link {
  font-size: 12px;
  color: var(--teal, #14b8a6);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cep-help-link:hover {
  color: var(--teal-light, #2dd4bf);
}

.cep-status-hint {
  font-size: 12px;
  color: var(--teal, #14b8a6);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cep-status-hint.error {
  color: #f87171;
}

.address-split-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.address-split-geo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

@media (max-width: 768px) {
  .address-split-grid,
  .address-split-geo-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Map Reservation Modal in index.php
   ========================================================================== */

.map-reservation-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  width: 480px;
  max-width: 95vw;
  margin: auto;
  padding: 0;
  overflow: hidden;
}

.map-reservation-dialog::backdrop {
  background: rgba(4, 7, 13, 0.8);
  backdrop-filter: blur(5px);
}

.map-reservation-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.map-reservation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-reservation-header h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ==========================================================================
   Mobile-First Dashboard Model (Cadastro & Ativação de Clientes)
   ========================================================================== */

.mobile-dash-spotlight,
.mobile-customer-cards,
.mobile-bottom-bar {
  display: none;
}

@media (max-width: 768px) {
  .app-main {
    padding-bottom: 96px;
  }

  .mobile-dash-spotlight {
    display: grid;
    gap: 14px;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 16px;
    border: 1px solid rgba(20, 184, 166, 0.35);
    background: linear-gradient(155deg, rgba(20, 184, 166, 0.14) 0%, var(--bg-surface) 58%, var(--bg-surface-elevated) 100%);
    box-shadow: var(--shadow-md);
  }

  .mobile-spotlight-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }

  .mobile-spotlight-kicker {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--teal-light, #2dd4bf);
  }

  .mobile-spotlight-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(20, 184, 166, 0.16);
    border: 1px solid rgba(20, 184, 166, 0.35);
    color: var(--teal-light, #2dd4bf);
  }

  .mobile-spotlight-title {
    margin: -4px 0 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
  }

  .mobile-hero-ctas {
    display: grid;
    gap: 10px;
  }

  .mobile-hero-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    min-height: 64px;
    border-radius: 14px;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .mobile-hero-cta:active {
    transform: scale(0.985);
  }

  .mobile-hero-cta--register {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.28);
  }

  .mobile-hero-cta--activate {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.24);
  }

  .mobile-cta-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }

  .mobile-cta-copy {
    display: grid;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }

  .mobile-cta-copy strong {
    font-size: 15.5px;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
  }

  .mobile-cta-copy small {
    font-size: 12px;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.88);
  }

  .mobile-cta-arrow {
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
    color: #fff;
  }

  .mobile-cta-badge {
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 800;
    background: #fff;
    color: #0369a1;
    flex-shrink: 0;
  }

  .mobile-quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-quick-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
  }

  .tenant-dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
  }

  .tenant-dashboard-hero h1 {
    font-size: 20px;
  }

  .tenant-hero-cta {
    display: none !important;
  }

  .tenant-desktop-table {
    display: none !important;
  }

  .mobile-customer-cards {
    display: grid;
    gap: 12px;
  }

  .mobile-customer-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-surface-elevated);
  }

  .mobile-customer-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-customer-card__top strong {
    display: block;
    font-size: 14.5px;
    color: var(--text-main);
  }

  .mobile-customer-card__top small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .mobile-customer-card__addr {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-muted);
  }

  .mobile-customer-card__meta {
    font-size: 12px;
    color: var(--text-main);
  }

  .mobile-customer-card__actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .mobile-customer-card__actions .button {
    min-height: 40px;
    justify-content: center;
    text-align: center;
    font-size: 13px;
  }

  .mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(10, 15, 28, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  }

  html[data-theme="light"] .mobile-bottom-bar {
    background: rgba(255, 255, 255, 0.94);
  }

  .mobile-bottom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 46px;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
  }

  .mobile-bottom-btn--register {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
  }

  .mobile-bottom-btn--activate {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  }
}
