:root {
  --radius: 0.65rem;

  /* ── deZem Corporate Design Colors ── */
  --dezem-orange: #f3941a;
  --dezem-orange-rgb: #fb9700;
  --dezem-grey: #4c4c4c;
  --dezem-grey-light: #808080;
  --dezem-grey-box: #eaeaea;
  --dezem-grey-dark: #575756;
  --dezem-blue: #5e82c8;
  --dezem-blue-light: #adc0e2;
  /* ── deZem Corporate Design Colors ── */

  --background: #ffffff;
  --foreground: #4c4c4c;
  --card: #ffffff;
  --card-foreground: #4c4c4c;
  --popover: #ffffff;
  --popover-foreground: #4c4c4c;
  --primary: #f3941a;
  --primary-foreground: #ffffff;
  --secondary: #eaeaea;
  --secondary-foreground: #4c4c4c;
  --muted: #eaeaea;
  --muted-foreground: #808080;
  --accent: #f5f5f5;
  --accent-foreground: #4c4c4c;
  --destructive: #d32f2f;
  --border: #e0e0e0;
  --input: #f5f5f5;
  --ring: #f3941a;
  --chart-1: #f3941a;
  --chart-2: #5e82c8;
  --chart-3: #adc0e2;
  --chart-4: #808080;
  --chart-5: #4c4c4c;
  --sidebar: #ffffff;
  --sidebar-foreground: #4c4c4c;
  --sidebar-primary: #f3941a;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #f5f5f5;
  --sidebar-accent-foreground: #4c4c4c;
  --sidebar-border: #e0e0e0;
  --sidebar-ring: #f3941a;

  /* Legacy mappings for compatibility */
  --bg-dark: #ffffff;
  --bg-panel: #ffffff;
  --bg-input: #f5f5f5;
  --bg-hover: #eaeaea;
  --bg-active: var(--primary);
  --text: #4c4c4c;
  --text-muted: #808080;
  --text-bright: #333333;
  --success: #4caf50;
  --warning: #f3941a;
  --danger: var(--destructive);

  /* Layout */
  --header-height: 48px;
  --toolbar-width: 50px;
  --panel-width: 280px;
  --status-height: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Open Sans", sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 13px;
  overflow: hidden;
  height: 100vh;
}

/* Material Icons Styling */
.material-icons {
  font-size: 18px;
  vertical-align: middle;
  line-height: 1;
}

.header-btn .material-icons,
.btn .material-icons {
  font-size: 16px;
  margin-right: 4px;
}

