:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #d1d5db;
  --hdr: #1f2a37; --hdr-ink: #fff; --accent: #0696d7; --accent-ink: #fff;
  --ok: #15803d; --warn: #b45309; --err: #b91c1c; --run: #0369a1;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141a; --card: #1a222c; --ink: #e5e7eb; --muted: #9ca3af; --line: #334155;
          --hdr: #0b1016; --accent: #38bdf8; --accent-ink: #062033; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  background: var(--hdr); color: var(--hdr-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; }
header h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.hdr-btn { background: none; border: 0; color: inherit; font-size: 28px; line-height: 1; padding: 0 6px; }
.hdr-btn.small { font-size: 14px; opacity: .8; }
main { padding: 12px 12px calc(env(safe-area-inset-bottom) + 90px); max-width: 640px; margin: 0 auto; }
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav#tabs button { flex: 1; background: none; border: 0; color: var(--muted); font-size: 12px;
  padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; position: relative; }
nav#tabs button span { font-size: 22px; }
nav#tabs button.active { color: var(--accent); font-weight: 600; }
#badge { position: absolute; top: 4px; left: 55%; background: var(--run); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 6px; }

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  margin: 18px 4px 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px;
  text-align: left; color: var(--ink); font-size: 15px; font-weight: 600; min-height: 84px;
  display: flex; flex-direction: column; justify-content: space-between; }
.tile .ic { font-size: 26px; }

/* ACC-like form */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.form-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.form-head .ic { font-size: 26px; }
.form-head .meta { font-size: 12px; color: var(--muted); }
.q { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q label.lbl { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.q .num { color: var(--muted); font-weight: 500; margin-right: 6px; }
.req { color: var(--err); margin-left: 2px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password],
select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; appearance: none; -webkit-appearance: none; }
textarea { min-height: 84px; resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px;
  background-repeat: no-repeat; padding-right: 30px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: 10px 4px; font-size: 14px; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.chk input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.files-btns { display: flex; gap: 8px; }
.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 11px 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg); font-size: 10px; display: flex; align-items: center;
  justify-content: center; text-align: center; word-break: break-all; padding: 2px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 10px; width: 20px;
  height: 20px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 20px; padding: 0; }
.submitbar { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 64px); margin-top: 14px; }

/* jobs */
.job { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  margin-bottom: 8px; display: block; width: 100%; text-align: left; color: var(--ink); font: inherit; }
.job .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.job .t { font-weight: 600; }
.job .s { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 600; border-radius: 10px; padding: 2px 8px; color: #fff; flex: none; }
.pill.queued { background: var(--muted); } .pill.running { background: var(--run); }
.pill.done { background: var(--ok); } .pill.error { background: var(--err); } .pill.cancelled { background: var(--warn); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.result { white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.result code { background: var(--bg); padding: 1px 4px; border-radius: 4px; font-size: 13px; }
details summary { font-weight: 600; cursor: pointer; }
.log { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; word-break: break-word; margin-top: 8px; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line);
  border-top-color: var(--run); border-radius: 50%; animation: sp 1s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.muted { color: var(--muted); font-size: 13px; }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 76px);
  background: #111827; color: #fff; padding: 12px 14px; border-radius: 10px; z-index: 10; font-size: 14px; }

/* login */
.login { margin-top: 12vh; }
.login .logo { font-size: 44px; text-align: center; }
.login h2 { text-align: center; margin: 6px 0 20px; }
.login .q { border: 0; padding: 6px 0; }
