/* ShelfScan dashboard — system fonts only, no external requests. */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #5b6572;
  --line: #dde2e7;
  --green: #0f7a3d;
  --green-bg: #e2f3e8;
  --amber: #7a4d00;
  --amber-bg: #fff1c9;
  --red: #b42318;
  --red-bg: #fdecea;
  --grey-bg: #eef1f4;
  --focus: #0b5cab;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(28, 36, 48, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
button:disabled { opacity: 0.55; cursor: wait; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0;
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--green); color: #fff;
  font-size: 1.5rem;
}
.brand-name { display: block; font-size: 1.35rem; line-height: 1.1; }
.brand-tag { display: block; color: var(--muted); font-size: 0.9rem; }
.topbar-note { color: var(--muted); margin: 0; text-align: right; }

main { max-width: 1080px; margin: 0 auto; padding: 1rem 1.25rem 2rem; }

.hero { padding: 1.25rem 0 1.5rem; }
.hero h1 { margin: 0 0 0.4rem; font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.15; letter-spacing: -0.02em; }
.hero-sub { margin: 0; font-size: 1.1rem; color: var(--muted); max-width: 42rem; }

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}
.steps li {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.7rem 0.8rem;
  font-weight: 600; font-size: 0.95rem;
}
.step-no {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grey-bg); color: var(--ink);
}

.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--red-bg); border: 2px solid var(--red);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.alert[hidden] { display: none; }
.alert-body { display: flex; flex-direction: column; }
#alertTitle { font-size: 1.1rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.panel h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 0.6rem 0 0; }

.view-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--grey-bg);
  border-radius: 12px;
  overflow: hidden;
  display: grid; place-items: center;
}
.view-frame img, .view-frame video {
  width: 100%; height: 100%;
  object-fit: contain; background: #111;
}
.view-frame [hidden] { display: none !important; }
.view-empty { text-align: center; color: var(--muted); padding: 1rem; }
.view-empty p { margin: 0.35rem 0; }
.view-empty strong { color: var(--ink); }

.error { color: var(--red); font-weight: 600; min-height: 1.4em; margin: 0.75rem 0 0; }
.error:empty { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.8rem 1.1rem;
  min-height: 44px;
  font-weight: 650;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-secondary { background: var(--grey-bg); color: var(--ink); border-color: var(--line); }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-large { width: 100%; padding: 0.95rem 1.1rem; font-size: 1.05rem; margin-top: 1rem; }
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-btn { position: relative; }

.state-badge {
  display: flex; align-items: center; gap: 0.75rem;
  border-radius: 14px; padding: 1.1rem 1.25rem;
  font-size: 1.6rem; font-weight: 800; line-height: 1.2;
  border: 2px solid var(--line);
}
#stateIcon { font-size: 1.9rem; line-height: 1; }
.state-none { background: var(--grey-bg); }
.state-full { background: var(--green-bg); border-color: var(--green); color: #0b5c2e; }
.state-low { background: var(--amber-bg); border-color: var(--amber); color: #5c3a00; }
.state-gap { background: var(--red-bg); border-color: var(--red); color: #8f1a12; }
.state-check { background: var(--grey-bg); border-color: var(--muted); }
.state-action { font-size: 1.05rem; margin: 0.9rem 0 0; }

.meter { margin-top: 1.4rem; }
.meter-head { display: flex; justify-content: space-between; font-weight: 650; font-size: 0.95rem; }
.meter-track { height: 14px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; margin-top: 0.4rem; }
.meter-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.3s ease; }
.meter-fill.warn { background: #c47a00; }
.meter-fill.danger { background: var(--red); }
.meter-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.82rem; margin: 0.35rem 0 0; }

.stats { margin: 1.4rem 0 0; border-top: 1px solid var(--line); }
.stats div { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: 0.9rem; }
.stats dd { margin: 0; font-weight: 650; }
#countEstimate { font-size: 1.35rem; }

.secondary-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.advanced { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.advanced summary { cursor: pointer; font-weight: 650; }
.slider-label { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.slider-label input { flex: 1; min-width: 160px; }

.explainer { margin-top: 1.25rem; }
.state-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1.5rem; }
.state-list li { display: flex; gap: 0.6rem; align-items: flex-start; }
.dot { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; margin-top: 0.35rem; border: 2px solid transparent; }
.dot-full { background: var(--green); }
.dot-low { background: #e0a800; }
.dot-gap { background: var(--red); }
.dot-check { background: var(--muted); }

footer {
  max-width: 1080px; margin: 0 auto; padding: 0 1.25rem 2rem;
  color: var(--muted); font-size: 0.9rem;
}
footer p { margin: 0.25rem 0; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .state-list { grid-template-columns: 1fr; }
  .topbar-note { display: none; }
  .actions .btn, .file-btn { flex: 1 1 100%; text-align: center; }
  .state-badge { font-size: 1.35rem; }
  .stats div { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}