.tool-btn .material-icons {
  font-size: 20px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon img {
  height: 200px;
  width: auto;
}

.logo-icon .material-icons {
  font-size: 64px;
  color: var(--primary);
}

.logo-sm {
  display: flex;
  align-items: center;
}

.logo-sm img {
  height: 80px;
  width: auto;
}

.logo-sm .material-icons {
  font-size: 20px;
  color: var(--primary);
}

.upload-icon .material-icons {
  font-size: 48px;
  color: var(--primary);
}

.panel-section h3 .material-icons {
  font-size: 16px;
  margin-right: 6px;
  opacity: 0.8;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.material-icons.spinning {
  animation: spin 1s linear infinite;
}

/* Upload Overlay */
.upload-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.upload-overlay.hidden {
  display: none;
}

.upload-modal {
  text-align: center;
  max-width: 500px;
}

.logo {
  margin-bottom: 40px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.logo h1 {
  font-size: 32px;
  font-weight: 300;
  color: var(--foreground);
  margin-bottom: 8px;
}

.tagline {
  color: var(--muted-foreground);
  font-size: 16px;
}

.upload-zone {
  background: var(--input);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 40px;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(243, 148, 26, 0.06);
}

.upload-content .upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.upload-content h2 {
  font-size: 20px;
  font-weight: 400;
  color: var(--foreground);
  margin-bottom: 8px;
}

.upload-content p {
  color: var(--muted-foreground);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.link-btn:hover {
  color: var(--chart-1);
}

.upload-hint {
  font-size: 12px;
  margin-top: 16px;
}

/* App Container */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app.hidden {
  display: none;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--card);
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

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

.header-left {
  min-width: 0;
  overflow: hidden;
}

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

.logo-sm {
  font-size: 18px;
}

.app-title {
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  flex-shrink: 0;
}

.divider {
  color: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.file-name {
  color: var(--muted-foreground);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.file-name::after {
  content: "/";
  margin: 0 4px;
  color: var(--border);
}

.file-name:empty::after {
  content: none;
}

.dataset-name {
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.op-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.op-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(94, 130, 200, 0.1);
  color: #5e82c8;
  border: 1px solid rgba(94, 130, 200, 0.3);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.op-tag .material-icons {
  font-size: 13px;
}

/* ── Mode toggle (test / training) ── */
.mode-toggle {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 6px;
}

.mode-toggle.hidden {
  display: none;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: #777;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s;
  white-space: nowrap;
}

.mode-btn .material-icons {
  font-size: 15px;
}

.mode-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.04);
  color: #555;
}

.mode-btn.active {
  background: #fff;
  color: var(--primary, #3b82f6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

.header-btn {
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--foreground);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  transition: all 0.2s;
}

.header-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--muted-foreground);
}

.header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.header-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.header-btn.primary:hover:not(:disabled) {
  background: var(--chart-1);
}

/* Workspace */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Toolbar */
.left-toolbar {
  width: var(--toolbar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.tool-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--sidebar-border);
}

.tool-section:last-child {
  border-bottom: none;
}

.tool-section-bottom {
  margin-top: auto;
}

.tool-section-title {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  text-align: center;
  margin-bottom: 6px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  color: var(--foreground);
  background: var(--sidebar-accent);
}

.tool-btn.active {
  color: var(--sidebar-primary-foreground);
  background: var(--sidebar-primary);
}

.tool-btn span:first-child {
  font-size: 16px;
}

.tool-label {
  font-size: 9px;
  margin-top: 2px;
}

/* Canvas Area */
.canvas {
  flex: 1;
  background: var(--background);
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
}

.plot-canvas {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.plot-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.plot-loading .spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.data-table-container {
  flex: 1;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Split View */
#view-split {
  flex-direction: column;
}

.split-top,
.split-bottom {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.split-top {
  display: flex;
}

.split-bottom {
  display: flex;
}

.split-divider {
  height: 4px;
  background: var(--border);
  cursor: ns-resize;
}

.split-divider:hover {
  background: var(--primary);
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.data-table th {
  background: var(--card);
  color: var(--foreground);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 500;
}

.data-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:hover {
  background: var(--accent);
}

.data-table .anomaly {
  background: rgba(243, 148, 26, 0.08);
}

.table-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  overscroll-behavior: contain;
  overflow-anchor: none;
}

.data-table-body {
  table-layout: fixed;
  overflow-anchor: none;
}

.table-status {
  padding: 6px 12px;
  text-align: right;
  color: var(--muted-foreground);
  font-size: 11px;
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
}

/* Right Panel */
.right-panel {
  width: var(--panel-width);
  background: var(--sidebar);
  border-left: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--sidebar-border);
}

.panel-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 11px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.panel-tab:hover {
  color: var(--foreground);
  background: var(--sidebar-accent);
}

.panel-tab.active {
  color: var(--foreground);
  border-bottom-color: var(--primary);
}

.panel-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.panel-content.active {
  display: flex;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 0;
}

.panel-section {
  margin-bottom: 16px;
}

.panel-section h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Panel-card section styling ────────────────────────── */
.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  border-left: 3px solid var(--border);
}

.panel-card > h3,
.panel-card > .collapsible {
  margin-top: 2px;
}

.panel-card--settings {
  border-left-color: var(--primary);
}

.panel-card--weights {
  border-left-color: #4a90d9;
}

.panel-card--blocks {
  border-left-color: #7b61c2;
}

.panel-card--settings > h3 .material-icons {
  color: var(--primary);
}
.panel-card--weights > h3 .material-icons,
.panel-card--weights > .collapsible .material-icons {
  color: #4a90d9;
}
.panel-card--blocks > h3 .material-icons,
.panel-card--blocks > .collapsible .material-icons {
  color: #7b61c2;
}

.panel-section.collapsed .collapse-content {
  display: none;
}

.collapsible {
  cursor: pointer;
  user-select: none;
}

.collapsible:hover {
  color: var(--primary);
}

.collapse-icon {
  font-size: 10px;
  margin-left: auto;
  transition: transform 0.2s;
}

.panel-section:not(.collapsed) > .collapsible .collapse-icon {
  transform: rotate(90deg);
}

.collapse-content {
  margin-top: 10px;
}

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

.settings-group {
  border-top: 1px solid var(--border);
}

.settings-group.collapsed .settings-group-content {
  display: none;
}

.settings-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: var(--foreground);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.settings-group-toggle:hover {
  color: var(--primary);
}

.settings-group-toggle .material-icons {
  font-size: 16px;
}

.settings-group:not(.collapsed) > .collapsible .collapse-icon {
  transform: rotate(90deg);
}

.settings-group-content {
  padding: 0 0 2px;
}

.settings-group-content .form-row:last-child {
  margin-bottom: 12px;
}

/* Form Elements */
.form-row {
  margin-bottom: 10px;
}

.form-row.disabled-param {
  opacity: 0.35;
}

.form-row.disabled-param .input-hint,
.form-row.disabled-param label,
.form-row.disabled-param .value {
  color: var(--muted-foreground);
}

.form-row label {
  display: block;
  font-size: 11px;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}

.form-row label .value {
  color: var(--primary);
  font-weight: 500;
}

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

.input-suffix {
  color: var(--muted-foreground);
  font-size: 11px;
}

.input,
select.input {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--foreground);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
}

/* Hide number input spinners */
.input[type="number"] {
  -moz-appearance: textfield;
  text-align: center;
}

.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Seed Control */
.seed-control {
  display: flex;
  gap: 6px;
}

/* Multiplier Button Group */
.multiplier-group {
  display: flex;
  gap: 6px;
}

.multiplier-btn {
  flex: 1;
  padding: 8px 4px;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.multiplier-btn:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--muted-foreground);
}

.multiplier-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.multiplier-preview {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted-foreground);
  text-align: center;
  min-height: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-rows {
  color: var(--muted-foreground);
}

.preview-dates {
  color: var(--muted-foreground);
  font-size: 10px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-dates.projected {
  color: var(--primary);
  opacity: 0.85;
}

.preview-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
  display: inline-block;
  width: 32px;
  text-align: right;
}

.input-hint {
  display: block;
  font-size: 10px;
  color: var(--muted-foreground);
  margin-top: 4px;
  opacity: 0.7;
}

.advanced-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.seed-control .seed-mode {
  flex: 1;
  min-width: 80px;
}

.seed-control .seed-value {
  flex: 1;
  min-width: 60px;
}

.seed-control .seed-value:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.slider,
.slider-sm {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--input);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  border: none;
}

.slider {
  width: 100%;
}

.slider-sm {
  width: 80px;
}

/* Webkit (Chrome, Edge, Safari) */
.slider::-webkit-slider-runnable-track,
.slider-sm::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--input);
  border-radius: 2px;
}

