/*
 * NexusBot UI 2026
 * Canonical visual layer: M3 Expressive components, Stripe-like composition,
 * Linear-like interaction density. Loaded after the legacy component styles
 * so behaviour can evolve independently from presentation.
 */

:root,
[data-theme="light"] {
  color-scheme: light;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --neutral-0: #ffffff;
  --neutral-25: #fbfcfe;
  --neutral-50: #f7f9fc;
  --neutral-100: #eef2f7;
  --neutral-200: #dde4ee;
  --neutral-300: #c8d2df;
  --neutral-500: #64748b;
  --neutral-700: #334155;
  --neutral-900: #0f172a;

  --md-sys-color-primary: var(--brand-600);
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #e7f0ff;
  --md-sys-color-on-primary-container: #123a7a;
  --md-sys-color-secondary: #52627a;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #e9eef5;
  --md-sys-color-on-secondary-container: #27364c;
  --md-sys-color-tertiary: #52627a;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #e9eef5;
  --md-sys-color-on-tertiary-container: #27364c;
  --md-sys-color-error: #b42318;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #fee4e2;
  --md-sys-color-on-error-container: #7a271a;
  --md-sys-color-background: #f5f7fb;
  --md-sys-color-on-background: var(--neutral-900);
  --md-sys-color-surface: #ffffff;
  --md-sys-color-on-surface: var(--neutral-900);
  --md-sys-color-surface-variant: #e9eef5;
  --md-sys-color-on-surface-variant: #52627a;
  --md-sys-color-outline: #718096;
  --md-sys-color-outline-variant: #d7dee9;
  --md-sys-color-shadow: #0f172a;
  --md-sys-color-surface-dim: #e8edf4;
  --md-sys-color-surface-bright: #ffffff;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f8fafc;
  --md-sys-color-surface-container: #f1f5f9;
  --md-sys-color-surface-container-high: #e9eef5;
  --md-sys-color-surface-container-highest: #dde4ee;
  --md-sys-color-success-container: #dcfae6;
  --md-sys-color-on-success-container: #08662f;
  --md-sys-color-caution-container: #fef0c7;
  --md-sys-color-on-caution-container: #7a4d00;

  --app-canvas: #f5f7fb;
  --app-panel: #ffffff;
  --app-panel-muted: #f8fafc;
  --app-panel-raised: #ffffff;
  --app-text: #0f172a;
  --app-text-muted: #64748b;
  --app-border: #dce3ed;
  --app-border-strong: #cbd5e1;
  --app-hover: #f1f5f9;
  --app-selected: #eaf2ff;
  --app-selected-border: #a9c7ff;
  --app-blue-soft: #eef5ff;
  --app-shadow-xs: 0 1px 2px rgb(15 23 42 / 5%);
  --app-shadow-sm: 0 1px 3px rgb(15 23 42 / 7%), 0 4px 12px rgb(15 23 42 / 4%);
  --app-shadow-md: 0 12px 32px rgb(15 23 42 / 10%);
}

