:root {
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #fafafa; --text: #1d1d1f; --text-2: #6e6e73; --text-3: #a1a1a6;
  --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.14); --accent: #0b8a5f; --accent-text: #ffffff; --accent-soft: rgba(11,138,95,.12);
  --ok: #248a3d; --ok-soft: rgba(52,199,89,.14); --warn: #c93400; --warn-soft: rgba(255,159,10,.16); --bad: #d70015; --bad-soft: rgba(255,59,48,.12); --info: #0b8a5f;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05); --shadow-lg: 0 24px 64px rgba(0,0,0,.18);
  --r: 16px; --r-sm: 10px; --sidebar: 240px; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --text: #f5f5f7; --text-2: #98989d; --text-3: #636366; --line: rgba(255,255,255,.1); --line-2: rgba(255,255,255,.18);
    --accent: #22b37d; --accent-soft: rgba(34,179,125,.18); --ok: #30d158; --ok-soft: rgba(48,209,88,.16); --warn: #ff9f0a; --warn-soft: rgba(255,159,10,.18); --bad: #ff453a; --bad-soft: rgba(255,69,58,.16); --info: #22b37d;
    --shadow: 0 1px 0 rgba(255,255,255,.04) inset; --shadow-lg: 0 24px 64px rgba(0,0,0,.6); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; } h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
p { margin: 0; } a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--text-2); } .small { font-size: 13px; } .tiny { font-size: 12px; color: var(--text-3); }
.row { display: flex; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: scale(.98); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); } .btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); } .btn.danger:hover { background: var(--bad-soft); }
.btn.ok { color: var(--ok); border-color: var(--ok-soft); } .btn.ok:hover { background: var(--ok-soft); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 12px; font-size: 13px; } .btn.wide { width: 100%; } .btn.icon { padding: 8px; border-radius: 10px; }
.link { background: none; border: 0; color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; padding: 0; } .link:hover { color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field > span { font-weight: 500; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 42px; height: 26px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + i { background: var(--ok); } .switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 4px var(--accent-soft); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.check b { font-weight: 500; display: block; font-size: 14px; } .check span { font-size: 12px; color: var(--text-2); }
.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segment button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.segment button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.form-error { color: var(--bad); font-size: 13px; min-height: 1.2em; }
.hint { color: var(--text-2); font-size: 13px; }

/* layout */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 36px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 24px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; } .login-brand .logo { width: 44px; height: 44px; margin-bottom: 8px; } .login-brand p { color: var(--text-2); }
#login-form { display: flex; flex-direction: column; gap: 14px; }
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; gap: 18px; border-right: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; padding: 4px 10px; } .brand .logo { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; font-size: 14px; position: relative; }
.nav a svg { width: 19px; height: 19px; } .nav a:hover { background: var(--surface); color: var(--text); } .nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.badge { margin-left: auto; background: var(--bad); color: #fff; font-style: normal; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 10px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.pill.ok i { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); } .pill.warn i { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); } .pill.bad i { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.main { min-width: 0; padding: 0 32px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 26px 0 18px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 18px; font-size: 14px; background: var(--warn-soft); color: var(--text); border: 1px solid transparent; }
.banner.bad { background: var(--bad-soft); } .banner .btn { margin-left: auto; }
.view { display: flex; flex-direction: column; gap: 20px; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .card-title h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; } .grid.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } .grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } .grid.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.tile .label { font-size: 13px; color: var(--text-2); font-weight: 500; } .tile .value { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; } .tile .sub { font-size: 12px; color: var(--text-3); }
.tile.accent .value { color: var(--accent); } .tile.bad .value { color: var(--bad); } .tile.warn .value { color: var(--warn); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; } .kv dt { color: var(--text-2); } .kv dd { margin: 0; min-width: 0; word-break: break-word; }
.list { display: flex; flex-direction: column; } .list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 4px; cursor: pointer; border-radius: 8px; transition: background .12s; } .item:hover { background: var(--surface-2); }
.item .title { font-weight: 500; font-size: 14px; } .item .meta { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.succeeded, .status.connected, .status.active, .status.applied, .status.approved, .status.delivered { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status.failed, .status.cancelled, .status.disconnected, .status.revoked, .status.denied, .status.error, .status.expired { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.status.running, .status.awaiting_approval, .status.waiting_for_limit, .status.pending, .status.limited, .status.not_configured { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.status.running::before { animation: pulse 1s infinite; } @keyframes pulse { 50% { opacity: .3; } }
.status.queued { color: var(--info); background: var(--accent-soft); border-color: transparent; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-2); font-size: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty b { color: var(--text); font-weight: 600; font-size: 15px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .toolbar input, .toolbar select { width: auto; min-width: 160px; padding: 8px 12px; font-size: 14px; }
.search { position: relative; } .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); } .search input { padding-left: 32px; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); } .meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.result { font-size: 14.5px; line-height: 1.55; } .result p { margin: 0 0 10px; } .result ul, .result ol { margin: 0 0 10px; padding-left: 22px; } .result h1, .result h2, .result h3 { margin: 14px 0 8px; font-size: 16px; } .result pre { margin: 0 0 10px; }
.timeline { display: flex; flex-direction: column; gap: 0; } .tl { display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding: 8px 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: var(--line); } .tl:first-child::before { top: 14px; } .tl:last-child::before { bottom: auto; height: 14px; }
.tl i { width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); margin: 6px 0 0 4px; z-index: 1; } .tl.ok i { background: var(--ok); } .tl.bad i { background: var(--bad); } .tl.tool i { background: var(--accent); } .tl.warn i { background: var(--warn); }
.tl .what { font-size: 13.5px; } .tl .when { font-size: 12px; color: var(--text-3); } .tl pre { margin-top: 6px; max-height: 220px; font-size: 12px; }
.live { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.55; min-height: 40px; }
.live.streaming::after { content: "▍"; color: var(--accent); animation: pulse 1s infinite; }
.keybox { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.keybox .btn { margin-left: auto; }
.pcard .tools { display: flex; gap: 6px; flex-wrap: wrap; } .chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.pcard .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; } .table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; } .table tr:last-child td { border-bottom: 0; } .table tr.click { cursor: pointer; } .table tr.click:hover td { background: var(--surface-2); }

