:root {
  color-scheme: light;
  --bg: #0f172a;
  --bg-soft: #111a33;
  --card: #f5f3ef;
  --accent: #f97316;
  --accent-dark: #c2410c;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e2e8f0;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
  font-family: "Space Grotesk", "Montserrat", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #1e293b, #0f172a 60%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  color: #f8fafc;
}

.brand {
  font-size: 1.4rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.user-area {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-area button {
  margin-left: 12px;
}

.avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0f172a;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.15);
}

.avatar.is-clickable {
  cursor: pointer;
}

.avatar.is-clickable:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-letter {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: #0f172a;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

.avatar img.is-hidden {
  display: none;
}

.backup-dot {
  margin-left: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.6);
}

.backup-dot.ok {
  background: #22c55e;
}

.backup-dot.error {
  background: #ef4444;
}

.backup-dot.pending {
  background: #f59e0b;
}

.backup-speed {
  color: #e2e8f0;
  font-size: 0.78rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.backup-speed:empty {
  display: none;
}

.admin-link {
  margin-left: 12px;
  color: #f8fafc;
  text-decoration: none;
  font-weight: 600;
}

.admin-link:hover {
  text-decoration: underline;
}

.portal-home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.portal-home-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-home-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.portal-connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
}

.portal-home-identity .backup-dot {
  margin-left: 0;
  box-shadow: none;
}

.portal-home-identity .backup-speed {
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-pill-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(249, 115, 22, 0.14);
  color: #9a3412;
  border: 1px solid rgba(249, 115, 22, 0.22);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.portal-space-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.portal-space-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 170px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 247, 237, 0.92)),
    var(--card);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.portal-space-card h2,
.portal-space-card p {
  margin: 0;
}

.portal-space-card p {
  color: var(--muted);
}

.space-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b45309;
  font-weight: 700;
}

.space-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.space-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #0f172a;
  color: #f8fafc;
  text-decoration: none;
  font-weight: 600;
}

.space-link.is-secondary {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid rgba(154, 52, 18, 0.16);
}

.space-link:hover {
  text-decoration: none;
  filter: brightness(1.04);
}

.portal-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: -10px 0 18px;
}

.portal-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.14);
  color: #e2e8f0;
  border: 1px solid rgba(226, 232, 240, 0.18);
  text-decoration: none;
  font-weight: 600;
}

.portal-nav-link:hover {
  text-decoration: none;
  background: rgba(248, 250, 252, 0.2);
}

.portal-nav-link.is-active {
  background: #f97316;
  color: #fff7ed;
  border-color: rgba(249, 115, 22, 0.45);
}

.space-context-card {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background:
    linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(248, 250, 252, 0.96)),
    var(--card);
}

.space-context-card h1,
.space-context-card p {
  margin: 0;
}

.space-context-card p {
  color: var(--muted);
}

.space-context-eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b45309;
  font-weight: 700;
}

.acquisition-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.acquisition-head h1 {
  margin: 0;
}

.acquisition-intro {
  margin-top: 8px;
  max-width: 60ch;
}

.acquisition-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.acquisition-status-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.acquisition-status-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b45309;
  font-weight: 700;
}

.acquisition-status-value {
  font-size: 1rem;
  color: #0f172a;
}

.acquisition-status-meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

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

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

