/* Centro de mando · Clínica Hispana América. Paleta: navy #0A192F, oro #C5A059, marfil #F0EEE9 */
@font-face { font-family: "Montserrat"; font-weight: 400; font-display: swap; src: url("fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url("fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url("fonts/montserrat-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-display: swap; src: url("fonts/playfair-display-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 700; font-display: swap; src: url("fonts/playfair-display-latin-700-normal.woff2") format("woff2"); }

:root {
  --navy: #0A192F; --navy-2: #12264a; --navy-3: #1c3561;
  --gold: #C5A059; --gold-2: #d8b878; --ivory: #F0EEE9; --ivory-2: #e4e0d6;
  --ink: #1d2433; --muted: #6b7280; --green: #2f8f5b; --red: #b4443a; --amber: #c27c0e; --grey: #8a8f99;
  --radius: 12px; --shadow: 0 2px 10px rgba(10, 25, 47, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Montserrat", system-ui, sans-serif; font-size: 14px; color: var(--ink); background: var(--ivory); line-height: 1.45; }
h1, h2, h3 { font-family: "Playfair Display", Georgia, serif; color: var(--navy); margin: 0 0 .6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.inline { display: inline; margin: 0; }

/* Marca */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-family: "Playfair Display", serif; font-weight: 700; font-size: .95rem; letter-spacing: .5px; }
.brand-title { font-family: "Playfair Display", serif; font-size: 1.35rem; font-weight: 700; color: var(--ivory); }
.brand-sub { font-size: .75rem; color: var(--gold-2); letter-spacing: .4px; text-transform: uppercase; }

/* Botones */
.btn { font: 600 .85rem "Montserrat", sans-serif; border-radius: 8px; padding: .55em 1.1em; border: 1px solid transparent; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover:not(:disabled) { background: var(--gold-2); }
.btn-ghost { background: transparent; color: var(--ivory); border-color: rgba(197, 160, 89, .55); }
.btn-ghost:hover { background: rgba(197, 160, 89, .15); }
.btn-danger { background: var(--red); color: #fff; }
.btn-link { background: none; color: var(--muted); text-decoration: underline; padding: 0; border: 0; margin-top: 10px; }
.modal .btn-ghost { color: var(--navy); }

/* Acceso / instalación */
body.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, var(--navy-3), var(--navy) 60%); }
.auth-card { background: var(--navy-2); color: var(--ivory); width: min(420px, 92vw); padding: 32px; border-radius: 16px; border: 1px solid rgba(197, 160, 89, .35); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-card.wide { width: min(560px, 94vw); }
.auth-card h1 { color: var(--ivory); font-size: 1.4rem; margin-top: 20px; }
.auth-card form { display: grid; gap: 14px; margin-top: 22px; }
.auth-card label { display: grid; gap: 6px; font-size: .8rem; color: var(--gold-2); text-transform: uppercase; letter-spacing: .4px; }
.auth-card input { font: 1rem "Montserrat", sans-serif; padding: .7em .8em; border-radius: 8px; border: 1px solid #36507d; background: var(--navy); color: var(--ivory); }
.auth-card input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.auth-card .muted { color: #a8b3c7; }
.auth-card code { color: var(--gold-2); }
.alert { margin-top: 18px; background: rgba(180, 68, 58, .18); border: 1px solid var(--red); color: #ffd9d4; padding: 10px 12px; border-radius: 8px; }
.ok { margin-top: 18px; background: rgba(47, 143, 91, .2); border: 1px solid var(--green); padding: 10px 12px; border-radius: 8px; }
.foot { margin-top: 22px; font-size: .75rem; color: #8592aa; }
.qr { background: #fff; width: 220px; height: 220px; margin: 14px auto; padding: 6px; border-radius: 8px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { word-break: break-all; }

/* Panel */
.topbar { background: var(--navy); padding: 14px 28px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border-bottom: 3px solid var(--gold); }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.conn { font-size: .8rem; font-weight: 600; color: #7fd1a3; margin-right: 6px; }
.conn.bad { color: #ff9b8f; }
main#app { padding: 24px 28px 40px; max-width: 1500px; margin: 0 auto; }
.summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; align-items: stretch; }
.stat { background: var(--navy); color: var(--ivory); border-radius: var(--radius); padding: 12px 18px; min-width: 150px; }
.stat-n { font-family: "Playfair Display", serif; font-size: 1.6rem; color: var(--gold); font-weight: 700; }
.stat-l { font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; }
.pc { background: #fff; border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); font-weight: 600; }
.pc .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grey); }
.pc.on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(47, 143, 91, .2); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card { text-align: left; font: inherit; color: inherit; background: #fff; border: 1px solid var(--ivory-2); border-left: 5px solid var(--grey); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(10, 25, 47, .14); }
.card.state-working { border-left-color: var(--gold); }
.card.state-idle { border-left-color: var(--green); }
.card.state-error { border-left-color: var(--red); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-name { font-family: "Playfair Display", serif; font-size: 1.2rem; font-weight: 700; color: var(--navy); display: flex; gap: 8px; align-items: center; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: .82rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last { margin: 0; font-size: .85rem; color: #374151; border-top: 1px dashed var(--ivory-2); padding-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; text-transform: uppercase; letter-spacing: .3px; background: #e5e7eb; color: #374151; white-space: nowrap; }
.pill-working { background: rgba(197, 160, 89, .22); color: #7a5a17; }
.pill-idle { background: rgba(47, 143, 91, .15); color: #1f6b42; }
.pill-error { background: rgba(180, 68, 58, .15); color: var(--red); }
.pill-offline { background: #e5e7eb; color: #6b7280; }
.pill-cmd-done { background: rgba(47, 143, 91, .15); color: #1f6b42; }
.pill-cmd-queued, .pill-cmd-delivered { background: rgba(197, 160, 89, .22); color: #7a5a17; }
.pill-cmd-rejected, .pill-cmd-failed, .pill-cmd-expired { background: rgba(180, 68, 58, .15); color: var(--red); }

.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.panel { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.timeline.small { max-height: 420px; }
.ev { display: grid; grid-template-columns: 74px 96px auto 1fr; gap: 10px; align-items: baseline; padding: 7px 4px; border-bottom: 1px solid #f1efe9; font-size: .84rem; }
.timeline.small .ev { grid-template-columns: 74px 96px 1fr; }
.ev time { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev .tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--navy); background: var(--ivory); border-radius: 6px; padding: 2px 6px; text-align: center; }
.ev .who { font-weight: 600; color: var(--navy-3); white-space: nowrap; }
.ev .txt { overflow-wrap: anywhere; }
.ev-run-start .tag, .ev-tool-start .tag { background: rgba(197, 160, 89, .25); }
.ev-run-error .tag, .ev-tool-error .tag, .ev-run-aborted .tag { background: rgba(180, 68, 58, .15); color: var(--red); }
.ev-message-assistant .tag { background: var(--navy); color: var(--gold); }
.ev-command-result .tag { background: rgba(47, 143, 91, .15); color: #1f6b42; }

table.cmds { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.cmds th { text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--ivory-2); padding: 6px; }
table.cmds td { border-bottom: 1px solid #f1efe9; padding: 7px 6px; vertical-align: top; }

/* Diálogos */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(1100px, 96vw); max-height: 92vh; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); background: var(--ivory); }
.modal::backdrop { background: rgba(10, 25, 47, .6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; background: #fff; border-bottom: 3px solid var(--gold); position: sticky; top: 0; z-index: 1; }
.modal-head h2 { margin: 0; }
.modal-body { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; padding: 20px 24px; }
.modal-body.single { display: block; }
@media (max-width: 900px) { .modal-body { grid-template-columns: 1fr; } }
.facts { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.fact { background: #fff; border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); font-weight: 600; }
.d-left, .d-right { min-width: 0; }
.d-left .timeline { background: #fff; border-radius: var(--radius); padding: 6px 10px; }
.box { background: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.box h3 { margin: 0; }
.box textarea, .box select { font: .9rem "Montserrat", sans-serif; width: 100%; padding: .6em; border-radius: 8px; border: 1px solid var(--ivory-2); background: #fdfcf9; resize: vertical; }
.box textarea:focus, .box select:focus { outline: 2px solid var(--gold); }
.box label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
.box label.check { display: flex; align-items: center; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cmdlist { list-style: none; padding: 0; margin: 0; font-size: .84rem; }
.cmdlist li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px solid #f1efe9; }
.cmdlist time { color: var(--muted); }
.flash { display: none; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.flash.show { display: block; }
.flash.good { background: rgba(47, 143, 91, .15); color: #1f6b42; }
.flash.bad { background: rgba(180, 68, 58, .15); color: var(--red); }