[data-theme="dark"] {
  color-scheme: dark;
  --md-sys-color-primary: #8fb5ff;
  --md-sys-color-on-primary: #072b63;
  --md-sys-color-primary-container: #143f7e;
  --md-sys-color-on-primary-container: #d9e6ff;
  --md-sys-color-secondary: #b9c6da;
  --md-sys-color-on-secondary: #233044;
  --md-sys-color-secondary-container: #303e54;
  --md-sys-color-on-secondary-container: #d8e2f2;
  --md-sys-color-tertiary: #b9c6da;
  --md-sys-color-on-tertiary: #233044;
  --md-sys-color-tertiary-container: #303e54;
  --md-sys-color-on-tertiary-container: #d8e2f2;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #7f1d1d;
  --md-sys-color-on-error-container: #fee2e2;
  --md-sys-color-background: #0d1320;
  --md-sys-color-on-background: #e7edf7;
  --md-sys-color-surface: #111827;
  --md-sys-color-on-surface: #e7edf7;
  --md-sys-color-surface-variant: #2a3547;
  --md-sys-color-on-surface-variant: #aebbcf;
  --md-sys-color-outline: #8492a7;
  --md-sys-color-outline-variant: #344156;
  --md-sys-color-shadow: #000000;
  --md-sys-color-surface-dim: #0d1320;
  --md-sys-color-surface-bright: #263247;
  --md-sys-color-surface-container-lowest: #0a0f1a;
  --md-sys-color-surface-container-low: #111827;
  --md-sys-color-surface-container: #172033;
  --md-sys-color-surface-container-high: #202b3d;
  --md-sys-color-surface-container-highest: #2a3547;
  --md-sys-color-success-container: #14532d;
  --md-sys-color-on-success-container: #bbf7d0;
  --md-sys-color-caution-container: #713f12;
  --md-sys-color-on-caution-container: #fef3c7;

  --app-canvas: #0d1320;
  --app-panel: #111827;
  --app-panel-muted: #172033;
  --app-panel-raised: #192337;
  --app-text: #e7edf7;
  --app-text-muted: #9eacc1;
  --app-border: #2d394d;
  --app-border-strong: #3c4a60;
  --app-hover: #1d293b;
  --app-selected: #18345f;
  --app-selected-border: #416da9;
  --app-blue-soft: #142d52;
  --app-shadow-xs: 0 1px 2px rgb(0 0 0 / 20%);
  --app-shadow-sm: 0 1px 3px rgb(0 0 0 / 28%), 0 6px 16px rgb(0 0 0 / 16%);
  --app-shadow-md: 0 16px 38px rgb(0 0 0 / 34%);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    color-scheme: dark;
    --md-sys-color-primary: #8fb5ff;
    --md-sys-color-on-primary: #072b63;
    --md-sys-color-primary-container: #143f7e;
    --md-sys-color-on-primary-container: #d9e6ff;
    --md-sys-color-secondary: #b9c6da;
    --md-sys-color-on-secondary: #233044;
    --md-sys-color-secondary-container: #303e54;
    --md-sys-color-on-secondary-container: #d8e2f2;
    --md-sys-color-tertiary: #b9c6da;
    --md-sys-color-on-tertiary: #233044;
    --md-sys-color-tertiary-container: #303e54;
    --md-sys-color-on-tertiary-container: #d8e2f2;
    --md-sys-color-background: #0d1320;
    --md-sys-color-on-background: #e7edf7;
    --md-sys-color-surface: #111827;
    --md-sys-color-on-surface: #e7edf7;
    --md-sys-color-surface-variant: #2a3547;
    --md-sys-color-on-surface-variant: #aebbcf;
    --md-sys-color-outline: #8492a7;
    --md-sys-color-outline-variant: #344156;
    --md-sys-color-surface-container-lowest: #0a0f1a;
    --md-sys-color-surface-container-low: #111827;
    --md-sys-color-surface-container: #172033;
    --md-sys-color-surface-container-high: #202b3d;
    --md-sys-color-surface-container-highest: #2a3547;
    --app-canvas: #0d1320;
    --app-panel: #111827;
    --app-panel-muted: #172033;
    --app-panel-raised: #192337;
    --app-text: #e7edf7;
    --app-text-muted: #9eacc1;
    --app-border: #2d394d;
    --app-border-strong: #3c4a60;
    --app-hover: #1d293b;
    --app-selected: #18345f;
    --app-selected-border: #416da9;
    --app-blue-soft: #142d52;
    --app-shadow-xs: 0 1px 2px rgb(0 0 0 / 20%);
    --app-shadow-sm: 0 1px 3px rgb(0 0 0 / 28%), 0 6px 16px rgb(0 0 0 / 16%);
    --app-shadow-md: 0 16px 38px rgb(0 0 0 / 34%);
  }
}

