:root {
  --bg: #f5f6f4; --surface: #ffffff; --surface-2: #f0f2ef; --line: #dfe3dd; --line-strong: #c7cdc5;
  --text: #1b211e; --muted: #5d6762; --faint: #8a938e;
  --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e3f0eb;
  --ok: #1d7a46; --ok-soft: #e2f3e8; --warn: #9a6200; --warn-soft: #fbf0d9;
  --bad: #b3261e; --bad-soft: #fbe5e3; --info: #2b5c9e; --info-soft: #e4ecf8; --neutral-soft: #eceeec;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,30,25,.06), 0 4px 16px rgba(20,30,25,.06);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --surface: #181d1b; --surface-2: #1f2522; --line: #2b322e; --line-strong: #3a433e;
    --text: #e6ebe8; --muted: #a3aea8; --faint: #77827c;
    --accent: #4fb596; --accent-ink: #0b1411; --accent-soft: #19332b;
    --ok: #5cc98a; --ok-soft: #173225; --warn: #e2ac4a; --warn-soft: #362a12;
    --bad: #f08a80; --bad-soft: #3a1c1a; --info: #8db4ec; --info-soft: #1a2638; --neutral-soft: #242a27;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.mode { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; letter-spacing: .02em; }
.mode.mock { background: var(--warn-soft); color: var(--warn); }
.mode.live { background: var(--ok-soft); color: var(--ok); }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.me { margin-left: auto; position: relative; }
.menu { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; color: var(--text); font: inherit; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.banner { padding: 10px 24px; background: var(--warn-soft); color: var(--warn); font-size: 13px; border-bottom: 1px solid var(--line); }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

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

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 450; }
.check input { margin-top: 3px; }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; }
.login-card .brand { margin-bottom: 4px; }

/* upload */
.upload-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 48px 24px; text-align: center; cursor: pointer;
  background: var(--surface); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 16px; margin: 10px 0 4px; }
.drop svg { color: var(--accent); }
.steps { margin: 0; padding-left: 18px; color: var(--muted); }
.steps li { margin: 4px 0; }
.cols { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cols span { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.cols span.req { border-color: var(--accent); color: var(--accent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat.ok .n { color: var(--ok); } .stat.bad .n { color: var(--bad); } .stat.warn .n { color: var(--warn); } .stat.info .n { color: var(--info); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }

/* progress */
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 4px 0 16px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }

/* tables */
.tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; color: var(--muted); font: inherit; font-weight: 550; cursor: pointer; }
.tabs button.on { background: var(--surface-2); color: var(--text); }
.tabs .count { color: var(--faint); font-weight: 450; margin-left: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr { cursor: default; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; color: var(--faint); }
td.title { min-width: 220px; }
td.title .sub { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
td.note { color: var(--muted); font-size: 13px; min-width: 200px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: var(--neutral-soft); color: var(--muted); }
.pill.run::before { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.ticket { font-family: var(--mono); font-weight: 600; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(10,15,12,.35); z-index: 20; display: flex; justify-content: flex-end; }
.drawer-body { width: min(560px, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 24px; }
.drawer-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.drawer-head .btn { margin-left: auto; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0 0 20px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.stages { display: flex; gap: 6px; margin: 4px 0 20px; flex-wrap: wrap; }
.stage { flex: 1; min-width: 90px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; }
.stage b { display: block; font-size: 13px; }
.stage.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.stage.fail { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.stage.run { background: var(--info-soft); border-color: transparent; color: var(--info); }
.trail { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.trail li { position: relative; padding: 0 0 12px 16px; font-size: 13px; }
.trail li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.trail time { color: var(--faint); font-size: 12px; display: block; }
.resume { margin-top: 20px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); display: grid; gap: 12px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(500px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10,15,12,.45); }
dialog form { padding: 24px; display: grid; gap: 14px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.secret { font-family: var(--mono); padding: 10px 12px; background: var(--surface-2); border-radius: 8px; user-select: all; word-break: break-all; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 40; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input { flex: 1; min-width: 200px; }
.roles { display: flex; gap: 12px; flex-wrap: wrap; }
pre.json { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 0; }

@media (max-width: 860px) {
  .top { padding: 0 16px; gap: 10px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .nav { order: 3; width: 100%; overflow-x: auto; margin: 0 0 8px; }
  .page { padding: 20px 16px 48px; }
  .upload-grid, .grid2 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 110px 1fr; }
}
.mt { margin-top: 20px; }
.nowrap { white-space: nowrap; }
.nav a { white-space: nowrap; }
.sd { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sd + .me { margin-left: 0; }
.sd-on { font-size: 12.5px; font-weight: 600; color: var(--ok); background: var(--ok-soft); padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.banner.info { background: var(--info-soft); color: var(--info); }
img.captcha { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.cards { display: grid; gap: 14px; }
.tcard { padding: 16px 18px; }
.tcard header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tcard .dur { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.tgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.tgrid input, .tgrid textarea { width: 100%; }
.c-project { grid-column: span 4; } .c-title { grid-column: span 8; }
.c-date { grid-column: span 4; } .c-time { grid-column: span 2; }
.c-res { grid-column: span 4; } .c-desc { grid-column: span 12; } .c-src { grid-column: span 4; }
.tgrid .c-res { grid-column: 1 / span 8; }
.opt { font-weight: 400; font-size: 12px; }
input.bad, textarea.bad { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.btn.add { width: 100%; height: 48px; margin-top: 14px; border-style: dashed; color: var(--accent); font-size: 15px; }
.btn.add span { font-size: 20px; line-height: 1; }
.danger-text { color: var(--bad); }
.savebar { position: sticky; bottom: 12px; margin-top: 16px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .tgrid > label { grid-column: span 12 !important; }
  .tgrid .c-time { grid-column: span 6 !important; }
}
.remote { position: fixed; inset: 0; z-index: 50; background: rgba(10,15,12,.55); display: grid; place-items: center; padding: 16px; }
.remote-box { width: min(1140px, 100%); max-height: 100%; overflow: auto; background: var(--surface); border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.remote-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 14px 14px 0 0; }
.remote-url { font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.remote-note { margin: 0; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.remote-note.bad { color: var(--bad); }
.remote-screen { position: relative; padding: 0 14px 14px; }
.remote-screen canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: default; outline: none; }
.r-keys { position: absolute; left: 14px; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; }
