:root {
  --bg: #0f1216;
  --panel: #181d23;
  --panel-2: #1f262e;
  --border: #2a323c;
  --text: #e6e9ee;
  --muted: #8b97a5;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --fail: #ff5d5d;
  --warn: #f5b342;
}

* { box-sizing: border-box; }
html { overflow-y: scroll; scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: relative;
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; }
.topbar nav {
  display: flex; gap: 16px;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.topbar .logout { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar .who { color: var(--muted); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; color: var(--muted); margin: 22px 0 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }

button, .btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
/* Botón azul (anchors tipo acción, e.g. "ver" en la tabla de ejecuciones). */
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.1); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* Paginación */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-per { display: flex; align-items: center; gap: 8px; }
.pager-per .per-opt { padding: 2px 8px; border-radius: 6px; }
.pager-per .per-opt.active { background: var(--accent); color: #fff; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.form label, .form-inline label { display: block; margin-bottom: 14px; }
.form input, .form select, .form-inline select, .form-inline input[type=number] {
  display: block; width: 100%; margin-top: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.form .row { display: flex; gap: 16px; }
.form .row label { flex: 1; }
.form-inline { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.form-inline label { margin-bottom: 0; }
.form-inline .check { display: flex; align-items: center; gap: 6px; }
.form-inline .check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 18px; padding: 14px 16px; }
legend { color: var(--accent); font-weight: 600; padding: 0 6px; }

.login-card { max-width: 360px; margin: 8vh auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.login-card h1 { margin-bottom: 16px; }
.login-card label { display: block; margin-bottom: 14px; }
.login-card input { display: block; width: 100%; margin-top: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; }
.login-card button { width: 100%; margin-top: 6px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--border); }
table.grid th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
table.grid tr:last-child td { border-bottom: none; }

.badge { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-running { background: rgba(245,179,66,.15); color: var(--warn); }
.badge-success { background: rgba(46,204,113,.15); color: var(--ok); }
.badge-failed { background: rgba(255,93,93,.15); color: var(--fail); }
.badge-cancelled { background: rgba(139,151,165,.18); color: var(--muted); }
.badge-interrupted { background: rgba(139,151,165,.18); color: var(--muted); }

.page-head .actions { display: flex; align-items: center; gap: 10px; }
button.danger { background: var(--fail); border-color: var(--fail); color: #fff; font-weight: 600; }
button.danger:hover { filter: brightness(1.1); }
.row-actions { display: flex; align-items: center; gap: 12px; }
.row-actions form { margin: 0; }
button.link-danger { background: none; border: none; color: var(--fail); padding: 0; cursor: pointer; font-size: 14px; }
button.link-danger:hover { text-decoration: underline; }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.tag-set { background: rgba(46,204,113,.15); color: var(--ok); }
.tag-empty { background: rgba(139,151,165,.15); color: var(--muted); }

dl.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; }
dl.meta div { display: flex; gap: 10px; }
dl.meta dt { color: var(--muted); min-width: 90px; }
dl.meta dd { margin: 0; }

pre.log {
  background: #0b0e12; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; overflow: auto; max-height: 60vh;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

.flashes { list-style: none; padding: 0; margin: 0 0 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--border); }
.flash-success { background: rgba(46,204,113,.12); border-color: rgba(46,204,113,.4); }
.flash-error { background: rgba(255,93,93,.12); border-color: rgba(255,93,93,.4); }
.flash-info { background: var(--panel-2); }

.notice { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 6px; padding: 12px 14px; margin-bottom: 18px; }
[data-field] { display: block; }
[hidden] { display: none !important; }

/* Credenciales: spoiler por comercio + 3 campos en línea */
details.cred { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: var(--panel-2); }
details.cred > summary {
  cursor: pointer; padding: 11px 14px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
details.cred > summary::-webkit-details-marker { display: none; }
details.cred > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.cred[open] > summary::before { transform: rotate(90deg); }
details.cred[open] > summary { border-bottom: 1px solid var(--border); }
.cred-row { display: flex; gap: 16px; padding: 14px; }
.cred-row label { flex: 1; margin-bottom: 0; }
.cred-head { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

/* Tabs (masters por país) */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 16px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
table.grid tr.row-fixed td { background: rgba(79,140,255,.08); }
