/* Consola del cliente final (#2619) — identidad Recepción en PAPEL, igual que
   las formas públicas: crema + tinta + oro. --primary lo pone el operador
   (branding) desde base.html; el chrome es papel. Sin fuentes externas: el
   CSP solo permite estilos propios. */

:root {
  --primary: #c9a45c;
  --primary-dark: #9c7f4a;
  --bg: #f2ede4;
  --card: #fffdf9;
  --text: #26221f;
  --muted: #6f6862;
  --border: #e2ded7;
  --field: #faf7f1;
  --error: #9a3b2f;
  --error-bg: #f7ece8;
  --ok: #166534;
  --ok-bg: #e9f3ea;
  --ink: #0d0d0d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.portal {
  font-family: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(201,164,92,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Cabecera */
.portal-head { background: var(--ink); color: #e7dfd2; }
.portal-head-inner {
  max-width: 900px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.portal-brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.portal-brand img { max-height: 32px; max-width: 160px; display: block; }
.portal-brand .bell { width: 30px; height: 24px; color: var(--primary); }
.portal-brand-name {
  font-family: Georgia, "Times New Roman", serif; font-size: 0.95rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: #e7dfd2;
}
.portal-nav { display: flex; align-items: center; gap: 14px; font-size: 0.85rem; }
.portal-nav a { color: var(--primary); text-decoration: none; }
.portal-nav a:hover { text-decoration: underline; }
.portal-who { color: #a9a29a; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cuerpo */
.portal-main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 22px 16px 32px; }
body.portal-auth .portal-main { max-width: 480px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 18px 44px -24px rgba(38,34,31,0.22);
  padding: 22px; margin-bottom: 16px;
}
.card h2 { font-size: 1.22rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
.card p.lead { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; }
.card-auth h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 1.35rem; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--muted); }
.field { margin-bottom: 16px; }
.field .help { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: var(--field); color: var(--text);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
input.code-input {
  font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.6rem; letter-spacing: 0.35em;
  text-align: center;
}
.err {
  font-size: 0.88rem; color: var(--error); background: var(--error-bg);
  border: 1px solid #e6cfc7; padding: 9px 12px; border-radius: 6px; margin: 0 0 14px;
}
.flashes { margin-bottom: 14px; }
.flash { padding: 9px 12px; border-radius: 6px; font-size: 0.88rem; margin-bottom: 8px; border: 1px solid var(--border); }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #cfe3d1; }
.flash-error { background: var(--error-bg); color: var(--error); border-color: #e6cfc7; }

button.primary {
  width: 100%; background: var(--ink);
  color: color-mix(in srgb, var(--primary) 50%, #fff);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, #fff);
  padding: 14px; min-height: 50px; font-size: 0.92rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; letter-spacing: 0.12em; text-transform: uppercase;
  transition: background 180ms ease, color 180ms ease;
}
button.primary:hover { background: color-mix(in srgb, var(--primary) 50%, #fff); color: var(--ink); }
button.primary[disabled] { opacity: 0.6; cursor: default; }
button.link {
  background: none; border: 0; padding: 0; color: var(--primary-dark); font: inherit;
  font-size: 0.88rem; text-decoration: underline; cursor: pointer;
}
button.secondary {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 6px; font: inherit; font-size: 0.88rem; cursor: pointer;
}
button.secondary:hover { border-color: var(--primary); }
a.button-secondary {
  display: inline-block; background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 6px; font-size: 0.88rem; text-decoration: none; white-space: nowrap;
}
a.button-secondary:hover { border-color: var(--primary); }
.form-inline-aux { margin-top: 14px; text-align: center; }
.aux { text-align: center; font-size: 0.88rem; color: var(--muted); margin: 14px 0 0; }
.aux a { color: var(--primary-dark); }

/* Pie */
.portal-foot {
  max-width: 900px; margin: 0 auto; padding: 14px 16px 26px; width: 100%;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--muted);
}
.portal-foot-brand { font-family: Georgia, serif; letter-spacing: 0.2em; text-transform: uppercase; color: var(--primary-dark); }

/* Consola: lista de solicitudes */
.portal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.portal-toolbar h1 { font-family: Georgia, serif; font-weight: 400; font-size: 1.4rem; margin: 0; }
a.button-primary {
  display: inline-block; background: var(--ink); color: color-mix(in srgb, var(--primary) 50%, #fff);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, #fff); padding: 11px 16px; border-radius: 6px;
  text-decoration: none; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
}
a.button-primary:hover { background: color-mix(in srgb, var(--primary) 50%, #fff); color: var(--ink); }
.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px;
  text-decoration: none; color: inherit;
}
.ticket-row:hover { border-color: var(--primary); }
.ticket-row .t-title { font-weight: 600; }
.ticket-row .t-meta { font-size: 0.82rem; color: var(--muted); grid-column: 1 / -1; }
.ticket-row .t-folio { font-family: SFMono-Regular, Menlo, monospace; font-size: 0.78rem; color: var(--muted); }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--field); color: var(--muted);
}
.badge-open { color: #1d4ed8; background: #e8effd; border-color: #c7d7fb; }
.badge-ready { color: var(--ok); background: var(--ok-bg); border-color: #cfe3d1; }
.badge-closed { color: var(--muted); }
.badge-new { color: #92400e; background: #fdf1e0; border-color: #f3d9b1; }
.section-title { font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.empty { color: var(--muted); font-size: 0.92rem; padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.notice { font-size: 0.82rem; color: var(--muted); background: var(--field); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

/* Consola: detalle y conversación */
.detail-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.detail-head h1 { font-family: Georgia, serif; font-weight: 400; font-size: 1.3rem; margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.88rem; margin-top: 10px; }
.kv .k { color: var(--muted); }
.docs { list-style: none; margin: 10px 0 0; padding: 0; }
.docs li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.docs li:first-child { border-top: 0; }
.docs .d-meta { font-size: 0.78rem; color: var(--muted); }
.thread { list-style: none; margin: 0; padding: 0; }
.msg { max-width: 82%; margin-bottom: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--field); }
.msg.me { margin-left: auto; background: #fff; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.msg.them { margin-right: auto; }
.msg .m-who { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.msg .m-body { white-space: pre-wrap; word-break: break-word; }
.msg .m-when { font-size: 0.72rem; color: var(--muted); margin-top: 4px; text-align: right; }
.msg.sys { max-width: 100%; text-align: center; background: transparent; border: 0; color: var(--muted); font-size: 0.8rem; padding: 4px; }
.compose { margin-top: 14px; }
.compose textarea { min-height: 84px; }
.compose .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.compose .hint { font-size: 0.78rem; color: var(--muted); }
.compose button.primary { width: auto; min-height: 42px; padding: 10px 18px; }

@media (max-width: 600px) {
  .portal-head-inner { padding: 10px 12px; }
  .portal-main { padding: 16px 12px 28px; }
  .card { padding: 16px; }
  .msg { max-width: 92%; }
}

/* Detalle: lo capturado en la forma */
.sol-list { margin: 8px 0 0; }
.sol-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 4px 14px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 0.9rem; }
.sol-row:first-child { border-top: 0; }
.sol-row dt { color: var(--muted); }
.sol-row dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.sol-row-emph dd { font-weight: 600; }
@media (max-width: 600px) { .sol-row { grid-template-columns: 1fr; gap: 2px; } }

/* Secciones plegables del detalle */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary h2::before { content: "▸"; display: inline-block; width: 1em; color: var(--primary-dark); transition: transform 120ms ease; }
details.fold[open] > summary h2::before { transform: rotate(90deg); }
details.fold .fold-hint { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.04em; }
details.fold .fold-body { margin-top: 12px; }
