:root {
  color-scheme: light;
  --industrial-orange: #ff5a00;
  --industrial-orange-dark: #c94700;
  --safety-yellow: #ffc107;
  --industrial-red: #c7352b;
  --industrial-green: #16845a;
  --industrial-grey-950: #15191f;
  --industrial-grey-900: #1e232a;
  --industrial-grey-850: #252b33;
  --industrial-grey-800: #303740;
  --light-grey: #e8ebee;
  --light-grey-2: #f6f7f9;
  --white: #ffffff;
  --ink: #11151b;
  --muted: #626d7a;
  --muted-strong: #3c4653;
  --line: rgba(17, 21, 27, 0.1);
  --line-strong: rgba(17, 21, 27, 0.18);
  --orange-soft: #fff0e7;
  --yellow-soft: #fff7d7;
  --green-soft: #e7f6ef;
  --red-soft: #fde8e6;
  --blue-soft: #e8edf5;
  --shadow-card: 0 10px 24px rgba(10, 14, 20, 0.12);
  --shadow-tight: 0 1px 2px rgba(10, 14, 20, 0.08), 0 8px 18px rgba(10, 14, 20, 0.08);
  --radius-xl: 8px;
  --radius-lg: 6px;
  --radius-md: 5px;
  --touch: 56px;
  --nav-height: 74px;
  --page-pad: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--industrial-grey-900);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--industrial-grey-950) 0, var(--industrial-grey-900) 310px, var(--light-grey) 310px),
    var(--industrial-grey-900);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  width: 1.12rem;
  height: 1.12rem;
  fill: currentColor;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px var(--page-pad) 26px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--white);
}

.brand-block {
  display: flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 156px;
  max-width: 100%;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-module {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: linear-gradient(145deg, #10141b, var(--industrial-grey-800));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.26);
}

.brand-mark::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(242, 106, 33, 0.95) 48% 65%, transparent 65%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent);
}

.brand-mark span {
  z-index: 1;
  width: 19px;
  height: 19px;
  border: 3px solid var(--white);
  border-top-color: var(--safety-yellow);
  border-radius: 50%;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.mode-toggle {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--light-grey-2);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 950;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.mode-toggle svg {
  width: 1rem;
  height: 1rem;
}

.mode-toggle.active {
  border-color: rgba(255, 90, 0, 0.48);
  background: var(--orange-soft);
  color: var(--industrial-orange-dark);
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--safety-yellow);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--white);
  font-family: Montserrat, "Arial Narrow", Arial, sans-serif;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.98;
}

h2,
h3,
.quick-action__label {
  font-family: Montserrat, "Arial Narrow", Arial, sans-serif;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0;
}

h3 {
  margin: 20px 0 9px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

main {
  display: grid;
  gap: 12px;
}

.icon-button,
.ghost-button,
.secondary-action,
.remove-file {
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--industrial-grey-900);
  font-weight: 900;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.icon-button {
  display: grid;
  min-width: var(--touch);
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.14);
}

.ghost-button,
.secondary-action {
  padding: 0 14px;
}

.remove-file {
  min-height: 44px;
  padding: 0 12px;
  color: var(--industrial-red);
  font-size: 0.78rem;
}

.icon-button:active,
.ghost-button:active,
.secondary-action:active,
.remove-file:active,
.mode-toggle:active,
.primary-action:active,
.tab:active,
.quick-action:active,
.record:active {
  transform: scale(0.97);
}

a.tab {
  text-decoration: none;
}

button:focus-visible,
label:focus-within {
  outline: 3px solid rgba(255, 210, 63, 0.72);
  outline-offset: 3px;
}

.system-card,
.panel-card,
.detail-body,
.record-list {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  background: var(--white);
  box-shadow: var(--shadow-card);
}

.system-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.dashboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.dashboard-grid,
.field-context {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 8px;
}

.context-item,
.service-line {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--light-grey-2);
}

