:root {
  --app-bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dfe6ef;
  --text: #111827;
  --muted: #64748b;
  --primary: #0f62fe;
  --primary-dark: #0844b8;
  --success: #0f8a5f;
  --warning: #b7791f;
  --danger: #c2410c;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .07);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin-bottom: 56px;
  background:
    linear-gradient(180deg, #eef4ff 0, rgba(238, 244, 255, 0) 260px),
    var(--app-bg);
  color: var(--text);
}

.app-shell {
  max-width: 1440px;
  padding-left: 24px;
  padding-right: 24px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, .28);
}

.app-nav {
  min-height: 68px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.app-brand:hover {
  color: var(--text);
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, .24);
  padding: 4px;
}

.app-brand strong,
.app-brand small {
  display: block;
  line-height: 1.2;
}

.app-brand small {
  color: var(--muted);
  font-size: .8rem;
  margin-top: 2px;
}

.app-menu {
  gap: 4px;
}

.app-menu .nav-link {
  color: #334155;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.app-menu .nav-link:hover {
  background: #eaf1ff;
  color: var(--primary-dark);
}

.app-main {
  margin-top: 24px;
}

.app-footer {
  color: var(--muted);
  padding: 18px 0;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 750;
  letter-spacing: 0;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.panel,
.metric,
.job-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

.form-panel {
  padding: 24px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.upload-destination-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-panel .row > .col-lg-7 {
  order: 1;
  width: 100%;
  flex: 0 0 100%;
}

.upload-destination-section {
  order: 2;
  width: 100%;
  flex: 0 0 100%;
}

.destination-detail {
  order: 3;
}

.standardize-only {
  order: 4;
}

.form-panel .row > .destination-detail {
  order: 3;
}

.upload-destination-section .upload-destination-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upload-destination-section .upload-destination-card {
  min-height: 86px;
}

.upload-destination-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.upload-destination-card:has(input:checked) {
  border-color: #7aa7ff;
  background: #f3f8ff;
  box-shadow: 0 8px 18px rgba(15, 98, 254, .10);
}

.upload-destination-card input {
  margin-top: 4px;
}

.upload-destination-card strong,
.upload-destination-card small {
  display: block;
}

.upload-destination-card strong {
  color: #0f376d;
  font-size: 1rem;
}

.upload-destination-card small {
  color: var(--muted);
  margin-top: 6px;
}

.file-picker-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
}

.selected-file-names {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
}

.metric strong {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 10px;
}

.metric-green::before { background: var(--success); }
.metric-amber::before { background: var(--warning); }
.metric-red::before { background: var(--danger); }
.metric-slate::before { background: #475569; }

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.data-table {
  margin-bottom: 0;
}

.data-table thead th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom-color: var(--line);
}

.data-table td {
  border-color: #edf2f7;
}

.file-jobs-table {
  table-layout: fixed;
  min-width: 680px;
}

.file-jobs-table th:nth-child(1),
.file-jobs-table td:nth-child(1) {
  width: 42px;
}

.file-jobs-table th:nth-child(3),
.file-jobs-table td:nth-child(3) {
  width: 92px;
}

.file-jobs-table th:nth-child(4),
.file-jobs-table td:nth-child(4) {
  width: 48px;
}

.file-jobs-table th:nth-child(5),
.file-jobs-table td:nth-child(5) {
  width: 72px;
}

.job-output-path {
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-list {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.json-box {
  max-height: 520px;
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  padding: 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin: 0;
}

.advanced-analysis-card {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.advanced-analysis-card:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.advanced-analysis-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
}

.advanced-analysis-title strong {
  color: var(--text);
}

.advanced-analysis-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px 18px;
  margin: 0 0 18px;
}

.advanced-analysis-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid #94a3b8;
  border-radius: var(--radius);
  padding: 12px;
  background: #f8fafc;
}

.advanced-analysis-item span,
.advanced-score-card span,
.advanced-score-card small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: .84rem;
}

.advanced-analysis-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.metric-good {
  border-left-color: #0f8a5f;
  background: #effaf5;
}

.metric-warn {
  border-left-color: #b7791f;
  background: #fff8e8;
}

