:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #646b78;
  --border: #e3e6eb;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --ok-bg: #e8f6ee; --ok-text: #11643a;
  --err-bg: #fdecec; --err-text: #9b1c1c;
  --run-bg: #e8effd; --run-text: #1e48a8;
  --queue-bg: #f1f2f4; --queue-text: #4b5260;
  --code-bg: #0f1115; --code-text: #d7dbe2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013; --surface: #171a1f; --text: #e8eaee; --muted: #9aa1ad; --border: #2a2f37;
    --primary: #4f83f1;
    --ok-bg: #12301f; --ok-text: #7fd8a4; --err-bg: #3a1717; --err-text: #f4a3a3;
    --run-bg: #172744; --run-text: #9bbcf7; --queue-bg: #22262d; --queue-text: #b4bac4;
    --code-bg: #090a0c;
  }
}
* { 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(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
code, .mono, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.wrap { word-break: break-all; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); gap: 16px; flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar form { margin: 0; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--primary), #7c3aed); }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 8px 0 20px; flex-wrap: wrap; }
.page-head form { margin: 0; }
.title-with-icon { display: flex; align-items: center; gap: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 180px; }
.narrow { max-width: 560px; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.two-col > .card { margin-bottom: 0; }
.two-col + .card { margin-top: 16px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type=color] { padding: 2px; height: 40px; cursor: pointer; }
input[type=file] { padding: 7px; }
.error { color: var(--err-text); font-size: 13px; font-weight: 400; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.stack > .btn { align-self: flex-start; }
button.link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); white-space: pre-wrap; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--queue-bg); color: var(--queue-text); }
.badge.lg { font-size: 14px; padding: 4px 12px; }
.badge-succeeded { background: var(--ok-bg); color: var(--ok-text); }
.badge-failed { background: var(--err-bg); color: var(--err-text); }
.badge-running { background: var(--run-bg); color: var(--run-text); }

.app-card { display: flex; gap: 14px; align-items: center; color: var(--text); margin: 0; }
.app-card:hover { text-decoration: none; border-color: var(--primary); }
.app-icon { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.app-icon.lg { width: 64px; height: 64px; border-radius: 14px; }
.app-icon.placeholder { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 22px; }
.empty { text-align: center; padding: 48px 20px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }

.code, .log { background: var(--code-bg); color: var(--code-text); padding: 14px; border-radius: 8px; overflow-x: auto; margin: 0; }
.log { max-height: 520px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; }

.auth { max-width: 400px; margin: 48px auto; }
.auth h1 { margin-bottom: 4px; }