.context-item--live {
  background: var(--green-soft);
  border-color: rgba(22, 132, 90, 0.2);
}

.context-item span,
.service-line span,
.metric-label,
.file-meta,
.record-meta,
.detail-meta {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.35;
}

.context-item strong,
.service-line strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-line {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.service-line strong {
  text-align: right;
}

.tabs {
  position: static;
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
  padding: 5px;
  border: 1px solid rgba(17, 21, 27, 0.12);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-tight);
}

.tab {
  display: grid;
  min-height: 52px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: #7a8491;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.tab svg {
  width: 1.24rem;
  height: 1.24rem;
}

.tab.active {
  background: var(--orange-soft);
  color: var(--industrial-orange-dark);
}

.panel {
  display: none;
  padding-bottom: 24px;
  animation: panel-in 220ms ease both;
}

.panel.active {
  display: block;
}

.section-heading,
.system-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  margin: 4px 0 11px;
}

.section-heading.compact {
  margin: 0 0 12px;
}

.section-heading .section-kicker {
  color: var(--industrial-orange-dark);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 13px;
}

.quick-action {
  position: relative;
  display: grid;
  grid-column: auto;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 3px;
  aspect-ratio: auto;
  min-height: 78px;
  align-content: center;
  align-items: center;
  justify-items: start;
  overflow: hidden;
  padding: 11px 12px;
  border: 1px solid rgba(17, 21, 27, 0.08);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, #ffffff, #f7f9fb);
  box-shadow: 0 2px 4px rgba(10, 14, 20, 0.08), 0 12px 26px rgba(10, 14, 20, 0.12);
  color: var(--ink);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  appearance: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.quick-action::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  content: "";
  background: linear-gradient(90deg, var(--industrial-orange), var(--safety-yellow));
}

.quick-action:hover {
  border-color: rgba(242, 106, 33, 0.34);
  box-shadow: 0 16px 32px rgba(10, 14, 20, 0.18);
}

.quick-action:active {
  box-shadow: 0 2px 8px rgba(10, 14, 20, 0.14);
}

.quick-action input {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
}

.hidden-media-input {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50%);
}

.quick-action__icon {
  display: grid;
  grid-row: 1 / -1;
  grid-column: 1;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--industrial-grey-900);
  color: var(--safety-yellow);
}

.quick-action__icon svg {
  width: 1.48rem;
  height: 1.48rem;
}

.quick-action__badge {
  grid-row: 1;
  grid-column: 2;
  align-self: end;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--light-grey);
  color: var(--muted-strong);
  font-size: 0.58rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.quick-action__label {
  display: block;
  grid-row: 2;
  grid-column: 2;
  align-self: start;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 950;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action__count {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: grid;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  place-items: center;
  border-radius: 999px;
  background: var(--industrial-grey-900);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 950;
  opacity: 0;
  transform: translateY(-4px) scale(0.9);
  transition: opacity 160ms ease, transform 160ms ease;
}

.quick-action.has-count {
  border-color: rgba(242, 106, 33, 0.42);
  background:
    linear-gradient(180deg, #ffffff, #fff8f3);
}

.quick-action.has-count .quick-action__count {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.quick-action.has-count .quick-action__badge {
  visibility: hidden;
}

.panel-card {
  margin-top: 12px;
  padding: 14px;
}

.pipeline-card {
  background: #fbfcfd;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pipeline-stage {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 86px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--muted);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.pipeline-stage__icon {
  display: grid;
  width: 34px;
  height: 28px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--light-grey);
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-weight: 950;
}

.pipeline-stage strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-stage small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-stage i {
  display: block;
  height: 4px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--light-grey);
}

.pipeline-stage i::before {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--industrial-orange), var(--safety-yellow));
  content: "";
  transition: width 220ms ease;
}

