:root {
  --bg: #101418;
  --bg-panel: #171d24;
  --bg-input: #0d1117;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4c8dff;
  --accent-hover: #6ba1ff;
  --danger: #ff6b6b;
  --ok: #4cc38a;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.02em; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.budget { color: var(--muted); font-size: 0.9rem; }
.logout-link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.logout-link:hover { color: var(--accent-hover); }

/* layout */
.panels { max-width: 900px; margin: 0 auto; padding: 1rem 1rem 3rem; display: grid; gap: 1rem; }
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.panel h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* forms */
.row { margin-bottom: 0.75rem; }
.row label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.25rem; }
select, textarea, input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font: inherit;
}
select:focus, textarea:focus, input:focus { outline: 1px solid var(--accent); }
textarea { resize: vertical; }
.row.triple { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.row.actions { display: flex; gap: 0.75rem; align-items: center; }

button {
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  padding: 0.5rem 1rem;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost { font-size: 0.78rem; padding: 0.25rem 0.6rem; color: var(--muted); }
.upload-btn {
  display: inline-block;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  cursor: pointer;
  color: var(--muted);
}
.upload-btn:hover { color: var(--text); border-color: var(--accent); }

.status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.status.error { color: var(--danger); }

/* keyframe result */
.keyframe-result { margin-top: 0.75rem; }
.keyframe-result img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.result-actions { margin-top: 0.5rem; display: flex; gap: 0.75rem; }

/* quote + jobs */
.quote-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quote { color: var(--ok); font-size: 0.92rem; }
.jobs { display: grid; gap: 0.75rem; }
.job { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.75rem; background: var(--bg-input); }
.job-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
.job video { width: 100%; border-radius: var(--radius); display: block; }
.download-link { display: inline-block; margin-top: 0.4rem; color: var(--accent); font-size: 0.85rem; }

/* history */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.history-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-input);
}
.history-item img { width: 100%; height: 90px; object-fit: cover; display: block; }
.history-item figcaption { font-size: 0.72rem; color: var(--muted); padding: 0.35rem 0.45rem; word-break: break-all; }

/* footer */
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1rem 0 2rem; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(4, 6, 9, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.lightbox-close {
  position: absolute; top: 0.5rem; right: 0.9rem;
  background: none; border: none; color: var(--text);
  font-size: 2rem;
}
#lightbox-content { max-width: 92vw; max-height: 88vh; text-align: center; }
#lightbox-content img, #lightbox-content video { max-width: 92vw; max-height: 80vh; border-radius: var(--radius); }
#lightbox-content p { color: var(--muted); font-size: 0.8rem; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(380px, 92vw);
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.3rem; }
.login-sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.85rem; }
.login-form label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }
.login-form button { width: 100%; margin-top: 1.25rem; background: var(--accent); border-color: var(--accent); color: #fff; }
.login-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 0.5rem; }

/* responsive */
@media (max-width: 560px) {
  .row.triple { grid-template-columns: 1fr; }
  .quote-row { flex-direction: column; align-items: stretch; }
  .quote-row button { width: 100%; }
  .topbar { flex-wrap: wrap; gap: 0.4rem; }
  .history-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
