/* Sistema visual compartido por la app (/) y el panel (/panel).
   Paleta y tipografía tomadas del prototipo "Activacion de Lineas" (Claude Design). */
:root {
  --bg: #E9F1FB;
  --card: #FFFFFF;
  --ink: #10263F;
  --ink2: #2E4E74;
  --muted: #5A7594;
  --muted2: #6A82A0;
  --muted3: #8698B1;
  --line: #D6E3F5;
  --line2: #E7EEF8;
  --line3: #C6D9F0;
  --soft: #F2F7FD;
  --soft2: #EEF4FC;
  --soft3: #F7FAFE;
  --blue: #1668D8;
  --blue-hover: #2F80EA;
  --blue-dark: #0F55B0;
  --navy: #0B2A6B;
  --green: #158A52;
  --green-dark: #0E7A47;
  --red: #C7343A;
  --red-bright: #FF4D4F;
  --amber: #F5A623;
  --font: 'Space Grotesk', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 22px rgba(22, 104, 216, .10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(120% 80% at 50% 0%, #F2F7FD 0%, #E9F1FB 70%);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line3); border-radius: 8px; }

/* ---- tipografía ---- */
.h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 0; }
.h1.big { font-size: 34px; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.h3 { font-size: 16px; font-weight: 600; margin: 0; }
.sub { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted2); font-weight: 600; }
.label-caps { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted2); font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.muted2 { color: var(--muted2); }
.muted3 { color: var(--muted3); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.green { color: var(--green); }
.red { color: var(--red); }
.blue { color: var(--blue); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { word-break: break-all; }

/* ---- layout helpers ---- */
.flex { display: flex; align-items: center; gap: 10px; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
.flex.start { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; } .mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; } .mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; } .mb-14 { margin-bottom: 14px; }
.hidden { display: none !important; }

/* ---- botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 14px; padding: 13px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s, transform .05s; user-select: none;
  background: var(--soft); color: var(--ink2);
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.lg { padding: 17px; border-radius: 16px; font-size: 16px; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.xs { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; font-weight: 700; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 8px 22px rgba(22, 104, 216, .28); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-outline { background: transparent; border-color: var(--line3); color: var(--ink2); }
.btn-outline:hover { border-color: #8FB4DE; color: var(--ink); }
.btn-outline.blue { color: var(--blue); }
.btn-outline.blue:hover { border-color: var(--blue); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: transparent; border-color: #F0C9CB; color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: #FDEDEE; }
.btn-danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn-success { background: var(--green); color: #fff; }
.btn:disabled, .btn.disabled { background: var(--line2); color: var(--muted3); box-shadow: none; cursor: not-allowed; border-color: transparent; }
.link-back { font-size: 14px; color: var(--muted); cursor: pointer; font-weight: 500; background: none; border: none; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.link-back:hover { color: var(--ink); }

/* ---- inputs ---- */
.input, .select, .textarea {
  width: 100%; background: var(--soft); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 15px; color: var(--ink); font-size: 15px; outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); background: #fff; }
.input.mono { font-family: var(--mono); letter-spacing: .06em; }
.input.sm, .select.sm { padding: 10px 12px; font-size: 14px; border-radius: 10px; }
.select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A7594' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .label-caps { font-size: 10.5px; letter-spacing: .08em; }
.field .hint { font-size: 11px; color: var(--muted3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }
.input-file { border: 1px dashed var(--line3); background: var(--soft); border-radius: 14px; padding: 13px; font-size: 12.5px; color: var(--ink2); width: 100%; }

/* ---- tarjetas y filas ---- */
.card { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.white { background: #fff; }
.card.dashed { background: var(--soft3); border-style: dashed; }
.card.sm { padding: 12px 14px; border-radius: var(--radius-sm); }
.row-item { display: flex; align-items: center; gap: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.row-item.click { cursor: pointer; transition: border-color .15s; }
.row-item.click:hover { border-color: #8FB4DE; }
.row-item.on { border-color: var(--blue); background: rgba(22, 104, 216, .06); }
.row-item .chev { color: #93AAC6; font-size: 18px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list.tight { gap: 6px; }
.tile { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.tile .n { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1.1; }
.tile .l { font-size: 10px; color: var(--muted2); margin-top: 3px; letter-spacing: .04em; text-transform: uppercase; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line2); font-size: 12.5px; }
.kv:first-child { border-top: none; }
.kv .k { color: var(--muted2); font-size: 11.5px; letter-spacing: .02em; }
.kv .v { font-weight: 600; text-align: right; max-width: 62%; }
.empty { background: var(--soft2); border: 1px dashed var(--line3); border-radius: 14px; padding: 18px; text-align: center; font-size: 13px; color: var(--muted3); }
.icon-box { width: 34px; height: 34px; border-radius: 10px; background: var(--soft3); border: 1px solid var(--line3); display: flex; align-items: center; justify-content: center; color: var(--blue); font-size: 15px; flex: none; }
.sq { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; flex: none; }
.sq.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 8px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.checkbox-mark { width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted3); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.row-item.on .checkbox-mark { border-color: var(--blue); color: var(--blue); }

/* ---- chips / tags ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--ink2); font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; }
.chip.mono { font-family: var(--mono); font-size: 12px; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.sm { padding: 7px 11px; font-size: 12px; border-radius: 10px; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.tag.ok { background: rgba(21, 138, 82, .12); color: var(--green-dark); }
.tag.err { background: rgba(199, 52, 58, .12); color: var(--red); }
.tag.warn { background: rgba(245, 166, 35, .18); color: #9A6100; }
.tag.info { background: rgba(22, 104, 216, .12); color: var(--blue-dark); }
.tag.gray { background: var(--line2); color: var(--muted); }

/* ---- alertas ---- */
.alert { border-radius: 14px; padding: 13px 14px; font-size: 13px; line-height: 1.45; display: flex; gap: 10px; align-items: flex-start; }
.alert.err { background: rgba(255, 77, 79, .10); border: 1px solid rgba(255, 77, 79, .35); color: var(--red); }
.alert.ok { background: rgba(21, 138, 82, .10); border: 1px solid rgba(21, 138, 82, .35); color: var(--green-dark); }
.alert.info { background: rgba(22, 104, 216, .10); border: 1px solid rgba(22, 104, 216, .35); color: var(--blue-dark); }
.alert.warn { background: rgba(245, 166, 35, .12); border: 1px solid rgba(245, 166, 35, .4); color: #9A6100; }
.alert .bang { width: 20px; height: 20px; border-radius: 50%; background: var(--red-bright); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.alert .t { font-weight: 700; letter-spacing: .04em; font-size: 13px; }
.alert .d { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 5px; }
.alert .n { font-size: 11px; color: var(--muted2); margin-top: 4px; }

/* ---- visor del escáner (QR: marco cuadrado) ---- */
.visor { position: relative; border-radius: 20px; overflow: hidden; background: #04070E; border: 1px solid var(--line); aspect-ratio: 1 / 1; max-height: 340px; width: 100%; }
.visor .reader, .visor video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover; }
.visor .reader video { object-fit: cover !important; }
.visor .bars { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .04) 0 6px, transparent 6px 12px); pointer-events: none; transition: opacity .3s; }
.visor .mask { position: absolute; left: 14%; right: 14%; top: 14%; bottom: 14%; border-radius: 14px; box-shadow: 0 0 0 2000px rgba(5, 6, 10, .55); pointer-events: none; }
.visor .corner { position: absolute; width: 26px; height: 26px; border: 0 solid var(--blue); pointer-events: none; }
.visor .corner.tl { left: 14%; top: 14%; border-top-width: 3px; border-left-width: 3px; border-radius: 8px 0 0 0; }
.visor .corner.tr { right: 14%; top: 14%; border-top-width: 3px; border-right-width: 3px; border-radius: 0 8px 0 0; }
.visor .corner.bl { left: 14%; bottom: 14%; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 8px; }
.visor .corner.br { right: 14%; bottom: 14%; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 8px 0; }
.visor .scanline { position: absolute; left: 14%; right: 14%; top: 14%; height: 2px; background: linear-gradient(90deg, transparent, var(--blue), transparent); animation: scanline 2.1s ease-in-out infinite alternate; pointer-events: none; }
.visor .hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-family: var(--mono); font-size: 11px; color: #CFE2F7; pointer-events: none; padding: 0 12px; }
.visor.off .scanline { display: none; }
@keyframes scanline { 0% { transform: translateY(0); } 100% { transform: translateY(var(--scan-h, 200px)); } }
@keyframes pulseRing { 0% { opacity: .55; transform: scale(.9); } 70% { opacity: 0; transform: scale(1.35); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.rise { animation: riseIn .3s ease both; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--blue); animation: spin 1s linear infinite; flex: none; }
.spinner.lg { width: 40px; height: 40px; border-width: 3px; }

/* ---- modales ---- */
.modal-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(16, 38, 63, .45); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line3); border-radius: 18px; padding: 18px; box-shadow: 0 18px 40px rgba(16, 38, 63, .25); max-height: 92vh; overflow-y: auto; animation: riseIn .2s ease both; }
.modal.wide { max-width: 640px; }
.modal .modal-title { font-size: 16px; font-weight: 700; }
.modal .modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions .btn { flex: 1; }

/* ---- toasts ---- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; font-size: 13px; box-shadow: 0 10px 30px rgba(16, 38, 63, .3); animation: riseIn .2s ease both; }
.toast.ok { background: var(--green-dark); }
.toast.err { background: var(--red); }

/* ---- tablas ---- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.tbl th { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted3); font-weight: 600; background: var(--soft2); }
.tbl tbody tr:hover { background: var(--soft3); }
.tbl tbody tr.click { cursor: pointer; }
.tbl td.mono { font-family: var(--mono); font-size: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; font-size: 12px; color: var(--muted); }

/* ---- secciones colapsables ---- */
.collapse-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.collapse-head .caret { transition: transform .2s; color: var(--muted2); }
.collapse.open .collapse-head .caret { transform: rotate(180deg); }
.collapse-body { display: none; }
.collapse.open .collapse-body { display: block; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 36px; width: auto; max-width: 120px; display: block; object-fit: contain; }
.brand .brand-name { font-size: 14px; font-weight: 700; letter-spacing: -.01em; color: var(--navy); line-height: 1.1; }
.brand .brand-sub { font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--blue); text-transform: uppercase; white-space: nowrap; }

/* ---- progreso ---- */
.bar { height: 6px; border-radius: 3px; background: #E3ECF8; overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; background: var(--blue); }

@media (max-width: 480px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .h1.big { font-size: 30px; }
}
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* Modo demo (DEMO_MODE): aviso fijo de que todo es simulado. */
.demo-banner { background: #FFF4D6; border: 1px solid #F0C75E; color: #7A5200; border-radius: 12px; padding: 8px 12px; font-size: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.demo-banner .tag { background: #F5A623; color: #fff; }

/* Línea de tiempo (portabilidad). */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--line2); color: var(--muted); border: 2px solid var(--line); }
.tl-item.done .tl-dot { background: var(--green); border-color: var(--green); color: #fff; }
.tl-item.done::before { background: var(--green); }
.tl-item.now .tl-dot { background: var(--blue); border-color: var(--blue); color: #fff; }
.tl-item.fail .tl-dot { background: var(--red); border-color: var(--red); color: #fff; }
.tl-item .t { font-size: 14px; font-weight: 600; }
.tl-item .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-item.pend .t { color: var(--muted); font-weight: 500; }

/* QR del perfil eSIM. */
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box img, .qr-box canvas { width: 180px; height: 180px; }

/* Selector segmentado (Chip/eSIM en la app; sub-pestañas en el panel). */
.seg { display: flex; gap: 6px; background: var(--soft2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--muted); border-radius: 9px; padding: 9px 12px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.seg button:hover { color: var(--ink2); }
.seg button.on { background: var(--blue); color: #fff; }
