:root {
  --bg: #111215;
  --bg2: #17181c;
  --panel: #1d1f24;
  --panel2: #24262c;
  --line: #2e3138;
  --text: #e6e6e9;
  --muted: #8d919b;
  --accent: #e8b04a;
  --accent-ink: #1a1408;
  --green: #3fb672;
  --red: #e05a5a;
  --yellow: #e0b44a;
  --blue: #5a9be0;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 24px; margin: 0; }
h2 { margin: 0 0 6px; }
h3 { font-size: 13px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--red); margin: 8px 0 0; white-space: pre-wrap; }
.error:empty { display: none; }
.spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand.big { font-size: 20px; justify-content: center; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 18px; flex: none; }
.logo.huge { width: 64px; height: 64px; font-size: 40px; border-radius: 16px; margin: 0 auto 16px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { border-color: #464a54; background: #2b2e35; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: #f0bf60; }
.btn.success { background: #1f4b33; border-color: #2c6a48; color: #bff0d3; }
.btn.success:hover:not(:disabled) { background: #26603f; }
.btn.danger { background: #4d2323; border-color: #6e3030; color: #ffd0d0; }
.btn.danger:hover:not(:disabled) { background: #5e2a2a; }
.btn.ghost { background: transparent; }
.btn.danger.ghost { background: transparent; color: #ff8f8f; border-color: #5a2a2a; }
.btn .ic { font-size: 11px; }
.btn.busy { pointer-events: none; opacity: .7; }

input, select, textarea { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; font-weight: 400; }
textarea, input[spellcheck="false"] { font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #e8b04a22; }
input.invalid, select.invalid { border-color: var(--red); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label small, .lbl small { font-weight: 400; color: var(--muted); }
.lbl { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.ferr { color: #ff8f8f; font-weight: 500; font-size: 12.5px; }
.ferr:empty { display: none; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* Switches */
.switches { display: flex; flex-direction: column; gap: 14px; }
.switch { flex-direction: row; align-items: flex-start; gap: 12px; cursor: pointer; font-weight: 400; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .sw { flex: none; width: 38px; height: 22px; border-radius: 99px; background: #3a3d45; position: relative; transition: .15s; margin-top: 1px; }
.switch .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cfd2d8; transition: .15s; }
.switch input:checked + .sw { background: var(--accent); }
.switch input:checked + .sw::after { left: 19px; background: var(--accent-ink); }
.switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch b { display: block; font-weight: 600; }
.switch small { display: block; color: var(--muted); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card p { margin: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 270px 1fr; height: 100%; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; min-height: 0; }
.side-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; padding: 4px 6px 0; }
.instance-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; flex: 1; margin-top: -6px; }
.inst { display: flex; gap: 11px; align-items: center; padding: 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; background: none; color: inherit; font: inherit; text-align: left; width: 100%; }
.inst:hover { background: var(--panel); }
.inst.active { background: var(--panel); border-color: var(--line); }
.inst .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst > div { min-width: 0; flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #555; }
.dot.running { background: var(--green); box-shadow: 0 0 0 3px #3fb67233; }
.dot.stopping, .dot.updating, .dot.starting { background: var(--yellow); animation: pulse 1s infinite; }
.dot.crashed { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
.side-foot { display: flex; gap: 6px; flex-wrap: wrap; }
.whoami { width: 100%; color: var(--muted); font-size: 12px; padding: 0 4px; }
.note { color: #f3d48c; font-size: 13px; }
.note:empty { display: none; }
/* Inside the HustleChess dashboard the host page already shows the branding. */
.embedded .sidebar > .brand { display: none; }
.embedded .main { padding-top: 18px; }
.side-empty { color: var(--muted); padding: 6px; font-size: 13px; }

.main { overflow: auto; padding: 26px 30px 0; min-width: 0; position: relative; }
.main > div { padding-bottom: 40px; }
.empty { max-width: 560px; margin: 10vh auto; text-align: center; }
.empty h2 { font-size: 22px; margin-bottom: 18px; }
.steps-intro { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 18px 40px; margin: 0 0 22px; display: flex; flex-direction: column; gap: 10px; color: #c9ccd3; }

.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.title-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; background: var(--panel2); border: 1px solid var(--line); color: #cfd3da; font-family: var(--mono); cursor: pointer; }
.chip:hover { border-color: #464a54; }
.chip.plain { cursor: default; font-family: inherit; }
.chip.plain:hover { border-color: var(--line); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 99px; font-size: 12.5px; font-weight: 650; background: var(--panel2); color: var(--muted); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.running { background: #1d3b2a; color: #8de2b1; }
.pill.crashed { background: #452222; color: #ff9d9d; }
.pill.stopping, .pill.updating, .pill.starting { background: #45391d; color: #f3d48c; }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: 10px; background: #45391d; color: #f3d48c; margin-bottom: 16px; border: 1px solid #5c4b25; }
.banner span { flex: 1; }
.banner.bad { background: #3a1f1f; color: #ffc0c0; border-color: #5a2a2a; }
.banner .btn:empty { display: none; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: #5a2626; color: #ffb0b0; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.dot-mini { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.panel > p.muted { margin: -6px 0 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.panel-head h3 { margin: 0; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h3 { display: inline; margin: 0; }
details.panel > summary::before { content: "▸ "; color: var(--muted); }
details.panel[open] > summary::before { content: "▾ "; }
details.panel[open] > summary { margin-bottom: 14px; }
.danger-zone { border-color: #3d2a2a; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.two .panel { margin-bottom: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.card .k { color: var(--muted); font-size: 12px; font-weight: 600; }
.card .v { font-size: 18px; font-weight: 650; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; align-items: center; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.kv dd .v { font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.copy:hover { color: var(--text); background: var(--panel2); }
.ok-t { color: #8de2b1; } .bad-t { color: #ff9d9d; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.grid .wide { grid-column: 1 / -1; }

.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin: 0 -30px; background: #1b1c21ee; backdrop-filter: blur(6px); border-top: 1px solid var(--line); z-index: 5; flex-wrap: wrap; }
.savebar-msg { font-weight: 600; color: #f3d48c; }
.savebar-msg::before { content: "● "; }
.config:not(.dirty):not(.is-new) .savebar { display: none; }
.config.is-new .savebar-msg { color: var(--muted); }
.config.is-new .savebar-msg::before { content: ""; }

pre { margin: 0; }
.cmd { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: #cfd3da; }
.log { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; background: #0b0c0e; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; height: calc(100vh - 300px); min-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #c4c8cf; }
.log.mini { height: 200px; min-height: 0; }
.log .w { color: var(--yellow); }
.log .e { color: #ff7b7b; }
.log .p { color: var(--blue); }
.log mark { background: #e8b04a55; color: inherit; border-radius: 2px; }
.log-wrap { position: relative; }
.jump { position: absolute; right: 18px; bottom: 14px; box-shadow: 0 4px 14px #0008; }
.log-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.log-toolbar select { width: auto; max-width: 340px; }
.log-toolbar input[type="search"] { width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bg2); border: 0; color: var(--muted); font: inherit; font-weight: 600; font-size: 12.5px; padding: 0 12px; height: 34px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--panel2); color: var(--text); }
.seg span { background: #ffffff12; border-radius: 99px; padding: 0 6px; font-size: 11px; }
.log-foot { color: var(--muted); font-size: 12px; margin-top: 6px; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px dashed var(--line); border-radius: 12px; padding: 30px 16px; text-align: center; cursor: pointer; color: var(--muted); margin: 0 0 14px; font-weight: 400; }
.drop b { color: var(--text); }
.drop-ic { font-size: 28px; line-height: 1; color: var(--accent); }
.drop:hover, .drop.over { border-color: var(--accent); background: #e8b04a0a; }
.drop.has { border-style: solid; border-color: #4b5b46; background: #3fb67210; }
.drop input { display: none; }
.plan { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.plan ol { margin: 6px 0 0; padding-left: 20px; color: #c9ccd3; }
.opts-box { margin-bottom: 14px; }
.opts-box > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.job-view { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.jsteps { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.jsteps li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }
.jsteps li::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #464a54; box-sizing: border-box; flex: none; }
.jsteps li.active { color: var(--text); }
.jsteps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.jsteps li.done { color: #8de2b1; }
.jsteps li.done::before { content: "✓"; border: 0; background: #1d3b2a; color: #8de2b1; font-size: 11px; display: grid; place-items: center; }
.jsteps li.failed { color: #ff9d9d; }
.jsteps li.failed::before { content: "✕"; border: 0; background: #452222; color: #ff9d9d; font-size: 11px; display: grid; place-items: center; }
.jsteps li.skipped { opacity: .45; text-decoration: line-through; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { position: relative; height: 22px; background: var(--bg2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.progress.failed .bar { background: var(--red); }
.progress.done .bar { background: var(--green); }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; mix-blend-mode: difference; }
.job { margin-top: 10px; font-family: var(--mono); font-size: 12.5px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

.bk { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.bk:first-child { border-top: 0; }
.bk .n { flex: 1; min-width: 180px; }
.bk .n b { display: block; }
.bk .n small { color: var(--muted); }
.tag { font-size: 11px; background: var(--panel2); border-radius: 99px; padding: 1px 8px; color: var(--muted); margin-left: 6px; font-weight: 600; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: #000a; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h3 { text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--text); margin: 0; }
dialog p { margin: 0; color: #c9ccd3; }

.toast { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 20; box-shadow: 0 6px 20px #0009; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.ok { border-color: #2c6a48; }
.toast.bad { border-color: #6e3030; color: #ffc4c4; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100%; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .instance-list { max-height: 210px; }
  .main { padding: 16px 16px 0; overflow: visible; }
  .savebar { margin: 0 -16px; }
  .log { height: 60vh; }
  .log-toolbar input[type="search"], .log-toolbar select { width: 100%; max-width: none; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}
