:root {
  /* Material Theme - Dark Mode */
  --mdc-theme-background: #121212;
  --mdc-theme-surface: #1E1E1E;
  --mdc-theme-surface-2: #252525;
  --mdc-theme-primary: #BB86FC;
  --mdc-theme-primary-dark: #3700B3;
  --mdc-theme-secondary: #03DAC6;
  --mdc-theme-error: #CF6679;
  --mdc-theme-success: #4CAF50;
  --mdc-theme-warning: #FF9800;
  --mdc-theme-info: #2196F3;

  --mdc-theme-text-primary-on-background: rgba(255, 255, 255, 0.87);
  --mdc-theme-text-secondary-on-background: rgba(255, 255, 255, 0.60);
  --mdc-theme-text-hint-on-background: rgba(255, 255, 255, 0.38);
  --mdc-theme-text-disabled-on-background: rgba(255, 255, 255, 0.38);

  --mdc-elevation-1: 0 2px 1px -1px rgba(0, 0, 0, .2), 0 1px 1px 0 rgba(0, 0, 0, .14), 0 1px 3px 0 rgba(0, 0, 0, .12);
  --mdc-elevation-2: 0 3px 1px -2px rgba(0, 0, 0, .2), 0 2px 2px 0 rgba(0, 0, 0, .14), 0 1px 5px 0 rgba(0, 0, 0, .12);
  --mdc-elevation-3: 0 3px 3px -2px rgba(0, 0, 0, .2), 0 3px 4px 0 rgba(0, 0, 0, .14), 0 1px 8px 0 rgba(0, 0, 0, .12);
  --mdc-elevation-4: 0 2px 4px -1px rgba(0, 0, 0, .2), 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12);
  --mdc-elevation-8: 0 5px 5px -3px rgba(0, 0, 0, .2), 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12);
  --mdc-elevation-24: 0 11px 15px -7px rgba(0, 0, 0, .2), 0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12);

  --mdc-border-color: rgba(255, 255, 255, 0.12);

  --gauge-inner-bg: #1a1a2e;
  --gauge-empty-tick: rgba(255, 255, 255, 0.10);
  --gauge-ring-border: rgba(255, 255, 255, 0.06);
  --gauge-text: #ffffff;
  --gauge-unit-text: rgba(255, 255, 255, 0.60);
  --chart-grid: rgba(255, 255, 255, 0.1);
  --chart-text: rgba(255, 255, 255, 0.7);
  --gauge-card-bg: #1a1a2e;
  --gauge-card-border: rgba(255, 255, 255, 0.08);
  --gauge-card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--mdc-theme-background);
  color: var(--mdc-theme-text-primary-on-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.theme-light {
  --mdc-theme-background: #f6f7fb;
  --mdc-theme-surface: #ffffff;
  --mdc-theme-surface-2: #eef1f7;
  --mdc-theme-primary: #2957ff;
  --mdc-theme-primary-dark: #1e3fb8;
  --mdc-theme-secondary: #0f9bbf;
  --mdc-theme-error: #b42318;
  --mdc-theme-success: #15803d;
  --mdc-theme-warning: #f59e0b;
  --mdc-theme-info: #2563eb;

  --mdc-theme-text-primary-on-background: #0f172a;
  --mdc-theme-text-secondary-on-background: rgba(15, 23, 42, 0.7);
  --mdc-theme-text-hint-on-background: rgba(15, 23, 42, 0.5);
  --mdc-theme-text-disabled-on-background: rgba(15, 23, 42, 0.4);

  --mdc-border-color: rgba(15, 23, 42, 0.12);

  --gauge-inner-bg: #f3f5fb;
  --gauge-empty-tick: rgba(15, 23, 42, 0.12);
  --gauge-ring-border: rgba(15, 23, 42, 0.12);
  --gauge-text: #0f172a;
  --gauge-unit-text: rgba(15, 23, 42, 0.6);
  --chart-grid: rgba(15, 23, 42, 0.12);
  --chart-text: rgba(15, 23, 42, 0.7);
  --gauge-card-bg: #ffffff;
  --gauge-card-border: rgba(15, 23, 42, 0.12);
  --gauge-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.reduced-motion * {
  animation: none !important;
  transition: none !important;
}

* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Helpers */
.primary-text {
  color: var(--mdc-theme-primary);
}

.success-text {
  color: var(--mdc-theme-success);
}

.warning-text {
  color: var(--mdc-theme-warning);
}

.info-text {
  color: var(--mdc-theme-info);
}

.error-text {
  color: var(--mdc-theme-error);
}

.mt-3 {
  margin-top: 1.5rem;
}

.flex-1 {
  flex: 1;
}

.span-2 {
  grid-column: span 2;
}

@media(max-width: 600px) {
  .span-2 {
    grid-column: span 1;
  }
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar / Drawer */
.mdc-drawer {
  width: 280px;
  background-color: var(--mdc-theme-surface);
  border-right: 1px solid var(--mdc-border-color);
  display: flex;
  flex-direction: column;
}

.mdc-drawer__header {
  padding: 24px 16px;
  border-bottom: 1px solid var(--mdc-border-color);
}

.mdc-drawer__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--mdc-theme-text-primary-on-background);
}

.mdc-drawer__subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--mdc-theme-text-secondary-on-background);
  font-weight: 400;
}