.slider::-webkit-slider-thumb,
.slider-sm::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -4px;
  border: none;
  box-shadow: 0 0 0 2px #ffffff;
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}

.slider::-webkit-slider-thumb:hover,
.slider-sm::-webkit-slider-thumb:hover {
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 0 5px rgba(243, 148, 26, 0.3);
  transform: scale(1.15);
}

/* Firefox */
.slider::-moz-range-track,
.slider-sm::-moz-range-track {
  height: 4px;
  background: var(--input);
  border-radius: 2px;
  border: none;
}

.slider::-moz-range-thumb,
.slider-sm::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px #ffffff;
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}

.slider::-moz-range-thumb:hover,
.slider-sm::-moz-range-thumb:hover {
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 0 5px rgba(243, 148, 26, 0.3);
  transform: scale(1.15);
}

/* Toggle */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--input);
  border-radius: 10px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--foreground);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

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

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn.primary:hover {
  background: var(--chart-1);
}

.btn.secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--accent);
}

.btn.large {
  padding: 12px 24px;
  font-size: 14px;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 10px;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--secondary-foreground);
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-sm:hover {
  background: var(--accent);
}

.panel-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--sidebar);
  box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.08);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.panel-footer-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.panel-action {
  margin-top: 16px;
  padding: 16px 24px 16px 24px;
  border-top: 1px solid var(--border);
  margin-left: -12px;
  margin-right: -12px;
  margin-bottom: -12px;
}

