* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --ok: #3fb950;
  --err: #f85149;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

h1 { font-size: 1.3rem; }
h2 { font-size: 1rem; margin-bottom: 10px; }

main { padding: 20px; max-width: 1100px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}
.badge.on { background: #238636; color: #fff; }
.badge.off { background: var(--err); color: #fff; }

.hidden { display: none; }
.error { color: var(--err); margin-top: 8px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 10px; }
code { background: var(--border); padding: 1px 6px; border-radius: 4px; font-size: 0.85em; }

form { display: flex; flex-direction: column; gap: 8px; }
input, select, button {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
button {
  background: #238636;
  border-color: #2ea043;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: #2ea043; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); padding: 4px 10px; font-size: 0.8rem; }
button.danger:hover { background: var(--err); color: #fff; }

.device-list { list-style: none; }
.device-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.device-list li:last-child { border-bottom: none; }
.device-list .info { flex: 1; min-width: 0; }
.device-list .name { font-weight: 600; }
.device-list .meta { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.event-list {
  list-style: none;
  max-height: 420px;
  overflow-y: auto;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
}
.event-list li { padding: 4px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.event-list li b { color: var(--text); }

.project-list { list-style: none; }
.project-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.project-list li:last-child { border-bottom: none; }
.project-list .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.project-list .name { font-weight: 600; }
.project-list .meta { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list .clone-url { font-size: 0.74rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list .actions { display: flex; flex-direction: column; gap: 6px; }
.project-list .actions button { font-size: 0.75rem; padding: 4px 8px; }

.card.wide { grid-column: 1 / -1; }
.subform { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; }
.check input { width: auto; }
textarea {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.task-list { list-style: none; margin-top: 10px; }
.task-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.task-list li:last-child { border-bottom: none; }
.task-list .info { flex: 1; min-width: 200px; }
.task-list .name { font-weight: 600; font-size: 0.92rem; }
.task-list .meta { color: var(--muted); font-size: 0.78rem; }
.task-list .actions { display: flex; gap: 6px; }
.task-list .actions button { font-size: 0.74rem; padding: 3px 8px; }
.badge.live { background: #bb8009; color: #fff; }
.badge.err { background: #a40e26; color: #fff; }
.task-log {
  flex-basis: 100%;
  margin: 6px 0 0;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  background: #010409;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  color: var(--muted);
}

/* ---------------- PWA / mobile ---------------- */

button.ghost {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
}
button.ghost:hover { background: var(--accent); color: #0d1117; }

.banner {
  background: #bb8009;
  color: #010409;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------------- card Acesso MCP ---------------- */

.mcp-block { margin-bottom: 12px; }
.mcp-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.mcp-label button.ghost { padding: 3px 10px; }
.mcp-code {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
.hint.warn { color: #d29922; }

.client-list { list-style: none; }
.client-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.client-list li:last-child { border-bottom: none; }
.client-list .name { font-weight: 600; font-size: 0.9rem; }
.client-list .meta { color: var(--muted); font-size: 0.78rem; }
.client-list .methods { color: var(--muted); font-size: 0.72rem; font-family: "Cascadia Code", Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes pulse { 50% { opacity: 0.55; } }
.task-list li.running { animation: pulse 1.6s ease-in-out infinite; }

@media (max-width: 720px) {
  header { padding-left: 16px; padding-right: 16px; }
  header h1 { font-size: 1.1rem; }
  main { padding: 12px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  /* no celular a tela de comando vem antes de tudo */
  #card-tasks { order: 1; }
  #card-devices { order: 2; }
  #card-projects { order: 3; }
  #card-pair { order: 4; }
  #card-events { order: 5; }
  #card-mcp-clients { order: 6; }
  #card-mcp { order: 7; }
  /* 16px evita o zoom automático do iOS ao focar um campo */
  form input, form select, form textarea, form button { font-size: 1rem; min-height: 44px; }
  .event-list { max-height: 240px; }
  .task-log { max-height: 200px; }
}
