/* Infokey – estilos (modo claro y oscuro) */
:root {
  --bg: #F1F5F9; --surface: #FFFFFF; --surface2: #F8FAFC; --border: #E2E8F0; --row: #F1F5F9;
  --text: #0F172A; --muted: #475569; --input: #CBD5E1; --seg: #E2E8F0;
  --primary: #0F766E; --primary-h: #115E59; --primary-soft: #CCFBF1;
  --danger: #B91C1C; --danger-soft: #FEE2E2;
  --header: #0F172A; --header-b: #0F172A;
  --pro-bg: #CCFBF1; --pro-fg: #115E59; --dte-bg: #DBEAFE; --dte-fg: #1E40AF;
  --t-admin-bg: #FEE2E2; --t-admin-fg: #991B1B; --t-conta-bg: #E0E7FF; --t-conta-fg: #3730A3;
  --t-fact-bg: #FEF3C7; --t-fact-fg: #92400E; --t-cons-bg: #E2E8F0; --t-cons-fg: #334155;
  --accent2-bg: #FFEDD5; --accent2-fg: #C2410C;
  --shadow: 0 1px 2px rgba(15,23,42,.08), 0 8px 24px rgba(15,23,42,.06);
  --emb-c: #141414; --emb-l: #FFFFFF;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0B1120; --surface: #111827; --surface2: #0F172A; --border: #1F2937; --row: #1A2332;
  --text: #E5E7EB; --muted: #9CA3AF; --input: #374151; --seg: #1F2937;
  --primary: #0D9488; --primary-h: #14B8A6; --primary-soft: #042F2E;
  --danger: #F87171; --danger-soft: #450A0A;
  --header: #020617; --header-b: #1F2937;
  --pro-bg: #042F2E; --pro-fg: #99F6E4; --dte-bg: #172554; --dte-fg: #BFDBFE;
  --t-admin-bg: #450A0A; --t-admin-fg: #FCA5A5; --t-conta-bg: #1E1B4B; --t-conta-fg: #C7D2FE;
  --t-fact-bg: #422006; --t-fact-fg: #FDE68A; --t-cons-bg: #1F2937; --t-cons-fg: #D1D5DB;
  --accent2-bg: #431407; --accent2-fg: #FDBA74;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --emb-c: #F8FAFC; --emb-l: #111827;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 18px; }

/* Botones */
.btn { height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--input); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.btn.primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 8px; }
.icon-btn.danger { color: var(--danger); }