.mdc-drawer__content {
  flex: 1;
  padding: 8px 0;
}

/* List Items */
.mdc-list {
  display: flex;
  flex-direction: column;
}

.mdc-list-item {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 48px;
  color: var(--mdc-theme-text-primary-on-background);
  position: relative;
  transition: background-color 0.2s;
  border-radius: 0 24px 24px 0;
  margin-right: 16px;
}

.mdc-list-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.mdc-list-item--activated {
  color: var(--mdc-theme-primary);
  background-color: rgba(187, 134, 252, 0.12);
  /* Primary w/ opacity */
}

.mdc-list-item--activated:hover {
  background-color: rgba(187, 134, 252, 0.16);
}

.mdc-list-item__graphic {
  margin-right: 24px;
  font-size: 24px;
}

.mdc-list-item__text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Drawer Footer */
.drawer-footer {
  padding: 16px;
  border-top: 1px solid var(--mdc-border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 8px;
  background-color: var(--mdc-theme-surface-2);
}

.drawer-footer .mdc-button {
  font-size: 0.75rem !important;
  padding: 8px 12px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.drawer-footer .mdc-button i {
  margin-right: 4px;
}

.status-chip i {
  font-size: 18px;
}


.status-running {
  color: var(--mdc-theme-success);
}

.status-stopped {
  color: var(--mdc-theme-error);
}

/* Top App Bar */
.mdc-top-app-bar {
  background-color: var(--mdc-theme-surface);
  color: var(--mdc-theme-text-primary-on-background);
  box-shadow: var(--mdc-elevation-4);
  z-index: 4;
  position: sticky;
  top: 0;
}

.mdc-top-app-bar__row {
  display: flex;
  height: 64px;
  padding: 0 20px;
  align-items: center;
}

.mdc-top-app-bar__section {
  display: flex;
  flex: 1;
  align-items: center;
}

.mdc-top-app-bar__title {
  font-size: 1.25rem;
  font-weight: 500;
}

/* Content */
.main-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.content-section {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-title {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--mdc-theme-text-primary-on-background);
}

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

.section-header .section-title {
  margin: 0;
}

/* Grid Layouts */
.mdc-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

/* Cards */
.mdc-card {
  background-color: var(--mdc-theme-surface);
  border-radius: 8px;
  box-shadow: var(--mdc-elevation-2);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.mdc-card--outlined {
  box-shadow: none;
  border: 1px solid var(--mdc-border-color);
  flex-direction: row;
  align-items: center;
  padding: 16px 20px;
  gap: 20px;
}

.card-icon i {
  font-size: 32px;
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--mdc-theme-text-secondary-on-background);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--mdc-theme-text-primary-on-background);
}

.speed-card {
  flex-direction: row;
  align-items: center;
  padding: 20px 24px;
  gap: 24px;
}

.speed-card i {
  font-size: 36px;
}

.speed-value {
  font-size: 1.5rem;
  font-weight: 500;
}

.speed-label {
  font-size: 0.875rem;
  color: var(--mdc-theme-text-secondary-on-background);
}

/* Configurations Grid */
.config-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-card {
  padding: 12px 16px;
  background-color: var(--mdc-theme-surface-2);
  transition: box-shadow 0.2s, background-color 0.2s;
  border-radius: 8px;
  border-left: 4px solid transparent;
}

.config-card--active {
  border-left-color: var(--mdc-theme-success);
}

.config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.config-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.drag-indicator-box {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mdc-theme-text-disabled-on-background);
  cursor: grab;
}

