/* ===================== Panel de administración ===================== */

body.admin {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 0% -10%, rgba(43, 143, 230, 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(43, 230, 168, 0.07), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%);
  background-attachment: fixed;
}

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

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 380px; padding: 28px 26px 24px; }
.login-card .brand-lockup { margin-bottom: 24px; }
.login-card h1 { font-size: 19px; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-error {
  display: none; margin-bottom: 14px; padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff9d9d; font-size: 13px;
}
.login-error.show { display: block; }
.login-hint { text-align: center; margin-top: 16px; font-size: 11.5px; color: var(--muted-2); }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } }

.side {
  border-right: 1px solid var(--line);
  background: rgba(8, 13, 24, 0.6);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
@media (max-width: 900px) {
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); gap: 16px; }
}

.side .brand-lockup { padding: 0 6px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 900px) { .side-nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; } }

.side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-align: left; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.side-nav button svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-nav button:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.side-nav button.active {
  color: var(--text); background: rgba(47, 143, 230, 0.12);
  border-color: rgba(47, 143, 230, 0.3);
}
.side-nav button.active svg { color: var(--teal); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 900px) { .side-foot { margin-top: 0; } }
.side-rate {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.side-rate .lbl { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 5px; }
.side-rate .val { font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--teal); }
.side-rate .src { font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }

/* ---------- main ---------- */

.main { padding: 26px 28px 60px; min-width: 0; }
@media (max-width: 600px) { .main { padding: 20px 16px 48px; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head h1 { font-size: 22px; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

.view { display: none; }
.view.active { display: block; animation: viewIn 0.25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- métricas ---------- */

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .metrics { grid-template-columns: 1fr; } }

.metric {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px;
  background: linear-gradient(180deg, rgba(19, 30, 54, 0.6), rgba(10, 17, 32, 0.6));
}
.metric .k { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 9px; }
.metric .k .dot { width: 7px; height: 7px; border-radius: 50%; }
.metric .v { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.metric .s { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.search {
  position: relative; flex: 1; min-width: 200px;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.search input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px 11px 36px; border-radius: var(--r-sm); outline: none; font-size: 13.5px;
}
.search input:focus { border-color: var(--blue); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02); color: var(--muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: all 0.15s ease;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { color: #04101f; background: linear-gradient(90deg, var(--teal), var(--blue)); border-color: transparent; }

/* ---------- tabla ---------- */

.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: rgba(10, 17, 32, 0.5); }
.table-scroll { overflow-x: auto; }

table.ops { width: 100%; border-collapse: collapse; min-width: 780px; }
table.ops th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-2); padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015); white-space: nowrap;
}
table.ops td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
table.ops tbody tr { transition: background 0.12s ease; cursor: pointer; }
table.ops tbody tr:hover { background: rgba(47, 143, 230, 0.06); }
table.ops tbody tr:last-child td { border-bottom: 0; }
table.ops .cod { font-family: var(--display); font-weight: 700; color: var(--teal); }
table.ops .cli { font-weight: 600; }
table.ops .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
table.ops .num { font-family: var(--display); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
table.ops .acts { display: flex; gap: 6px; justify-content: flex-end; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.15s ease;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { color: var(--teal); border-color: rgba(43, 230, 168, 0.4); background: rgba(43, 230, 168, 0.08); }
.icon-btn.danger:hover { color: #ff9d9d; border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.1); }

.empty { padding: 54px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 12px; }
.empty h3 { font-size: 15px; margin: 0 0 6px; color: var(--text); }
.empty p { margin: 0 auto 18px; font-size: 13px; max-width: 320px; }

/* ---------- editor ---------- */

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
@media (max-width: 1080px) { .editor-grid { grid-template-columns: 1fr; } }

.panel { padding: 20px; }
.panel + .panel { margin-top: 18px; }
.panel h2 {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  margin: 0 0 16px; display: flex; align-items: center; gap: 8px; color: var(--muted);
}
.panel h2 svg { width: 15px; height: 15px; color: var(--teal); }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 520px) { .form-actions .btn { flex: 1; } }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 10px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02); color: var(--muted);
  font-size: 12.5px; font-weight: 700; cursor: pointer; transition: all 0.15s ease;
}
.seg button.active { color: #04101f; background: linear-gradient(90deg, var(--blue-deep), var(--blue)); border-color: transparent; }

/* ---------- panel del QR ---------- */

.qr-panel { position: sticky; top: 24px; padding: 20px; }
@media (max-width: 1080px) { .qr-panel { position: static; } }

.qr-canvas-wrap {
  display: flex; justify-content: center; margin-bottom: 16px;
  border-radius: var(--r-xl); overflow: hidden;
}
#qrCanvas { width: 100%; max-width: 360px; height: auto; display: block; border-radius: 22px; }

.qr-empty {
  border: 1px dashed var(--line-strong); border-radius: var(--r-xl);
  padding: 48px 22px; text-align: center; color: var(--muted-2); font-size: 13px; line-height: 1.6;
}
.qr-empty svg { width: 30px; height: 30px; margin-bottom: 12px; opacity: 0.6; }

.link-box {
  margin-top: 14px; padding: 11px 12px; border-radius: var(--r-sm);
  background: var(--input-bg); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); word-break: break-all; line-height: 1.5;
}
.link-box strong {
  display: block; margin-bottom: 5px; font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--teal);
}

.qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.qr-actions .btn { width: 100%; }
.qr-actions .full { grid-column: 1 / -1; }

/* ---------- timeline ---------- */

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 5px; top: 16px; bottom: 0; width: 1px; background: var(--line);
}
.tl-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; background: var(--blue); box-shadow: 0 0 0 3px rgba(47, 143, 230, 0.15); }
.tl-body { min-width: 0; }
.tl-body .t { font-size: 13px; font-weight: 600; }
.tl-body .d { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.tl-body .m { font-size: 11px; color: var(--muted-2); margin-top: 3px; }

/* ---------- ajustes ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

.rate-preview {
  border: 1px solid rgba(43, 230, 168, 0.25); border-radius: var(--r-md);
  background: rgba(43, 230, 168, 0.05); padding: 14px 16px; margin-bottom: 16px;
}
.rate-preview .lbl { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.rate-preview .val { font-family: var(--display); font-weight: 700; font-size: 24px; color: var(--teal); }
.rate-preview .src { font-size: 11px; color: var(--muted-2); margin-top: 4px; }

/* ---------- aviso de cotización sin actualizar ---------- */

.stale-warn {
  display: flex; align-items: flex-start; gap: 9px;
  margin: -6px 0 16px; padding: 11px 13px; border-radius: var(--r-sm);
  background: rgba(255, 182, 72, 0.08); border: 1px solid rgba(255, 182, 72, 0.32);
  color: #ffd79a; font-size: 12.5px; line-height: 1.5;
}
.stale-warn svg { width: 15px; height: 15px; color: var(--warn); flex-shrink: 0; margin-top: 1px; }

/* ---------- cotización heredada ---------- */

.panel-note {
  margin: -6px 0 16px; padding: 11px 13px; border-radius: var(--r-sm);
  background: rgba(47, 143, 230, 0.06); border: 1px solid rgba(47, 143, 230, 0.2);
  color: var(--muted); font-size: 12.5px; line-height: 1.55;
}
.panel-note strong { color: var(--text); font-weight: 600; }

.locked-note {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: rgba(43, 230, 168, 0.05); border: 1px solid rgba(43, 230, 168, 0.24);
}
.locked-note svg { width: 17px; height: 17px; color: var(--teal); flex-shrink: 0; }
.locked-note .locked-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.locked-note strong { font-size: 13px; font-weight: 600; }
.locked-note span { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.locked-note .btn { flex-shrink: 0; }
.locked-note.abierta { background: rgba(255, 182, 72, 0.06); border-color: rgba(255, 182, 72, 0.3); }
.locked-note.abierta svg { color: var(--warn); }
@media (max-width: 520px) { .locked-note { flex-wrap: wrap; } .locked-note .btn { width: 100%; } }

fieldset.cot-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.cot-fields[disabled] { opacity: 0.55; }
fieldset.cot-fields[disabled] .seg button,
fieldset.cot-fields[disabled] input,
fieldset.cot-fields[disabled] select { cursor: not-allowed; }

.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--teal); font-size: 11.5px; font-weight: 600; text-decoration: underline;
}

