:root {
  --bg: #0b1724;
  --surface: #112235;
  --surface-2: #17304a;
  --border: #23405f;
  --text: #e6eef7;
  --muted: #8ea4bc;
  --primary: #38bdf8;
  --primary-text: #04263a;
  --accent: #f59e0b;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
}

.brand-product {
  padding-left: 16px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .brand-logo {
    height: 26px;
  }

  .brand-product {
    display: none;
  }
}

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

h1,
h2,
h3 {
  margin: 0 0 12px;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card.narrow {
  max-width: 420px;
  margin: 60px auto;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

label.check {
  flex-direction: row;
  align-items: center;
  color: var(--text);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

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

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn.primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  font: inherit;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.model {
  margin-bottom: 24px;
}

.model > h2 {
  color: var(--accent);
}

.board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.board-head h3 {
  margin: 0;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}

.badge.off {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td.actions {
  white-space: nowrap;
}

td.actions > * {
  margin-right: 6px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.progress progress {
  flex: 1;
  height: 10px;
}

.token-result {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
}

.token-result textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.empty {
  color: var(--muted);
  padding: 20px 0;
}

.markdown {
  padding: 28px 32px;
  line-height: 1.65;
}

.markdown h1 {
  font-size: 1.7rem;
  margin-bottom: 16px;
}

.markdown h2 {
  font-size: 1.3rem;
  margin: 36px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--primary);
}

.markdown h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
}

.markdown h4 {
  margin: 18px 0 6px;
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 14px;
}

.markdown li {
  margin-bottom: 4px;
}

.markdown a {
  color: var(--primary);
}

.markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.markdown blockquote {
  margin: 0 0 16px;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

.markdown blockquote p:last-child {
  margin-bottom: 0;
}

.markdown :not(pre) > code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  word-break: break-word;
}

.markdown .table-wrap {
  margin-bottom: 16px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.markdown details.collapsible {
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.markdown details.collapsible > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.markdown details.collapsible > summary::-webkit-details-marker {
  display: none;
}

.markdown details.collapsible > summary::before {
  content: '▸';
  color: var(--primary);
  font-size: 1.1rem;
  transition: transform 0.15s ease;
}

.markdown details.collapsible[open] > summary::before {
  transform: rotate(90deg);
}

.markdown details.collapsible > summary::after {
  content: 'Mostrar';
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.markdown details.collapsible[open] > summary::after {
  content: 'Ocultar';
}

.markdown details.collapsible > summary h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.markdown details.collapsible[open] > summary {
  border-bottom: 1px solid var(--border);
}

.collapsible-body {
  padding: 4px 22px 8px;
}

.code-block {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  background: var(--bg);
}

.code-block code {
  font-size: 0.82rem;
  line-height: 1.5;
}

.copy-dialog {
  width: min(820px, 92vw);
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.copy-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.copy-dialog textarea {
  width: 100%;
  margin-bottom: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.clipboard-helper {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}
