/* Aerofusion Mail Desk — tema "panel de instrumentos" */
:root {
  --bg: #04070d;
  --bg2: #0a1020;
  --panel: rgba(14, 22, 40, .62);
  --panel-solid: #0c1426;
  --panel-2: #0a1020;
  --line: rgba(120, 160, 255, .14);
  --line-hi: rgba(120, 200, 255, .38);
  --ink: #e6ecf8;
  --muted: #8a98b4;
  --sky: #22d3ee;
  --violet: #8b5cf6;
  --sky-ink: #001218;
  --grad: linear-gradient(90deg, #22d3ee, #8b5cf6);
  --amber: #fbbf24;
  --ok: #34d399;
  --err: #f87171;
  --radius: 14px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
a { color: var(--sky); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--err); min-height: 1.2em; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* botones y campos */
.btn { font: 600 .95rem var(--font); border: 1px solid transparent; border-radius: 8px; padding: .55rem 1rem; cursor: pointer; color: var(--ink); background: var(--panel-2); }
.btn.primary { background: var(--grad); color: var(--sky-ink); box-shadow: 0 8px 30px -8px rgba(34, 211, 238, .6); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { color: var(--err); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: progress; }
input, select, textarea { font: inherit; color: var(--ink); background: #060b16; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; width: 100%; }
textarea { resize: vertical; line-height: 1.55; }
label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea, label > .pw-wrap { color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink); white-space: nowrap; }
.check input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: 500 .9rem var(--font); background: transparent; color: var(--muted); border: 0; padding: .45rem .85rem; cursor: pointer; }
.seg button.on { background: rgba(34, 211, 238, .08); color: var(--ink); box-shadow: inset 0 -2px 0 var(--sky); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* login — mismo esquema que Vision */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px); gap: 4rem; align-items: center; max-width: 1180px; margin: 0 auto; padding: 32px 24px; }
.login-hero img { height: auto; max-height: 130px; max-width: 280px; object-fit: contain; }
.login-hero h1 { font-size: clamp(3.5rem, 9vw, 7rem); line-height: 1; font-weight: 700; letter-spacing: -.03em; margin: 1rem 0 .75rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p { color: var(--muted); font-size: 1.05rem; max-width: 46ch; margin: 0 0 1.5rem; }
.demo { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, rgba(34, 211, 238, .05), transparent 60%), var(--bg2); padding: 1.1rem; display: grid; gap: .5rem; max-width: 520px; overflow: hidden; }
.demo::before { content: ''; position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, transparent, var(--sky), transparent); }
.demo .row-d { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .75rem; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; background: rgba(4, 7, 13, .6); }
.demo .row-d span { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo .row-d i { font: 600 .72rem var(--mono); font-style: normal; padding: .15rem .45rem; border-radius: 4px; border: 1px solid currentColor; }
.demo .t1 { color: var(--sky); } .demo .t2 { color: var(--ok); } .demo .t3 { color: var(--violet); } .demo .t4 { color: var(--err); }
.demo .row-d.junk span { text-decoration: line-through; opacity: .55; }
.login-card { display: grid; gap: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; backdrop-filter: blur(10px); }
.login-card h2 { font-size: 1.4rem; }
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; gap: 2rem; padding: 24px 16px; }
  .login-hero img { height: 90px; }
  .demo { display: none; }
}
.private-note { border: 1px solid var(--amber); border-radius: 10px; padding: .8rem 1rem; display: grid; gap: .45rem; font-size: .88rem; color: var(--muted); }
.private-note p { margin: 0; }
.private-note b { color: var(--ink); }
.private-note .ip-line { border-top: 1px dashed var(--line); padding-top: .45rem; }
.private-note .ip-line b { color: var(--sky); font-family: var(--mono); }

