.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}

[data-minimal="true"] .card {
  box-shadow: none;
  border-radius: var(--radius-md);
}

.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  margin: 0 0 3px 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.muted {
  color: var(--text-muted);
  font-size: 0.835rem;
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.835rem;
  font-weight: 500;
  padding: 9px 14px;
  min-height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn:hover {
  background: var(--bg-surface-alt);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-sm {
  padding: 5px 10px;
  min-height: 34px;
  font-size: 0.79rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  flex-shrink: 0;
}

.icon-badge-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Network Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.status-offline .status-dot {
  background: var(--warning);
}

/* Accessible Switch Toggle */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.switch input:checked + .switch-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Bottom Sheet for "More" Modules */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.5);
  backdrop-filter: blur(2px);
  z-index: 50;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 78dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.more-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  min-height: 74px;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.more-tile.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Form Controls */
.select-input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.835rem;
  min-height: 36px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-border);
  font-size: 0.71rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.module-item-card {
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius-md);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 360px);
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