.pipeline-stage.active {
  border-color: rgba(242, 106, 33, 0.42);
  background: var(--orange-soft);
  box-shadow: 0 0 0 3px rgba(242, 106, 33, 0.1), 0 12px 24px rgba(242, 106, 33, 0.14);
}

.pipeline-stage.active .pipeline-stage__icon {
  background: var(--industrial-grey-900);
  color: var(--safety-yellow);
}

.pipeline-stage.active i::before {
  width: 58%;
  animation: progress-pulse 1.5s ease-in-out infinite;
}

.pipeline-stage.done {
  border-color: rgba(22, 132, 90, 0.26);
  background: var(--green-soft);
  animation: stage-complete 320ms ease both;
}

.pipeline-stage.done .pipeline-stage__icon {
  background: var(--industrial-green);
  color: var(--white);
}

.pipeline-stage.done i::before {
  width: 100%;
  background: var(--industrial-green);
}

.pipeline-stage.failed {
  border-color: rgba(199, 53, 43, 0.36);
  background: var(--red-soft);
  box-shadow: 0 0 0 3px rgba(199, 53, 43, 0.1);
}

.pipeline-stage.failed .pipeline-stage__icon {
  background: var(--industrial-red);
  color: var(--white);
}

.selected-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.file-list {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.selection-summary {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.selection-summary.warning {
  color: var(--industrial-red);
}

.file-list[aria-busy="true"] {
  opacity: 0.58;
}

.file-list-more {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.file-list-more .ghost-button {
  width: 100%;
}

.file-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--light-grey-2);
}

.file-thumb {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, var(--industrial-grey-900), var(--industrial-grey-800));
  background-position: center;
  background-size: cover;
  color: var(--white);
  font-size: 0.66rem;
  font-weight: 950;
}

.file-thumb::after {
  content: attr(data-kind);
}

.file-thumb.has-preview::after {
  content: "";
}

.file-type-dot {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: var(--industrial-orange);
}

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

.file-name {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
}

.primary-action {
  display: inline-flex;
  width: 100%;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--industrial-orange), var(--industrial-orange-dark));
  color: var(--white);
  font-weight: 950;
  letter-spacing: 0.02em;
  box-shadow: 0 18px 30px rgba(242, 106, 33, 0.3);
  transition: transform 150ms ease, filter 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.selected-card .primary-action {
  position: sticky;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px);
  z-index: 9;
}

.primary-action:hover {
  filter: brightness(1.03);
}

.primary-action:disabled {
  background: #b7bec8;
  box-shadow: none;
  opacity: 0.8;
}

.primary-action.compact {
  width: auto;
  min-width: 104px;
  min-height: 52px;
  padding: 0 18px;
}

.record-list {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.record {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-tight);
  color: var(--ink);
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

button.record:hover {
  border-color: rgba(242, 106, 33, 0.3);
  box-shadow: var(--shadow-card);
}

.record strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 950;
}

.field-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.field-facts span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--light-grey-2);
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-weight: 850;
}

.field-facts b {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.record-status {
  display: grid;
  justify-items: end;
  gap: 5px;
  align-content: start;
}

.record-status > span:not(.badge) {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.error-text {
  margin-top: 8px;
  color: var(--industrial-red);
}

.upload-progress-label {
  display: block;
  margin: 10px 0 7px;
  color: var(--muted-strong);
  font-size: 0.74rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}

.upload-actions .ghost-button {
  min-height: 44px;
}

.upload-actions .upload-cancel {
  color: var(--industrial-red);
}

.record-footer {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.record-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  margin: -2px 0 13px;
}

.search-box,
.filter-box {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-tight);
}

.search-box {
  min-width: 0;
}

.search-box svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.search-box input,
.filter-box select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
}

.filter-box {
  flex: 0 0 auto;
}

.filter-box span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.grouped-list {
  display: grid;
  gap: 16px;
}

.history-group {
  display: grid;
  gap: 10px;
}

.history-group h3 {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 950;
  text-transform: uppercase;
}