.metric-bad {
  border-left-color: #c2410c;
  background: #fff1ed;
}

.metric-neutral {
  border-left-color: #64748b;
}

.advanced-summary {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}

.advanced-score-card {
  border: 1px solid var(--line);
  border-left: 4px solid #64748b;
  border-radius: var(--radius);
  padding: 14px;
}

.advanced-score-card strong {
  display: block;
  font-size: 2.2rem;
  line-height: 1;
  margin: 10px 0 6px;
}

.advanced-chart {
  width: 100%;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.advanced-recommendation {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.advanced-recommendation-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.advanced-recommendation-section h3 {
  font-size: .9rem;
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 750;
}

.advanced-recommendation-section dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
}

.advanced-recommendation-section dt {
  color: var(--muted);
  font-weight: 700;
}

.advanced-recommendation-section dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.advanced-recommendation-section ul,
.advanced-recommendation-section p {
  margin: 0;
  padding-left: 18px;
}

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

.job-card {
  padding: 16px;
}

.job-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 130px minmax(220px, auto);
  gap: 14px;
  align-items: start;
}

.job-id {
  font-weight: 800;
  color: #334155;
}

.job-main {
  min-width: 0;
}

.job-file {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: .875rem;
}

.job-state {
  min-width: 0;
}

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

.job-progress-row {
  margin-top: 14px;
}

.job-progress-shell {
  height: 24px;
  background: #e8eef7;
}

.job-export {
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.job-error {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.realtime-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 12px;
  background: #eef2f7;
  color: #475569;
  font-weight: 700;
  font-size: .82rem;
}

.realtime-pill.success {
  background: #e8f8f0;
  color: #08734f;
}

.realtime-pill.warning {
  background: #fff7e6;
  color: #9a6700;
}

.realtime-pill.danger {
  background: #fff1f2;
  color: #be123c;
}

.folder-list code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.output-picker {
  display: grid;
  gap: 16px;
}

.output-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid #cfe0ff;
  border-radius: var(--radius);
  background: #f7faff;
}