.mobile-qr-wrap {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.mobile-qr-image {
  width: 220px;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.mobile-qr-url {
  max-width: min(560px, 100%);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.mobile-qr-wrap:hover .mobile-qr-url,
.mobile-qr-wrap:focus-within .mobile-qr-url {
  opacity: 1;
  transform: translateY(0);
}

.mobile-qr-url:empty {
  display: none;
}


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

.password-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  background: #94a3b8;
}

.password-dot.ok {
  background: #22c55e;
}

.password-dot.error {
  background: #ef4444;
}

.password-label {
  cursor: help;
}

.toggle-password {
  background: #e2e8f0;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.toggle-password:hover:not(:disabled) {
  background: #cbd5f5;
}
main {
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.collapsible-frame {
  position: relative;
}

.collapsible-frame-title {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.collapsible-frame-title::before {
  content: "▸";
  color: #64748b;
  font-size: 0.9em;
  line-height: 1;
  transform-origin: 50% 50%;
  transition: transform 120ms ease;
}

.collapsible-frame:not(.is-collapsed) > .collapsible-frame-title::before {
  transform: rotate(90deg);
}

.collapsible-frame-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
}

.collapsible-frame-content {
  margin-top: 14px;
}

.collapsible-frame-title .size-label,
.collapsible-frame-title .settings-sync-status,
.collapsible-frame-title .count-label {
  margin-left: 0;
}

.settings-section.collapsible-frame {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(248, 250, 252, 0.95));
  box-shadow:
    0 8px 20px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.settings-section.collapsible-frame .collapsible-frame-content {
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.muted {
  color: var(--muted);
  margin: 0 0 16px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

form label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

input.optimized-param:not([type="checkbox"]) {
  background: #dcfce7;
  border-color: #22c55e;
}

input.optimized-param[type="checkbox"] {
  box-shadow: 0 0 0 2px #22c55e;
  border-radius: 4px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.form-msg {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--accent-dark);
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.size-label {
  margin-left: 10px;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}

.settings-sync-status {
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}

.settings-sync-status .backup-dot {
  margin-left: 0;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}

.count-label {
  margin-left: 10px;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  width: min(420px, 92vw);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.dynamic-spectrogram-modal-card {
  width: min(860px, 96vw);
}

.dynamic-spectrogram-subtitle {
  margin: 8px 0 12px;
  color: #64748b;
  font-size: 0.95rem;
}

.dynamic-spectrogram-controls {
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.dynamic-spectrogram-mode {
  font-size: 0.88rem;
  color: #334155;
  font-weight: 600;
}

.dynamic-spectrogram-controls select {
  width: 100%;
}

#dynamicSpectrogramAutoplayBtn.is-active {
  background: #0369a1;
}

.dynamic-spectrogram-canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #cbd5e1;
}

.dynamic-spectrogram-timeline {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.dynamic-spectrogram-timeline input[type="range"] {
  width: 100%;
}

.dynamic-spectrogram-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #475569;
  font-size: 0.88rem;
}

.calibration-modal-card {
  width: min(560px, 94vw);
}

.measurement-sampling-modal-card {
  width: min(520px, 94vw);
}

.calibration-model-target-card {
  width: min(620px, 94vw);
}

.calibration-noise-modal-card {
  width: min(980px, 96vw);
  max-height: min(88vh, 900px);
  overflow: auto;
}

.calibration-noise-subtitle {
  margin-bottom: 10px;
}

.cal-noise-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px);
  gap: 10px;
}

.cal-noise-source-select {
  width: 100%;
}

.cal-noise-summary {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.cal-noise-metric-card {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
}

.cal-noise-metric-label {
  font-size: 0.78rem;
  color: #64748b;
}

.cal-noise-metric-value {
  margin-top: 4px;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.95rem;
  word-break: break-word;
}

.noise-snr-value {
  font-weight: 700;
}

.noise-snr-value.zone-bad {
  color: #dc2626;
}

.noise-snr-value.zone-mid {
  color: #16a34a;
}

.noise-snr-value.zone-very-good {
  color: #166534;
}

.cal-noise-plot-card {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  margin-top: 12px;
  padding: 10px;
}

.cal-noise-plot-title {
  margin-bottom: 8px;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 700;
}

.cal-noise-plot-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: zoom-in;
}

.cal-noise-table-wrap {
  margin-top: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: auto;
  background: #ffffff;
}

.cal-noise-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.cal-noise-table th,
.cal-noise-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.cal-noise-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.cal-noise-footnote {
  margin: 10px 0 0;
  font-size: 0.82rem;
}

.noise-plot-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.76);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 10px;
}

.noise-plot-fullscreen-card {
  width: 100%;
  height: 100%;
  background: #f8fafc;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
}

.noise-plot-fullscreen-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.noise-plot-fullscreen-title {
  color: #0f172a;
  font-weight: 700;
}

.noise-plot-fullscreen-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.noise-plot-fullscreen-hint {
  color: #64748b;
  font-size: 0.85rem;
}

.noise-plot-fullscreen-canvas-wrap {
  min-height: 0;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
}

.noise-plot-fullscreen-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #ffffff;
  border-radius: 8px;
  cursor: grab;
}

.noise-plot-fullscreen-canvas.is-panning {
  cursor: grabbing;
}

.noise-plot-fullscreen-status {
  color: #334155;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.cal-model-target-block {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.cal-model-target-select {
  width: 100%;
}

.cal-model-target-new-btn {
  justify-self: start;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.calibration-point-id {
  margin-top: 4px;
  font-size: 0.82rem;
}

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

.calibration-flow-mode-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.calibration-mode-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #0f172a;
}

.mode-btn.is-active {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1d4ed8;
}

.mode-btn.is-running {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.delta-control {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.delta-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.delta-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}

.delta-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #0f172a;
  left: 35%;
}

#calibrationSensitivityInput {
  width: 100%;
}

.calibration-reference-actions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.calibration-reference-actions .measure-btn {
  width: 140px;
  height: 140px;
}

.deps-list {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  padding-left: 18px;
}

.deps-list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 8px;
}

.dependency-status-dot {
  position: absolute;
  left: 0;
  top: 0.38rem;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.15);
}

.dependency-status-dot.ok {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.16);
}

.dependency-status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.14);
}

.version-grid {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 8px;
}

.plot-wrap {
  margin-top: 14px;
  background: #0f172a;
  border-radius: 16px;
  padding: 12px;
}

.plot-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.plot-wrap canvas {
  cursor: zoom-in;
}

.plot-wrap:fullscreen,
.plot-wrap:-webkit-full-screen,
.plot-wrap.plot-wrap-fallback-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  padding: 14px;
  background: #0b1225;
  display: flex;
  flex-direction: column;
}

.plot-wrap:fullscreen canvas,
.plot-wrap:-webkit-full-screen canvas,
.plot-wrap.plot-wrap-fallback-fullscreen canvas {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 120px);
  cursor: zoom-out;
}

#plotCanvas {
  width: 100%;
  height: auto;
  background: #ffffff;
  border-radius: 10px;
}

#pcaXWeightsCanvas,
#inputSpectraOverlayCanvas {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  border-radius: 10px;
}

