/* ─── Reset / base ─────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #e6e9ef;
  background: #0d1117;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
/* Prevent iOS zoom-on-focus by ensuring 16px+ inputs */
input, select, textarea, button { font-family: inherit; font-size: 16px; }

a { color: #6aa8ff; text-decoration: none; }
a:hover { text-decoration: underline; }

button { -webkit-tap-highlight-color: transparent; }

/* ─── Layout shell ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) minmax(0, 1fr);
  min-height: 100dvh;
}
.app.collapsed { --sidebar-w: 64px; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  background: #0a0d12;
  border-right: 1px solid #1f2630;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #1f2630;
  min-height: 56px;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand .dot { color: #6aa8ff; }
.app.collapsed .brand-text { display: none; }

.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #c5cbd6;
  white-space: nowrap;
  min-height: 44px;
}
.nav a:hover { background: #131922; text-decoration: none; }
.nav a.active { background: #1a2332; color: #ffffff; }
.nav .icon { width: 20px; height: 20px; flex: 0 0 20px; display: inline-flex; align-items: center; justify-content: center; }
.app.collapsed .nav-label { display: none; }

.sidebar-foot {
  border-top: 1px solid #1f2630;
  padding: 8px;
}
.sidebar-foot .who {
  padding: 8px 12px;
  font-size: 12px;
  color: #7a8597;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app.collapsed .sidebar-foot .who { display: none; }

/* ─── Topbar ───────────────────────────────────────────────── */
.main {
  min-width: 0; /* critical: prevent grid child from overflowing */
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #1f2630;
  background: #0d1117;
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 1px solid #1f2630;
  background: transparent;
  color: #c5cbd6;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: #131922; }
.icon-btn:active { transform: scale(0.97); }

.content {
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  flex: 1;
  min-width: 0;
}
.content-wrap { max-width: 1100px; margin: 0 auto; min-width: 0; }

/* ─── Mobile drawer ───────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 20;
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 84vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    z-index: 30;
  }
  .app.drawer-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  .app.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  /* On mobile we never use the desktop "collapsed" rail */
  .app.collapsed { --sidebar-w: 0; }
  .app.collapsed .brand-text,
  .app.collapsed .nav-label,
  .app.collapsed .sidebar-foot .who { display: initial; }
}
@media (min-width: 769px) {
  .scrim { display: none; }
}

/* ─── Cards / forms ────────────────────────────────────────── */
.card {
  background: #131922;
  border: 1px solid #1f2630;
  border-radius: 12px;
  padding: 20px;
  min-width: 0;
}
.card + .card { margin-top: 16px; }

.center-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.center-card {
  width: 100%;
  max-width: 420px;
  background: #131922;
  border: 1px solid #1f2630;
  border-radius: 14px;
  padding: 24px;
}
.center-card h1 { margin: 0 0 4px; font-size: 22px; }
.center-card .sub { color: #7a8597; margin-bottom: 20px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: #c5cbd6; }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2a3340;
  background: #0d1117;
  color: #e6e9ef;
  outline: none;
  min-height: 44px;
}
.input:focus { border-color: #6aa8ff; box-shadow: 0 0 0 3px rgba(106,168,255,0.15); }
textarea.input { min-height: 90px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #2a3340;
  color: #e6e9ef;
  cursor: pointer;
  min-height: 44px;
  font-weight: 500;
}
.btn:hover { background: #34404f; }
.btn-primary { background: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: #2a3340; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #2a1212; border: 1px solid #5b1a1a; color: #ffb4b4; }
.alert-info { background: #11202b; border: 1px solid #1c4053; color: #b6dcff; }

/* ─── Lists / tables ───────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: 8px; }
.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 12px 14px;
  background: #131922;
  border: 1px solid #1f2630;
  border-radius: 10px;
  align-items: center;
}
.job-row .url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: #e6e9ef;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-row .meta { font-size: 12px; color: #7a8597; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #2a3340;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge.queued    { color: #b6dcff; border-color: #1c4053; background: #11202b; }
.badge.running   { color: #ffd591; border-color: #563a17; background: #2b1d0c; }
.badge.completed { color: #9be29b; border-color: #1f4a25; background: #102213; }
.badge.failed    { color: #ffb4b4; border-color: #5b1a1a; background: #2a1212; }

pre.code {
  background: #0a0d12;
  border: 1px solid #1f2630;
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  max-width: 100%;
  min-width: 0;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.spacer { flex: 1; }
.muted { color: #7a8597; }
.kicker { font-size: 12px; color: #7a8597; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }

@media (max-width: 480px) {
  .center-card { padding: 20px; border-radius: 12px; }
  .content { padding: 12px; }
}
