/* HSW design system v2 — dark premium (#0B0F1A) + dourado + azul, conforme referência do dono */
:root {
  --bg: #0b0f1a;
  --surface: #12182a;
  --surface-2: #161c2b;
  --surface-3: #1e242c;
  --border: rgba(255,255,255,.07);
  --gold: #f2b33d;
  --gold-soft: rgba(242,179,61,.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59,130,246,.14);
  --text: #eef1f7;
  --text-dim: #9aa3b2;
  --text-faint: #6b7280;
  --danger: #ef4444;
  --ok: #22c55e;
  --purple: #a78bfa;
  --teal: #2dd4bf;
  --glass-bg: rgba(11,15,26,.72);
  --glass-blur: blur(16px) saturate(1.3);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 15px; line-height: 1.45; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100dvh; }
#app { display: flex; flex-direction: column; min-height: 100dvh; }
#view { flex: 1; padding: 14px 16px calc(96px + var(--safe-bottom)); overflow-y: auto; }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
}
#topbar-title {
  flex: 1; font-weight: 700; font-size: 17px; letter-spacing: .3px; text-align: center;
}
#topbar button {
  background: none; border: none; color: var(--text);
  font-size: 19px; padding: 6px 10px; border-radius: 12px; min-width: 40px; min-height: 40px;
}
#topbar button:active { background: rgba(255,255,255,.08); }

/* conexão */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(34,197,94,.55); }
.dot.off { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,.4); }
.dot.ws { background: var(--blue); box-shadow: 0 0 8px rgba(59,130,246,.55); }

/* ---------- tabbar inferior (referência: 5 abas, ativa dourada) ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
}
#tabbar .tab {
  flex: 1; background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; padding: 4px 0; border-radius: 14px; min-height: 50px;
  transition: color .15s;
}
#tabbar .tab .ico { font-size: 21px; line-height: 1; filter: grayscale(.3); }
#tabbar .tab.active { color: var(--gold); }
#tabbar .tab.active .ico { filter: none; }
#tabbar .tab:active { background: rgba(255,255,255,.05); }

/* ---------- drawer lateral (referência tela 10: painel com logo e lista vertical) ---------- */
#drawer {
  position: fixed; inset: 0; z-index: 60; display: flex;
  background: rgba(3,6,12,.55); backdrop-filter: blur(4px);
}
.drawer-panel {
  width: min(78vw, 320px); height: 100%; padding: calc(24px + var(--safe-top)) 18px 24px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.drawer-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.drawer-brand .logo {
  width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #f2b33d, #d97706);
  display: grid; place-items: center; font-weight: 800; color: #1a1206; font-size: 19px;
}
.drawer-brand b { display: block; font-size: 16px; }
.drawer-brand span { color: var(--text-dim); font-size: 12px; }
#drawer button.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; color: var(--text);
  font-size: 15px; padding: 13px 12px; border-radius: var(--radius-sm); text-align: left;
}
#drawer button.item:active { background: var(--surface-2); }
#drawer button.item .ic {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-size: 16px; background: var(--surface-3);
}
.drawer-foot { margin-top: auto; color: var(--text-faint); font-size: 11.5px; padding: 12px 8px 0; }

/* ---------- cards & seções (referência: cards empilhados, chevron à direita) ---------- */
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .6px; margin: 20px 2px 10px;
}
.section-title:first-child { margin-top: 4px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px;
}
.card.running { border-left: 3px solid var(--gold); }
.card.awaiting { border-left: 3px solid var(--danger); }
.card-row { display: flex; align-items: center; gap: 10px; }
.card-title { font-weight: 600; font-size: 15px; flex: 1; }
.card-sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.card-meta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.card .chev { color: var(--text-faint); font-size: 18px; }

/* quick actions (referência tela 2: grid de ações rápidas com ícones coloridos) */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 6px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text); font-size: 12px; font-weight: 500; font-family: inherit;
}
.quick .ic {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-size: 20px;
}
.quick:active { background: var(--surface-2); }

/* ícones coloridos (referência: cada ação com cor própria) */
.ic-gold { background: var(--gold-soft); }
.ic-blue { background: var(--blue-soft); }
.ic-green { background: rgba(34,197,94,.14); }
.ic-purple { background: rgba(167,139,250,.14); }
.ic-teal { background: rgba(45,212,191,.14); }
.ic-red { background: rgba(239,68,68,.14); }

/* status */
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.running { background: var(--gold); box-shadow: 0 0 7px rgba(242,179,61,.5); animation: pulse 2s infinite; }
.status-dot.completed { background: var(--ok); }
.status-dot.awaiting, .status-dot.failed { background: var(--danger); }
.status-dot.paused { background: var(--text-faint); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-dim); font-weight: 500; border: none;
}
.chip.status { background: var(--gold-soft); color: var(--gold); }
.chip.on { background: rgba(34,197,94,.14); color: var(--ok); }