.recorder-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.sampling-point-default-bar {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.sampling-point-default-control {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 0.95rem;
}

.sampling-point-default-control select {
  max-width: min(520px, 100%);
}

.sampling-point-default-caption {
  margin: 0;
  font-size: 0.88rem;
}

.sampling-point-default-launch-wrap {
  display: none;
  margin-top: 12px;
  width: 100%;
  justify-content: center;
}

.sampling-point-default-launch-btn {
  width: min(43vw, 186px);
  height: min(43vw, 186px);
  max-height: 186px;
  border-radius: 24px;
  border: none;
  background: #0f766e;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.34);
}

.sampling-point-default-launch-btn:disabled {
  background: #94a3b8;
  box-shadow: 0 12px 26px rgba(100, 116, 139, 0.3);
}

.sampling-point-default-launch-title {
  font-size: 0.8rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.sampling-point-default-launch-value {
  font-size: 0.92rem;
  line-height: 1.24;
  font-weight: 800;
}

.recorder-split {
  align-items: center;
}

.last-reference {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

.last-reference-spectrum {
  width: 160px;
  height: 60px;
}

.last-reference-spectrum.reference {
  background: #ffffff;
  border-color: #cbd5f5;
}

.last-reference-spectrum.expired {
  background: #ef4444;
  border-color: #b91c1c;
}

.last-reference-info {
  text-align: left;
  max-width: 360px;
}

.last-reference-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.last-reference-meta {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.last-reference-comment {
  font-size: 0.9rem;
  color: #0f172a;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 6px 8px;
}

.recorder-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.measure-btn {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: #0ea5e9;
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  --btn-progress: 0;
  --btn-progress-ring-visible: 0;
  --btn-progress-ring-color: #fbbf24;
  --btn-progress-ring-track: rgba(255, 255, 255, 0.18);
  --btn-progress-ring-thickness: 5px;
  isolation: isolate;
}

.measure-btn::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--btn-progress-ring-thickness));
  border-radius: inherit;
  background:
    radial-gradient(
      farthest-side,
      transparent calc(100% - var(--btn-progress-ring-thickness) - 1px),
      var(--btn-progress-ring-track) calc(100% - var(--btn-progress-ring-thickness))
    ),
    conic-gradient(
      var(--btn-progress-ring-color) calc(var(--btn-progress) * 1turn),
      transparent 0
    );
  -webkit-mask:
    radial-gradient(
      farthest-side,
      transparent calc(100% - var(--btn-progress-ring-thickness)),
      #000 calc(100% - var(--btn-progress-ring-thickness) + 1px)
    );
  mask:
    radial-gradient(
      farthest-side,
      transparent calc(100% - var(--btn-progress-ring-thickness)),
      #000 calc(100% - var(--btn-progress-ring-thickness) + 1px)
    );
  opacity: var(--btn-progress-ring-visible);
  pointer-events: none;
  transition: opacity 120ms ease;
}

.measure-btn > * {
  position: relative;
  z-index: 1;
}

.reference-btn {
  background: #2563eb;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}

.measure-btn:disabled {
  opacity: 0.9;
}

.btn-label {
  font-size: 1rem;
}

.btn-sub {
  font-size: 1.1rem;
  font-weight: 800;
  opacity: 0.9;
}

.secondary-action-title {
  display: none;
}

body.secondary-portal-mode .app {
  max-width: 480px;
  min-height: 100dvh;
  padding: 14px 12px 20px;
}

body.secondary-portal-mode .topbar {
  margin-bottom: 14px;
}

body.secondary-portal-mode .brand {
  display: none;
}

body.secondary-portal-mode main {
  display: block;
}

body.secondary-portal-mode #recorderCard.secondary-portal-recorder {
  min-height: calc(100dvh - 110px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 10px;
}

body.secondary-portal-mode #recorderCard .recorder-header.recorder-split {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  justify-items: center;
}

body.secondary-portal-mode #recorderCard .secondary-action-title {
  display: none;
  width: 100%;
  text-align: center;
  color: #0f172a;
  font-size: 0.86rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
}

body.secondary-portal-mode #recorderCard.secondary-widget-running .secondary-action-title {
  display: block;
}

body.secondary-portal-mode #recorderCard .sampling-point-default-launch-wrap {
  display: flex;
}

body.secondary-portal-mode #recorderCard .recorder-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

body.secondary-portal-mode #recorderCard .measure-btn {
  width: min(43vw, 186px);
  height: min(43vw, 186px);
  max-height: 186px;
  border-radius: 999px;
  padding: 12px;
  gap: 8px;
  font-size: 0.95rem;
}

body.secondary-portal-mode #recorderCard .measure-btn:disabled {
  opacity: 1;
}

body.secondary-portal-mode #recorderCard .btn-label {
  font-size: 0.86rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

body.secondary-portal-mode #recorderCard .btn-sub {
  font-size: 0.92rem;
  line-height: 1.24;
  font-weight: 800;
}

body.secondary-portal-mode #recorderCard .measure-btn[data-launch-state="ready"] {
  background: #16a34a;
  box-shadow: 0 12px 26px rgba(22, 163, 74, 0.34);
}

body.secondary-portal-mode #recorderCard .measure-btn[data-launch-state="blocked"] {
  background: #94a3b8;
  box-shadow: 0 12px 26px rgba(100, 116, 139, 0.3);
}

body.secondary-portal-mode #recorderCard .measure-btn[data-launch-state="preliminary"] {
  background: #d97706;
  box-shadow: 0 12px 26px rgba(217, 119, 6, 0.33);
}

@media (max-width: 430px) {
  body.secondary-portal-mode #recorderCard.secondary-portal-recorder {
    min-height: calc(100dvh - 100px);
    padding: 10px 6px;
  }

  body.secondary-portal-mode #recorderCard .recorder-header.recorder-split {
    gap: 10px;
  }

  body.secondary-portal-mode #recorderCard .measure-btn {
    width: min(44vw, 172px);
    height: min(44vw, 172px);
    padding: 10px;
  }

  body.secondary-portal-mode #recorderCard .sampling-point-default-launch-btn {
    width: min(44vw, 172px);
    height: min(44vw, 172px);
    padding: 10px;
  }

  body.secondary-portal-mode #recorderCard .btn-label {
    font-size: 0.78rem;
  }

  body.secondary-portal-mode #recorderCard .btn-sub {
    font-size: 0.84rem;
  }
}