.drag-indicator-box i {
  font-size: 24px;
}

.config-info {
  display: flex;
  flex-direction: column;
}

.config-title {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 500;
}

.config-meta {
  font-size: 0.8125rem;
  color: var(--mdc-theme-text-secondary-on-background);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.green {
  background-color: var(--mdc-theme-success);
  box-shadow: 0 0 4px var(--mdc-theme-success);
}

.status-dot.grey {
  background-color: var(--mdc-theme-text-disabled-on-background);
}

.config-live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.config-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.config-shares {
  margin-top: 16px;
  border-top: 1px solid var(--mdc-border-color);
  padding-top: 16px;
}

.divider {
  height: 1px;
  background-color: var(--mdc-border-color);
  margin: 16px 0;
  width: 100%;
}

.share-title {
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--mdc-theme-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.share-qr {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  background: white;
  padding: 4px;
}

.share-details {
  flex: 1;
  min-width: 0;
}

.share-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.share-url-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-input {
  font-family: inherit;
  color: var(--mdc-theme-text-primary-on-background);
  background: var(--mdc-theme-background);
  border: 1px solid var(--mdc-border-color);
  padding: 8px;
  border-radius: 4px;
  flex: 1;
  font-size: 0.875rem;
  min-width: 0;
  /* allows text truncation */
  text-overflow: ellipsis;
  outline: none;
}

.config-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Settings */
.settings-card {
  padding: 24px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.settings-subtitle {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 500;
}

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

.settings-row--form {
  flex-wrap: wrap;
  align-items: flex-start;
}

.settings-row--form .settings-row-info {
  flex: 1 1 220px;
}

.settings-row--form .settings-row-control {
  flex: 0 1 220px;
}

.settings-row + .settings-row {
  margin-top: 12px;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-row-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.settings-row-help {
  font-size: 0.82rem;
  color: var(--mdc-theme-text-secondary-on-background);
}

.settings-row-control {
  min-width: 170px;
}

.settings-select-wrap {
  position: relative;
}

.settings-select {
  width: 100%;
  background: var(--mdc-theme-background);
  border: 1px solid var(--mdc-border-color);
  color: var(--mdc-theme-text-primary-on-background);
  border-radius: 6px;
  padding: 8px 36px 8px 12px;
  font-size: 0.85rem;
  appearance: none;
  -webkit-appearance: none;
}

.settings-select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--mdc-theme-text-secondary-on-background);
  pointer-events: none;
}

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

.helper-text {
  font-size: 0.875rem;
  color: var(--mdc-theme-text-secondary-on-background);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  flex-wrap: wrap;
}

.helper-text i {
  font-size: 18px;
  margin-top: 2px;
}

.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-list li {
  display: flex;
  gap: 8px;
}

.info-label {
  color: var(--mdc-theme-text-secondary-on-background);
  min-width: 140px;
}

/* Buttons */
.mdc-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 64px;
  border: none;
  outline: none;
  line-height: inherit;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  overflow: visible;
  vertical-align: middle;
  background: transparent;
  padding: 0 16px;
  height: 36px;
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.0892857143em;
  text-transform: uppercase;
  color: var(--mdc-theme-primary);
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.mdc-button:hover {
  background-color: rgba(187, 134, 252, 0.08);
}

.mdc-button--raised {
  box-shadow: var(--mdc-elevation-2);
  background-color: var(--mdc-theme-surface-2);
  color: var(--mdc-theme-text-primary-on-background);
}

.mdc-button--raised:hover {
  box-shadow: var(--mdc-elevation-4);
  background-color: rgba(255, 255, 255, 0.08);
}

.mdc-button--primary {
  background-color: var(--mdc-theme-primary);
  color: var(--mdc-theme-background);
}

.mdc-button--primary:hover {
  background-color: #d1a6ff;
}

.mdc-button--outlined {
  border: 1px solid var(--mdc-border-color);
  padding: 0 15px;
  /* adjust for border */
}

.mdc-button--outlined:hover {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.2);
}

.mdc-button--warning {
  background-color: var(--mdc-theme-warning);
  color: black;
}

.mdc-button--warning:hover {
  background-color: #ffb74d;
}

.mdc-button__icon {
  margin-left: -4px;
  margin-right: 8px;
  display: inline-block;
  width: 18px;
  height: 18px;
  font-size: 18px;
}

.mdc-icon-button {
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--mdc-theme-text-secondary-on-background);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}

