:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --accent-2: #4f6ee0;
  --danger: #e05561;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 64px; }

/* ------------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.user { color: var(--muted); font-size: 14px; }

/* -------------------------------------------------------------------- login */
.login-card {
  max-width: 360px; margin: 12vh auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card form { margin-top: 20px; display: grid; gap: 14px; }

/* -------------------------------------------------------------------- cards */
.grid {
  display: grid; gap: 16px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 650; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 14px; }
.count {
  background: var(--panel-2); color: var(--muted); border-radius: 20px;
  padding: 1px 9px; font-size: 12px; margin-left: 4px;
}

/* -------------------------------------------------------------------- stats */
.stats { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.stat {
  flex: 1 1 140px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column;
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------- form */
.form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.hint { color: #5f6779; font-size: 11px; }
.pair { display: flex; align-items: center; gap: 6px; }
.pair em { color: var(--muted); font-style: normal; }

input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 10px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=file] { color: var(--muted); font-size: 12px; max-width: 200px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-block; padding: 9px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 14px; font-family: inherit; line-height: 1.2;
}
.btn:hover { border-color: #3b4252; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #43272c; }
.btn.danger:hover { background: #2a1a1d; }
.btn.block { width: 100%; padding: 11px; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.tiny { padding: 2px 8px; font-size: 13px; line-height: 1.3; }

/* ------------------------------------------------------------------ flashes */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); font-size: 14px; }
.flash.error { border-color: #4a2a2f; background: #241a1d; color: #ffb4bb; }
.flash.success { border-color: #234a2c; background: #17241a; color: #a8e6b0; }

/* --------------------------------------------------------------------- jobs */
.job { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: var(--panel-2); }
.job-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.job-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: #2a2f3a; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge.running { background: #1d2a4a; color: #9fc0ff; }
.badge.done { background: #17301d; color: #7ee094; }
.badge.error { background: #331b1f; color: #ff9aa3; }
.bar { height: 6px; background: #11141a; border-radius: 20px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: var(--accent); transition: width .4s ease; }
.job.done .bar > div { background: var(--ok); }
.job.error .bar > div { background: var(--danger); }
.job details { margin-top: 8px; font-size: 12px; color: var(--muted); }
.job pre { white-space: pre-wrap; word-break: break-word; background: #11141a; padding: 8px; border-radius: 6px; max-height: 220px; overflow: auto; }

.up { font-size: 12px; margin-top: 6px; padding: 5px 8px; border-radius: 6px; }
.up.ok { background: #14231a; color: #8fd8a0; }
.up.err { background: #241a1d; color: #ffb4bb; }
.up a { color: inherit; text-decoration: underline; }

/* --------------------------------------------------------------- drive card */
.stat.drive { flex: 1 1 200px; }
.stat.drive .num { font-size: 20px; }
.stat.drive .actions { margin-top: 8px; }
.tiny-txt { font-size: 11px; color: #6f778a; word-break: break-all; }

.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check.disabled { color: var(--muted); }
.check em { color: var(--muted); font-style: normal; font-size: 12px; }

/* ------------------------------------------------------------------ gallery */
.gallery { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.vid { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.vid video { width: 100%; aspect-ratio: 9 / 16; background: #000; display: block; object-fit: contain; }
.vid figcaption { padding: 10px; display: grid; gap: 4px; font-size: 12px; }
.vid figcaption strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.actions { display: flex; gap: 6px; margin-top: 4px; }

/* ----------------------------------------------------------------- filelist */
.filelist { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid #21252e; font-size: 13px; }
.filelist li:last-child { border-bottom: none; }
.fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload { display: flex; align-items: center; gap: 8px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- schedule */
.navlink { color: var(--muted); font-size: 14px; padding: 4px 8px; border-radius: 6px; }
.navlink:hover { color: var(--text); background: var(--panel-2); }
.navlink.on { color: var(--text); background: var(--panel-2); }
.stat .num.on { color: var(--ok); }
.hist {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 0; border-bottom: 1px solid #21252e; font-size: 12px;
}
.hist:last-child { border-bottom: none; }
.hist-when { font-variant-numeric: tabular-nums; }
.badge.skipped, .badge.queued { background: #2a2f3a; color: var(--muted); }
.small-note { font-size: 12px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.wrap-any { word-break: break-all; display: inline-block; margin-top: 4px; }
.warn-txt { color: var(--warn); }
.badge.notifying { background: #2a2450; color: #c2b6ff; }
.badge.unknown { background: #2a2f3a; color: #6f778a; }

/* ----------------------------------------------------------------- live log */
.log {
  background: #0b0d12; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; height: 340px; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55;
}
.logline { display: flex; gap: 10px; white-space: pre-wrap; word-break: break-word; }
.logline .ts { color: #5f6779; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.logline .jid { color: #5a6274; flex: 0 0 34px; }
.logline .msg { flex: 1; color: #c3c9d8; }
.logline.success .msg { color: #8fd8a0; }
.logline.error .msg { color: #ff9aa3; }
.logline.warn .msg { color: #e2c07a; }
.logline a { color: inherit; text-decoration: underline; }

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #3b4252; margin-left: 6px; vertical-align: middle;
}
.dot.busy { background: var(--ok); box-shadow: 0 0 0 0 rgba(63,185,80,.6);
            animation: pulse 1.6s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

.muted { color: var(--muted); }

@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; }
}