.meter {
  margin-top: 18px;
  background: #e2e8f0;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

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

.db-label {
  margin-top: 8px;
  font-size: 0.85rem;
}

.meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #f97316);
  transition: width 0.12s linear;
}

.measure-cycle-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #dbe5f1;
  background: #f8fafc;
}

.measure-cycle-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.measure-cycle-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.measure-cycle-meta {
  margin: 10px 0 8px;
  font-size: 0.84rem;
}

.measure-cycle-volume {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 0.94rem;
  color: #0f172a;
}

.measure-cycle-variance {
  margin: -4px 0 10px;
  font-weight: 600;
  font-size: 0.87rem;
  color: #334155;
}

.measure-cycle-averages {
  margin: -2px 0 10px;
  font-weight: 600;
  font-size: 0.87rem;
  color: #0f172a;
}

.measure-cycle-canvas-wrap {
  border: 1px solid #dbe5f1;
  border-radius: 12px;
  background: #ffffff;
  padding: 6px;
}

.measure-cycle-canvas {
  display: block;
  width: 100%;
  height: 250px;
}

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

.calibration-tree-hint {
  margin-top: 10px;
}

.library-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.library-filters #importZipBtn {
  background: #0ea5e9;
}

.recording-type-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.9rem;
}

.recording-type-filter-label select {
  min-width: 150px;
  margin: 0;
  padding: 6px 8px;
}

.tab {
  background: #e2e8f0;
  color: #0f172a;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.recordings {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.calibration-tree {
  margin-top: 16px;
}

.cal-tree-node {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  padding: 10px 12px;
}

.cal-tree-node + .cal-tree-node {
  margin-top: 10px;
}

.cal-tree-summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.cal-tree-run > .cal-tree-summary[draggable="true"] {
  cursor: grab;
}

.cal-tree-run > .cal-tree-summary.is-drag-source {
  cursor: grabbing;
  opacity: 0.68;
  border-color: #38bdf8;
  background: #f0f9ff;
}

.cal-tree-summary.is-drop-target {
  border-color: #0ea5e9;
  background: #e0f2fe;
}

.cal-tree-summary.selection-all {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.cal-tree-summary.selection-none {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.cal-tree-summary.selection-none .cal-tree-title,
.cal-tree-summary.selection-none .cal-tree-meta {
  color: #64748b;
}

.cal-tree-summary.selection-partial {
  background:
    repeating-linear-gradient(
      -45deg,
      #ffffff 0px,
      #ffffff 8px,
      #f1f5f9 8px,
      #f1f5f9 16px
    );
  border-color: #cbd5e1;
}

.cal-tree-summary::-webkit-details-marker {
  display: none;
}

.cal-tree-title {
  font-weight: 700;
}

.cal-tree-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.cal-tree-children {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.cal-tree-point > .cal-tree-children {
  margin-left: 8px;
}

.cal-tree-run {
  border-style: dashed;
}

.cal-point-alias-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.cal-point-alias-row input {
  width: 100%;
}

.alias-manager-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 8px;
}

.alias-manager-toolbar input[type="search"] {
  width: 100%;
}

.alias-manager-hint {
  margin-top: 0;
  margin-bottom: 12px;
}

.alias-manager-bulk {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.alias-manager-table-wrap {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: auto;
  background: #ffffff;
}

.alias-manager-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.alias-manager-table th,
.alias-manager-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

.alias-manager-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.alias-manager-table td input[type="text"] {
  width: 100%;
  min-width: 180px;
}

.alias-manager-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: #334155;
  white-space: nowrap;
}

.alias-row-focus {
  background: #eff6ff;
}

.alias-row-dirty {
  background: #fefce8;
}

.calibration-tree-leaf {
  margin-top: 6px;
}

.admin-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.admin-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
}

.admin-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-item .settings-actions {
  justify-content: flex-end;
}

.profile-permission-content {
  display: grid;
  gap: 10px;
}

.profile-permission-group {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.profile-permission-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #9a3412;
}

.profile-permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.profile-permission-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  margin: 0;
}

.profile-permission-option input[type="checkbox"] {
  margin-top: 2px;
}

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

.profile-permission-label {
  font-weight: 600;
  color: #0f172a;
}

.profile-permission-code {
  font-size: 0.78rem;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.secondary-portal-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.secondary-portal-list[hidden] {
  display: none !important;
}

.secondary-portal-toggle-heading {
  margin-bottom: 0;
}

.secondary-portal-toggle-btn {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.secondary-portal-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.secondary-portal-toggle-chevron {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  transform: rotate(-90deg);
  transition: transform 120ms ease;
}

.secondary-portal-toggle-chevron.is-open {
  transform: rotate(0deg);
}

.secondary-portal-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.secondary-portal-title {
  font-weight: 600;
}

.secondary-portal-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 4px;
}

.recording {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
}

.recording.is-disabled {
  background: #e5e7eb;
  border-color: #cbd5e1;
  opacity: 0.78;
}

.recording.is-disabled .title,
.recording.is-disabled .meta,
.recording.is-disabled .comment-block label,
.recording.is-disabled .comment-input,
.recording.is-disabled .comment-msg {
  color: #475569;
}

.recording-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.spectrum {
  width: 160px;
  height: 60px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid #e2e8f0;
  align-self: center;
  cursor: pointer;
  transition: width 0.2s ease, height 0.2s ease;
}

.calibration-spectrum {
  background: #1e3a8a;
}

.disabled-calibration-spectrum {
  background: #dc2626 !important;
  border-color: #991b1b;
}

.spectrum.expanded {
  width: 520px;
  height: 220px;
}

.spectrum.reference {
  background: #ffffff;
  border-color: #cbd5f5;
}

.recording .title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sync-state-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  flex: 0 0 24px;
  background-image: url("sync-ok.png");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.sync-state-icon.pending {
  background-image: url("sync-pending.png");
}

.sync-state-icon.error {
  background-image: url("sync-error.png");
}

.recording .meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.preview {
  margin-top: 12px;
}

.comment-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
  align-items: end;
}