/* ---------- enlace temporal ---------- */

.temp-link {
  margin-top: 16px; padding: 14px; border-radius: var(--r-md);
  border: 1px dashed var(--line-strong); background: rgba(255, 255, 255, 0.015);
}
.temp-link h3 {
  display: flex; align-items: center; gap: 7px; margin: 0 0 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
}
.temp-link h3 svg { width: 14px; height: 14px; color: var(--blue); }
.temp-link p { margin: 0 0 12px; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }

.temp-row { display: flex; gap: 8px; }
.temp-row select {
  flex: 1; min-width: 0; background: var(--input-bg); border: 1px solid var(--line);
  color: var(--text); font-size: 12.5px; padding: 8px 10px; border-radius: var(--r-sm);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c8aa3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}
.temp-row .btn { flex-shrink: 0; }

.temp-active { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.temp-url {
  font-size: 11px; color: var(--teal); word-break: break-all; line-height: 1.5;
  background: var(--input-bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 10px;
}
.temp-meta { font-size: 11px; color: var(--muted-2); margin-top: 7px; }
.temp-actions { display: flex; gap: 8px; margin-top: 10px; }
.temp-actions .btn { flex: 1; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: viewIn 0.18s ease;
}
.modal { width: 100%; max-width: 400px; padding: 24px; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.modal .form-actions { justify-content: flex-end; }

.hidden { display: none !important; }