.mdc-icon-button:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--mdc-theme-text-primary-on-background);
}

/* Toggle Switch */
.mdc-switch {
  display: inline-flex;
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.mdc-switch__native-control {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.mdc-switch__background {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.38);
  transition: background-color 0.15s;
  position: relative;
}

.mdc-switch__knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mdc-switch__native-control:checked+.mdc-switch__background {
  background-color: rgba(187, 134, 252, 0.5);
  /* Primary with opacity */
}

.mdc-switch__native-control:checked+.mdc-switch__background .mdc-switch__knob {
  transform: translateX(16px);
  background-color: var(--mdc-theme-primary);
}

.switch-label {
  font-size: 0.875rem;
  color: var(--mdc-theme-text-primary-on-background);
}

/* Forms & Text Fields */
.form-section-title {
  margin: 24px 0 16px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--mdc-theme-primary);
}

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

.form-section-header .form-section-title {
  margin: 0;
}

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

.mdc-text-field {
  display: inline-flex;
  position: relative;
  height: 56px;
  background-color: transparent;
  width: 100%;
  box-sizing: border-box;
}

.mdc-text-field--outlined {
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  transition: border-color 0.15s;
}

.mdc-text-field--outlined:focus-within {
  border-color: var(--mdc-theme-primary);
  border-width: 2px;
}

