:root {
  --bg: #0c0f0f;
  --surface: #151919;
  --surface-raised: #1a1f1e;
  --surface-soft: #202625;
  --line: #2b3331;
  --line-strong: #3a4542;
  --text: #f1f4f2;
  --muted: #929c98;
  --faint: #7a8581;
  --green: #5bd590;
  --green-strong: #22ac69;
  --green-soft: #203e31;
  --amber: #f2b45f;
  --amber-soft: #433420;
  --unhook: #df8467;
  --unhook-soft: #452d27;
  --red: #ef716b;
  --red-soft: #432727;
  --cyan: #70cbd0;
  --idle: #505b57;
  --radius: 6px;
  --font: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-width: 320px;
  overflow: hidden;
}

.session-loading .dashboard-shell { visibility: hidden; }
.auth-gate { position: fixed; z-index: 100; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bg); color: var(--muted); font-size: 14px; }
.auth-gate[hidden], .auth-gate button[hidden] { display: none; }
.auth-gate button { padding: 8px 22px; }

button,
select {
  color: inherit;
  font: inherit;
}

button,
select,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
tr:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(112, 203, 208, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(112, 203, 208, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 72%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dashboard-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  height: 100vh;
  padding: 16px 20px 12px;
}

.dashboard-shell::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 150px;
  height: 2px;
  background: var(--cyan);
  box-shadow: -170px 0 0 rgba(112, 203, 208, 0.28), 170px 0 0 rgba(112, 203, 208, 0.28);
  opacity: 0.65;
  transform: translateX(-50%);
  content: "";
}

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid #34423f;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 330px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--green-strong);
  border-radius: 5px;
  background: var(--green-strong);
  color: #07110b;
  font-size: 18px;
  font-weight: 900;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

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