/* Campos */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--input); background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.input:disabled { opacity: .6; }
.input-row { display: flex; gap: 6px; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.err { font-size: 14px; color: var(--danger); margin: 0; min-height: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }

/* Encabezado */
.top { background: var(--header); color: #FFFFFF; border-bottom: 1px solid var(--header-b); }
.top-in { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; }
.top-l, .top-r { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #FFFFFF; text-decoration: none; font-weight: 750; font-size: 20px; background: none; border: 0; cursor: pointer; padding: 0; }
.brand svg { width: 30px; height: 30px; }
.top .ghost { height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid #334155; background: transparent; color: #E2E8F0; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.top .ghost:hover { border-color: #64748B; }
.who { font-size: 14px; color: #CBD5E1; }
.who b { color: #FFFFFF; font-weight: 600; }
.theme-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid #334155; background: #1E293B; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #FDE68A; }
.theme-btn.on-light { position: fixed; top: 16px; right: 16px; }

/* Inicio de sesión */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 20px; background: #0F172A; position: relative; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.login .card { width: 100%; max-width: 420px; padding: 36px 32px; display: flex; flex-direction: column; gap: 20px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.lockup { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 4px; }
.lockup svg { width: 44px; height: 44px; flex: none; }
.lockup .wm { height: 32px; }
/* Emblema (círculo + candado) y logotipo */
.emb-c { fill: var(--emb-c); }
.emb-l { fill: var(--emb-l); }
.emb-s { stroke: var(--emb-l); }
.top .emb-c { fill: #FFFFFF; }
.top .emb-l { fill: #0F172A; }
.top .emb-s { stroke: #0F172A; }
.wm { height: 40px; width: auto; max-width: 100%; }
.wm-blanco { display: none; }
[data-theme="dark"] .wm-negro { display: none; }
[data-theme="dark"] .wm-blanco { display: inline; }
.wm-top { height: 20px; width: auto; }
.h-sub { font-size: 18px; font-weight: 600; color: var(--muted); }
.login .card { position: relative; padding-bottom: 40px; }
.version { position: absolute; right: 18px; bottom: 12px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.linkbtn { background: none; border: 0; padding: 8px 0; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 14px; }

/* Panel */
main.page { padding-top: 36px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.tile { text-align: left; cursor: pointer; padding: 30px; min-height: 210px; display: flex; flex-direction: column; gap: 16px; color: var(--text); position: relative; }
.tile:hover { border-color: var(--primary); }
.tile .ico { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.tile .t { font-size: 26px; font-weight: 750; }
.tile .go { margin-top: auto; font-weight: 600; font-size: 14px; }
.badge { position: absolute; top: 18px; right: 18px; background: var(--danger); color: #FFFFFF; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }

/* Barra de herramientas */
.bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.bar-r { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--seg); }
.seg button { height: 38px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.lockinfo { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding: 10px 14px; border-radius: 10px; color: var(--muted); border: 1px dashed var(--input); }
.btn.toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }

/* Tabla */
.table-box { overflow-x: auto; }
table.t { width: 100%; min-width: 1240px; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 13px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--row); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--surface2); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.Infopro { background: var(--pro-bg); color: var(--pro-fg); }
.pill.InfoDTE { background: var(--dte-bg); color: var(--dte-fg); }
.pill.Administrador { background: var(--t-admin-bg); color: var(--t-admin-fg); }
.pill.Contador { background: var(--t-conta-bg); color: var(--t-conta-fg); }
.pill.Facturador { background: var(--t-fact-bg); color: var(--t-fact-fg); }
.pill.Consulta { background: var(--t-cons-bg); color: var(--t-cons-fg); }
.pill.Asesor { background: var(--dte-bg); color: var(--dte-fg); }
.pill.ok { background: var(--pro-bg); color: var(--pro-fg); }
.pill.warn { background: var(--t-fact-bg); color: var(--t-fact-fg); }
.cell { display: inline-flex; align-items: center; gap: 6px; }
.secret { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.locked { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.acts { display: flex; gap: 6px; }

/* Utilidades */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.cards .card { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.cards .card.wide { grid-column: 1 / -1; }
.gen-out { flex: 1; min-width: 0; height: 46px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--border); display: flex; align-items: center; padding: 0 12px; overflow: hidden; font-size: 15px; }
.log { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.log table.t { min-width: 600px; }
.code { font-size: 22px; letter-spacing: .12em; font-weight: 700; padding: 14px; border-radius: 10px; background: var(--surface2); border: 1px dashed var(--input); text-align: center; word-break: break-all; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.6); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow: auto; z-index: 50; }
.modal { width: 100%; max-width: 640px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.modal.sm { max-width: 440px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.sys-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sys-pick button { min-height: 70px; padding: 12px 14px; border-radius: 12px; text-align: left; display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; }
.sys-pick button[aria-pressed="true"].Infopro { background: var(--pro-bg); border-color: var(--primary); }
.sys-pick button[aria-pressed="true"].InfoDTE { background: var(--dte-bg); border-color: #3B82F6; }
.sys-pick b { font-size: 16px; }
.sys-pick span { font-size: 13px; color: var(--muted); }
.dte-box { display: flex; flex-direction: column; gap: 16px; padding: 18px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }

/* Aviso */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #0F172A; color: #FFFFFF; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; border: 1px solid #334155; }
.toast.bad { background: #7F1D1D; border-color: #991B1B; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media print { .top, .bar, .acts { display: none; } }