/* progress (referência tela 5/6: barra fina colorida com % à direita) */
.progress-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.progress { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--gold)); }
.progress-pct { font-size: 11.5px; color: var(--text-dim); min-width: 34px; text-align: right; }

/* ---------- botões ---------- */
.btn-primary {
  width: 100%; padding: 15px; border: none; border-radius: var(--radius);
  background: linear-gradient(135deg, #f2b33d, #d97706); color: #1a1206;
  font-size: 15.5px; font-weight: 700; letter-spacing: .2px;
}
.btn-primary:disabled { opacity: .55; }
.btn-primary:active { transform: scale(.985); }
.btn-ghost {
  width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 14.5px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; text-align: left; font-family: inherit;
}
.btn-ghost:active { background: var(--surface-2); }
.btn-sm {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600;
}
.btn-sm.accent { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
.btn-sm.blue { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(88px + var(--safe-bottom));
  width: 54px; height: 54px; border-radius: 18px; border: none;
  background: linear-gradient(135deg, #f2b33d, #d97706); color: #1a1206;
  font-size: 26px; font-weight: 700; z-index: 30;
  box-shadow: 0 6px 20px rgba(242,179,61,.35);
}
.fab:active { transform: scale(.94); }

/* ---------- login (referência: logo + CTA dourado único) ---------- */
.login-box { max-width: 420px; margin: 8vh auto 0; padding: 0 8px; display: flex; flex-direction: column; gap: 14px; }
.login-logo {
  width: 76px; height: 76px; border-radius: 24px; margin: 0 auto 4px;
  background: linear-gradient(135deg, #f2b33d, #d97706);
  display: grid; place-items: center; font-weight: 800; color: #1a1206; font-size: 34px;
}
.login-box h1 { text-align: center; font-size: 24px; margin: 6px 0 0; }
.login-box h1 em { color: var(--gold); font-style: normal; }
.login-box p { text-align: center; color: var(--text-dim); margin: 0 0 8px; font-size: 14px; }
.login-box input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 15px 16px; font-size: 16px; outline: none; width: 100%;
}
.login-box input:focus { border-color: rgba(242,179,61,.45); }

/* ---------- chat / Sol (referência tela 3: bolhas azuis do usuário, avatar com Online) ---------- */
.chat-wrap { display: flex; flex-direction: column; min-height: calc(100dvh - 230px); }
.chat-list { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 14px; }
.bubble {
  max-width: 82%; padding: 11px 14px; border-radius: 18px; font-size: 15px;
  position: relative; word-break: break-word; white-space: pre-wrap;
}
.bubble .t { display: block; font-size: 10.5px; opacity: .55; margin-top: 4px; text-align: right; }
.bubble.user {
  align-self: flex-end; background: var(--blue); color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.assistant {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.bubble.pending { opacity: .6; }
.typing {
  align-self: flex-start; display: flex; gap: 4px; padding: 13px 16px;
  background: var(--surface); border-radius: 18px; border: 1px solid var(--border);
}
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* barra de entrada do chat */
.sol-input {
  position: sticky; bottom: calc(92px + var(--safe-bottom));
  display: flex; gap: 8px; padding: 8px;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: 22px; z-index: 5; margin-top: 8px;
}
.sol-input input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-size: 16px; padding: 8px 6px; min-width: 0; font-family: inherit;
}
.sol-input button {
  width: 42px; height: 42px; border-radius: 50%; border: none; flex: none;
  background: var(--surface-3); color: var(--text); font-size: 17px;
  display: grid; place-items: center;
}
.sol-input button.send { background: linear-gradient(135deg, #f2b33d, #d97706); color: #1a1206; }
.sol-input button.send:disabled { opacity: .45; }
.sol-input .mic.rec { background: var(--danger); color: #fff; animation: pulse 1s infinite; }

/* cabeçalho Sol no chat (referência: avatar com ponto Online verde) */
.sol-head-row { display: flex; align-items: center; gap: 12px; padding: 4px 2px 14px; }
.sol-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; overflow: hidden;
  border: 2px solid rgba(242,179,61,.5); position: relative; background: var(--surface-3);
  display: grid; place-items: center; font-size: 22px;
}
.sol-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sol-avatar .online {
  position: absolute; bottom: -1px; right: -1px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--ok); border: 2.5px solid var(--bg);
}
.sol-head-row .who b { display: block; font-size: 16px; }
.sol-head-row .who span { color: var(--ok); font-size: 12px; font-weight: 500; }

/* ---------- streams (browser/desktop) ---------- */
.stream-wrap { display: flex; flex-direction: column; gap: 10px; }
.stream-wrap canvas { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: #000; touch-action: none; display: block; }
.stream-hud { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-pill {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; display: flex; align-items: center; gap: 8px; min-height: 38px;
}
.hud-pill input { background: none; border: none; outline: none; color: var(--text); font-size: 13.5px; min-width: 120px; font-family: inherit; }
.urlbar { flex: 1; }
.control-chip { cursor: pointer; user-select: none; }
.control-chip.owner { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.control-chip.hermes { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.app-row { display: flex; gap: 8px; flex-wrap: wrap; }
.app-tile {
  flex: 1; min-width: 90px; padding: 12px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
}
.app-tile:active { background: var(--surface-2); }

/* ---------- listas / histórico ---------- */
.history-item {
  display: flex; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-dim);
}
.history-item b { color: var(--text); font-weight: 600; white-space: nowrap; font-size: 12.5px; padding-top: 1px; }
.task-line { display: flex; gap: 10px; align-items: center; padding: 10px 4px; font-size: 13.5px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.task-line .st { flex: none; }
.settings-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 4px; border-bottom: 1px solid var(--border); font-size: 14.5px;
}
.settings-row .k { color: var(--text); }
.settings-row .v { color: var(--text-dim); font-size: 13px; }

/* switch */
.switch { position: relative; width: 46px; height: 28px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3);
  transition: background .2s; pointer-events: none; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s;
}
.switch input:checked + .slider { background: var(--gold); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- home hero (referência tela 1: saudação) ---------- */
.hero {
  border-radius: 22px; padding: 20px 18px; margin-bottom: 6px;
  background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(242,179,61,.10));
  border: 1px solid var(--border);
}
.hero h2 { margin: 0 0 4px; font-size: 21px; }
.hero h2 em { color: var(--gold); font-style: normal; }
.hero p { margin: 0; color: var(--text-dim); font-size: 13.5px; }

/* ---------- estados ---------- */
.empty {
  text-align: center; color: var(--text-dim); padding: 42px 20px; font-size: 14px;
}
.empty .big { font-size: 34px; display: block; margin-bottom: 10px; opacity: .5; }
.loading { display: grid; place-items: center; padding: 60px 0; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--gold);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast {
  position: relative; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 12px 16px; border-radius: 14px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); margin-bottom: 8px; animation: slideup .25s;
}
.toast.warn { border-color: rgba(239,68,68,.4); }
@keyframes slideup { from { transform: translateY(8px); opacity: 0; } }

#toasts {
  position: fixed; left: 16px; right: 16px; bottom: calc(100px + var(--safe-bottom));
  z-index: 80; display: flex; flex-direction: column; align-items: stretch;
}

/* banner offline discreto com spinner */
#offline-banner {
  position: fixed; top: calc(58px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: rgba(239,68,68,.16); color: #fda4af; border: 1px solid rgba(239,68,68,.35);
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 500; z-index: 70;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
#offline-banner .mini-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(253,164,175,.35); border-top-color: #fda4af;
  animation: spin .9s linear infinite;
}

/* ---------- painel Sol (overlay tela cheia) ---------- */
#sol-panel {
  position: fixed; inset: 0; z-index: 65; display: flex; flex-direction: column;
  background: var(--bg);
}
#sol-panel .sol-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-top)) 14px 12px; border-bottom: 1px solid var(--border);
}
#sol-panel .sol-head .sol-avatar { width: 42px; height: 42px; }
#sol-panel .sol-name { flex: 1; font-weight: 600; }
#sol-panel .sol-head button { background: none; border: none; color: var(--text-dim); font-size: 17px; padding: 6px 10px; }
#sol-messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
#sol-panel .sol-input { position: sticky; bottom: 0; border-radius: 22px; margin: 0 12px calc(10px + var(--safe-bottom)); }

/* ---------- monitor (bottom sheet) ---------- */
#monitor-overlay { position: fixed; inset: 0; z-index: 62; background: rgba(3,6,12,.6); display: flex; align-items: flex-end; }
.mon-sheet {
  width: 100%; max-height: 78dvh; border-radius: 24px 24px 0 0; overflow: hidden;
  display: flex; flex-direction: column; border-top: 1px solid var(--border);
  background: rgba(14,18,28,.97);
}
.mon-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 10px; }
.mon-head > div { display: flex; gap: 6px; }
.mon-head button { background: none; border: none; color: var(--text-dim); font-size: 17px; padding: 6px 10px; }
#mon-title { font-weight: 700; font-size: 16px; }
#mon-body { overflow-y: auto; padding: 4px 16px calc(20px + var(--safe-bottom)); }
#mon-body img { max-width: 100%; border-radius: 12px; }
#mon-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
#mon-body th, #mon-body td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
#mon-body pre { background: var(--surface); padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; }

.mission-detail { display: flex; flex-direction: column; gap: 4px; }

/* acessibilidade */
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid rgba(242,179,61,.6); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