.output-selected-label,
.output-section-title {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.output-selected strong {
  display: block;
  font-size: 1.05rem;
}

.output-selected code,
.quick-location code,
.recent-location code {
  display: block;
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #475569;
}

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

.quick-location-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-location,
.recent-location {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  min-height: 92px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.quick-location:hover,
.recent-location:hover {
  border-color: #8bb4ff;
  box-shadow: 0 8px 18px rgba(15, 98, 254, .12);
  transform: translateY(-1px);
}

.quick-location strong,
.recent-location strong {
  display: block;
  margin-bottom: 4px;
}

.quick-location span {
  display: block;
  color: var(--muted);
  font-size: .875rem;
}

.quick-location.skeleton {
  color: var(--muted);
  min-height: 48px;
}

.recent-location-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.folder-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.folder-breadcrumb {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb-chip {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 4px 10px;
  color: #334155;
  font-size: .82rem;
  font-weight: 650;
}

.breadcrumb-chip:hover {
  border-color: #8bb4ff;
  color: var(--primary-dark);
}

.folder-item {
  display: grid;
  grid-template-columns: minmax(160px, 260px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.editor-shell {
  display: grid;
  gap: 18px;
}

.editor-workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.workflow-step {
  border: 1px solid #d8e6fb;
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 14px;
}

.workflow-step strong,
.workflow-step span {
  display: block;
}

.workflow-step strong {
  color: #0f376d;
}

.workflow-step span {
  margin-top: 6px;
  color: var(--muted);
  font-size: .875rem;
}

.editor-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: 16px;
  align-items: end;
}

.editor-title .form-label {
  font-weight: 750;
  color: var(--muted);
}

.editor-status {
  padding: 12px;
  border: 1px solid #d8e6fb;
  border-radius: var(--radius);
  background: #f8fbff;
}

.editor-status code {
  display: block;
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.wave-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  overflow: hidden;
}

.waveform {
  min-height: 190px;
  padding: 10px 12px 0;
}

.timeline-label {
  padding: 10px 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .875rem;
}

.render-preview {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

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

.render-preview-header strong {
  color: #334155;
}

.render-preview-header span {
  color: var(--muted);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.render-preview-bar {
  min-height: 78px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, rgba(148, 163, 184, .16) 0 1px, transparent 1px 48px),
    #f8fafc;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px;
  overflow: hidden;
}

.render-preview-segment {
  min-width: 6px;
  border-radius: 4px;
  background: #8aa3c7;
  transition: height .18s ease, background .18s ease;
}

.render-preview-segment.gain-up {
  background: #0f62fe;
}

.render-preview-segment.gain-down {
  background: #b45309;
}

.editor-transport,
.editor-actions,
.editor-footer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.zoom-control label {
  color: var(--muted);
  font-weight: 700;
}

.zoom-control input {
  width: 190px;
}

.time-readout {
  margin-left: auto;
  display: inline-flex;
  gap: 8px;
  color: #334155;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.editor-actions {
  padding-top: 4px;
}

.editor-footer-actions {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.editor-message {
  color: var(--muted);
  font-weight: 700;
}

.editor-message.success {
  color: var(--success);
}

.editor-message.warning {
  color: var(--warning);
}

.editor-message.danger {
  color: var(--danger);
}

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

.decision-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.decision-item strong,
.decision-item span {
  display: block;
}

.decision-item span {
  color: var(--muted);
  margin-top: 2px;
  font-size: .875rem;
}

.batch-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.batch-toolbar .form-select {
  min-width: 260px;
}

.batch-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.batch-table th,
.batch-table td {
  white-space: nowrap;
}

.batch-table .file-name-cell {
  min-width: 220px;
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.batch-file-row.analysis-busy {
  opacity: .58;
}

.advanced-qc-running {
  background: #f59e0b;
  color: #111827;
}

.analysis-status-cell {
  min-width: 190px;
}

.analysis-progress {
  position: relative;
  height: 22px;
  min-width: 170px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #eef2f7;
}

.analysis-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f62fe, #0f8a5f);
  transition: width .25s ease;
}

.analysis-progress span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #111827;
  font-size: .78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.deep-toggle,
.deep-toggle-placeholder {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: top;
}

.deep-toggle {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-weight: 800;
  line-height: 1;
}

.deep-toggle:hover {
  border-color: #7aa7ff;
  color: var(--primary-dark);
}

.deep-detail-row td {
  background: #f8fafc;
  border-top: 0;
  white-space: normal;
}

.deep-detail-panel {
  margin: 0 0 8px 40px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.deep-detail-list {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 8px 18px;
  margin: 0;
}

.deep-detail-list dt {
  color: var(--muted);
  font-weight: 750;
}

.deep-detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 360px;
}

.batch-actions form {
  margin: 0;
}

.btn {
  border-radius: 8px;
  font-weight: 650;
}

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

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

.form-control,
.form-select {
  border-radius: 8px;
  border-color: #cfd8e3;
}

.form-control:focus,
.form-select:focus,
.btn:focus,
.btn:active:focus {
  border-color: #7aa7ff;
  box-shadow: 0 0 0 .2rem rgba(15, 98, 254, .14);
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .quick-location-grid,
  .recent-location-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-heading {
    flex-direction: column;
  }

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

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

  .job-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .job-state,
  .job-actions {
    grid-column: 2;
  }

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

  .detail-list {
    grid-template-columns: 1fr;
  }

  .advanced-analysis-list,
  .advanced-recommendation,
  .advanced-summary {
    grid-template-columns: 1fr;
  }

  .output-selected {
    align-items: flex-start;
    flex-direction: column;
  }

  .output-selected-actions {
    justify-content: flex-start;
  }

  .upload-destination-grid {
    grid-template-columns: 1fr;
  }

  .folder-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .editor-workflow {
    grid-template-columns: 1fr;
  }

  .editor-topbar {
    grid-template-columns: 1fr;
  }

  .time-readout {
    margin-left: 0;
    width: 100%;
  }

  .zoom-control {
    min-width: 100%;
  }

  .zoom-control input {
    width: 100%;
  }
}
