:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel2: #181c26;
  --line: #242a37;
  --text: #e7eaf0;
  --muted: #8a93a6;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 12px;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent2); }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
pre { background: #0a0c10; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

button, .btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
button:hover, .btn:hover { border-color: #3a4256; }
button.primary { background: linear-gradient(135deg, var(--accent), #5b8cff); border: 0; color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: #fca5a5; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 12.5px; }

input, select, textarea {
  width: 100%; background: #0d1016; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 800; font-size: 17px; margin: 0 8px 22px; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; font-size: 16px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; margin-bottom: 4px; cursor: pointer; }
nav a.active, nav a:hover { background: var(--panel2); color: var(--text); }
aside .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
main { padding: 26px 30px; max-width: 1200px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  aside nav { display: flex; flex-wrap: wrap; }
  aside .foot { display: none; }
  .brand { margin: 0 10px 0 0; }
  .grid2 { grid-template-columns: 1fr; }
  main { padding: 18px; }
}

/* stats + status */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { font-size: 22px; display: block; }
.stat span { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.b-queued { background: #1e293b; color: #93c5fd; }
.b-running, .b-downloading { background: #2e1f5e; color: #c4b5fd; }
.b-completed { background: #0f2e1c; color: #86efac; }
.b-failed { background: #3b1111; color: #fca5a5; }
.b-cancelled { background: #2a2a2a; color: #bbb; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--err); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* jobs */
.jobs { display: grid; gap: 12px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.job .media { background: #07080b; border-radius: 8px; min-height: 124px; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; text-align: center; }
.job video { width: 100%; max-height: 260px; display: block; }
.job .prompt { font-size: 14px; margin: 6px 0 8px; white-space: pre-wrap; word-break: break-word; max-height: 84px; overflow: auto; }
.job .meta { color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.job .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.job .err { color: #fca5a5; font-size: 12.5px; margin-top: 6px; }
.thumbs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; padding: 6px; }
.thumbs img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; }
.progress { height: 6px; background: #0a0c10; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }
.progress.indet i { width: 35% !important; animation: indet 1.3s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.logs { margin-top: 10px; max-height: 260px; overflow: auto; font-size: 12px; }
.logs div { padding: 2px 0; border-bottom: 1px dashed #1b2029; white-space: pre-wrap; word-break: break-word; }
.logs time { color: var(--muted); margin-right: 6px; }
@media (max-width: 700px) { .job { grid-template-columns: 1fr; } }

/* drop zone */
.drop { border: 1.5px dashed #343c4f; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: #171433; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.previews .p { position: relative; }
.previews img { width: 78px; height: 78px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.previews .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; padding: 0; justify-content: center; font-size: 11px; background: #000; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; background: #0d1016; font-size: 13px; }
.chip.on { border-color: var(--accent); background: #1d1745; color: #d8ccff; }

/* console */
.chat { background: #0a0c10; border: 1px solid var(--line); border-radius: 10px; height: 460px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 10px; background: var(--panel2); white-space: pre-wrap; word-break: break-word; }
.msg.out { align-self: flex-end; background: #2c2266; }
.msg .t { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.msg .kb { display: grid; gap: 4px; margin-top: 8px; }
.msg .kb .r { display: flex; gap: 4px; }
.msg .kb button { flex: 1; font-size: 12px; padding: 5px 8px; justify-content: center; }
.msg .m { font-size: 11.5px; color: var(--accent2); }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--panel2); border: 1px solid var(--line); padding: 12px 16px; border-radius: 10px; z-index: 99; max-width: 420px; box-shadow: 0 8px 30px #0008; }
.toast.err { border-color: var(--err); }
.toast.ok { border-color: var(--ok); }
.hidden { display: none !important; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1000px 500px at 20% 0%, #2a1d6655, transparent), radial-gradient(800px 400px at 100% 100%, #0e4f5f55, transparent), var(--bg); }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 20px 60px #0007; }
.login h1 { text-align: center; margin-bottom: 6px; }
.login .sub { text-align: center; }
.login button { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login .err { color: #fca5a5; min-height: 18px; font-size: 13px; text-align: center; margin-top: 10px; }