.panel-action .noise-section {
  margin-top: 12px;
}

.panel-action .noise-section .form-row {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Anomaly Options */
.anomaly-options.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--foreground) !important;
}

.anomaly-block-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}

.block-builder-header,
.block-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.block-builder-header {
  display: none;
}

#anomaly-block-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block-row {
  position: relative;
  grid-template-columns: 20px minmax(0, 1fr) 84px 84px;
  grid-template-areas:
    "drag type type type"
    ". . gap length";
  padding: 12px 44px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(76, 76, 76, 0.06);
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.block-row:hover {
  border-color: rgba(243, 148, 26, 0.35);
  background: #fffdf9;
  box-shadow: 0 6px 16px rgba(76, 76, 76, 0.1);
}

.block-row.dragging {
  opacity: 0.88;
  border-color: var(--primary);
  background: #fffaf2;
  box-shadow: 0 10px 24px rgba(243, 148, 26, 0.2);
  transform: scale(0.995);
}

.block-drag {
  grid-area: drag;
  align-self: start;
  width: 20px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: grab;
  font-size: 0.82rem;
  line-height: 0.9;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.block-drag:active {
  cursor: grabbing;
}

.block-drag:hover {
  background: rgba(243, 148, 26, 0.08);
  color: var(--foreground);
  transform: translateY(-1px);
}

.block-builder-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 4px;
}

.block-field {
  min-width: 0;
}

.block-type-wrap {
  grid-area: type;
}

.block-gap-wrap {
  grid-area: gap;
}

.block-length-wrap {
  grid-area: length;
}

.block-field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.block-type-wrap .input {
  font-size: 11px;
  padding-right: 28px;
}

.block-gap-wrap,
.block-length-wrap {
  width: 100%;
}

.block-gap-wrap .input,
.block-length-wrap .input {
  padding: 6px 6px;
  font-size: 11px;
}

.block-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}

.block-remove:hover {
  background: #fff1f1;
  border-color: rgba(211, 47, 47, 0.25);
  color: var(--destructive);
}

/* Weight Rows */
.weight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.weight-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}

.weight-toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--muted-foreground);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.weight-toggle:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.weight-toggle:checked::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--background);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.weight-toggle:hover {
  border-color: var(--primary);
}

.weight-row span:first-of-type {
  flex: 1;
  color: var(--muted-foreground);
}

.weight-row:has(.weight-toggle:not(:checked)) span:first-of-type {
  opacity: 0.4;
}

.weight-row input[type="range"]:disabled {
  opacity: 0.2;
  pointer-events: none;
}

.weight-row input[type="range"]:disabled::-webkit-slider-thumb {
  background: var(--muted-foreground);
  box-shadow: none;
}

.weight-row input[type="range"]:disabled::-moz-range-thumb {
  background: var(--muted-foreground);
  box-shadow: none;
}

.weight-val {
  width: 32px;
  text-align: right;
  color: var(--primary);
}

.weight-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}

.weight-divider::before,
.weight-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.sc-duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
}

.sc-duration-row label {
  min-width: 90px;
  font-size: 0.78rem;
  color: var(--foreground);
}

.sc-duration-row input[type="range"] {
  flex: 1;
}

/* Anomaly type description tooltips */
.anomaly-name {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted currentColor;
}

.anomaly-name[data-desc]::after {
  content: attr(data-desc);
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 100;
  width: 220px;
  padding: 6px 8px;
  background: var(--foreground);
  color: var(--background);
  font-size: 10.5px;
  line-height: 1.4;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s,
    visibility 0.15s;
}

.anomaly-name[data-desc]:hover::after {
  opacity: 1;
  visibility: visible;
}