.mdc-text-field__input {
  align-self: flex-end;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 12px 16px 14px;
  border: none;
  background: transparent;
  color: var(--mdc-theme-text-primary-on-background);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

.mdc-text-field__input[type="text"],
.mdc-text-field__input[type="number"],
.mdc-text-field__input[type="email"] {
  appearance: none;
}

.mdc-text-field select.mdc-text-field__input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23BB86FC' d='M0 0l6 8 6-8H0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.mdc-floating-label {
  position: absolute;
  left: 16px;
  top: 18px;
  font-size: 1rem;
  color: var(--mdc-theme-text-secondary-on-background);
  pointer-events: none;
  transition: transform 0.15s, color 0.15s, font-size 0.15s;
  background: var(--mdc-theme-surface);
  padding: 0 4px;
}

.mdc-text-field__input:focus~.mdc-floating-label,
.mdc-text-field__input:not(:placeholder-shown)~.mdc-floating-label,
.mdc-text-field__input:not([value=""])~.mdc-floating-label {
  transform: translateY(-28px);
  font-size: 0.75rem;
}

.mdc-text-field__input:focus~.mdc-floating-label {
  color: var(--mdc-theme-primary);
}

/* Select */
.mdc-select {
  position: relative;
  width: 100%;
  height: 56px;
}

.mdc-select label {
  position: absolute;
  left: 12px;
  top: -8px;
  font-size: 0.75rem;
  color: var(--mdc-theme-primary);
  background: var(--mdc-theme-surface);
  padding: 0 4px;
  z-index: 1;
}

.native-select {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  color: var(--mdc-theme-text-primary-on-background);
  padding: 0 16px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.native-select:focus {
  border-color: var(--mdc-theme-primary);
  border-width: 2px;
}

.input-with-button {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-button .mdc-button {
  height: 56px;
}

/* Snackbars / Alerts */
.mdc-snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 400;
  box-shadow: var(--mdc-elevation-4);
  background-color: #323232;
  color: white;
  transition: opacity 0.3s;
}

.mdc-snackbar--success {
  background-color: #2E7D32;
}

.mdc-snackbar--error {
  background-color: #C62828;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 16px 24px 28px;
  border-top: 1px solid var(--mdc-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--mdc-theme-text-secondary-on-background);
}

.app-footer__left,
.app-footer__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-footer__brand {
  font-weight: 600;
  color: var(--mdc-theme-text-primary-on-background);
}

.app-footer__divider {
  opacity: 0.4;
}

.app-footer__link {
  color: var(--mdc-theme-primary);
  font-weight: 600;
}

.app-footer__link:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   Config Dialog — Premium redesign
   ═══════════════════════════════════════════════════════════ */

.cfg-dialog {
  background: #1a1a2e;
  border: 1px solid rgba(187, 134, 252, 0.2);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  width: 100%;
  max-width: 620px;
  /* Use height + max-height so flex children can reliably scroll */
  height: 90dvh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* clip rounded corners; body handles its own scroll */
}

/* ── Header ──────────────────────────────────────────────── */
.cfg-dialog__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  background: linear-gradient(135deg, rgba(187, 134, 252, 0.12) 0%, rgba(3, 218, 198, 0.06) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.cfg-dialog__header-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(187, 134, 252, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cfg-dialog__header-icon i {
  font-size: 20px;
  color: var(--mdc-theme-primary);
}

.cfg-dialog__title {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}

.cfg-dialog__close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.cfg-dialog__close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.cfg-dialog__close i {
  font-size: 18px;
}

/* ── Scrollable body ─────────────────────────────────────── */
.cfg-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.cfg-dialog__body {
  flex: 1 1 0;
  /* 0 basis so it can shrink below content size */
  min-height: 0;
  /* CRITICAL — allows flex child to shrink & scroll */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* iOS momentum scroll */
  overscroll-behavior: contain;
  /* stop page scroll bleeding through */
  touch-action: pan-y;
  /* allow vertical swipe on touch */
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(187, 134, 252, 0.3) transparent;
}

.cfg-dialog__body::-webkit-scrollbar {
  width: 4px;
}

.cfg-dialog__body::-webkit-scrollbar-thumb {
  background: rgba(187, 134, 252, 0.3);
  border-radius: 4px;
}

/* ── Section block ───────────────────────────────────────── */
.cfg-section {
  padding: 18px 20px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cfg-section:last-of-type {
  border-bottom: none;
}

.cfg-section__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mdc-theme-primary);
  margin-bottom: 14px;
}

.cfg-section__label i {
  font-size: 15px;
  opacity: 0.9;
}

/* ── Grid ────────────────────────────────────────────────── */
.cfg-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.cfg-grid--1 {
  grid-template-columns: 1fr;
}

.cfg-grid--2 {
  grid-template-columns: 1fr 1fr;
}

/* ── Field ───────────────────────────────────────────────── */
.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cfg-field--full {
  grid-column: 1 / -1;
}

.cfg-field--row {
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}

.cfg-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cfg-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.cfg-input:focus {
  border-color: var(--mdc-theme-primary);
  background: rgba(187, 134, 252, 0.06);
  box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.12);
}

.cfg-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
}

.cfg-mono {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.78rem;
}

/* ── Select ──────────────────────────────────────────────── */
.cfg-select-wrap {
  position: relative;
  width: 100%;
}

.cfg-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.cfg-select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.cfg-select option {
  background: #1e1e2e;
  color: #fff;
}

/* ── Generate button ─────────────────────────────────────── */
.cfg-gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  flex-shrink: 0;
  background: rgba(187, 134, 252, 0.12);
  border: 1px solid rgba(187, 134, 252, 0.3);
  border-radius: 8px;
  color: var(--mdc-theme-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  align-self: flex-end;
}

.cfg-gen-btn:hover {
  background: rgba(187, 134, 252, 0.2);
  border-color: rgba(187, 134, 252, 0.5);
}

.cfg-gen-btn i {
  font-size: 16px;
}

/* ── Sticky footer ───────────────────────────────────────── */
.cfg-dialog__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.cfg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.cfg-btn i {
  font-size: 16px;
}

.cfg-btn:active {
  transform: scale(0.97);
}

.cfg-btn--ghost {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cfg-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.cfg-btn--primary {
  background: var(--mdc-theme-primary);
  color: #000;
  box-shadow: 0 2px 12px rgba(187, 134, 252, 0.35);
}

.cfg-btn--primary:hover {
  background: #d1a6ff;
  box-shadow: 0 4px 20px rgba(187, 134, 252, 0.5);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .cfg-dialog {
    max-height: 98dvh;
    border-radius: 12px;
  }

  .cfg-grid--2 {
    grid-template-columns: 1fr;
  }

  .cfg-field--row {
    flex-direction: column;
    align-items: stretch;
  }

  .cfg-gen-btn {
    width: 100%;
    justify-content: center;
  }

  .cfg-dialog__footer {
    flex-direction: row;
  }
}

/* Modal / Dialog */
.mdc-dialog-scrim {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}



.mdc-dialog {
  background-color: var(--mdc-theme-surface);
  border-radius: 4px;
  box-shadow: var(--mdc-elevation-24);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mdc-dialog__title {
  margin: 0;
  padding: 20px 24px;
  font-size: 1.25rem;
  font-weight: 500;
  border-bottom: 1px solid var(--mdc-border-color);
  flex-shrink: 0;
}

.mdc-dialog__content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.mdc-dialog__actions {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--mdc-border-color);
  flex-shrink: 0;
  background-color: var(--mdc-theme-surface);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--mdc-theme-text-secondary-on-background);
  grid-column: 1 / -1;
  border: 1px dashed var(--mdc-border-color);
  border-radius: 8px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Info Cards Grid */
.info-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 16px 0 24px 0;
}

.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background-color: var(--mdc-theme-surface);
  border: 1px solid var(--mdc-border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.info-card:hover {
  background-color: var(--mdc-theme-surface-2);
  border-color: var(--mdc-theme-primary);
}

.info-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  width: 48px;
  height: 48px;
  background-color: rgba(187, 134, 252, 0.1);
  border-radius: 50%;
  color: var(--mdc-theme-primary);
}

.info-card-icon i {
  font-size: 24px;
}

.info-card-content {
  flex: 1;
  min-width: 0;
}

.info-card-label {
  font-size: 0.75rem;
  color: var(--mdc-theme-text-secondary-on-background);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.info-card-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--mdc-theme-text-primary-on-background);
  word-break: break-word;
}

