:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2330;
  --texto: #e8e9ec;
  --texto-tenue: #9aa0ac;
  --borde: #2b3040;
  --acento: #5b8cff;
  --acento-texto: #ffffff;
  --error: #ff6b6b;
  --ok: #4cd490;
  --radio: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--acento); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .marca { font-weight: 700; text-decoration: none; color: var(--texto); }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; font-size: 0.95rem; }

.contenido { max-width: 900px; margin: 0 auto; padding: 16px; }

/* --- login --- */
.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 28px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.3rem; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--texto-tenue); }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--borde);
  color: var(--texto);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
}
input.input-error { border-color: var(--error); }

button {
  background: var(--acento);
  color: var(--acento-texto);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; }
.acciones button, .tabla-historial button { padding: 6px 10px; font-size: 0.85rem; }

.error { color: var(--error); margin: 0; }
.ayuda { color: var(--texto-tenue); font-size: 0.85rem; margin: 4px 0 0; }

/* --- lista --- */
.lista-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.lista-toolbar input { flex: 1; min-width: 180px; }

.tabla-snippets, .tabla-historial {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
}
.tabla-snippets th, .tabla-snippets td,
.tabla-historial th, .tabla-historial td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--borde);
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}
.tabla-snippets code { color: var(--acento); }
.tabla-snippets .acciones { display: flex; gap: 6px; flex-wrap: wrap; white-space: nowrap; }
.fila-avanzada { opacity: 0.75; }

.badge {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--texto-tenue);
}
.badge-aviso { color: #e8b04b; border-color: #4a3c1f; }

@media (max-width: 640px) {
  .tabla-snippets thead { display: none; }
  .tabla-snippets tr { display: block; padding: 10px 12px; }
  .tabla-snippets td { display: block; border: none; padding: 3px 0; }
  .tabla-snippets td:first-child { font-size: 1rem; }
}

/* --- constructor --- */
.campo { margin-bottom: 20px; display: flex; flex-direction: column; gap: 6px; }
.campo > label { font-weight: 600; font-size: 0.9rem; color: var(--texto-tenue); }

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.editor-toolbar button { background: var(--panel-2); border: 1px solid var(--borde); color: var(--texto); }

.editor {
  min-height: 160px;
  background: var(--panel-2);
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.editor:focus { outline: 2px solid var(--acento); }

.chip {
  display: inline-block;
  background: rgba(91, 140, 255, 0.18);
  border: 1px solid var(--acento);
  border-radius: 999px;
  padding: 1px 10px;
  margin: 0 2px;
  font-size: 0.9em;
  user-select: none;
}
.chip-cursor { border-color: #e8b04b; background: rgba(232, 176, 75, 0.18); }
.chip-date { border-color: #4cd490; background: rgba(76, 212, 144, 0.18); }

.preview {
  background: var(--panel);
  border: 1px dashed var(--borde);
  border-radius: 8px;
  padding: 12px;
  min-height: 60px;
  white-space: pre-wrap;
  color: var(--texto-tenue);
}

.acciones-guardar { display: flex; align-items: center; gap: 14px; }

dialog {
  background: var(--panel);
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 20px;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; }
.dialog-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.dialog-botones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.dialog-botones button:first-child { background: var(--panel-2); color: var(--texto); }
.opcion-fila { display: flex; gap: 6px; margin-bottom: 6px; }
.opcion-fila button { background: var(--panel-2); color: var(--texto); padding: 6px 10px; }
.ejemplo { margin: 0; color: var(--texto-tenue); font-size: 0.9rem; }