.status-chip,
.badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-weight: 950;
  white-space: nowrap;
}

.topbar .status-chip {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

.status-chip.uploaded,
.status-chip.processing,
.status-chip.uploading,
.status-chip.waiting,
.status-chip.paused,
.status-chip.finalizing,
.status-chip.cancelling,
.badge.uploaded,
.badge.processing,
.badge.uploading,
.badge.waiting,
.badge.paused,
.badge.finalizing,
.badge.cancelling {
  background: var(--yellow-soft);
  color: #7a5600;
}

.status-chip.completed,
.status-chip.ok,
.status-chip.ready,
.badge.completed,
.badge.ok,
.badge.ready {
  background: var(--green-soft);
  color: var(--industrial-green);
}

.status-chip.failed,
.status-chip.offline,
.status-chip.auth_required,
.status-chip.update_required,
.badge.failed,
.badge.offline,
.badge.auth_required,
.badge.update_required {
  background: var(--red-soft);
  color: var(--industrial-red);
}

:root[data-theme="dark"] body[data-apms-module="capture"] .section-kicker {
  color: #ff8b4d;
}

:root[data-theme="dark"] body[data-apms-module="capture"] .error-text,
:root[data-theme="dark"] body[data-apms-module="capture"] .upload-actions .upload-cancel {
  color: #ffaaa5;
}

:root[data-theme="dark"] body[data-apms-module="capture"] .status-chip.paused,
:root[data-theme="dark"] body[data-apms-module="capture"] .status-chip.finalizing,
:root[data-theme="dark"] body[data-apms-module="capture"] .status-chip.cancelling,
:root[data-theme="dark"] body[data-apms-module="capture"] .badge.paused,
:root[data-theme="dark"] body[data-apms-module="capture"] .badge.finalizing,
:root[data-theme="dark"] body[data-apms-module="capture"] .badge.cancelling {
  color: #f6d66a;
}

:root[data-theme="dark"] body[data-apms-module="capture"] .status-chip.auth_required,
:root[data-theme="dark"] body[data-apms-module="capture"] .status-chip.update_required,
:root[data-theme="dark"] body[data-apms-module="capture"] .badge.auth_required,
:root[data-theme="dark"] body[data-apms-module="capture"] .badge.update_required {
  color: #ffaaa5;
}

.topbar .status-chip.ok {
  background: rgba(22, 132, 90, 0.22);
  color: #b8f7d9;
}

.topbar .status-chip.failed,
.topbar .status-chip.waiting {
  background: rgba(255, 210, 63, 0.16);
  color: #ffeaa1;
}

.progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce2ea;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--industrial-orange), var(--safety-yellow));
  transition: width 220ms ease;
}

.detail-body {
  padding: 15px;
}

.detail-summary {
  display: grid;
  gap: 12px;
}

.detail-hero {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--industrial-grey-950), var(--industrial-grey-800));
  color: var(--white);
}

.detail-hero strong,
.detail-hero .detail-meta {
  color: var(--white);
}

.detail-hero .detail-meta {
  opacity: 0.8;
}

.knowledge-grid,
.detail-grid,
.report-grid {
  display: grid;
  gap: 10px;
}

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

.detail-item,
.knowledge-item,
.report-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--light-grey-2);
}

.knowledge-item strong,
.report-card strong {
  display: block;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 950;
}

.knowledge-item span,
.report-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.detail-body pre {
  max-height: 42vh;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--industrial-grey-950);
  color: #f8fafc;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.technical-details {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--light-grey-2);
}

.technical-details summary {
  min-height: 54px;
  padding: 15px;
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
}

.technical-details .detail-grid,
.technical-details h3 {
  margin-right: 12px;
  margin-left: 12px;
}

.technical-details .detail-grid:last-child {
  margin-bottom: 12px;
}

.empty-list {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.9rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(12px);
}