h1 {
  margin-top: 3px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.site-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.site-context strong {
  overflow: hidden;
  color: #d9dfdc;
  font-weight: 600;
  text-overflow: ellipsis;
}

.context-label {
  color: var(--faint);
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

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

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.select-wrap select {
  width: 148px;
  height: 36px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  padding: 0 32px 0 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.select-wrap svg {
  position: absolute;
  right: 10px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  pointer-events: none;
}

.segment-control {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #111514;
}

.language-control {
  grid-template-columns: repeat(2, 36px);
}

.language-control .segment {
  font-size: 12px;
  font-weight: 700;
}

.segment {
  position: relative;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 0 5px;
  white-space: nowrap;
  cursor: pointer;
}

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

.segment.active {
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.segment.active::after {
  position: absolute;
  right: 9px;
  bottom: 1px;
  left: 9px;
  height: 1px;
  background: var(--cyan);
  content: "";
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.icon-button svg,
.text-button svg,
.small-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clock-block {
  display: grid;
  min-width: 86px;
  padding-left: 4px;
  text-align: right;
}

.clock-block strong {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  line-height: 1.1;
}

.clock-block span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

main {
  position: relative;
  display: grid;
  grid-template-rows: 128px minmax(0, 1fr) 20px;
  gap: 12px;
  min-height: 0;
}

.dashboard-notice {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.dashboard-notice.error {
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--red);
  background: var(--red-soft);
}

#recordsNoticeBody td {
  width: auto;
  padding: 30px 16px;
  border-bottom: 0;
  white-space: normal;
}

#recordsNoticeBody tr {
  background: transparent;
  cursor: default;
}

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

.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 15px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.kpi-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--line-strong);
  content: "";
}

.kpi-card > *:not(.kpi-sparkline) {
  position: relative;
  z-index: 1;
}

.kpi-sparkline {
  position: absolute;
  z-index: 0;
  right: 12px;
  bottom: 28px;
  width: 92px;
  height: 30px;
  opacity: 0.78;
  pointer-events: none;
}

.primary-kpi::before {
  background: var(--green);
}

.opportunity-kpi::before,
.rigging-kpi::before {
  background: var(--amber);
}

.dual-kpi-value {
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin-top: 4px;
}

.dual-metric {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.dual-metric strong {
  font-size: clamp(22px, 1.5vw, 28px);
  white-space: nowrap;
}

.dual-metric small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.dual-divider {
  width: 1px;
  height: 36px;
  flex: 0 0 auto;
  background: var(--line-strong);
}

.rigging-kpi .kpi-sparkline {
  display: none;
}

.rigging-kpi .kpi-foot {
  margin-top: 3px;
}

.kpi-topline,
.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.kpi-topline {
  color: #c7cecb;
  min-height: 32px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 16px;
  gap: 6px;
}

.kpi-topline > span:first-child {
  min-width: 0;
}

.kpi-topline .mini-tag {
  flex: 0 0 auto;
  min-height: 20px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 18px;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 4px;
  min-height: 32px;
}

.kpi-value strong {
  font-family: "Cascadia Mono", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-size: clamp(28px, 2vw, 36px);
  font-weight: 720;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-value small {
  color: var(--muted);
  font-size: 13px;
}

.kpi-value.dual-kpi-value {
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.dual-kpi-value .dual-metric {
  flex: 1 1 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
}

.dual-kpi-value .dual-metric strong {
  font-size: clamp(22px, 1.5vw, 28px);
}

.dual-kpi-value .dual-metric strong.missing {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
}

.dual-kpi-value .dual-metric small {
  max-width: 100%;
  font-size: 12px;
  line-height: 1.25;
  white-space: normal;
}

.kpi-foot {
  margin-top: auto;
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.kpi-foot span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--amber) !important;
}

.accent-text {
  color: var(--amber) !important;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(91, 213, 144, 0.12);
}

.mini-tag,
.protocol-chip,
.record-count {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.mini-tag.warning {
  border-color: #5b4426;
  background: var(--amber-soft);
  color: var(--amber);
}

.mini-tag.accent {
  border-color: #5b4426;
  color: var(--amber);
}

.mini-tag b {
  margin-left: 3px;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: minmax(272px, 1.05fr) minmax(244px, 0.95fr);
  gap: 10px;
  min-height: 0;
}

.panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel::before,
.panel::after {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  pointer-events: none;
  content: "";
}

.panel::before {
  top: -1px;
  left: -1px;
  border-top: 1px solid var(--cyan);
  border-left: 1px solid var(--cyan);
}

.panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 1px solid var(--cyan);
  border-bottom: 1px solid var(--cyan);
  opacity: 0.48;
}

.work-panel {
  grid-column: 1 / span 6;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 15px 16px 12px;
}

.composition-panel {
  grid-column: 7 / span 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.composition-panel > * {
  flex-shrink: 0;
}

.composition-overview {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.opportunity-panel {
  grid-column: 10 / span 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  padding: 15px 16px 12px;
}

.trend-panel {
  grid-column: 1 / span 4;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 14px 16px 12px;
}

.comparison-panel {
  grid-column: 5 / span 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 12px;
}

.records-panel {
  grid-column: 8 / span 5;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 14px 16px 10px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.panel-header.compact {
  align-items: center;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.panel-header > div:first-child {
  min-width: 0;
}

.panel-header p {
  margin-top: 4px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.3;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.protocol-chip {
  border-color: #315441;
  background: var(--green-soft);
  color: var(--green);
}

.current-cycle {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #111514;
  white-space: nowrap;
}

.current-cycle span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: var(--muted);
  font-size: 11px;
}

.current-cycle-copy,
.legend-row b,
.composition-list span b,
.data-quality span > b,
.trend-insight span > b {
  color: inherit;
  font: inherit;
}

.current-cycle strong {
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.current-cycle small {
  color: var(--faint);
  font-size: 10px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(91, 213, 144, 0.35);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(91, 213, 144, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(91, 213, 144, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 213, 144, 0); }
}

.chart-wrap {
  position: relative;
  min-height: 0;
}

.work-chart-wrap {
  margin-top: 7px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-svg polyline,
.kpi-sparkline polyline,
.mini-trend-block polyline {
  filter: drop-shadow(0 0 3px rgba(112, 203, 208, 0.22));
}

.chart-svg text {
  font-family: var(--font);
  font-size: 12px;
}

.chart-grid {
  stroke: #2a302f;
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-axis-text {
  fill: var(--faint);
}

.chart-value-text {
  fill: #cbd2cf;
  font-size: 13px;
  font-weight: 650;
}

.chart-tooltip {
  position: fixed;
  z-index: 4;
  display: none;
  min-width: 145px;
  max-width: min(270px, calc(100vw - 16px));
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #0f1312;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  font-size: 10px;
  line-height: 1.6;
}

.lang-en .brand-block {
  min-width: 390px;
}

.lang-en h1 {
  white-space: nowrap;
}

.lang-en .range-control {
  grid-template-columns: 54px 78px 60px;
}

.lang-en .kpi-topline > span:first-child {
  min-width: 0;
  white-space: normal;
}

.lang-en .kpi-topline .mini-tag {
  flex: 0 0 auto;
}

.lang-en .work-panel .chart-footer {
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
}

.lang-en .trend-panel .panel-header,
.lang-en .work-panel .panel-header {
  flex-wrap: wrap;
}

.lang-en .trend-panel .legend-row {
  flex-wrap: wrap;
  white-space: normal;
}

.lang-en .dashboard-footer {
  flex-wrap: wrap;
  gap: 4px 18px;
  white-space: normal;
}

.small-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 11px;
}

.chart-tooltip span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.chart-tooltip b {
  color: var(--text);
  font-weight: 600;
}

.chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.work-panel .protocol-chip,
.work-panel .method-note {
  display: none;
}

.work-panel .legend-row {
  flex-wrap: wrap;
  gap: 5px 12px;
  white-space: normal;
  line-height: 1.4;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-row.slim {
  gap: 10px;
  color: var(--faint);
}

.legend-swatch {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 2px;
}

.legend-swatch.productive {
  background: var(--green-strong);
}

.legend-swatch.hook {
  background: var(--amber);
}

.legend-swatch.unhook {
  background: var(--unhook);
}

.legend-swatch.idle {
  background: var(--idle);
}

.line-legend {
  display: inline-block;
  width: 13px;
  height: 2px;
  background: var(--green);
}

.line-legend.target {
  height: 0;
  border-top: 1px dashed var(--amber);
  background: transparent;
}

.line-legend.rolling {
  height: 0;
  border-top: 1px dashed var(--cyan);
  background: transparent;
}

.line-legend.throughput {
  height: 2px;
  background: var(--cyan);
}

.method-note {
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gauge-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 80px auto;
  justify-items: center;
  row-gap: 8px;
}

.gauge {
  grid-area: 1 / 1;
  width: 108px;
  height: 80px;
}

.gauge-label {
  display: contents;
}

.gauge-label strong {
  grid-area: 1 / 1;
  align-self: end;
  margin-bottom: 18px;
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 21px;
  font-weight: 720;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.gauge-label span {
  grid-area: 2 / 1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

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

.composition-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  row-gap: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.composition-list span {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.composition-list strong {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mini-trend-block {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.mini-trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 11px;
}

.mini-trend-head strong {
  color: var(--cyan);
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 12px;
}

.mini-trend-block svg {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
  overflow: visible;
}

.data-quality {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  padding: 6px 8px;
  border: 1px solid #524128;
  border-radius: 4px;
  background: rgba(242, 180, 95, 0.06);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.data-quality svg,
.dialog-notice svg,
.trend-insight svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.data-quality strong {
  display: block;
  color: var(--amber);
  font-size: 10px;
}

.data-quality.complete {
  border-color: #315441;
  background: rgba(91, 213, 144, 0.06);
}

.data-quality.complete svg,
.data-quality.complete strong {
  color: var(--green);
  stroke: var(--green);
}

.comparison-columns,
.comparison-row {
  display: grid;
  grid-template-columns: minmax(48px, 1fr) 70px minmax(88px, 1fr);
  gap: 7px;
  align-items: center;
}

.comparison-columns {
  margin-top: 10px;
  padding: 0 7px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.35;
}

.comparison-columns span:not(:first-child) {
  text-align: right;
}

.comparison-list {
  min-height: 0;
  overflow-y: auto;
}

.comparison-row {
  width: 100%;
  min-height: 42px;
  padding: 5px 7px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.comparison-row:hover,
.comparison-row.selected {
  background: var(--surface-soft);
}

.comparison-row.selected {
  box-shadow: inset 2px 0 0 var(--green);
}

.comparison-device,
.comparison-metric {
  min-width: 0;
}

.comparison-device strong,
.comparison-metric strong {
  display: block;
  overflow: hidden;
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-device strong {
  font-family: var(--font);
}

.comparison-device small,
.comparison-metric small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-metric {
  text-align: right;
}

.comparison-metric.missing strong {
  color: var(--faint);
}

.impact-total {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--amber);
  font-size: 10px;
}

.impact-total b {
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.opportunity-list {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.opportunity-item {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.opportunity-rank {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
}

.opportunity-copy {
  min-width: 0;
}

.opportunity-copy strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opportunity-copy p {
  margin-top: 4px;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opportunity-impact {
  color: var(--amber);
  font-family: "Cascadia Mono", "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.text-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: #d5dbd8;
  cursor: pointer;
}

.text-button {
  width: 100%;
  height: 32px;
  margin-top: auto;
  font-size: 11px;
}

.text-button:hover,
.small-button:hover {
  border-color: var(--line-strong);
  background: #252c2a;
}

.text-button svg {
  width: 13px;
  height: 13px;
}

.trend-chart-wrap {
  margin-top: 5px;
}

.trend-insight {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.trend-insight svg {
  stroke: var(--green);
}

.trend-insight span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-insight strong {
  margin-right: 6px;
  color: #dce2df;
}

.small-button {
  min-width: 62px;
  height: 28px;
  padding: 0 9px;
  font-size: 10px;
}

.record-count {
  min-height: 18px;
}

.table-wrap {
  min-height: 0;
  margin-top: 8px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 7px 5px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--faint);
  white-space: normal;
  line-height: 1.3;
  font-size: 11px;
  font-weight: 600;
}

td {
  color: #c9d0cd;
  font-variant-numeric: tabular-nums;
}

th:first-child,
td:first-child {
  width: 9%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 14%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 13%;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5),
th:nth-child(7),
td:nth-child(7) {
  width: 11%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 13%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 14%;
}

tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

tbody tr:hover,
tbody tr:focus-visible {
  background: var(--surface-soft);
}

.cycle-id {
  color: var(--green);
  font-weight: 700;
}

.duration-warn {
  color: var(--amber);
}

.duration-danger {
  color: var(--red);
}

.unhook-cell {
  color: var(--unhook);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid #315441;
  border-radius: 3px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
}

.status-badge.warning {
  border-color: #5b4426;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.alert {
  border-color: #633532;
  background: var(--red-soft);
  color: var(--red);
}

.records-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
}

.records-foot span {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.records-foot span:last-child {
  margin-left: auto;
}

.records-foot b {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dashboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #59635f;
  font-size: 10px;
  white-space: nowrap;
}

.protocol-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.protocol-dialog::backdrop {
  background: rgba(3, 5, 5, 0.76);
  backdrop-filter: blur(3px);
}

#protocolDialog .dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 19px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin-top: 4px;
  font-size: 18px;
}

.dialog-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 18px 0;
  padding: 11px 12px;
  border: 1px solid #315441;
  border-radius: 5px;
  background: rgba(91, 213, 144, 0.06);
}

.dialog-notice strong {
  color: var(--green);
  font-size: 12px;
}

.dialog-notice p {
  margin-top: 4px;
  color: #b9c0bd;
  font-size: 11px;
  line-height: 1.55;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px 18px;
}

.mapping-grid > div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #111514;
}

.mapping-grid span,
.raw-fields span {
  display: block;
  color: var(--green);
  font-size: 9px;
  font-weight: 700;
}

.mapping-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 12px;
}

.mapping-grid small {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.5;
}

.dialog-notice svg {
  stroke: var(--green);
}

.formula-block {
  margin: 0 18px 18px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #111514;
}

.formula-block h3 {
  margin-bottom: 10px;
  font-size: 11px;
}

.formula-block code {
  display: block;
  margin: 5px 0;
  color: #d7dedb;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
}

.formula-block p {
  margin-top: 10px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.55;
}

.drawer-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(3, 5, 5, 0.65);
  backdrop-filter: blur(2px);
}

.cycle-drawer {
  position: fixed;
  z-index: 21;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
  transform: translateX(102%);
  transition: transform 220ms ease;
}

.cycle-drawer.open {
  transform: translateX(0);
}

.drawer-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 18px 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #111514;
  color: var(--muted);
  font-size: 10px;
}

.drawer-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 18px 0;
}

.drawer-metrics > div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-raised);
}

.drawer-metrics dt {
  color: var(--faint);
  font-size: 9px;
}

.drawer-metrics dd {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.snapshot-block {
  margin: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.snapshot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.snapshot-head h3 {
  font-size: 12px;
}

.snapshot-head span {
  color: var(--faint);
  font-size: 9px;
}

.snapshot-grid {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.snapshot-row {
  display: grid;
  grid-template-columns: 72px 1fr 22px 1fr;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
}

.snapshot-row strong {
  color: var(--text);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.snapshot-row i {
  color: var(--green);
  font-style: normal;
  text-align: center;
}

.raw-fields {
  margin: 0 18px 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #101413;
}

.raw-fields code {
  display: block;
  margin-top: 6px;
  color: #b9c2be;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1.5;
}

/* Keep secondary information readable from a wall-screen viewing distance. */
.eyebrow,
.clock-block span,
.mini-tag,
.protocol-chip,
.record-count,
.current-cycle span,
.current-cycle small,
.chart-value-text,
.legend-row,
.method-note,
.gauge-label span,
.mini-trend-head,
.data-quality,
.data-quality strong,
.impact-total,
.opportunity-rank,
.opportunity-copy p,
.text-button,
.trend-insight,
.small-button,
th,
.status-badge,
.records-foot,
.dashboard-footer {
  font-size: 12px;
}

.chart-tooltip,
.dialog-notice strong,
.dialog-notice p,
.mapping-grid span,
.mapping-grid small,
.formula-block code,
.formula-block p,
.drawer-status,
.drawer-metrics dt,
.snapshot-head span,
.snapshot-row,
.snapshot-row strong,
.raw-fields span,
.raw-fields code {
  font-size: 12px;
}

.chart-tooltip strong,
.mapping-grid strong,
.formula-block h3 {
  font-size: 13px;
}

.mini-tag,
.protocol-chip,
.record-count {
  min-height: 22px;
  padding-right: 7px;
  padding-left: 7px;
}

.refreshing svg {
  animation: spin 700ms linear infinite;
}

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

@media (max-width: 1540px) {
  .site-context {
    display: none;
  }

  .brand-block {
    margin-right: auto;
  }

  .kpi-card {
    padding-right: 12px;
    padding-left: 12px;
  }

  .kpi-foot span:last-child {
    display: none;
  }

  .kpi-sparkline {
    display: none;
  }
}

@media (min-width: 1181px) and (max-width: 1280px) {
  .lang-en h1 { font-size: 22px; }
  .lang-en .clock-block { display: none; }
}

@media (max-height: 950px) and (min-width: 1181px) {

  th,
  td {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .status-badge {
    height: 18px;
  }

  .table-wrap {
    margin-top: 5px;
  }

  .records-foot {
    padding-top: 5px;
  }
}

@media (max-height: 820px) and (min-width: 1181px) {
  .dashboard-shell {
    grid-template-rows: 60px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 20px 8px;
  }

  .topbar {
    padding-bottom: 8px;
  }

  main {
    grid-template-rows: 116px minmax(0, 1fr) 18px;
    gap: 8px;
  }

  .kpi-card {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .panel-header h2 {
    font-size: 16px;
  }

  .content-grid {
    grid-template-rows: minmax(250px, 1.05fr) minmax(220px, 0.95fr);
  }

}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .dashboard-shell {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    flex-wrap: wrap;
    min-height: 66px;
  }

  .top-actions {
    width: 100%;
  }

  .clock-block {
    margin-left: auto;
  }

  main {
    display: block;
    margin-top: 14px;
  }

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

  .kpi-card {
    min-height: 124px;
  }

  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    margin-top: 10px;
  }

  .work-panel,
  .composition-panel,
  .opportunity-panel,
  .trend-panel,
  .comparison-panel,
  .records-panel {
    grid-column: auto;
    grid-row: auto;
    min-height: 320px;
  }

  .work-panel,
  .records-panel {
    grid-column: 1 / -1;
  }

  .dashboard-footer {
    margin-top: 10px;
    padding: 8px 0;
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    padding: 12px;
  }

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

  .lang-en .brand-block {
    min-width: 0;
  }

  h1 {
    font-size: 21px;
  }

  .lang-en h1 {
    font-size: 20px;
    white-space: normal;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, 36px);
    gap: 6px;
    width: 100%;
  }

  .select-wrap select {
    width: 100%;
  }

  .range-control {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, 1fr);
    width: calc(100% - 88px);
    justify-self: end;
  }

  .lang-en .range-control {
    grid-template-columns: 1fr 1.4fr 1fr;
  }

  .language-control {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(2, 1fr);
    width: 80px;
    justify-self: start;
  }

  .clock-block {
    display: none;
  }

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

  .kpi-card {
    min-height: 124px;
  }

  .kpi-topline {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .kpi-topline > span:first-child {
    flex: 1 1 100px;
  }

  .primary-kpi,
  .cycle-kpi,
  .opportunity-kpi,
  .rigging-kpi {
    grid-column: 1 / -1;
  }

  .content-grid {
    display: block;
  }

  .panel {
    margin-top: 10px;
  }

  .work-panel,
  .trend-panel,
  .comparison-panel,
  .records-panel,
  .composition-panel,
  .opportunity-panel {
    min-height: 320px;
  }

  .work-panel {
    min-height: 390px;
  }

  .panel-header {
    flex-wrap: wrap;
  }

  .current-cycle {
    width: 100%;
    justify-content: flex-end;
  }

  .chart-footer,
  .records-foot,
  .dashboard-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend-row {
    flex-wrap: wrap;
    white-space: normal;
  }

  .records-panel {
    padding-right: 0;
  }

  .records-header,
  .records-foot {
    padding-right: 16px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  #recordsNoticeBody .dashboard-notice {
    max-width: calc(100vw - 90px);
  }

  table {
    min-width: 780px;
  }

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

  .dashboard-footer {
    white-space: normal;
    line-height: 1.5;
  }
}

@media (max-width: 480px) {
  .kpi-card:not(.primary-kpi):not(.cycle-kpi) .kpi-sparkline {
    display: none;
  }
}

@media (max-width: 360px) {
  .lang-en .kpi-card:not(.primary-kpi):not(.cycle-kpi):not(.rigging-kpi) {
    min-height: 132px;
  }

  .lang-en .kpi-card:not(.primary-kpi):not(.cycle-kpi):not(.rigging-kpi) .kpi-topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .lang-en .kpi-card:not(.primary-kpi):not(.cycle-kpi):not(.rigging-kpi) .kpi-topline > span:first-child {
    overflow: visible;
    white-space: normal;
  }
}

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