:root {
  --md-ref-typeface-brand: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-ref-typeface-plain: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-ref-typeface-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --page-max-lg: 1360px;
  --drawer-width: 288px;
  --app-card-padding: 24px;
  --app-card-gap: 24px;
  --app-shape-panel: 20px;
  --md-sys-shape-corner-extra-small: 6px;
  --md-sys-shape-corner-small: 10px;
  --md-sys-shape-corner-medium: 16px;
  --md-sys-shape-corner-large: 20px;
  --md-sys-shape-corner-extra-large: 20px;
  --md-sys-shape-corner-full: 999px;
  --md-sys-shape-corner-morph-hover: 16px;
  --md-sys-shape-corner-morph-active: 12px;
  --md-sys-shape-corner-dialog: 20px;
  --motion-duration-short: 180ms;
  --motion-duration-medium: 200ms;
  --motion-duration-long: 220ms;
  --motion-easing-standard: cubic-bezier(.2, .8, .2, 1);
  --motion-easing-emphasized: cubic-bezier(.16, 1, .3, 1);
  --motion-easing-spring: cubic-bezier(.16, 1, .3, 1);
  --app-surface-border: var(--app-border);
  --app-surface-tint: var(--app-blue-soft);
  --app-surface-tint-strong: var(--app-selected);
  --app-state-hover: var(--app-hover);
  --app-state-pressed: var(--app-selected);
  --app-focus-ring: rgb(37 99 235 / 24%);
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: var(--app-shadow-xs);
  --md-sys-elevation-level2: var(--app-shadow-sm);
  --md-sys-elevation-level3: var(--app-shadow-md);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--app-canvas);
  text-rendering: optimizeLegibility;
}

html,
body {
  width: 100%;
  min-width: 320px;
}

body {
  background: var(--app-canvas);
  color: var(--app-text);
  font-family: var(--md-ref-typeface-plain);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
}

body::before,
body::after {
  display: none !important;
  animation: none !important;
}

button,
input,
select,
textarea { font: inherit; }

.material-symbols-outlined {
  font-family: "Material Symbols Rounded" !important;
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24;
}

.app-shell {
  background: var(--app-canvas);
}