.modal.hidden {
  display: none;
}

body.camera-session-open {
  overflow: hidden;
}

body.camera-session-open .apms-global-header,
body.camera-session-open .apms-global-nav {
  visibility: hidden;
  pointer-events: none;
}

.camera-session-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #080a0e;
  color: var(--white);
}

.camera-session-modal.hidden {
  display: none;
}

.camera-session-panel {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #080a0e;
}

.camera-session-header {
  z-index: 2;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #151920;
}

.camera-session-header h2 {
  color: var(--white);
  font-size: 1.18rem;
}

.camera-session-header .section-kicker {
  color: var(--safety-yellow);
}

.camera-session-count {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 210, 63, 0.32);
  border-radius: 14px;
  background: rgba(255, 210, 63, 0.12);
  color: var(--safety-yellow);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.video-session-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.video-session-status .camera-session-count {
  min-height: 40px;
  padding: 0 10px;
  white-space: nowrap;
}

.camera-session-preview {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.camera-session-preview video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  touch-action: none;
}

.camera-torch-toggle {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: inline-flex;
  min-width: 88px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 14px;
  background: rgba(10, 14, 20, 0.78);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.camera-torch-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
}

.camera-torch-toggle.is-active {
  border-color: var(--safety-yellow);
  background: rgba(255, 210, 63, 0.94);
  color: #171a20;
}

.camera-torch-toggle:disabled {
  opacity: 0.46;
}