/* estructura */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 1.25rem .75rem; background: var(--bg2); border-right: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; gap: .35rem; padding: 0 .6rem 1.25rem; }
.brand img { height: auto; max-height: 64px; max-width: 100%; width: auto; align-self: flex-start; object-fit: contain; }
.brand span { font: 700 1.35rem var(--font-head); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rail a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.rail a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.rail a.on { background: rgba(34, 211, 238, .08); color: var(--ink); box-shadow: inset 2px 0 0 var(--sky); }
.rail a.on svg { stroke: var(--sky); }
.badge { margin-left: auto; background: var(--amber); color: #1d1300; font: 700 .75rem var(--font); border-radius: 99px; padding: .05rem .5rem; }
.rail-foot { margin-top: auto; display: grid; gap: .4rem; }
main { padding: 1.5rem 2rem 0; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type=search] { width: auto; min-width: 180px; }
.hint { color: var(--muted); max-width: 70ch; margin: 0 0 1.25rem; }
.panel h3 { margin-top: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; max-width: 760px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

/* bandeja: correos como tiras de vuelo */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.split.reading { grid-template-columns: minmax(300px, 2fr) minmax(0, 3fr); }
.strips { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; align-content: start; }
.strip { display: grid; grid-template-columns: 6px 64px minmax(0, 1fr) auto; align-items: stretch; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; overflow: hidden; }
.strip:hover { border-color: var(--muted); }
.strip.sel { border-color: var(--line-hi); box-shadow: 0 0 0 1px var(--sky) inset, 0 8px 30px -12px rgba(34, 211, 238, .5); }
.strip .band { background: var(--acc, var(--muted)); }
.strip .when { padding: .55rem .5rem; border-right: 1px dashed var(--line); font: 500 .78rem var(--mono); color: var(--muted); text-align: center; line-height: 1.3; }
.strip .when b { display: block; color: var(--ink); font-size: .88rem; font-weight: 600; }
.strip .body { padding: .5rem .8rem; min-width: 0; }
.strip .who { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .subj { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92rem; }
.strip.unread .who { font-weight: 600; }
.strip.unread .subj { color: var(--ink); }
.strip .tag { padding: .5rem .8rem; font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: .2rem; white-space: nowrap; }
.strip .tag .ans { color: var(--ok); font-weight: 600; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.more { justify-self: center; margin: .5rem 0 1rem; }

.reader { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; align-self: start; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.reader h3 { margin: 0 0 .5rem; font-size: 1.35rem; }
.reader .meta { font-size: .9rem; color: var(--muted); display: grid; gap: .1rem; margin-bottom: 1rem; }
.reader .meta b { color: var(--ink); font-weight: 500; }
.reader .actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0 1rem; }
.reader iframe { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.reader pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.reader .att { font-size: .88rem; color: var(--muted); margin-top: 1rem; }
.reader .close { float: right; }

/* por aprobar */
.out-list { display: grid; gap: 1rem; max-width: 900px; }
.out-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: grid; gap: .7rem; }
.out-card.enviado { border-left-color: var(--ok); }
.out-card.rechazado { border-left-color: var(--muted); opacity: .8; }
.out-card.error { border-left-color: var(--err); }
.out-card .top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.out-card .note { background: var(--panel-2); border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; }
.out-card .sig-prev { border-top: 1px dashed var(--line); padding-top: .6rem; font-size: .85rem; color: var(--muted); }
.out-card .sig-prev iframe { width: 100%; height: 120px; border: 0; background: #fff; border-radius: 6px; }
.out-card .errline { color: var(--err); font-size: .9rem; }

/* cuentas */
.acc-list { display: grid; gap: .6rem; max-width: 1000px; }
.acc { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 1rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.acc .id b { display: block; font-weight: 600; }
.acc .id span { color: var(--muted); font-size: .88rem; }
.acc .lights { display: flex; gap: .9rem; font-size: .85rem; color: var(--muted); }
.light { display: inline-flex; align-items: center; gap: .35rem; }
.light::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 2px var(--panel-2); }
.light.ok::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.light.error::before, .light.sin_clave::before { background: var(--err); box-shadow: 0 0 8px var(--err); }
.light.testing::before { background: var(--amber); animation: blink .8s infinite alternate; }
@keyframes blink { to { opacity: .3; } }
.acc .lasterr { grid-column: 1 / -1; color: var(--err); font-size: .85rem; margin-top: -.3rem; }

.acc-summary { margin: 0 0 .5rem; font-weight: 500; }
.acc .quick { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: .7rem; }
.acc .quick input { flex: 1; min-width: 200px; max-width: 360px; }
.acc .quick .msg { font-size: .88rem; }
.acc .quick .msg.ok { color: var(--ok); }
.acc .quick .msg.bad { color: var(--err); }

/* agente */
.chip { font: 600 .8rem var(--mono); padding: .3rem .65rem; border-radius: 99px; border: 1px solid var(--line-hi); color: var(--muted); }
.chip.on { color: var(--ok); border-color: var(--ok); box-shadow: 0 0 12px -2px var(--ok); }
.ag-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .4rem; }
.ag-accounts label { flex-direction: row; display: flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; color: var(--ink); }
.ag-accounts input { width: auto; }
code { font: .85em var(--mono); background: #060b16; border: 1px solid var(--line); border-radius: 4px; padding: .05rem .35rem; color: var(--sky); }
.cat { font: 600 .68rem var(--mono); padding: .05rem .4rem; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.cat-cliente { color: var(--ok); } .cat-cotizacion { color: var(--sky); } .cat-proveedor { color: #7dd3fc; } .cat-operaciones { color: var(--violet); }
.cat-administrativo { color: #c4b5fd; } .cat-personal { color: #f9a8d4; } .cat-aviso, .cat-otro { color: var(--muted); } .cat-posible_basura { color: var(--err); }
.prio-alta { color: var(--amber); font-weight: 700; }
.ai-line { background: rgba(34, 211, 238, .06); border: 1px solid var(--line); border-left: 3px solid var(--sky); border-radius: 8px; padding: .55rem .8rem; margin-bottom: .9rem; font-size: .92rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.strip .ai { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .ai b { color: var(--sky); font-weight: 500; }

/* basura */
.junk-form { display: flex; gap: .5rem; flex-wrap: wrap; max-width: 900px; }
.junk-form select { width: auto; }
.junk-form input { flex: 1; min-width: 220px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.plain-list li { display: flex; align-items: center; gap: .75rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; min-width: 0; }
.plain-list li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list li .n { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.plain-list.small li { font-size: .88rem; }

/* analítica */
.kpis { background: var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.kpi { background: var(--panel); padding: 1rem 1.1rem; }
.kpi b { display: block; font: 600 2rem/1.1 var(--mono); }
.kpi span { color: var(--muted); font-size: .9rem; }
.kpi.warn b { color: var(--amber); }
.kpi:first-child b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chart-box { margin: 0 0 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.chart-box figcaption { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.chart-box figcaption i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.chart-box svg { width: 100%; height: auto; display: block; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.data th { text-align: left; font-weight: 500; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }

/* conector */
.copy-row { display: flex; gap: .5rem; margin: 1rem 0; }
.copy-row input { font-size: .85rem; }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; display: grid; gap: .3rem; }
.pw-form { display: grid; gap: .6rem; max-width: 360px; }
.ms-form { display: grid; gap: .75rem; }
.copy-row.tight { margin: 0; }
.btn.ms { background: #0b1830; border-color: var(--line-hi); }

/* diálogos */
.dlg { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 32px); background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }
.dlg::backdrop { background: rgba(2, 5, 10, .72); backdrop-filter: blur(3px); }
.dlg form { display: grid; gap: .9rem; }
.dlg h3 { margin: 0; font-size: 1.4rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.span2 { grid-column: 1 / -1; }
.pw-wrap { display: flex; gap: .4rem; }
.adv summary { cursor: pointer; color: var(--muted); margin-bottom: .6rem; }
.sig-editor { min-height: 110px; max-height: 260px; overflow: auto; background: #fff; color: #111; border-radius: 8px; padding: .75rem; border: 1px solid var(--line); }
.sig-html { min-height: 140px; font-size: .85rem; }
.sig-tabs { justify-self: start; }
.test-result { margin: 0; display: grid; gap: .2rem; font-size: .92rem; }
.test-result .ok { color: var(--ok); }
.test-result .bad { color: var(--err); }
.dlg-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--panel-solid); border: 1px solid var(--line); color: var(--ink); padding: .65rem 1.1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { border-color: var(--err); }

/* footer Aerofusion */
.af-footer { display: flex; gap: 1.25rem; align-items: flex-start; border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0 2rem; font-size: .88rem; }
.af-footer img { height: auto; max-height: 48px; max-width: 120px; margin-top: .1rem; object-fit: contain; }
.af-footer p { margin: 0 0 .2rem; }

/* móvil / iPad vertical */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; justify-content: space-around; padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 20; }
  .brand, .rail-foot { display: none; }
  .rail a { flex-direction: column; gap: .15rem; font-size: .7rem; padding: .35rem .3rem; position: relative; }
  .rail a .badge { position: absolute; top: 0; right: 0; margin: 0; }
  main { padding: 1rem 16px 5.5rem; }
  .split.reading { grid-template-columns: 1fr; }
  .split.reading .strips { display: none; }
  .reader { position: static; max-height: none; }
  .two-col, .grid2 { grid-template-columns: 1fr; }
  .acc { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters select, .filters input[type=search] { min-width: 0; flex: 1 1 150px; }
  .strip { grid-template-columns: 5px 54px minmax(0, 1fr); }
  .strip .tag { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