.top-app-bar {
  min-height: 72px;
  padding: 0 24px;
  gap: 24px;
  background: color-mix(in srgb, var(--app-panel) 94%, transparent);
  border-bottom: 1px solid var(--app-border);
  box-shadow: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.top-app-bar .brand-block {
  width: 264px;
  gap: 12px;
}

.brand-icon {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 23px !important;
  box-shadow: 0 5px 14px rgb(37 99 235 / 20%);
}

.top-app-bar .brand-text h1 {
  color: var(--app-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.top-app-bar .brand-subtitle {
  margin: 1px 0 0;
  color: var(--app-text-muted);
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.header-actions {
  margin-left: auto;
}

.top-app-bar #theme-btn,
.top-app-bar #help-btn {
  --md-icon-button-icon-color: var(--app-text-muted);
  --md-outlined-button-label-text-color: var(--app-text-muted);
  --md-outlined-button-outline-color: var(--app-border);
}

#status-badge {
  --md-assist-chip-container-color: var(--app-panel-muted);
  --md-assist-chip-outline-color: var(--app-border);
  --md-assist-chip-label-text-color: var(--app-text-muted);
}

#plan-badge {
  --md-assist-chip-container-color: var(--app-blue-soft);
  --md-assist-chip-outline-color: var(--app-selected-border);
  --md-assist-chip-label-text-color: var(--md-sys-color-primary);
}

.app-layout {
  background: var(--app-canvas);
}

.navigation-drawer {
  width: var(--drawer-width);
  min-width: var(--drawer-width);
  background: var(--app-panel-muted);
  border-right: 1px solid var(--app-border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transition: transform 200ms var(--motion-easing-emphasized), opacity 200ms ease;
}

.drawer-header {
  padding: 24px 20px 8px;
}

.drawer-title-row {
  gap: 10px;
  margin: 0 0 2px;
}

.drawer-title-icon {
  color: var(--app-text-muted);
  font-size: 20px;
}

.drawer-header h2 {
  font-size: 13px;
  line-height: 20px;
  font-weight: 650;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.drawer-subtitle {
  padding-left: 30px;
  color: var(--app-text-muted);
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.drawer-search {
  padding: 12px 16px 8px;
}

.drawer-search md-outlined-text-field {
  --md-outlined-text-field-container-shape: 14px;
  --md-outlined-text-field-container-color: var(--app-panel);
  --md-outlined-text-field-outline-color: var(--app-border);
}

.drawer-list {
  padding: 8px 12px 16px;
}

md-list-item.account-list-item {
  margin: 4px 0 !important;
  border: 1px solid transparent !important;
  border-radius: 16px !important;
  --md-list-item-container-shape: 16px;
  --md-list-item-container-color: transparent;
  --md-list-item-two-line-container-height: 64px;
  box-shadow: none;
  transition: transform 180ms var(--motion-easing-standard), opacity 180ms ease !important;
}

md-list-item.account-list-item:hover {
  --md-list-item-container-color: var(--app-hover);
  --md-list-item-container-shape: 16px;
  border-radius: 16px !important;
  transform: translateX(2px);
  box-shadow: none;
}

md-list-item.account-list-item--selected,
md-list-item.account-list-item--selected:hover {
  --md-list-item-container-color: var(--app-selected) !important;
  --md-list-item-headline-color: var(--app-text) !important;
  --md-list-item-supporting-text-color: var(--app-text-muted) !important;
  --md-list-item-trailing-supporting-text-color: var(--app-text-muted) !important;
  --md-list-item-leading-icon-color: var(--md-sys-color-primary) !important;
  --md-list-item-container-shape: 16px !important;
  border: 1px solid var(--app-selected-border) !important;
  border-radius: 16px !important;
  box-shadow: var(--app-shadow-xs);
  transform: none;
}

.account-avatar--letter,
.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  box-shadow: none;
  text-shadow: none;
  font-size: 13px;
}

.account-avatar--letter:hover { transform: none; }

.account-avatar--running::after {
  width: 9px;
  height: 9px;
  border: 2px solid var(--app-panel-muted);
  animation: running-dot 2000ms ease-in-out infinite;
}

@keyframes running-dot {
  0%, 100% { opacity: .55; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1); }
}

.drawer-footer {
  padding: 16px;
  gap: 12px;
  background: var(--app-panel-muted);
  border-top: 1px solid var(--app-border);
}

.drawer-active-row {
  min-height: 40px;
  padding: 0 4px;
}

.content-pane {
  background: var(--app-canvas);
}

.content-document {
  max-width: var(--page-max-lg);
  padding: 32px 40px 64px;
}

.workspace-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
  margin: 0 0 16px;
  padding: 0 4px;
  background: transparent;
  background-image: none;
  border: 0;
  border-radius: 0;
}

.workspace-header-title-row {
  gap: 10px;
  margin-bottom: 2px;
}

.workspace-header-icon {
  width: 32px !important;
  height: 32px !important;
  border-radius: 10px;
  color: var(--md-sys-color-primary);
  background: var(--app-blue-soft);
  font-size: 18px;
}

.workspace-header-title {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -.035em;
}

.workspace-header-subtitle {
  padding-left: 42px;
  color: var(--app-text-muted);
  font-size: 13px;
}

.view-tabs-container {
  position: sticky;
  top: 12px;
  z-index: 20;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 24px;
  padding: 4px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--app-panel) 94%, transparent);
  box-shadow: var(--app-shadow-xs);
  backdrop-filter: blur(12px);
  --md-primary-tab-container-color: transparent;
  --md-primary-tab-active-indicator-color: var(--app-selected);
  --md-primary-tab-active-label-text-color: var(--md-sys-color-primary);
  --md-primary-tab-label-text-color: var(--app-text-muted);
}

.view-tabs-container md-primary-tab {
  min-width: 128px;
  --md-primary-tab-active-indicator-shape: 12px;
}

.view {
  animation: view-enter 200ms var(--motion-easing-emphasized) both !important;
}

.view.active {
  display: block;
  flex: none;
  min-height: auto;
  padding: 0;
  overflow: visible;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

#view-overview.active {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
}

#view-overview > * { min-width: 0; }

.status-hero {
  grid-column: 1 / -1;
  align-items: center;
  min-height: 148px;
  margin: 0;
  padding: 28px;
  gap: 24px;
  overflow: visible;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-image: none;
  border-radius: 20px;
  box-shadow: var(--app-shadow-sm);
}