.weight-row:has(.weight-toggle:not(:checked)) .anomaly-name {
  border-bottom-color: transparent;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-item {
  background: var(--card);
  padding: 10px;
  border-radius: var(--radius);
  text-align: center;
}

.stat-label {
  font-size: 10px;
  color: var(--muted-foreground);
  display: block;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

/* FFT Results */
.fft-results {
  margin-top: 12px;
  font-size: 11px;
}

.fft-results table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.fft-results th,
.fft-results td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.fft-results th {
  color: var(--muted-foreground);
  font-weight: 500;
}

/* Status Bar */
.status-bar {
  height: var(--status-height);
  background: #f5f5f5;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#status-mode {
  color: var(--primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
  background: #e8f5e9;
  color: #2e7d32;
}

.toast.error {
  border-color: var(--destructive);
  background: #ffebee;
  color: #c62828;
}

.toast.warning {
  border-color: var(--warning);
  background: #fff3e0;
  color: #e65100;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background);
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted-foreground);
}

.loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

.skeleton-cell {
  display: inline-block;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(90deg, #eaeaea 25%, #f5f5f5 50%, #eaeaea 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

tr.skeleton-row td {
  color: transparent;
  user-select: none;
}

/* Export Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 320px;
  max-width: 400px;
}

.modal-content h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--foreground);
}

.modal-content h2 .material-icons {
  color: var(--primary);
}

.modal-message {
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-content .form-row {
  margin-bottom: 16px;
}

.modal-content .form-row label {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}

.format-buttons {
  display: flex;
  gap: 8px;
}

.format-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.format-btn:hover {
  background: var(--accent);
  color: var(--foreground);
}

.format-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.format-btn .material-icons {
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* Training Data Modal */
.training-modal-content {
  max-width: 680px;
  width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.training-modal-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.training-modal-body::-webkit-scrollbar {
  width: 5px;
}

.training-modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.training-elongate-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 4px;
}

.training-elongate-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--accent);
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground);
  user-select: none;
  border: none;
  width: 100%;
  text-align: left;
}

.training-elongate-header:hover {
  background: var(--bg-hover);
}

.training-elongate-header .material-icons {
  font-size: 16px;
  color: var(--muted-foreground);
}

.training-elongate-header .collapse-icon {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted-foreground);
  transition: transform 0.15s;
}

.training-elongate-section.expanded .training-elongate-header .collapse-icon {
  transform: rotate(90deg);
}

.training-elongate-body {
  display: none;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.training-elongate-section.expanded .training-elongate-body {
  display: block;
}

.training-divider {
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.training-plot-container {
  margin-bottom: 16px;
}

.training-row-split-panel {
  margin-top: 8px;
  transition: opacity 0.15s ease;
}

.training-row-split-panel.is-disabled {
  opacity: 0.45;
}

.training-row-split-panel.is-disabled .training-preview-plot,
.training-row-split-panel.is-disabled .training-timestamp-info,
.training-row-split-panel.is-disabled .training-plot-label,
.training-row-split-panel.is-disabled .form-row {
  pointer-events: none;
}

.training-plot-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}

.training-preview-plot {
  width: 100%;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fafafa;
  cursor: crosshair;
}

.training-timestamp-info {
  display: flex;
  gap: 20px;
  padding: 8px 12px;
  background: var(--accent);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12px;
}

.ts-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ts-label {
  color: var(--muted-foreground);
  white-space: nowrap;
}

.ts-value {
  color: var(--foreground);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.training-preview {
  background: var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.training-preview .preview-rows {
  display: block;
  color: var(--foreground);
  font-weight: 500;
}

#training-multiplier-group {
  display: flex;
  gap: 4px;
}

#training-multiplier-group .multiplier-btn {
  flex: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .right-panel {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .app-title,
  .header-left > .divider {
    display: none;
  }

  .header-btn span:not(.material-icons) {
    display: none;
  }

  .header-btn {
    padding: 6px 8px;
  }
}

@media (max-width: 600px) {
  .file-name {
    display: none;
  }

  .op-tags {
    display: none;
  }

  .left-toolbar {
    width: 36px;
  }

  .tool-label {
    display: none;
  }
}
