:root {
  --bg: #0e1014; --surface: #161920; --surface2: #1d212a; --border: #262b35;
  --text: #e6e8eb; --muted: #8b93a1; --accent: #4f8cff; --accent2: #3b6fd1;
  --ok: #3ecf8e; --warn: #f5a524; --err: #f06363; --idle: #5b6270;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
a { color: var(--accent); }

.page { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 32px); }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-bottom: 8px; }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; font-size: 18px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--err); flex: none; }
.conn.on { background: var(--ok); }

.btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { background: transparent; border-color: #5a2a2a; color: var(--err); }
.btn.big { padding: 14px 20px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }

.empty { text-align: center; padding: 18vh 16px 0; color: var(--muted); }
.empty .glyph { font-size: 44px; opacity: .6; }
.empty p { margin: 10px 0 24px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.project-card { display: block; text-decoration: none; color: inherit; }
.project-card .name { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: var(--surface2); border-radius: 999px; padding: 3px 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: #22324f; color: #9cc0ff; }
.tag.prod { background: #3d2730; color: #ffb3c0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; }

.host { display: flex; align-items: center; gap: 12px; }
.host .info { flex: 1; min-width: 0; }
.host .info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-big { font-family: var(--mono); font-size: 22px; letter-spacing: .12em; color: var(--warn); }

.menu { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.menu-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 8px; text-align: center; }
.menu-item .ico { font-size: 24px; display: block; margin-bottom: 4px; }
.menu-item .lbl { font-weight: 600; }
.menu-item .sub { font-size: 12px; color: var(--muted); }
.menu-item:disabled { opacity: .4; }
.cmd-list { display: flex; flex-direction: column; gap: 8px; }
.cmd { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.cmd .lbl { flex: 1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.warn { background: var(--warn); } .bar > i.err { background: var(--err); }
.list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

pre.log { background: #0b0d10; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  min-height: 50vh; max-height: calc(100vh - 220px); overflow: auto; }
.status { font-weight: 600; }
.status.ok { color: var(--ok); } .status.err { color: var(--err); } .status.run { color: var(--warn); }

/* modali */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
@media (min-width: 600px) { .overlay { align-items: center; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 0 0; width: 100%; max-width: 520px;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 90vh; overflow: auto; }
@media (min-width: 600px) { .modal { border-radius: 16px; } }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 6px 0 14px; color: var(--muted); }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions .btn { flex: 1; }
.field { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: var(--text); }
.field:focus { outline: 2px solid var(--accent); border-color: transparent; }
.otp { font-family: var(--mono); font-size: 28px; letter-spacing: .4em; text-align: center; }
.err-msg { color: var(--err); font-size: 14px; min-height: 20px; margin-top: 8px; }
.cmdbox { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; user-select: all; }
.steps { margin: 6px 0 0; padding-left: 20px; font-family: var(--mono); font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); z-index: 60; }
#toast div { background: #2a1d1d; border: 1px solid #5a2a2a; color: #ffd0d0; padding: 10px 14px; border-radius: 10px; margin-top: 8px; max-width: 90vw; }
#toast div.info { background: #1d2a22; border-color: #2a5a3c; color: #c8f5da; }

/* login */
.login { max-width: 360px; margin: 0 auto; padding: 22vh 20px 0; text-align: center; }
.login h1 { margin: 0 0 6px; }

/* terminale */
.term-page { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0b0d10; }
.term-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: var(--surface); border-bottom: 1px solid var(--border); }
.term-top .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.term-wrap { flex: 1; min-height: 0; padding: 4px 4px 0 6px; position: relative; }
.term-wrap .xterm { height: 100%; }
.keybar { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: var(--surface); border-top: 1px solid var(--border); }
.keybar button { flex: none; min-width: 44px; height: 36px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 14px; }
.keybar button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.term-closed { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11,13,16,.85); }
.term-closed > div { text-align: center; }
