:root {
  --bg: #16181d;
  --panel: #20232a;
  --line: #2f333c;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #4f8cff;
  --ok: #3fb96b;
  --warn: #e0a43a;
  --err: #e5534b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 700; }
#nav { display: flex; gap: 14px; margin-left: auto; align-items: center; flex-wrap: wrap; }
#nav .who { color: var(--muted); font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #2a2e37;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { border-color: var(--err); color: var(--err); }
button:disabled { opacity: .5; cursor: default; }

input, select {
  font: inherit;
  background: #111317;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 40px;
  width: 100%;
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
label.check { display: flex; gap: 8px; align-items: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #2a2e37; }
.badge.running { background: rgba(63,185,107,.18); color: var(--ok); }
.badge.manual { background: rgba(79,140,255,.18); color: var(--accent); }
.badge.failed { background: rgba(229,83,75,.18); color: var(--err); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; overflow-x: auto; }
.tabs button { border: 0; border-radius: 8px 8px 0 0; background: none; color: var(--muted); }
.tabs button.on { color: var(--text); background: var(--panel); }

/* The stream: phone-shaped, as tall as the window allows. */
.screen-wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.screen {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(78vh, 900px);
  max-width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}
.screen iframe, .screen img { width: 100%; height: 100%; border: 0; display: block; object-fit: contain; }
.screen.view-only iframe { pointer-events: none; }
.screen .veil {
  position: absolute; inset: auto 0 0 0; padding: 8px; text-align: center;
  background: rgba(0,0,0,.55); font-size: 13px;
}
.controls { display: flex; flex-direction: column; gap: 10px; min-width: 220px; flex: 1; }

@media (max-width: 700px) {
  main { padding: 10px; }
  .screen { height: auto; width: 100%; }
  .controls { min-width: 0; }
}

.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
.form legend { padding: 0 6px; color: var(--muted); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: flex; gap: 4px; align-items: center; }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat .n { font-size: 26px; font-weight: 700; }
.bar { height: 6px; background: #2a2e37; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); }

.log { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.log .t { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.log .warn { color: var(--warn); }
.log .error { color: var(--err); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

.secret {
  font: 600 20px/1.3 ui-monospace, Consolas, monospace;
  letter-spacing: 1px;
  padding: 10px;
  background: #111317;
  border-radius: 8px;
  user-select: all;
}

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #2a2e37; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px;
  z-index: 50; max-width: calc(100% - 32px);
}
.toast.err { border-color: var(--err); }

.login { max-width: 360px; margin: 10vh auto; display: grid; gap: 12px; }
