:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --panel: #ffffff;
  --text: #17211b;
  --muted: #66736b;
  --line: #dce4de;
  --accent: #0f7b6c;
  --accent-dark: #09594e;
  --warn: #b36b00;
  --bad: #b72d38;
  --good: #0b6f3a;
  --shadow: 0 14px 34px rgba(30, 46, 36, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.status-badge {
  min-width: 260px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-badge span {
  display: block;
  font-size: 1.45rem;
  font-weight: 900;
}

.status-badge small {
  color: var(--muted);
  font-weight: 700;
}

.status-badge.excellent,
.status-badge.good {
  border-color: rgba(11, 111, 58, 0.35);
}

.status-badge.warning {
  border-color: rgba(179, 107, 0, 0.45);
}

.status-badge.bad,
.status-badge.not-synced {
  border-color: rgba(183, 45, 56, 0.35);
}

.controls,
.readouts,
.live-panel,
.timecode-context,
.chart-section,
.details,
.note {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) repeat(2, minmax(130px, 0.7fr)) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

label span,
.metric span,
.live-panel span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

button {
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  background: #eef4f0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.client-readouts {
  margin-top: 10px;
}

.metric {
  min-height: 108px;
  background: var(--panel);
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 1.45rem;
  white-space: nowrap;
}

.metric.primary strong {
  color: var(--accent-dark);
  font-size: 1.8rem;
}

.live-panel {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.live-panel div {
  background: #101916;
  color: #effcf5;
  padding: 18px;
}

.live-panel span {
  color: #9fc5b7;
}

.live-panel strong {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.45rem, 4vw, 2.8rem);
  letter-spacing: 0;
}

.timecode-context,
.chart-section,
.details,
.note {
  padding: 18px;
}

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

.frame-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.frame-item.excellent {
  border-color: rgba(11, 111, 58, 0.35);
  background: #f2fbf5;
}

.frame-item.good {
  border-color: rgba(15, 123, 108, 0.35);
  background: #f1faf8;
}

.frame-item.warning {
  border-color: rgba(179, 107, 0, 0.45);
  background: #fff8eb;
}

.frame-item.bad,
.frame-item.not-synced {
  border-color: rgba(183, 45, 56, 0.35);
  background: #fff5f6;
}

.frame-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.frame-item span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.frame-item .frame-accuracy {
  margin: 10px 0 4px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
}

.frame-item .frame-percent {
  color: var(--accent-dark);
}

.frame-item .frame-rating {
  margin-top: 10px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p {
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 700;
}

canvas {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfb;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1060px;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #eef4f0;
  color: #3c4b42;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr.used {
  background: #eaf7ef;
}

tbody tr.failed {
  background: #fff0f0;
  color: #7a2028;
}

.used-pill {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  border-radius: 999px;
  background: #d5efe0;
  color: var(--good);
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 900;
}

.note p {
  max-width: 980px;
  margin-bottom: 0;
  color: #435148;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .status-badge {
    min-width: 0;
  }

  .controls,
  .readouts,
  .live-panel,
  .frame-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .controls,
  .readouts,
  .live-panel,
  .frame-grid {
    grid-template-columns: 1fr;
  }
}