/* drawer, modal, toasts */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(620px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 40; display: flex; flex-direction: column; animation: slide .25s ease; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); } .drawer-body { padding: 18px 24px 32px; overflow: auto; display: flex; flex-direction: column; gap: 18px; } .drawer-body > *, .modal-card > * { flex: none; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 26px; display: flex; flex-direction: column; gap: 18px; animation: pop .22s cubic-bezier(.2,.8,.2,1); }
.modal-card.wide { max-width: 720px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .2s ease; pointer-events: auto; } .toast.bad { background: var(--bad); color: #fff; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; } @keyframes shimmer { to { background-position: -200% 0; } }
.hr { height: 1px; background: var(--line); margin: 4px 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 0; border-top: 1px solid var(--line); } .setting-row:first-of-type { border-top: 0; }
.setting-row .desc { font-size: 13px; color: var(--text-2); } .setting-row .ctl { flex: none; width: 240px; } .setting-row .ctl input, .setting-row .ctl select { padding: 8px 12px; font-size: 14px; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 10px; } .steps > div { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 14px; }
.steps > div::before { counter-increment: s; content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12px; display: grid; place-items: center; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; align-items: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: var(--surface); z-index: 30; gap: 0; }
  .brand, .sidebar-foot { display: none; } .nav { flex-direction: row; width: 100%; justify-content: space-around; } .nav a { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 8px; } .nav a span { display: none; } .badge { position: absolute; top: 2px; right: 6px; margin: 0; }
  .main { padding: 0 16px 90px; } .topbar { padding: 18px 0 14px; } .topbar h2 { font-size: 20px; } #new-task span { display: none; }
  .kv { grid-template-columns: 110px 1fr; } .setting-row { flex-direction: column; align-items: stretch; } .setting-row .ctl { width: 100%; }
}