.camera-zoom-control {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 70px;
  left: 16px;
  display: grid;
  min-height: 48px;
  grid-template-columns: auto minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(10, 14, 20, 0.76);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.camera-zoom-control input {
  width: 100%;
  min-height: 32px;
  margin: 0;
  accent-color: var(--industrial-orange);
}

.camera-zoom-control output {
  color: var(--safety-yellow);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.camera-zoom-control.is-unavailable {
  opacity: 0.48;
}

.camera-session-message {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(10, 14, 20, 0.76);
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
  backdrop-filter: blur(12px);
}

.camera-session-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: var(--white);
}

.camera-session-flash.active {
  animation: camera-flash 180ms ease-out;
}

.camera-session-controls {
  display: grid;
  min-height: 116px;
  grid-template-columns: minmax(72px, 1fr) 92px minmax(72px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: #151920;
}

.camera-session-command {
  min-height: 60px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 950;
}

.camera-session-done {
  border-color: var(--industrial-orange);
  background: var(--industrial-orange);
  color: #171a20;
}

.camera-shutter {
  display: grid;
  width: 80px;
  height: 80px;
  place-self: center;
  place-items: center;
  padding: 0;
  border: 4px solid var(--white);
  border-radius: 50%;
  background: transparent;
}

.camera-shutter span {
  width: 62px;
  height: 62px;
  border: 3px solid #151920;
  border-radius: 50%;
  background: var(--white);
  transition: transform 100ms ease, background 100ms ease;
}

.camera-shutter:active span {
  transform: scale(0.88);
  background: var(--safety-yellow);
}

.video-record-toggle {
  display: grid;
  width: 80px;
  height: 80px;
  place-self: center;
  place-items: center;
  padding: 0;
  border: 4px solid var(--white);
  border-radius: 50%;
  background: transparent;
}

.video-record-toggle span {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e43932;
  transition: width 140ms ease, height 140ms ease, border-radius 140ms ease, transform 100ms ease;
}

.video-record-toggle svg {
  display: none;
  width: 34px;
  height: 34px;
  color: #fff;
  fill: none;
  stroke: currentColor;
}

.video-record-toggle:active span {
  transform: scale(0.88);
}

.video-record-toggle.is-recording span {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.video-recorder-modal[data-state="recording"] #videoRecorderTimer {
  border-color: rgba(228, 57, 50, 0.48);
  background: rgba(228, 57, 50, 0.16);
  color: #ff716b;
}

.camera-shutter:disabled,
.video-record-toggle:disabled,
.camera-session-command:disabled {
  opacity: 0.42;
}

@keyframes camera-flash {
  0% { opacity: 0.86; }
  100% { opacity: 0; }
}

.modal-panel {
  width: min(100%, 430px);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.modal-mark {
  margin-bottom: 16px;
}

.modal-panel .section-kicker {
  color: var(--industrial-orange-dark);
}

.modal-panel p:not(.section-kicker) {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.modal-panel input,
.modal-panel select {
  width: 100%;
  min-height: 54px;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--light-grey-2);
  color: var(--ink);
  font-size: 1rem;
}

.modal-panel select {
  appearance: auto;
}

.capture-context-panel {
  max-height: min(760px, calc(100dvh - 36px));
  overflow-y: auto;
}

.capture-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.capture-context-grid label {
  min-width: 0;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 900;
}

.capture-context-grid label > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.capture-context-grid b {
  color: var(--industrial-orange-dark);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.capture-context-grid small {
  color: var(--muted);
  font-size: 0.7rem;
}

.capture-context-grid select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.capture-context-wide {
  grid-column: 1 / -1;
}

.capture-context-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--industrial-red) !important;
  font-weight: 800;
}

.capture-context-status.ready {
  color: var(--industrial-green) !important;
}

@media (max-width: 560px) {
  .capture-context-grid {
    grid-template-columns: 1fr;
  }

  .capture-context-wide {
    grid-column: auto;
  }

  .capture-context-panel .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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

.voice-recorder-state {
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--light-grey-2);
}

.voice-recorder-state time {
  color: var(--muted-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.voice-recorder-dot {
  width: 14px;
  height: 14px;
  border: 3px solid rgba(199, 53, 43, 0.22);
  border-radius: 50%;
  background: var(--industrial-red);
}

.voice-recorder-panel[data-state="recording"] .voice-recorder-dot,
#voiceRecorderModal[data-state="recording"] .voice-recorder-dot {
  animation: recording-pulse 1.4s ease-in-out infinite;
}

.voice-recorder-meter {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 10px 0 4px;
}

.voice-recorder-meter span {
  width: 7px;
  height: 16px;
  border-radius: 4px;
  background: var(--industrial-orange);
}

#voiceRecorderModal[data-state="recording"] .voice-recorder-meter span {
  animation: voice-level 900ms ease-in-out infinite alternate;
}

#voiceRecorderModal[data-state="recording"] .voice-recorder-meter span:nth-child(2),
#voiceRecorderModal[data-state="recording"] .voice-recorder-meter span:nth-child(4) {
  animation-delay: 180ms;
}

#voiceRecorderModal[data-state="recording"] .voice-recorder-meter span:nth-child(3) {
  animation-delay: 360ms;
}

@keyframes recording-pulse {
  50% { box-shadow: 0 0 0 8px rgba(199, 53, 43, 0.14); }
}

@keyframes voice-level {
  to { height: 42px; }
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: #dfe5ec;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes progress-pulse {
  0%,
  100% {
    opacity: 0.76;
  }
  50% {
    opacity: 1;
  }
}

@keyframes stage-complete {
  from {
    transform: scale(0.985);
  }
  to {
    transform: scale(1);
  }
}