.status-hero::before {
  top: 24px;
  bottom: 24px;
  left: 0;
  right: auto;
  width: 4px;
  height: auto;
  background: var(--md-sys-color-primary);
  border-radius: 0 4px 4px 0;
}

.status-hero-body { gap: 20px; }

.status-hero-icon {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 18px;
  background: var(--app-blue-soft);
  transition: transform 200ms var(--motion-easing-standard), opacity 200ms ease;
}

.status-hero-icon:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.status-hero-chips { gap: 8px; }

.status-hero-hint,
.callout-banner {
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--app-panel-muted);
  color: var(--app-text-muted);
  font-size: 13px;
}

.status-hero-actions {
  gap: 8px;
  padding: 0;
}

.overview-command-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 56px;
  margin: 0 !important;
  padding: 8px 12px;
  gap: 8px !important;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-panel-muted);
}

.overview-command-bar .command-separator {
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--app-border);
}

#view-overview > .form-section {
  grid-column: span 4;
  margin: 0;
}

#view-overview > .form-section:has(.terminal-window) {
  grid-column: 1 / -1;
  margin-top: 0 !important;
}

.dashboard-grid {
  grid-column: span 8;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: stretch;
  gap: 16px;
  margin: 0;
}

.dashboard-card {
  min-height: 112px;
  padding: 20px;
  gap: 16px;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-left: 1px solid var(--app-border);
  border-radius: 18px;
  box-shadow: var(--app-shadow-xs);
  backdrop-filter: none;
  transition: transform 200ms var(--motion-easing-standard), opacity 200ms ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  background: var(--app-panel);
  border-color: var(--app-selected-border);
  border-left-color: var(--app-selected-border);
  border-radius: 18px;
  box-shadow: var(--app-shadow-sm);
}

.dashboard-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--app-blue-soft);
  color: var(--md-sys-color-primary);
  font-size: 21px !important;
}

.dashboard-card-label {
  color: var(--app-text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.dashboard-card-value {
  color: var(--app-text);
  font-family: var(--md-ref-typeface-plain);
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -.035em;
}

#stats-section,
#flood-section {
  grid-column: 1 / -1;
  margin: 0;
}

.inline-info-card {
  padding: 16px 20px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-panel);
  box-shadow: none;
  backdrop-filter: none;
}

.view-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 24px;
  padding: 0 4px;
}

.view-intro-copy { max-width: 680px; }

.view-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--md-sys-color-primary);
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.view-intro h2 {
  margin: 0 0 6px;
  color: var(--app-text);
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -.035em;
}

.view-intro p {
  margin: 0;
  color: var(--app-text-muted);
  font-size: 14px;
  line-height: 22px;
}

.settings-toolbar {
  display: flex;
  align-items: center;
  min-height: 64px;
  margin: 0 0 24px !important;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-panel);
  box-shadow: var(--app-shadow-xs);
}

.settings-category {
  margin: 0 0 32px;
}

.settings-category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 0 4px;
  color: var(--app-text-muted);
  font-size: 12px;
  line-height: 20px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.settings-category-title .material-symbols-outlined {
  color: var(--md-sys-color-primary);
  font-size: 18px;
}

.visual-group {
  margin: 0 0 16px;
  padding: 0;
  overflow: clip;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 20px;
  box-shadow: var(--app-shadow-xs);
}

.visual-group::before { display: none; }

details.visual-group[open] > *:not(summary),
.subsection-details > *:not(summary) {
  animation: content-reveal 200ms var(--motion-easing-emphasized) both !important;
}

@keyframes content-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

details.visual-group:not([open]) { padding-bottom: 0; }

summary.visual-group-header {
  min-height: 72px;
  align-items: center;
  margin: 0;
  padding: 16px 20px;
  gap: 14px;
  background: var(--app-panel);
  border-radius: 20px;
  transition: transform 180ms var(--motion-easing-standard), opacity 180ms ease;
}

summary.visual-group-header:hover { filter: none; }

details.visual-group[open] summary.visual-group-header {
  margin: 0;
  border-bottom: 1px solid var(--app-border);
  border-radius: 20px 20px 0 0;
}