.comment-block textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.comment-msg {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: #0f766e;
}

audio {
  width: 100%;
  margin-top: 12px;
}

@media (max-width: 720px) {
  .app {
    padding: 20px 14px 40px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }

  .user-area {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .user-area button,
  .admin-link {
    margin-left: 0;
  }

  .portal-nav {
    margin-top: 0;
  }

  .portal-nav-link {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
    text-align: center;
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-actions button,
  .settings-actions .space-link,
  .settings-actions .admin-link {
    width: 100%;
    justify-content: center;
  }

  .library-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .library-filters > * {
    width: 100%;
  }

  .recording-type-filter-label {
    justify-content: space-between;
  }

  .recording-type-filter-label select {
    min-width: 0;
    width: 100%;
  }

  .alias-manager-bulk {
    grid-template-columns: 1fr;
  }

  .admin-item {
    grid-template-columns: 1fr;
  }

  .admin-item .settings-actions {
    justify-content: stretch;
  }

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

  .recording-actions {
    justify-content: flex-start;
  }

  .spectrum {
    width: 100%;
  }

  .spectrum.expanded {
    width: 100%;
    height: 200px;
  }

  .measure-cycle-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .measure-cycle-canvas {
    height: 220px;
  }

  .dynamic-spectrogram-modal-card {
    width: min(96vw, 96vw);
    padding: 14px;
  }

  .dynamic-spectrogram-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .dynamic-spectrogram-controls {
    grid-template-columns: 1fr;
  }

  .analysis-page .topbar {
    margin-bottom: 16px;
  }
}

.chirp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.chirp-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chirp-controls label {
  font-size: 0.9rem;
  display: grid;
  gap: 6px;
}

.chirp-controls input,
.chirp-controls select {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.chirp-controls .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chirp-plot {
  position: relative;
  margin-top: 20px;
  background: #0f172a;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 8px;
  min-height: 420px;
}

#chirpCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
}

.chirp-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.35);
  max-width: 220px;
}

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

.analysis-page .app {
  max-width: none;
  margin: 0;
  padding: 24px 24px 60px 0;
}

.analysis-page .analysis-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.analysis-page.analysis-embedded .app {
  padding: 0;
}

.analysis-page.analysis-embedded .topbar {
  display: none;
}

.analysis-page.analysis-embedded .analysis-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.analysis-page.analysis-embedded .action-history-card {
  display: none;
}

.analysis-page.analysis-embedded .card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.analysis-page.analysis-embedded #plotCanvas {
  height: min(58vh, 640px);
}

.analysis-page.analysis-embedded #pcaXWeightsCanvas,
.analysis-page.analysis-embedded #inputSpectraOverlayCanvas {
  height: min(34vh, 340px);
}

.analysis-page.analysis-embedded.modeling-cleaning-embedded .card {
  padding: 8px 10px 10px;
}

.analysis-page.analysis-embedded.modeling-cleaning-embedded .settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.analysis-page.analysis-embedded.modeling-cleaning-embedded .color-filter-panel {
  margin: 8px 0 6px;
  padding: 10px 12px;
}

.analysis-page.analysis-embedded.modeling-cleaning-embedded .plot-wrap {
  margin-top: 8px;
  padding: 8px;
}

.analysis-page.analysis-embedded.modeling-cleaning-embedded #plotCanvas {
  height: min(66vh, 760px);
}

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

.modeling-page .app {
  padding: 24px 24px 60px;
}

.action-history-card {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.action-log-empty {
  margin-bottom: 10px;
}

.action-log-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.action-log-item {
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.35;
}

.action-log-item.error {
  color: #b91c1c;
  font-weight: 600;
}

.action-log-time {
  color: #64748b;
  font-weight: 600;
  margin-right: 6px;
}

.action-log-index {
  color: #0f766e;
  font-weight: 700;
  margin-right: 8px;
}

.source-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.source-options > div:first-child {
  margin-bottom: 2px;
}

.source-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.source-options input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.color-filter-panel {
  margin: 14px 0 8px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.color-filter-panel h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #0f172a;
}

.color-scale-values {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: #334155;
}

.color-scale-bar {
  position: relative;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  overflow: hidden;
  background: #e2e8f0;
}

.color-scale-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1px),
    rgba(15, 23, 42, 0.35) calc(10% - 1px),
    rgba(15, 23, 42, 0.35) 10%
  );
  z-index: 4;
}

.color-scale-selected-range {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 0%;
  width: 100%;
  border-left: 2px solid #0f172a;
  border-right: 2px solid #0f172a;
  background: linear-gradient(90deg, rgb(30, 140, 220) 0%, rgb(230, 80, 40) 100%);
  pointer-events: none;
  z-index: 2;
}

