:root {
  --bg: #121212;
  --bg-2: #171717;
  --panel: #1c1c1c;
  --panel-2: #232323;
  --border: #2e2e2e;
  --border-2: #3e3e3e;
  --text: #ededed;
  --muted: #a0a0a0;
  --faint: #707070;
  --brand: #3ecf8e;
  --brand-bg: #006239;
  --brand-border: #10b77f;
  --danger: #f2555a;
  --danger-bg: #3a1618;
  --warn: #f5a524;
  --radius: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
h1, h2 { font-weight: 500; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { display: block; color: var(--faint); font-size: 12.5px; font-weight: 400; margin-top: 2px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.rail { width: 52px; flex: none; border-right: 1px solid var(--border); background: var(--bg-2); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; position: sticky; top: 0; height: 100vh; }
.rail-logo { margin-bottom: 10px; display: grid; place-items: center; width: 36px; height: 36px; }
.rail-item { position: relative; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); border-radius: var(--radius); background: none; border: 0; cursor: pointer; }
.rail-item:hover { color: var(--text); background: var(--panel-2); }
.rail-item.active { color: var(--text); background: var(--panel-2); }
.rail-item.disabled { opacity: .4; cursor: default; }
.rail-tip { display: none; position: absolute; left: 44px; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--border); padding: 3px 8px; border-radius: 4px; font-size: 12px; color: var(--text); z-index: 5; }
.rail-item:hover .rail-tip { display: block; }
.rail-bottom { margin-top: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 48px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.crumb { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--border-2); }
.pill { font-size: 10.5px; letter-spacing: .04em; border: 1px solid var(--border-2); color: var(--muted); border-radius: 999px; padding: 0 7px; font-weight: 500; }
.pill.small { font-size: 10px; padding: 0 5px; }
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 40px 24px 80px; }
.page.narrow { max-width: 760px; }
.page-title { font-size: 26px; margin: 24px 0 28px; }

/* toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.spacer { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px; height: 32px; color: var(--faint); width: 100%; max-width: 300px; }
.search input, .search input[type=search] { background: none; border: 0; outline: 0; color: var(--text); width: 100%; font: inherit; height: 30px; padding: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #505050; }
.btn.primary { background: var(--brand-bg); border-color: var(--brand-border); color: #fff; }
.btn.primary:hover { background: #007a48; }
.btn.danger { background: var(--danger-bg); border-color: #7a2a2d; color: #ffd9da; }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; min-height: 150px; display: flex; flex-direction: column; transition: border-color .15s; }
.card:hover { border-color: var(--border-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-name { font-weight: 500; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 16px; }
.badge { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--border-2); border-radius: 4px; padding: 1px 6px; color: var(--muted); }
.badge.state-ok { color: var(--brand); border-color: #1e5c41; }
.badge.state-err { color: var(--danger); border-color: #6b2a2c; }
.badge.state-busy { color: var(--warn); border-color: #6b4d1a; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.big { width: 12px; height: 12px; }
.dot.ok { background: var(--brand); box-shadow: 0 0 0 3px rgba(62,207,142,.15); }
.dot.err { background: var(--danger); }
.dot.busy { background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.empty { border: 1px dashed var(--border-2); border-radius: 8px; padding: 48px; text-align: center; display: grid; gap: 10px; justify-items: center; }

/* panels & forms */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.panel-head { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.panel-head h1 { font-size: 18px; margin-bottom: 4px; }
.panel-row { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.panel-row:last-child { border-bottom: 0; }
.panel-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; background: var(--bg-2); border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.row-label { font-weight: 500; }
.row-field { min-width: 0; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input:not([type]), input[type=search] { height: 34px; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius); color: var(--text); padding: 0 10px; font: inherit; width: 100%; }
input:focus { outline: 2px solid rgba(62,207,142,.35); border-color: var(--brand-border); }
.segmented { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 12px; color: var(--muted); cursor: pointer; font-size: 13px; }
.segmented input:checked + span { background: var(--panel-2); color: var(--text); }
.features { display: grid; gap: 8px; }
.feature { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2); cursor: pointer; color: var(--text); }
.feature.locked { cursor: default; opacity: .85; }
.feature input { margin-top: 3px; accent-color: var(--brand); }
.feature-name { font-weight: 500; }
.big { font-size: 20px; font-weight: 500; }
.alert { border: 1px solid var(--border-2); background: var(--panel-2); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.alert.err { border-color: #6b2a2c; background: var(--danger-bg); color: #ffd9da; }
.flash { margin: 12px 24px 0; border: 1px solid #6b4d1a; background: #2d2414; color: #ffe2ad; border-radius: var(--radius); padding: 10px 12px; }

/* project */
.project-layout { display: flex; min-height: calc(100vh - 48px); }
.subnav { width: 220px; flex: none; border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; align-self: flex-start; height: calc(100vh - 48px); }
.subnav-title { font-size: 12px; color: var(--faint); padding: 6px 10px 10px; text-transform: uppercase; letter-spacing: .05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subnav a, .subnav .disabled { padding: 6px 10px; border-radius: var(--radius); color: var(--muted); font-size: 13.5px; }
.subnav a:hover, .subnav a.active { background: var(--panel-2); color: var(--text); }
.subnav .disabled { opacity: .5; }
.subnav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.danger-link { color: #ff8f93 !important; }
.project-head h1 { font-size: 30px; margin-bottom: 8px; }
.url-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.url { font-size: 14px; background: none; border: 0; padding: 0; color: var(--text); overflow-wrap: anywhere; }
.cards4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 28px 0 16px; }
.tile { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.tile-icon { width: 44px; height: 44px; flex: none; border: 1px solid var(--border-2); border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: var(--bg-2); }
.tile-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile-value { margin-top: 2px; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions form { display: flex; gap: 8px; }
.working { display: inline-flex; align-items: center; gap: 8px; color: var(--warn); font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid #6b4d1a; border-top-color: var(--warn); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-title { font-size: 17px; margin: 36px 0 12px; }
.section-title.danger { color: #ff8f93; }
.panel.danger { border-color: #5a2426; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); background: var(--bg-2); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.state { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-2); color: var(--muted); }
.state.ok { color: var(--brand); border-color: #1e5c41; }
.state.err { color: var(--danger); border-color: #6b2a2c; }
.state.busy { color: var(--warn); border-color: #6b4d1a; }
.log { background: #0b0b0b; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font: 12px/1.45 var(--mono); color: #cfcfcf; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 12px 0 0; }
.jobs { display: grid; gap: 6px; }
.job { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.job summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; }
.job summary::-webkit-details-marker { display: none; }
.job .log { margin: 0 12px 12px; }
.cred { display: grid; gap: 8px; margin-top: 12px; }

/* login */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 17px; margin-bottom: 36px; }
.auth-box h1 { font-size: 26px; margin-bottom: 4px; }
.auth-box form { margin-top: 24px; }

@media (max-width: 820px) {
  .subnav { display: none; }
  .panel-row { grid-template-columns: 1fr; gap: 10px; }
  .page { padding: 24px 16px 60px; }
  .rail { width: 44px; }
}