summary.visual-group-header > .material-symbols-outlined {
  width: 36px !important;
  height: 36px !important;
  border-radius: 11px;
  background: var(--app-blue-soft);
  color: var(--md-sys-color-primary);
  font-size: 19px;
}

.visual-group-header h2 {
  margin: 0;
  color: var(--app-text);
  font-size: 15px;
  line-height: 22px;
  font-weight: 650;
  letter-spacing: -.015em;
}

.visual-group-header p {
  margin: 2px 0 0;
  color: var(--app-text-muted);
  font-size: 12px;
}

.form-section {
  margin: 0;
  padding: 24px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#view-overview > .form-section {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 18px;
  box-shadow: var(--app-shadow-xs);
}

.visual-group .form-section + .form-section {
  border-top: 1px solid var(--app-border);
}

.form-section + .form-section::before { display: none; }

.section-title,
.subsection-title {
  margin: 0 0 16px;
  color: var(--app-text);
  font-size: 14px;
  line-height: 22px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.form-row {
  gap: 16px;
  margin-bottom: 16px;
}

.form-row:last-child { margin-bottom: 0; }

.form-row--switch {
  min-height: 48px;
  padding: 0;
  border: 0;
}

.form-divider {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--app-border);
}

.form-icon-label { gap: 10px; }

.field-focus-pulse {
  animation: focus-nudge 200ms var(--motion-easing-emphasized) both !important;
}

@keyframes focus-nudge {
  from { opacity: .72; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-icon-label > .material-symbols-outlined {
  color: var(--app-text-muted) !important;
  font-size: 19px;
}

.form-label,
.form-label--inline {
  color: var(--app-text);
  font-size: 13px;
  font-weight: 550;
}

md-outlined-text-field,
md-outlined-select {
  --md-outlined-text-field-container-shape: 14px;
  --md-outlined-text-field-outline-color: var(--app-border-strong);
  --md-outlined-text-field-hover-outline-color: var(--md-sys-color-primary);
  --md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary);
  --md-outlined-text-field-container-color: var(--app-panel);
  --md-outlined-select-text-field-container-shape: 14px;
  --md-outlined-select-text-field-outline-color: var(--app-border-strong);
  transition: transform 180ms var(--motion-easing-standard), opacity 180ms ease !important;
}

md-filled-button,
md-filled-tonal-button,
md-outlined-button,
md-text-button,
md-icon-button,
md-assist-chip,
.action-overflow-btn {
  --md-filled-button-container-shape: 12px;
  --md-filled-tonal-button-container-shape: 12px;
  --md-outlined-button-container-shape: 12px;
  --md-text-button-container-shape: 12px;
  --md-assist-chip-container-shape: 10px;
  transition: transform 180ms var(--motion-easing-standard), opacity 180ms ease !important;
}

md-filled-button:hover,
md-filled-tonal-button:hover,
md-outlined-button:hover,
md-text-button:hover,
md-icon-button:hover,
md-assist-chip:hover,
.action-overflow-btn:hover {
  transform: translateY(-1px);
  box-shadow: none;
  filter: none;
  --md-filled-button-container-shape: 12px;
  --md-filled-tonal-button-container-shape: 12px;
  --md-outlined-button-container-shape: 12px;
  --md-assist-chip-container-shape: 10px;
}

md-filled-button:active,
md-filled-tonal-button:active,
md-outlined-button:active,
md-text-button:active,
md-icon-button:active,
.action-overflow-btn:active {
  transform: scale(.98);
}

md-switch {
  --md-switch-selected-track-color: var(--md-sys-color-primary);
  --md-switch-selected-hover-track-color: var(--brand-700, #1d4ed8);
}

.action-overflow-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-panel);
  color: var(--app-text-muted);
}

.action-overflow-menu {
  min-width: 232px;
  padding: 8px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-panel-raised);
  box-shadow: var(--app-shadow-md);
}

.marks-table,
.messages-list,
.intervals-list,
.stop-rules-list,
.button-sequence-list {
  gap: 10px;
}