.color-scale-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
  z-index: 5;
}

.color-scale-slider::-webkit-slider-runnable-track {
  height: 20px;
  background: transparent;
}

.color-scale-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid #0f172a;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  pointer-events: auto;
}

.color-scale-slider::-moz-range-track {
  height: 20px;
  background: transparent;
}

.color-scale-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #0f172a;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  pointer-events: auto;
}

.color-scale-graduations {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  margin-top: 4px;
  font-size: 0.67rem;
  color: #64748b;
}

.color-scale-graduations span {
  text-align: center;
}

.color-filter-grid {
  margin-top: 10px;
  align-items: center;
}

.color-filter-readout {
  display: inline-block;
}

.color-filter-checkbox {
  align-self: end;
}

.color-filter-summary {
  margin: 10px 0 0;
  font-size: 0.82rem;
}

.model-step-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
}

.model-step-list .muted {
  margin: 2px 0 0;
  font-size: 0.86rem;
}

.model-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.model-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.model-selection-list {
  margin-top: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  max-height: 320px;
  overflow: auto;
}

.model-selection-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
  transition: background-color 120ms ease, opacity 120ms ease;
}

.model-selection-item:last-child {
  border-bottom: none;
}

.model-selection-item.is-unselected {
  background: #f8fafc;
}

.model-selection-item.is-unselected .model-selection-meta {
  color: #64748b;
}

.model-selection-item.is-unselected input[type="checkbox"] {
  opacity: 0.75;
}

.model-selection-item.is-selected {
  background: #ffffff;
}

.model-selection-meta {
  font-size: 0.9rem;
  color: #334155;
}

.model-db-actions {
  flex-wrap: wrap;
  align-items: center;
}

.model-db-actions .muted {
  margin: 0;
}

.inline-admin-link {
  color: #0f172a;
  margin-left: 0;
}

.model-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-select-row #savedModelSelect {
  flex: 1 1 230px;
  min-width: 200px;
}

.model-select-count {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
  white-space: nowrap;
}

.model-saved-details {
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
}

.model-saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.model-saved-block {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 8px 10px;
}

.model-saved-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.model-saved-value {
  color: #0f172a;
  font-size: 0.9rem;
}

.model-calibration-list {
  margin: 8px 0 0;
  padding-left: 16px;
  color: #334155;
  max-height: 140px;
  overflow: auto;
}

.model-history-wrap {
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: auto;
  background: #ffffff;
}

.model-history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.model-history-table th,
.model-history-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.85rem;
}

.model-history-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.models-manager-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.models-manager-list {
  display: grid;
  gap: 10px;
}

.models-manager-details {
  min-width: 0;
}

.model-manager-item {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
}

.model-manager-item.is-inactive {
  opacity: 0.72;
}

.model-manager-item.is-selected {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.25);
}

.model-manager-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #0f172a;
  font-weight: 700;
}

.model-manager-title-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.model-local-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.78rem;
  color: #334155;
}

.model-status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.model-status-chip.active {
  background: #dcfce7;
  color: #166534;
}

.model-status-chip.inactive {
  background: #f1f5f9;
  color: #475569;
}

.model-manager-meta {
  margin-top: 4px;
  color: #475569;
  font-size: 0.86rem;
}

.model-manager-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.model-action-danger {
  background: #dc2626;
}

.model-action-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.knn-weights-wrap {
  margin-top: 10px;
}

.knn-weights-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  border-radius: 10px;
}

.model-metrics-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.model-metric-card {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
  cursor: help;
}

.model-metric-label {
  font-size: 0.8rem;
  color: #64748b;
}

.model-metric-value {
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.model-progress {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.model-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.model-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
  transition: width 0.12s linear;
}

.model-progress-label {
  font-size: 0.82rem;
  color: #334155;
  font-weight: 600;
  min-width: 120px;
  text-align: right;
}

body.modeling-busy,
body.modeling-busy * {
  cursor: progress !important;
}

body.modeling-busy::after {
  content: "";
  position: fixed;
  top: 14px;
  right: 14px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(14, 165, 233, 0.25);
  border-top-color: #0ea5e9;
  border-right-color: #22c55e;
  animation: modeling-busy-spin 0.7s linear infinite;
  z-index: 6000;
  pointer-events: none;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85);
}

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

.model-results-wrap {
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: auto;
  background: #ffffff;
}

.model-results-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.model-results-table th,
.model-results-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 9px 10px;
  text-align: left;
  font-size: 0.88rem;
}

.model-results-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.model-results-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.model-results-table tbody tr:hover {
  background: #f8fafc;
}

.model-results-table tbody tr.result-row-high-distance {
  background: #fff7ed;
}

.model-results-table tbody tr.result-row-high-distance:hover {
  background: #ffedd5;
}

.family-benchmark-wrap {
  margin-top: 10px;
}

.family-benchmark-table th,
.family-benchmark-table td {
  white-space: nowrap;
  vertical-align: top;
}

.family-benchmark-table td:nth-child(8),
.family-benchmark-table td:nth-child(9),
.family-benchmark-table td:nth-child(10) {
  white-space: normal;
  min-width: 180px;
}

.family-benchmark-row-clickable {
  cursor: pointer;
}

.family-benchmark-row-clickable:hover {
  background: #eef6ff;
}

.family-benchmark-row-selected,
.family-benchmark-row-selected:hover {
  background: #dbeafe;
}

.family-benchmark-inline-progress {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 210px;
}

