/*
 * Portal de facturas de Sign24h
 *
 * Para adaptarlo a la marca, cambia los valores de :root.
 * --brand y --brand-strong son el color principal de Sign24h y su versión
 * más oscura (para hover). --font es la tipografía de la web principal:
 * si sign24h.com usa una fuente propia, añádela aquí con @font-face
 * alojada en vuestro servidor.
 */
:root {
  --brand: #0B4F6C;
  --brand-strong: #083A50;
  --brand-tint: #E7F0F3;

  --bg: #F5F6F4;
  --surface: #FFFFFF;
  --ink: #1B1F23;
  --muted: #5E6770;
  --line: #DDE1E4;
  --danger: #A12622;
  --danger-tint: #FBEAE9;
  --info-tint: #EEF1F3;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  --content: 1080px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--muted); }

/* ------------------------------------------------------------ Cabecera */

.site-header {
  background: var(--surface);
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: inline-flex; }
.brand__logo { height: 32px; width: auto; display: block; }

.back-link {
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); text-decoration: underline; }

.account {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  font-size: 0.9375rem;
}
.account form { margin: 0; }
.account__email {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ Estructura */

.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.is-entry .site-main { max-width: 480px; padding-top: 9vh; }

.site-footer {
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
}
.site-footer__inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.site-footer a { color: var(--muted); }

/* ------------------------------------------------------------ Avisos */

.notice {
  margin-bottom: 24px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--muted);
  background: var(--info-tint);
  font-size: 0.9375rem;
}
.notice--error { border-left-color: var(--danger); background: var(--danger-tint); color: var(--danger); }

/* ------------------------------------------------------------ Acceso */

.entry__title {
  margin: 0 0 12px;
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.entry__lead {
  margin: 0 0 28px;
  color: var(--muted);
}
.entry__lead strong { color: var(--ink); font-weight: 600; word-break: break-all; }

.entry__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  margin-top: 20px;
  font-size: 0.9375rem;
}
.entry__actions form { margin: 0; }

.entry__help {
  margin: 40px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}

/* ------------------------------------------------------------ Formularios */

.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field__label { font-size: 0.875rem; font-weight: 600; }

.field__input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid #B9C0C6;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.field__input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-tint); }
.field__input.is-invalid, .code-input.is-invalid { border-color: var(--danger); }

.field__error { font-size: 0.875rem; color: var(--danger); }

/* El campo del código: grande y con cifras de ancho fijo, para leerlo y copiarlo sin errores. */
.code-input {
  width: 100%;
  padding: 14px 0 14px 0.5em;
  border: 1px solid #B9C0C6;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 700 2.25rem/1 var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5em;
  text-align: center;
}
.code-input::placeholder { color: #C6CCD1; }
.code-input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-tint); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 20px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #FFFFFF;
  font: 600 1rem/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #FFFFFF; }
.button[disabled] { opacity: 0.7; cursor: progress; }

.button--secondary { background: var(--surface); color: var(--brand); }
.button--secondary:hover { background: var(--brand-tint); color: var(--brand-strong); }

.button--small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.875rem;
  white-space: nowrap;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.link-button:hover { color: var(--brand-strong); }

/* ------------------------------------------------------------ Facturas */

.invoices__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 24px;
}
.invoices__title { margin: 0; font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.01em; }
.invoices__count { margin: 0; color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.toolbar__search { flex: 1 1 320px; }
.toolbar__year { flex: 0 0 180px; }
.toolbar__clear { font-size: 0.9375rem; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.invoice-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.invoice-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.invoice-table tbody tr:last-child td { border-bottom: 0; }
.invoice-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-table__number { font-weight: 600; white-space: nowrap; }
.invoice-table__concept { min-width: 220px; max-width: 360px; }
.invoice-table__recipient { display: block; margin-top: 2px; font-size: 0.8125rem; color: var(--muted); }
.invoice-table__action { text-align: right; vertical-align: middle; }
.invoice-table td:nth-child(2) { white-space: nowrap; }

.is-voided td:not(.invoice-table__action) { color: var(--muted); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 1px;
}

.empty {
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty p { margin: 0; max-width: 60ch; }
.empty .empty__title { margin-bottom: 6px; color: var(--ink); font-weight: 600; }

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  font-size: 0.9375rem;
}
.pager a:last-child { justify-self: end; }
.pager__status { color: var(--muted); }

/* ------------------------------------------------------------ Móvil */

@media (max-width: 760px) {
  .site-header__inner, .site-main, .site-footer__inner { padding-left: 16px; padding-right: 16px; }
  .site-main { padding-top: 28px; }
  .account__email { display: none; }

  .toolbar__year { flex: 1 1 140px; }

  .table-wrap { background: none; border: 0; overflow: visible; }
  .invoice-table thead { display: none; }
  .invoice-table, .invoice-table tbody, .invoice-table tr, .invoice-table td { display: block; }
  .invoice-table tr {
    position: relative;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .invoice-table td { padding: 2px 0; border: 0; max-width: none; min-width: 0; }
  .invoice-table td[data-label="Tipo"], .invoice-table td[data-label="Fecha"] { color: var(--muted); font-size: 0.875rem; }
  .invoice-table__number { padding-right: 110px !important; }
  .invoice-table td[data-label="Importe"] {
    position: absolute;
    top: 14px;
    right: 16px;
    font-weight: 600;
  }
  .invoice-table td[data-label="Concepto"] { margin-top: 6px; }
  .invoice-table__action { margin-top: 12px; text-align: left; }
  .invoice-table__action .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