body.field-mode {
  --touch: 64px;
  --shadow-card: 0 8px 18px rgba(0, 0, 0, 0.24);
  --shadow-tight: 0 2px 8px rgba(0, 0, 0, 0.18);
  background:
    linear-gradient(180deg, #101318 0, #171a20 330px, #e6ebf1 330px),
    #171a20;
}

body.field-mode .app-shell {
  padding-right: 10px;
  padding-left: 10px;
}

body.field-mode h1 {
  font-size: clamp(1.95rem, 8vw, 3rem);
}

body.field-mode .section-kicker,
body.field-mode .pipeline-stage small,
body.field-mode .record-status > span:not(.badge),
body.field-mode .field-facts b {
  display: none;
}

body.field-mode .system-card,
body.field-mode .panel-card,
body.field-mode .record,
body.field-mode .detail-body {
  border-color: rgba(17, 21, 27, 0.22);
}

body.field-mode .quick-action {
  min-height: 82px;
  padding: 11px 12px;
  border-color: rgba(17, 21, 27, 0.2);
}

body.field-mode .quick-action__icon {
  width: 44px;
  height: 44px;
}

body.field-mode .quick-action__label {
  font-size: 0.98rem;
}

body.field-mode .pipeline {
  gap: 10px;
}

body.field-mode .pipeline-stage {
  min-height: 86px;
  border-color: rgba(17, 21, 27, 0.2);
}

body.field-mode .pipeline-stage strong {
  font-size: 0.88rem;
}

body.field-mode .file-row {
  grid-template-columns: 66px minmax(0, 1fr) auto;
  min-height: 82px;
}

body.field-mode .file-thumb {
  width: 66px;
  height: 66px;
}

body.field-mode .primary-action {
  min-height: 72px;
  font-size: 1.02rem;
}

body.field-mode .tab {
  min-height: 64px;
}

body.field-mode *,
body.field-mode *::before,
body.field-mode *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 80ms !important;
}

@media (max-width: 370px) {
  :root {
    --page-pad: 10px;
  }

  .topbar {
    gap: 8px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .mode-toggle {
    min-width: 42px;
    padding: 0;
    justify-content: center;
  }

  .mode-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .brand-logo { width: 112px; }
  .brand-module { padding-left: 8px; }

  h1 {
    font-size: 1.68rem;
  }

  .quick-actions {
    gap: 8px;
  }

  .quick-action {
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: 7px;
    min-height: 72px;
    padding: 9px;
    border-radius: var(--radius-lg);
  }

  .quick-action__icon {
    width: 36px;
    height: 36px;
  }

  .quick-action__badge {
    padding: 3px 5px;
    font-size: 0.48rem;
  }

  .quick-action__label {
    font-size: 0.84rem;
  }

  .pipeline-stage {
    min-height: 80px;
    padding: 8px;
  }

  .context-item {
    padding: 8px;
  }

  .history-tools {
    grid-template-columns: 1fr;
  }

  .filter-box {
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  .brand-logo { width: 108px; }
  .brand-module { display: none; }
  .topbar .status-chip { display: none; }
}

@media (min-width: 620px) {
  :root {
    --page-pad: 22px;
  }

  .dashboard-grid,
  .field-context {
    grid-template-columns: repeat(4, 1fr);
  }

  .quick-actions {
    grid-template-columns: repeat(4, minmax(132px, 1fr));
  }

  .quick-action { grid-column: auto; }

  .pipeline {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .report-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding-top: 30px;
  }

  main {
    gap: 18px;
  }

  .system-card,
  .panel.active {
    max-width: 920px;
  }

  .knowledge-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .detail-summary {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    padding-bottom: 16px;
  }

  .quick-actions {
    grid-template-columns: repeat(4, minmax(92px, 1fr));
  }

  .quick-action {
    grid-column: auto;
    min-height: 72px;
  }

  .camera-session-panel {
    grid-template-columns: minmax(0, 1fr) 132px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .camera-session-header {
    grid-column: 1 / -1;
    min-height: 58px;
    padding-top: calc(6px + env(safe-area-inset-top));
    padding-bottom: 6px;
  }

  .camera-session-controls {
    min-height: 0;
    grid-template-columns: 1fr;
    padding: 10px calc(10px + env(safe-area-inset-right)) 10px 10px;
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }

  .camera-zoom-control {
    right: 12px;
    bottom: 64px;
    left: 12px;
  }

  .camera-shutter {
    width: 72px;
    height: 72px;
  }

  .camera-shutter span {
    width: 54px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