.family-benchmark-inline-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #dbe4ef;
  overflow: hidden;
}

.family-benchmark-inline-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
  transition: width 0.12s linear;
}

.family-benchmark-inline-progress-bar.is-indeterminate {
  width: 35%;
  animation: family-benchmark-indeterminate 1s ease-in-out infinite;
}

.family-benchmark-inline-progress-label {
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  white-space: normal;
  line-height: 1.2;
}

@keyframes family-benchmark-indeterminate {
  0% {
    transform: translateX(-95%);
  }
  100% {
    transform: translateX(285%);
  }
}

.family-benchmark-metric.family-benchmark-best {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
}

.family-benchmark-metric.family-benchmark-worst {
  background: #fef2f2;
  color: #991b1b;
  font-weight: 700;
}

#familyBenchmarkStatus.error {
  color: #b91c1c;
}

#familyBenchmarkSummary {
  margin-top: 4px;
}

.knn-confidence-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  border: 1px solid transparent;
}

.knn-confidence-badge.high {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.knn-confidence-badge.medium {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.knn-confidence-badge.low {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.model-plot-hint {
  color: #cbd5e1;
  font-size: 0.82rem;
  align-self: center;
  margin-right: 2px;
}

@media (max-width: 720px) {
  .acquisition-status-grid {
    grid-template-columns: 1fr;
  }

  .portal-space-card {
    min-height: 0;
  }

  .model-history-wrap {
    margin-inline: -4px;
  }

  .noise-plot-fullscreen {
    padding: 0;
  }

  .noise-plot-fullscreen-card {
    border-radius: 0;
    padding: 10px;
  }

  .noise-plot-fullscreen-actions {
    width: 100%;
  }

  .chirp-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .chirp-plot {
    min-height: 320px;
  }
}

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

  .analysis-page .app {
    padding: 20px 16px 48px;
  }

  .action-history-card {
    position: static;
    max-height: none;
  }

  .models-manager-layout {
    grid-template-columns: 1fr;
  }

  .model-history-wrap,
  .alias-manager-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.filter-layout {
  display: grid;
  gap: 24px;
}

.filter-file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-meta {
  margin: 12px 0 0;
  color: #475569;
  font-size: 0.9rem;
}

.band-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.band-header h2 {
  margin-bottom: 0;
}

.band-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spectrum-mode-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: #334155;
}

.spectrum-mode-control select {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #0f172a;
  font-size: 0.86rem;
}

.filter-plus-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  line-height: 1;
  padding: 0;
  font-size: 1.2rem;
  border-radius: 999px;
}

.spectrum-editor-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
}

.spectrum-editor-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
}

.band-badges {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.band-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  padding: 5px 8px;
}

.band-badge-color {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.band-badge-text {
  font-size: 0.82rem;
  color: #0f172a;
}

.band-badge-remove {
  border: none;
  background: transparent;
  color: #475569;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0;
}

.band-badge-remove:hover:not(:disabled) {
  transform: none;
  background: #e2e8f0;
  color: #0f172a;
}

.band-list {
  display: grid;
  gap: 12px;
}

.band-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.band-row label {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 0.9rem;
}

.band-enable {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.9rem;
}

.band-enable input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
}

.secondary-btn {
  background: #e2e8f0;
  color: #0f172a;
}

.secondary-btn:hover:not(:disabled) {
  background: #cbd5e1;
}

.band-remove-btn {
  justify-self: stretch;
}

.filter-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-status {
  margin-top: 12px;
}

.filter-status[data-state="error"] {
  color: #b91c1c;
}

.filter-status[data-state="ok"] {
  color: #166534;
}

.filter-status[data-state="busy"] {
  color: #1d4ed8;
}

.filter-download {
  display: inline-flex;
  align-items: center;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  color: #0f172a;
  background: #ffffff;
  text-decoration: none;
  font-weight: 600;
}

.filter-download:hover {
  background: #f8fafc;
}

.filter-audio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.filter-audio-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #ffffff;
}

.filter-audio-card h2 {
  margin: 0 0 8px;
}

.filter-audio-card audio {
  width: 100%;
}

.app-context-menu {
  position: fixed;
  z-index: 4000;
  min-width: 190px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.app-context-menu-item {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #0f172a;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
}

.app-context-menu-item:hover:not(:disabled) {
  transform: none;
  background: #e2e8f0;
  color: #0f172a;
}

.app-context-menu-item:disabled {
  color: #64748b;
  cursor: not-allowed;
}

.model-compat-panel {
  margin-top: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px 12px;
}

.model-compat-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.model-preproc-spectral-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 10px;
  color: #334155;
  font-size: 0.92rem;
}

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

.model-compat-column-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.model-compat-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.model-compat-item {
  color: #334155;
}

.model-compat-item.warning {
  color: #b45309;
}

.model-compat-item.error {
  color: #b91c1c;
}

.model-compat-item.recommendation {
  color: #0f766e;
}

.model-compat-item-empty {
  color: #64748b;
}

.modeling-guide-shell {
  position: sticky;
  top: 8px;
  z-index: 10;
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.modeling-guide-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 14px;
  align-items: center;
}

.modeling-guide-mode {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modeling-guide-name {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(360px, 100%);
  flex: 1 1 280px;
}

.modeling-guide-name input {
  width: 100%;
}

.modeling-guide-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid #dbe3ee;
  background: #ffffff;
}

.mode-toggle-item {
  position: relative;
  cursor: pointer;
}

.mode-toggle-item input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.mode-toggle-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  color: #334155;
}

