/* CronPanel — panel de instrumentos.
   Los datos (horas, expresiones, códigos, duraciones) van en monoespaciada con
   cifras tabulares: la lista se lee como una tira de telemetría, alineada en
   columnas verticales. El texto de interfaz va en sans, más pequeño y en gris. */

:root {
    --ink:      #14181f;
    --ink-2:    #5a6472;
    --ink-3:    #8b95a3;
    --line:     #dfe3ea;
    --line-2:   #eef0f4;
    --bg:       #eceff4;
    --panel:    #ffffff;
    --accent:   #3a35c9;
    --accent-2: #ecebfb;
    --ok:       #0b7a57;
    --ok-bg:    #e4f4ee;
    --fail:     #c0304a;
    --fail-bg:  #fbe9ec;
    --warn:     #b4690e;
    --warn-bg:  #fbf0df;
    --paused:   #8a8f98;

    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --r: 6px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------------------------------------------------------------- cabecera */

.topbar {
    background: var(--ink);
    color: #fff;
    padding: 0 20px;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 52px;
    flex-wrap: wrap;
}

.brand {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
}
.brand:hover { text-decoration: none; opacity: 0.8; }

.topnav { display: flex; gap: 18px; margin-right: auto; }

.topnav a {
    color: #aeb7c4;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.topnav a:hover { color: #fff; text-decoration: none; }
.topnav a.is-current { color: #fff; border-bottom-color: var(--accent); }

.account-switch { display: flex; align-items: center; gap: 8px; }

.account-switch select {
    background: #232833;
    color: #fff;
    border: 1px solid #333a48;
    border-radius: var(--r);
    padding: 5px 8px;
    font-family: var(--mono);
    font-size: 12px;
    max-width: 220px;
}

.whoami { color: #8d97a5; font-size: 12px; font-family: var(--mono); }

.linkbtn {
    background: none;
    border: 0;
    color: #8d97a5;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.linkbtn:hover { color: #fff; }

/* ---------------------------------------------------------------- estructura */

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

.pagehead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.pagehead h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.pagehead p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }

.eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0 0 2px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.panel + .panel { margin-top: 20px; }

.panel-head {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.panel-body { padding: 16px; }

/* ---------------------------------------------------------------- resumen */

.tallies {
    display: flex;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    overflow: hidden;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tally {
    padding: 12px 20px;
    border-right: 1px solid var(--line);
    flex: 1 1 120px;
    color: inherit;
}
.tally:last-child { border-right: 0; }
.tally:hover { background: var(--line-2); text-decoration: none; }
.tally.is-current { background: var(--accent-2); }

.tally-n {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: var(--ink);
}
.tally.t-fail .tally-n { color: var(--fail); }
.tally.t-paused .tally-n { color: var(--paused); }

.tally-l {
    font-size: 11px;
    font-family: var(--mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-top: 2px;
}

/* ---------------------------------------------------------------- tablas */

.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 500;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }

.table .num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
    white-space: nowrap;
}

.job-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.job-name:hover { color: var(--accent); text-decoration: none; }

.job-url {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink-3);
    margin-top: 2px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }

/* ------------------------------------------------- tira de salud (24 últimas) */

.strip { display: flex; gap: 2px; align-items: flex-end; }

.strip i {
    width: 5px;
    height: 16px;
    border-radius: 1px;
    background: var(--line);
    display: block;
}
.strip i.s-ok   { background: var(--ok); }
.strip i.s-fail { background: var(--fail); }
.strip i.s-void { background: var(--line); height: 4px; }

.strip-empty { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }

/* ---------------------------------------------------------------- estados */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.p-ok      { color: var(--ok);     background: var(--ok-bg); }
.p-fail    { color: var(--fail);   background: var(--fail-bg); }
.p-running { color: var(--warn);   background: var(--warn-bg); }
.p-paused  { color: var(--paused); background: var(--line-2); }
.p-idle    { color: var(--ink-3);  background: var(--line-2); }

.p-running::before { animation: blink 1.2s ease-in-out infinite; }

@keyframes blink { 50% { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
    .p-running::before { animation: none; }
}

.code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--line-2);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--ink);
}

/* ---------------------------------------------------------------- botones */

.btn {
    display: inline-block;
    font: inherit;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--line-2); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 500;
}
.btn-primary:hover { background: #2f2ba8; border-color: #2f2ba8; }

.btn-danger { color: var(--fail); border-color: #f0c9d1; }
.btn-danger:hover { background: var(--fail-bg); }

.btn-sm { font-size: 12px; padding: 4px 9px; }

.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.actions form { display: inline; }

/* ---------------------------------------------------------------- formularios */

.form { max-width: 720px; }

.field { margin-bottom: 18px; }

.field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}

.field .hint { font-size: 12px; color: var(--ink-2); margin: 0 0 6px; }

.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    font-family: var(--sans);
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    color: var(--ink);
}

.field input.mono,
.field textarea.mono { font-family: var(--mono); font-size: 13px; }

.field textarea { min-height: 90px; resize: vertical; }

.field .error {
    color: var(--fail);
    font-size: 12.5px;
    margin-top: 5px;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--fail); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }

.check { display: flex; align-items: flex-start; gap: 9px; }
.check input { margin-top: 3px; }
.check label { font-weight: 500; }

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
    margin: 0 0 20px;
}

legend {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3);
    padding: 0 6px;
}

/* ------------------------------------------- vista previa de la programación */

.preview {
    background: var(--line-2);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 11px 13px;
    margin-top: 8px;
}

.preview-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.preview ol {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: var(--mono);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
}

.preview li { padding: 1px 0; }
.preview.is-error { background: var(--fail-bg); border-color: #f0c9d1; }
.preview.is-error .preview-title { color: var(--fail); }

.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.preset {
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    cursor: pointer;
    color: var(--ink-2);
}
.preset:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- avisos */

.flash {
    border-radius: var(--r);
    padding: 11px 14px;
    margin-bottom: 18px;
    font-size: 13.5px;
    border: 1px solid;
}
.flash-ok    { background: var(--ok-bg);   border-color: #bfe3d4; color: #085c42; }
.flash-error { background: var(--fail-bg); border-color: #f0c9d1; color: #96223a; }

.empty { padding: 44px 20px; text-align: center; }
.empty h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.empty p { margin: 0 0 16px; color: var(--ink-2); font-size: 13px; }

/* ---------------------------------------------------------------- login */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--ink);
}

.login-card {
    background: var(--panel);
    border-radius: 10px;
    padding: 30px;
    width: 100%;
    max-width: 370px;
}

.login-card .brand { color: var(--ink); display: block; margin-bottom: 4px; }
.login-card h1 { font-size: 17px; margin: 0 0 22px; font-weight: 600; }
.login-card .btn { width: 100%; }

/* ---------------------------------------------------------------- historial */

.run-error {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--fail);
    margin-top: 3px;
    max-width: 460px;
    word-break: break-word;
}

details.snippet summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--ink-2);
    font-family: var(--mono);
}

details.snippet pre {
    background: var(--ink);
    color: #dfe4ec;
    padding: 11px;
    border-radius: var(--r);
    font-size: 11.5px;
    overflow-x: auto;
    margin: 7px 0 0;
    max-height: 260px;
}

.pager { display: flex; gap: 8px; justify-content: center; padding: 14px; }

/* ---------------------------------------------------------------- móvil */

@media (max-width: 860px) {
    .hide-sm { display: none; }
    .wrap { padding: 16px 12px 48px; }
    .table th, .table td { padding: 10px 12px; }
    .job-url { max-width: 200px; }
    .actions { justify-content: flex-start; }
}
