:root {
  --bg: #0c1324;
  --panel: #121a2e;
  --raised: #182239;
  --line: #24304d;
  --line-soft: #1c2640;
  --text: #dde4f4;
  --muted: #8a94ae;
  --faint: #5f6984;
  --accent: #7b8cff;
  --accent-2: #a07bff;
  --ok: #34d399;
  --warn: #f5b94a;
  --err: #f87171;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 85% -10%, rgba(123, 140, 255, .08), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line-soft);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--raised); color: var(--text); }
.nav svg { width: 16px; height: 16px; flex: none; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--faint); }

.main { min-width: 0; padding: 22px 28px 120px; max-width: 1180px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .grow { flex: 1; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

.hint-drop {
  display: flex; align-items: center; gap: 10px;
  border: 1px dashed var(--line); border-radius: var(--radius-m);
  padding: 10px 14px; margin-bottom: 18px; color: var(--muted); font-size: 13px;
}
.hint-drop svg { color: var(--accent); flex: none; }
.hint-drop .grow { flex: 1; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- surfaces ---------- */
.box { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-m); }
.box + .box, .box + .section, .section + .box { margin-top: 16px; }
.box-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.box-head .grow { flex: 1; }
.box-body { padding: 14px 16px; }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 10px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 16px; border-bottom: 1px solid var(--line-soft); }
td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(123, 140, 255, .04); }
.app-name { font-weight: 600; }
.app-slug { color: var(--faint); font-size: 12px; }
.table-wrap { overflow-x: auto; }

/* ---------- status ---------- */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.procs { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--raised); color: var(--muted); }
.tag.warn { background: rgba(245, 185, 74, .12); color: var(--warn); }
.tag.err { background: rgba(248, 113, 113, .12); color: var(--err); }
.tag.ok { background: rgba(52, 211, 153, .12); color: var(--ok); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--raised);
  cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: #33416a; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #0c1324; font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--bg);
}
.input:focus { border-color: var(--accent); outline: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .input { flex: 1; min-width: 160px; }
.err-text { color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- files ---------- */
.path { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.path a { color: var(--muted); }
.path a:last-child { color: var(--text); }
.fico { width: 16px; height: 16px; vertical-align: -3px; margin-right: 8px; color: var(--faint); }
.fico.dir { color: var(--accent); }

/* ---------- logs ---------- */
.logbox {
  background: #080d1a; border: 1px solid var(--line-soft); border-radius: var(--radius-s);
  padding: 12px; height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55; color: #c3cbe0;
}

/* ---------- empty ---------- */
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { padding: 0 0 20px; }
.auth-card .box-body { padding: 22px; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 10px; }

/* ---------- drop overlay ---------- */
.drop {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(8, 12, 24, .78); backdrop-filter: blur(3px);
  padding: 18px;
}
.drop.on { display: block; }
.drop-zone {
  height: 100%; border-radius: 18px;
  border: 2px dashed rgba(123, 140, 255, .65);
  background: radial-gradient(600px 300px at 50% 45%, rgba(123, 140, 255, .14), transparent 70%);
  display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center;
  color: var(--accent); pointer-events: none;
}
.drop-title { font-size: 22px; font-weight: 700; color: var(--text); }
.drop-target { color: var(--muted); font-size: 14px; }

/* ---------- job dock ---------- */
.dock { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 380px; max-width: calc(100vw - 36px); display: grid; gap: 10px; }
.job { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); overflow: hidden; }
.job-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.job-head .grow { flex: 1; min-width: 0; }
.job-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-bar { height: 3px; background: var(--line-soft); }
.job-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.job-bar.busy i { width: 35%; animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.job-steps { max-height: 220px; overflow: auto; padding: 0 12px 10px; font-size: 12px; display: none; }
.job.open .job-steps { display: block; }
.step { padding: 3px 0; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.step.error { color: var(--err); }
.step.warn { color: var(--warn); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 4px; }
.icon-btn:hover { color: var(--text); background: var(--panel); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(6, 10, 20, .7); display: grid; place-items: center; padding: 20px; }
.modal-wrap[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; }
.modal .box-body { display: grid; gap: 12px; }
.pick { display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.pick button { text-align: left; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.pick button:hover { border-color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 9px 14px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 70;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248, 113, 113, .5); color: var(--err); }

/* ---------- dropdown (mobile actions) ---------- */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-s); min-width: 150px; z-index: 30; padding: 4px; display: none; }
.menu.open .menu-list { display: block; }
.menu-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.menu-list button:hover { background: var(--panel); }
.only-mobile { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub, .side-foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a span { display: none; }
  .main { padding: 16px 14px 140px; }
  th, td { padding: 9px 10px; }
  .hide-mobile { display: none; }
  .only-mobile { display: block; }
  .logbox { height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- v1.1: file manager ---------- */
.selbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(123, 140, 255, .08); border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.selbar[hidden] { display: none; }
.ftable th.ck, .ftable td.ck { width: 36px; padding-right: 0; }
.ftable td.act, .ftable th.act { width: 44px; text-align: right; }
.ftable input[type="checkbox"], .switch input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; vertical-align: middle; }
.ftable tr.picked td { background: rgba(123, 140, 255, .07); }
.ftable td.fname a { color: var(--text); }
.ftable td.fname a:hover { color: var(--accent); text-decoration: none; }
.popmenu { position: fixed; z-index: 80; min-width: 170px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); }
.popmenu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.popmenu button:hover, .popmenu button:focus-visible { background: var(--panel); outline: none; }
.popmenu button.danger { color: var(--err); }
.owlist { max-height: 220px; overflow: auto; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-s); padding: 8px 10px; line-height: 1.7; }
.warn-text { color: var(--warn); font-size: 13px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.pick button { display: flex; align-items: center; }
.selbar .grow { flex: 1; white-space: nowrap; }