.mode-toggle-item input:checked + span {
  background: #0f172a;
  color: #ffffff;
}

.modeling-recipe-summary {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 12px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(226, 232, 240, 0.45);
}

.modeling-recipe-summary > div {
  min-width: 0;
}

.modeling-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}

.modeling-tab-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  line-height: 1.1;
}

.modeling-tab-btn.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.modeling-tab-btn.is-complete:not(.is-active) {
  border-color: #0f766e;
  color: #0f766e;
  background: #f0fdfa;
}

.modeling-tab-btn.is-recommended:not(.is-active) {
  border-color: #0369a1;
  color: #0369a1;
  background: #f0f9ff;
}

.modeling-tab-btn.is-passed-incomplete:not(.is-active) {
  border-color: #d97706;
  color: #b45309;
  background: #fffbeb;
}

.modeling-tab-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modeling-tab-panel-hidden {
  display: none !important;
}

.modeling-cleaning-frame-wrap {
  margin-top: 12px;
}

.modeling-cleaning-frame {
  width: 100%;
  height: clamp(520px, calc(100vh - 250px), 980px);
  min-height: 0;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #ffffff;
}

.model-advanced-block {
  margin-top: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #ffffff;
}

.model-advanced-block > summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  color: #0f172a;
}

.model-advanced-content {
  padding: 0 12px 12px;
}

.model-subpanel-block {
  margin-top: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #ffffff;
}

.model-subpanel-block > summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  color: #0f172a;
}

.model-subpanel-content {
  padding: 0 12px 12px;
}

.model-subpanel-content > .model-compat-panel {
  margin-top: 0;
}

.modeling-mode-simple .metric-advanced {
  display: none;
}

.modeling-mode-simple #modelCompatibilityPanel .model-compat-columns {
  grid-template-columns: 1fr;
}

.modeling-mode-simple #modelCompatibilityPanel .model-compat-column:nth-child(2) {
  display: none;
}

.modeling-mode-simple #knnWeightBandsGroup,
.modeling-mode-simple #knnOptimizeMinutesGroup,
.modeling-mode-simple #knnOptimizeEvalGroup,
.modeling-mode-simple #knnUseOptimizedGroup {
  display: none !important;
}

.modeling-mode-simple #modelHistoryBody {
  display: none !important;
}

@media (max-width: 760px) {
  .modeling-guide-shell {
    position: static;
  }

  .modeling-tabbar {
    gap: 6px;
  }

  .modeling-tab-btn {
    width: 100%;
    text-align: left;
    border-radius: 10px;
  }

  .modeling-cleaning-frame {
    height: clamp(420px, calc(100vh - 210px), 820px);
  }

  .analysis-page.analysis-embedded #plotCanvas {
    height: min(52vh, 560px);
  }

  .band-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

.usage-toolbar {
  align-items: end;
  gap: 10px;
}

.usage-period-control {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.usage-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.usage-kpi {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 12px;
}

.usage-kpi-label {
  font-size: 12px;
  color: #475569;
  margin-bottom: 4px;
}

.usage-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}

.usage-grid {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.usage-grid-v1 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.usage-grid-v2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.usage-panel {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}

.usage-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.usage-empty {
  color: #64748b;
  font-size: 13px;
  padding: 10px 0;
}

.usage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.usage-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
}

.usage-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.usage-timeline-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(24px, 1fr));
  gap: 6px;
}

.usage-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.usage-day-stack {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
}

.usage-day-segment {
  width: 100%;
}

.usage-day-label {
  font-size: 11px;
  color: #64748b;
}

.usage-bar-list {
  display: grid;
  gap: 8px;
}

.usage-bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 160px) 1fr auto;
  gap: 8px;
  align-items: center;
}

.usage-bar-label {
  font-size: 12px;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #0f766e;
}

.usage-bar-value {
  font-size: 12px;
  color: #475569;
}

.usage-sync-layout {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.usage-sync-donut {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(#cbd5e1 0 100%);
  position: relative;
  display: grid;
  place-items: center;
}

.usage-sync-donut-center {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #334155;
  text-align: center;
  padding: 4px;
}

.usage-sync-meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #334155;
}

.usage-sparkline {
  width: 100%;
  height: 70px;
}

.usage-sparkline polyline {
  fill: none;
  stroke: #0369a1;
  stroke-width: 2;
}

.usage-sparkline .usage-spark-bg {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.usage-recent-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.usage-recent-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

.usage-recent-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #334155;
}

.usage-recent-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

.usage-heatmap {
  display: grid;
  gap: 4px;
}

.usage-heatmap-row {
  display: grid;
  grid-template-columns: 38px repeat(24, minmax(8px, 1fr));
  gap: 3px;
  align-items: center;
}

.usage-heatmap-label {
  font-size: 11px;
  color: #64748b;
}

.usage-heatmap-cell {
  height: 11px;
  border-radius: 2px;
  background: #e2e8f0;
}

.usage-funnel {
  display: grid;
  gap: 8px;
}

.usage-funnel-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 8px;
  align-items: center;
}

.usage-funnel-label {
  font-size: 12px;
  color: #334155;
}

.usage-funnel-track {
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.usage-funnel-fill {
  height: 100%;
  border-radius: 999px;
  background: #0369a1;
}

.usage-funnel-value {
  font-size: 12px;
  color: #475569;
}

.usage-donut-layout {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.usage-category-donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(#cbd5e1 0 100%);
  border: 1px solid #dbe3ee;
}

.usage-category-legend {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.usage-category-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #334155;
}

.usage-category-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}