/* Gauge Meters */
.gauges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 16px;
  background-color: var(--gauge-card-bg);
  border: 1px solid var(--gauge-card-border);
  border-radius: 12px;
  box-shadow: var(--gauge-card-shadow);
}

.actions-row .mdc-button,
.actions-row a.mdc-button {
  min-width: 160px;
}

.gauge-canvas-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-canvas-wrapper canvas {
  max-width: 100%;
  height: auto;
}

.gauge-label {
  margin-top: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--mdc-theme-text-secondary-on-background);
}

.gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: 700;
  color: var(--mdc-theme-text-primary-on-background);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet  ≤ 768px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Layout ─────────────────────────────────────────────── */
  .app-layout {
    flex-direction: column;
    height: 100dvh;
    /* use dynamic viewport on mobile */
  }

  /* ── Sidebar → horizontal tab strip ─────────────────────── */
  .mdc-drawer {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--mdc-border-color);
    flex-shrink: 0;
  }

  .mdc-drawer__header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
  }

  .mdc-drawer__title {
    font-size: 1.1rem;
  }

  .mdc-drawer__subtitle {
    display: none;
  }

  .mdc-drawer__content {
    padding: 0;
  }

  .mdc-list {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 8px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
  }

  .mdc-list::-webkit-scrollbar {
    display: none;
  }

  .mdc-list-item {
    flex-shrink: 0;
    border-radius: 20px;
    margin-right: 4px;
    padding: 0 14px;
    height: 40px;
  }

  .mdc-list-item__graphic {
    margin-right: 8px;
    font-size: 20px;
  }

  .mdc-list-item__text {
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .drawer-footer {
    display: none;
  }

  /* ── Main wrapper scrolls freely ────────────────────────── */
  .main-wrapper {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  /* ── Top App Bar ─────────────────────────────────────────── */
  .mdc-top-app-bar__row {
    height: 52px;
    padding: 0 16px;
  }

  .mdc-top-app-bar__title {
    font-size: 1.1rem;
  }

  /* ── Content padding ─────────────────────────────────────── */
  .main-content {
    padding: 16px;
  }

  /* ── Overview info cards: 2 columns ─────────────────────── */
  .info-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* ── Gauges: 2 × 2 grid ─────────────────────────────────── */
  .gauges-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* ── Config card header: allow actions to wrap ───────────── */
  .config-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .config-header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .config-header-right {
    flex-shrink: 0;
  }

  /* ── Share items: let URL wrap below QR ─────────────────── */
  .share-item {
    flex-wrap: wrap;
    gap: 12px;
  }

  .share-qr {
    width: 56px;
    height: 56px;
  }

  .share-details {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* ── Section header: stack on small screens ─────────────── */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* ── Settings ────────────────────────────────────────────── */
  .settings-card {
    padding: 16px;
  }

  .actions-row {
    flex-wrap: wrap;
  }

  /* ── Modal: full-width with small margin ─────────────────── */
  .mdc-dialog-scrim {
    padding: 12px;
  }

  .mdc-dialog {
    max-width: 100%;
    max-height: 95dvh;
    border-radius: 8px;
  }

  .mdc-dialog__content {
    padding: 16px;
  }

  .mdc-dialog__title {
    padding: 16px;
    font-size: 1.1rem;
  }

  .mdc-dialog__actions {
    padding: 12px 16px;
  }

  /* ── Form grid: single column ────────────────────────────── */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .span-2 {
    grid-column: span 1;
  }

  /* ── Input + button row: stack ───────────────────────────── */
  .input-with-button {
    flex-direction: column;
    align-items: stretch;
  }

  .input-with-button .mdc-button {
    width: 100%;
    height: 44px;
  }

  /* ── Traffic chart card ──────────────────────────────────── */
  .mdc-card[style*="margin-top: 24px"] {
    margin-top: 16px !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Small phone  ≤ 480px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Overview info cards: single column ─────────────────── */
  .info-cards-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* ── Gauges: 2 per row but smaller ──────────────────────── */
  .gauges-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Scale the canvas DOWN proportionally on tiny screens */
  .gauge-canvas-wrapper {
    width: 140px;
    height: 140px;
  }

  /* ── Config meta: allow line-break ──────────────────────── */
  .config-meta {
    flex-wrap: wrap;
    font-size: 0.75rem;
  }

  /* ── Snackbar: full width ────────────────────────────────── */
  .mdc-snackbar {
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
    font-size: 0.8rem;
    padding: 10px 16px;
  }

  /* ── Top bar title shorter ───────────────────────────────── */
  .mdc-top-app-bar__title {
    font-size: 1rem;
  }

  /* ── Content padding tighter ─────────────────────────────── */
  .main-content {
    padding: 12px;
  }

  /* ── Buttons: full width in actions row ─────────────────── */
  .actions-row .mdc-button {
    flex: 1;
  }

  /* ── Empty state compact ─────────────────────────────────── */
  .empty-state {
    padding: 32px 16px;
  }

  .empty-state i {
    font-size: 36px;
  }
}
