:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 16px; }

button {
  background: var(--accent2);
  color: #06131f;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
button:hover { background: var(--accent); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: var(--panel2); }
button.danger { background: var(--red); color: #fff; }
button.small { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
}
input[type=checkbox] { width: auto; }

/* Login */
.login {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
}
.login-card {
  background: var(--panel); padding: 36px; border-radius: 16px;
  width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0 0 8px; }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; }
.yt-status { margin-left: auto; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }

.tabs { display: flex; gap: 4px; padding: 12px 24px 0; background: var(--panel); border-bottom: 1px solid var(--border); }
.tab { background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; }
.tab.active { color: var(--text); background: var(--bg); border: 1px solid var(--border); border-bottom: none; }

main { padding: 24px; max-width: 1000px; margin: 0 auto; }
h2 { font-size: 17px; margin: 20px 0 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card.live { border-color: var(--red); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-word; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge.live { background: rgba(239,68,68,.18); color: #fca5a5; }
.badge.completed { background: rgba(34,197,94,.16); color: #86efac; }
.badge.error { background: rgba(239,68,68,.16); color: #fca5a5; }
.badge.stopped { background: rgba(148,163,184,.18); color: #cbd5e1; }
.badge.preparing, .badge.completing { background: rgba(245,158,11,.18); color: #fcd34d; }
.badge.on { background: rgba(34,197,94,.16); color: #86efac; }
.badge.off { background: rgba(148,163,184,.18); color: #cbd5e1; }

.logs {
  background: #0a1120; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; height: 320px; overflow: auto; font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,.7); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 30px 16px; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 540px; max-width: 100%; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { color: var(--text); }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label { flex-direction: row; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; color: var(--text); cursor: pointer; }
.cron-preview { margin-top: 4px; font-family: ui-monospace, monospace; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; z-index: 100; max-width: 90%;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }

a { color: var(--accent); }

.thumb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thumb { width: 120px; height: 67px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.auto-del-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
input.mini { width: 70px; padding: 5px 8px; }
