/* Portal de Clientes — Support & Infraestructura (colores de la marca) */
:root {
  --navy-deep: #0A1F3F; --navy-mid: #132B52; --navy-light: #1A3A6B;
  --slate: #2F3E4E; --slate-light: #6B7B8D; --slate-lighter: #A0ACB8;
  --bg: #F3F5F8; --white: #FFFFFF; --line: #E2E7EE;
  --cyan: #00C6D7; --cyan-dark: #009FAD; --cyan-soft: #E0F8FA;
  --orange: #D4603A; --orange-soft: #FBEAE4;
  --green: #1E9E6A; --green-soft: #E3F5EC;
  --amber: #B7791F; --amber-soft: #FDF3DC;
  --red: #C53030; --red-soft: #FDE8E8;
  --radius: 14px; --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(10, 31, 63, .07);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--slate); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--cyan-dark); }
h1, h2, h3 { color: var(--navy-deep); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 700; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.sr, .skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; background: var(--white); padding: 8px 12px; z-index: 99; }
.mono { font-family: var(--mono); }
.muted { color: var(--slate-light); }
.small { font-size: .85rem; }

/* ---------- Cabecera ---------- */
.topbar { background: var(--navy-deep); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 20px rgba(0,0,0,.18); }
.topbar-in { display: flex; align-items: center; gap: 24px; min-height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand-icon { width: 44px; height: 44px; }
.brand-name { color: #fff; font-weight: 800; font-size: 1.05rem; line-height: 1.05; letter-spacing: -.01em; }
.brand-name span { display: block; color: var(--cyan); }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav > a { color: #C9D4E3; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .93rem; }
.nav > a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav > a.on { color: var(--navy-deep); background: var(--cyan); font-weight: 600; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy-light); color: var(--cyan); display: grid; place-items: center; font-weight: 700; }
.who { display: flex; flex-direction: column; line-height: 1.15; }
.who strong { color: #fff; font-size: .88rem; font-weight: 600; }
.who small { color: var(--slate-lighter); font-size: .75rem; }
.nav .mini { color: var(--slate-lighter); font-size: .8rem; text-decoration: none; padding: 4px 6px; }
.nav .mini:hover { color: var(--cyan); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle span:not(.sr) { display: block; width: 24px; height: 2px; background: #fff; margin: 5px 0; border-radius: 2px; }
@media (max-width: 960px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 76px; background: var(--navy-mid); flex-direction: column; align-items: stretch; padding: 12px 20px 20px; }
  .nav.open { display: flex; }
  .nav-user { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1); flex-wrap: wrap; }
}

/* ---------- Estructura ---------- */
.main { flex: 1; padding-top: 32px; padding-bottom: 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 0; color: var(--slate-light); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; color: var(--cyan-dark); margin-bottom: 6px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Indicadores ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cyan); }
.stat.orange::before { background: var(--orange); }
.stat.green::before { background: var(--green); }
.stat.navy::before { background: var(--navy-light); }
.stat b { display: block; font-family: var(--mono); font-size: 1.7rem; color: var(--navy-deep); line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--slate-light); }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 22px; font: 600 .93rem var(--font); cursor: pointer; text-decoration: none; background: var(--cyan); color: var(--navy-deep); transition: .2s; white-space: nowrap; }
.btn:hover { background: var(--cyan-dark); color: #fff; box-shadow: 0 0 24px rgba(0,198,215,.3); }
.btn-dark { background: var(--navy-deep); color: #fff; }
.btn-dark:hover { background: var(--navy-light); }
.btn-ghost { background: transparent; color: var(--navy-deep); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--white); color: var(--navy-deep); border-color: var(--cyan); box-shadow: none; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #BF5030; }
.btn-sm { padding: 7px 14px; font-size: .84rem; }
label { display: block; font-weight: 600; font-size: .86rem; color: var(--navy-deep); margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.hint { font-size: .8rem; color: var(--slate-light); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=month], select, textarea {
  width: 100%; font: 15px var(--font); color: var(--slate); background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; transition: .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(0,198,215,.15); }
textarea { min-height: 140px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; }
.filters .field { margin: 0; min-width: 150px; flex: 1; }
.filters input, .filters select { padding: 0 12px; height: 42px; }
.filters .btn { height: 42px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-light); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFCFD; }
td.mono { white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.t-link { color: var(--navy-deep); font-weight: 600; text-decoration: none; }
.t-link:hover { color: var(--cyan-dark); }
tfoot td { font-weight: 700; color: var(--navy-deep); border-top: 2px solid var(--line); }
.empty { text-align: center; padding: 40px 20px; color: var(--slate-light); }

/* ---------- Etiquetas ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: #EEF1F5; color: var(--slate); }
.st-abierto { background: var(--cyan-soft); color: #00737D; }
.st-en-proceso { background: #E6ECF7; color: var(--navy-light); }
.st-en-espera-del-cliente { background: var(--amber-soft); color: var(--amber); }
.st-resuelto { background: var(--green-soft); color: var(--green); }
.st-cerrado { background: #EEF1F5; color: var(--slate-light); }
.st-emitida { background: var(--cyan-soft); color: #00737D; }
.st-pagada { background: var(--green-soft); color: var(--green); }
.st-anulada { background: var(--red-soft); color: var(--red); }
.pr-baja { background: #EEF1F5; color: var(--slate-light); }
.pr-media { background: #E6ECF7; color: var(--navy-light); }
.pr-alta { background: var(--orange-soft); color: var(--orange); }
.pr-critica { background: var(--red); color: #fff; }

/* ---------- Alertas ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; border-left: 4px solid; }
.alert-ok { background: var(--green-soft); border-color: var(--green); color: #14684A; }
.alert-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.alert-info { background: var(--cyan-soft); border-color: var(--cyan-dark); color: #00626B; }

/* ---------- Ticket ---------- */
.ticket-meta { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: .9rem; margin: 0; }
.ticket-meta dt { color: var(--slate-light); }
.ticket-meta dd { margin: 0; color: var(--navy-deep); font-weight: 500; }
.desc { white-space: pre-wrap; word-wrap: break-word; }
.thread { list-style: none; padding: 0; margin: 0; }
.msg { display: flex; gap: 12px; padding: 18px 0; border-top: 1px solid var(--line); }
.msg .avatar { flex-shrink: 0; background: var(--cyan-soft); color: var(--cyan-dark); }
.msg.staff .avatar { background: var(--navy-deep); color: var(--cyan); }
.msg.internal { background: var(--amber-soft); margin: 0 -24px; padding: 18px 24px; }
.msg-head { font-size: .85rem; margin-bottom: 4px; }
.msg-head strong { color: var(--navy-deep); }
.files { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.files a { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; background: #F3F5F8; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; text-decoration: none; color: var(--navy-deep); }
.files a:hover { border-color: var(--cyan); }
.side-box h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--slate-light); }
.billing { background: linear-gradient(135deg, var(--navy-deep), var(--navy-light)); color: #fff; border: 0; }
.billing h2 { color: var(--cyan); }
.billing label { color: #fff; }
.billing .hint { color: var(--slate-lighter); }
.amount { font-family: var(--mono); font-size: 1.8rem; color: #fff; }

/* ---------- Login ---------- */
.auth { flex: 1; display: grid; grid-template-columns: 1.1fr 1fr; min-height: calc(100vh - 76px); }
.auth-hero { background: radial-gradient(circle at 20% 20%, rgba(0,198,215,.18), transparent 50%), linear-gradient(160deg, var(--navy-deep), var(--navy-mid)); color: #fff; padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { color: #fff; font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
.auth-hero h1 em { color: var(--cyan); font-style: normal; }
.auth-hero p { color: #C9D4E3; max-width: 460px; font-size: 1.05rem; }
.auth-list { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-list li { display: flex; gap: 12px; align-items: center; color: #E3EAF3; }
.auth-list li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); flex-shrink: 0; }
.auth-form { display: grid; place-items: center; padding: 48px 24px; }
.auth-form .card { width: 100%; max-width: 420px; padding: 36px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-hero { padding: 40px 24px; } }

/* ---------- Pie ---------- */
.foot { background: var(--navy-deep); color: var(--slate-lighter); font-size: .82rem; }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 18px; padding-bottom: 18px; }
.foot a { color: var(--slate-lighter); text-decoration: none; }
.foot a:hover { color: var(--cyan); }

/* ---------- Impresión (pre-liquidación en PDF) ---------- */
.doc { max-width: 900px; margin: 0 auto; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 3px solid var(--cyan); padding-bottom: 18px; margin-bottom: 20px; }
.doc-brand { display: flex; gap: 12px; align-items: center; }
.doc-brand .brand-name { color: var(--navy-deep); }
.doc-totals { margin-left: auto; width: 300px; max-width: 100%; }
.doc-totals td { padding: 8px 12px; }
.doc-totals tr.total td { font-size: 1.1rem; background: var(--navy-deep); color: #fff; }
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .foot, .no-print, .alert { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .doc-totals tr.total td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 16mm; }
}

/* ---------- Tope de S/ 1,500 por recibo ---------- */
.tope { margin-top: 10px; }
.tope-bar { height: 8px; border-radius: 99px; background: #E6EBF2; overflow: hidden; }
.tope-bar span { display: block; height: 100%; border-radius: 99px; background: var(--green); transition: width .4s; }
.tope-warn .tope-bar span { background: var(--amber); }
.tope-over .tope-bar span { background: var(--red); }
.tope-txt { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--slate-light); margin-top: 5px; }
.tope-over .tope-txt span:last-child { color: var(--red); font-weight: 600; }
.tope-warn .tope-txt span:last-child { color: var(--amber); font-weight: 600; }
.billing .tope-bar { background: rgba(255,255,255,.15); }
.billing .tope-txt { color: var(--slate-lighter); }
.tope-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.tope-list strong { color: var(--navy-deep); font-size: .92rem; }
