:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #596575;
  --line: #d7dde5;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warning: #9a3412;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  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 {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 48px);
}

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

.controls-panel {
  padding: 18px;
}

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand-row img {
  width: 74px;
  height: auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p,
label,
.status-box,
.result-log {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 18px 0;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
  color: var(--muted);
  cursor: pointer;
}

.tab-button.active {
  border-color: var(--accent);
  background: #e8f5f3;
  color: var(--accent-strong);
  font-weight: 700;
}

.tab-panel {
  display: none;
  gap: 14px;
}

.tab-panel.active {
  display: grid;
}

.file-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #aab5c2;
  border-radius: 8px;
  background: #fbfcfd;
}

label {
  display: grid;
  gap: 7px;
  font-size: 14px;
}

input[type="file"],
input[type="number"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #ffffff;
  color: var(--text);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-action {
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  background: #eef2f6;
  color: var(--text);
  border-color: var(--line);
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-box {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  font-size: 14px;
}

.metric-box {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-box strong {
  color: var(--text);
}

.output-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) minmax(170px, 30vh);
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.viewer-toolbar div {
  display: grid;
  gap: 5px;
}

.viewer {
  position: relative;
  min-height: 360px;
  background: #101820;
}

.viewer-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(12, 18, 24, 0.82);
  color: #f8fafc;
  font-size: 13px;
  pointer-events: none;
}

.viewer-legend[hidden] {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--swatch);
}

.result-log {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #f9fafb;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

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

  .output-panel {
    min-height: 720px;
  }
}

@media (max-width: 560px) {
  .tabs,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-row {
    align-items: flex-start;
  }
}
