:root {
  --bg: #f4efe6;
  --panel: #fffdf8;
  --ink: #1a1d1a;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b91c1c;
  --muted: #6b7280;
  --line: #d1d5db;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #fce7c8 0, transparent 35%),
    radial-gradient(circle at 90% 20%, #d1fae5 0, transparent 30%),
    var(--bg);
}

header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.8);
  backdrop-filter: blur(6px);
}

.status-dock {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.status-dock.collapsed .status-live-row {
  display: none;
}

.status-summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.status-live-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.status-control-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.top-api-label {
  font-size: 0.76rem;
  color: #4b5563;
}

.top-api-input {
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  width: 100%;
  min-width: 0;
}

.top-health-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-mini-btn {
  border: 1px solid #0f766e;
  background: #ecfeff;
  color: #0f766e;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  width: auto;
}

.top-item {
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: #111827;
  background: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-live-tile {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
}

.status-live-title {
  font-size: 0.72rem;
  color: #6b7280;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-live-detail {
  margin-top: 5px;
  font-size: 0.74rem;
  color: #4b5563;
  min-height: 34px;
}

@media (max-width: 1000px) {
  .status-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .status-control-row {
    grid-template-columns: 1fr auto;
  }

  .top-api-label {
    display: none;
  }
}

@media (max-width: 700px) {
  .status-dock {
    gap: 8px;
    padding: 8px 10px;
  }

  .status-live-row {
    grid-template-columns: 1fr;
  }

  .status-dock.mobile-collapsed .status-live-row {
    display: none;
  }
}

h1 { margin: 0; font-size: 1.4rem; }
p { margin: 6px 0 0; color: var(--muted); }

main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

@media (min-width: 900px) {
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide { grid-column: 1 / -1; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.05);
  align-self: start;
}

.card h2 { margin: 0 0 10px; font-size: 1rem; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.row.single { grid-template-columns: 1fr; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }

input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  font-size: 0.92rem;
  font-family: inherit;
}

textarea { min-height: 72px; }

button {
  background: linear-gradient(120deg, var(--accent), #115e59);
  color: white;
  border: none;
  cursor: pointer;
}
button.secondary { background: linear-gradient(120deg, var(--accent-2), #92400e); }
button.danger { background: linear-gradient(120deg, var(--danger), #991b1b); }

.status { font-weight: 600; margin-top: 6px; }

pre {
  margin: 0;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  max-height: 420px;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  background: #ecfeff;
  color: #0f766e;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  margin-top: 8px;
}

video {
  width: 100%;
  height: 220px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #111827;
  object-fit: contain;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.result-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.result-head {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.chip.success {
  background: #ecfdf3;
  color: #166534;
  border-color: #86efac;
}

.chip.warn {
  background: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.chip.danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.chip.neutral {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.mini {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #4b5563;
  word-break: break-word;
}

.mini.strong {
  margin-top: 10px;
  color: #111827;
  font-weight: 600;
}

.banner {
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  border: 1px solid transparent;
}

.banner.success {
  background: #ecfdf3;
  color: #166534;
  border-color: #86efac;
}

.banner.warn {
  background: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.banner.danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.banner.neutral {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.ocr-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}

@media (max-width: 900px) {
  .ocr-grid {
    grid-template-columns: 1fr;
  }
}

.ocr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.ocr-table th,
.ocr-table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 7px 6px;
  vertical-align: top;
}

.step-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.step-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 10px;
  background: #ffffff;
  font-size: 0.86rem;
}

.step-row.current {
  border-color: #0f766e;
  box-shadow: inset 0 0 0 1px #0f766e;
}

.step-badge {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.step-badge.pending {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.step-badge.done {
  background: #ecfdf3;
  color: #166534;
  border-color: #86efac;
}

.step-badge.failed {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 900px) {
  .compare-grid {
    grid-template-columns: 1fr;
  }
}

.compare-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.image-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #111827;
  overflow: hidden;
}

.image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.overlay-box {
  position: absolute;
  border: 2px solid #22c55e;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.15);
  display: none;
  pointer-events: none;
}