.mark-row,
.message-row,
.interval-row,
.stop-rule-row,
.compact-row,
.button-sequence-row,
.log-file-row {
  padding: 12px !important;
  gap: 12px;
  background: var(--app-panel-muted) !important;
  border: 1px solid var(--app-border) !important;
  border-radius: 16px !important;
  box-shadow: none !important;
  transition: transform 180ms var(--motion-easing-standard), opacity 180ms ease !important;
}

.mark-row:hover,
.message-row:hover,
.interval-row:hover,
.stop-rule-row:hover,
.compact-row:hover,
.button-sequence-row:hover,
.log-file-row:hover {
  transform: translateY(-1px);
  background: var(--app-panel-muted) !important;
  border-color: var(--app-selected-border) !important;
  box-shadow: none !important;
}

.button-mode-panel,
.detected-buttons-pool,
.checklist-details,
.subsection-details {
  padding: 16px;
  background: var(--app-panel-muted);
  border: 1px solid var(--app-border);
  border-radius: 16px;
}

.terminal-window {
  overflow: hidden;
  border: 1px solid #26344a;
  border-radius: 16px;
  background: #0b1220;
  box-shadow: none;
}

.terminal-header {
  min-height: 44px;
  padding: 0 14px;
  background: #111b2c;
  border-bottom: 1px solid #26344a;
}

.terminal-buttons { display: none; }

.terminal-title {
  color: #91a1b8;
  font-size: 11px;
  letter-spacing: .02em;
}

.logs-container {
  min-height: 220px;
  max-height: 420px;
  padding: 16px;
  color: #d8e2f2;
  background: #0b1220;
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px;
  line-height: 1.65;
}

.log-time { color: #6f87a8; }

.stats-grid { gap: 12px !important; }

.stat-card,
.system-stat-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--app-border);
  border-radius: 16px;
  background: var(--app-panel-muted);
  box-shadow: none;
}

.empty-state,
.no-selection-container {
  width: 100%;
  max-width: 760px;
  min-height: min(680px, 74vh) !important;
  margin: 0 auto;
  padding: 48px;
  border: 1px solid var(--app-border);
  border-radius: 20px;
  background: var(--app-panel);
  box-shadow: var(--app-shadow-xs);
}

.empty-state-icon,
.no-selection-icon {
  width: 72px !important;
  height: 72px !important;
  margin-bottom: 20px;
  border-radius: 20px;
  background: var(--app-blue-soft);
  color: var(--md-sys-color-primary);
  font-size: 34px !important;
  filter: none;
  animation: none !important;
}

.empty-state-title {
  margin: 0 0 8px;
  color: var(--app-text);
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -.04em;
}

.empty-state-desc {
  max-width: 520px;
  margin: 0 0 24px;
  color: var(--app-text-muted);
  font-size: 15px;
  line-height: 24px;
}

.empty-state-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  margin: 8px 0 28px;
  gap: 8px;
}

.empty-state-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-panel-muted);
  color: var(--app-text-muted);
  font-size: 12px;
  text-align: left;
}

.empty-state-feature .material-symbols-outlined {
  color: var(--md-sys-color-primary);
  font-size: 17px;
}

.connection-warning {
  padding: 8px 20px;
  background: var(--md-sys-color-error-container);
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-error) 24%, transparent);
  animation: banner-enter 200ms var(--motion-easing-emphasized) both;
}

.inline-error {
  margin: 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-error) 24%, transparent);
  border-radius: 12px;
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  font-size: 13px;
}

@keyframes banner-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

md-dialog {
  --md-dialog-container-color: var(--app-panel-raised);
  --md-dialog-container-shape: 20px;
  --md-dialog-headline-color: var(--app-text);
  --md-dialog-supporting-text-color: var(--app-text-muted);
}

md-dialog[open] {
  animation: dialog-enter 200ms var(--motion-easing-emphasized) both !important;
  --md-dialog-container-shape: 20px;
}

@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#login-overlay {
  --md-dialog-container-width: min(440px, calc(100vw - 32px));
}

#login-overlay-headline {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.035em;
}

