:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e0e3e9;
  --text: #14181f;
  --muted: #667085;
  --accent: #3253d8;
  --accent-text: #ffffff;
  --ok: #17794f;
  --ok-bg: #e6f5ee;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --err: #b3261e;
  --err-bg: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101319;
    --surface: #181c24;
    --border: #2a303c;
    --text: #e8eaee;
    --muted: #98a2b3;
    --accent: #7d97ff;
    --accent-text: #0d1017;
    --ok: #6ee7b7;
    --ok-bg: #10291f;
    --warn: #fbbf6e;
    --warn-bg: #2a2113;
    --err: #ff9a92;
    --err-bg: #2d1614;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; letter-spacing: .01em; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--err); }

.brand { font-size: 1.15rem; display: flex; align-items: center; gap: .5rem; margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: .6rem; }

.container { max-width: 920px; margin: 0 auto; padding: 1rem 1rem 4rem; display: grid; gap: 1rem; }

.centered { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.login { width: min(380px, 100%); display: grid; gap: .5rem; }
.login label { font-weight: 600; font-size: .9rem; }

input[type="password"] {
  width: 100%; padding: .65rem .75rem; font: inherit;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
input[type="password"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary { background: var(--accent); color: var(--accent-text); padding: .6rem 1rem; font-weight: 600; }
.primary:hover { filter: brightness(1.07); }

.ghost {
  background: transparent; color: var(--text);
  border-color: var(--border); padding: .35rem .7rem; font-size: .85rem;
}
.ghost:hover { background: var(--bg); }
.ghost[disabled] { opacity: .45; cursor: not-allowed; }
.ghost.danger { color: var(--err); }

.badge {
  font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.run { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }

/* -- upload ------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.75rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent);
  outline: none;
}
.dropzone-title { font-weight: 600; margin-bottom: .2rem; }

.checkbox { display: flex; align-items: center; gap: .55rem; margin-top: .9rem; font-size: .93rem; }
.checkbox input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.upload-list, .job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.upload-list:not(:empty) { margin-top: .9rem; }

.upload-row { display: grid; gap: .3rem; font-size: .9rem; }
.upload-row .name { display: flex; justify-content: space-between; gap: 1rem; }
.upload-row .name span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* -- jobs --------------------------------------------------------------- */

.job {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem .9rem; display: grid; gap: .55rem;
}
.job-head { display: flex; align-items: start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.job-name { font-weight: 600; word-break: break-word; min-width: 0; }
.job-meta { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.job-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.job-error {
  background: var(--err-bg); color: var(--err);
  border-radius: 8px; padding: .5rem .6rem; font-size: .85rem; white-space: pre-wrap;
}

.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.bar.indeterminate > i { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* -- viewer ------------------------------------------------------------- */

.viewer {
  width: min(760px, 94vw); max-height: 85dvh; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.viewer::backdrop { background: rgba(8, 11, 18, .55); }
.viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.viewer-body {
  margin: 0; padding: 1rem; overflow: auto; max-height: calc(85dvh - 4rem);
  white-space: pre-wrap; word-break: break-word;
  font: .9rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 540px) {
  .topbar { padding: .7rem .8rem; }
  .container { padding: .8rem .8rem 3rem; }
  .card { padding: .9rem; }
  .job-actions { width: 100%; }
  .job-actions .ghost { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.ghost.icon {
  min-width: 2.2rem; padding: .35rem .5rem;
  font-variant: normal; line-height: 1;
}