.toast {
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--app-border-strong);
  border-radius: 14px;
  background: var(--md-sys-color-inverse-surface, #111827);
  box-shadow: var(--app-shadow-md);
  animation: toast-enter 200ms var(--motion-easing-emphasized) both;
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.skeleton {
  background: linear-gradient(90deg, var(--app-border) 25%, var(--app-panel-muted) 50%, var(--app-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shift 1200ms linear infinite;
}

@keyframes skeleton-shift {
  from { opacity: .55; transform: translateX(0); }
  50% { opacity: 1; }
  to { opacity: .55; transform: translateX(0); }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--app-text-muted) 38%, transparent);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--app-text-muted) 60%, transparent);
  background-clip: padding-box;
  box-shadow: none;
}

.skip-link:focus {
  top: 12px;
  left: 12px;
  border-radius: 10px;
  background: var(--app-panel);
  color: var(--app-text);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

@media (max-width: 1199px) {
  .content-document { padding: 28px 28px 56px; }
  #view-overview > .form-section { grid-column: span 5; }
  .dashboard-grid { grid-column: span 7; }
}

@media (max-width: 839px) {
  .top-app-bar { padding: 0 16px; }
  .top-app-bar .brand-block { width: auto; }
  .menu-btn { display: inline-flex; }
  .navigation-drawer {
    position: fixed;
    inset: 72px auto 0 0;
    height: calc(100dvh - 72px);
    transform: translateX(-102%);
    opacity: 0;
    box-shadow: var(--app-shadow-md);
  }
  .app-shell.drawer-open .navigation-drawer {
    transform: translateX(0);
    opacity: 1;
  }
  .app-shell.drawer-open .drawer-scrim { display: block !important; }
  .content-document { padding: 24px 24px 48px; }
  #view-overview > .form-section,
  .dashboard-grid { grid-column: 1 / -1; }
  .dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard-card { min-height: 104px; padding: 16px; }
}

@media (max-width: 719px) {
  .top-app-bar { min-height: 64px; gap: 8px; }
  .navigation-drawer { inset-block-start: 64px; height: calc(100dvh - 64px); }
  .brand-icon { width: 36px !important; height: 36px !important; border-radius: 11px; }
  .brand-subtitle,
  #help-btn,
  #plan-badge,
  #status-badge { display: none; }
  .header-actions { gap: 0 !important; }
  .content-document { padding: 20px 16px 40px; }
  .workspace-header { min-height: 64px; margin-bottom: 12px; }
  .workspace-header-title { font-size: 20px; line-height: 28px; }
  .view-tabs-container {
    top: 8px;
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
  }
  .view-tabs-container md-primary-tab { min-width: 112px; }
  #view-overview.active { gap: 16px; }
  .status-hero {
    align-items: stretch;
    padding: 20px;
    border-radius: 18px;
  }
  .status-hero-body { align-items: flex-start; }
  .status-hero-icon { width: 52px; height: 52px; border-radius: 15px; }
  .status-hero-actions { width: 100%; }
  .status-hero-actions md-filled-button,
  .status-hero-actions md-filled-tonal-button { flex: 1; }
  .overview-command-bar { overflow-x: auto; justify-content: flex-start; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-card { min-height: 108px; }
  .view-intro { align-items: flex-start; flex-direction: column; }
  .view-intro h2 { font-size: 21px; line-height: 28px; }
  .settings-toolbar { overflow-x: auto; justify-content: flex-start; }
  .form-section { padding: 20px 16px; }
  .form-row,
  .form-row--compact { flex-direction: column; align-items: stretch; }
  .form-row--switch { flex-direction: row; align-items: center; }
  .empty-state,
  .no-selection-container {
    min-height: calc(100dvh - 144px) !important;
    padding: 32px 20px;
  }
  .empty-state-features { grid-template-columns: 1fr; }
  .button-sequence-row { grid-template-columns: 24px minmax(0, 1fr) auto !important; }
}

@media (max-width: 439px) {
  .top-app-bar .brand-text h1 { font-size: 16px; }
  #theme-btn { display: none; }
  .content-document { padding-inline: 12px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-card { min-height: 88px; }
  .status-hero-body { flex-direction: column; }
  .status-hero-actions { flex-direction: column; align-items: stretch; }
  .status-hero-actions > * { width: 100%; }
  .view-tabs-container md-primary-tab { min-width: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
