/* ═══════════════════════════════════════════════════════════════════════════
   Vertical Servicios (S05, S06) in the client portal: the subcontractor's pages —
   the access by link (/subcontractor/access, inside the auth layout), the list
   of invitations and one RFQ invitation (SubcontractorLayout). Design-system
   tokens only (light and dark): no fixed colour here.
   ═══════════════════════════════════════════════════════════════════════════ */

.sub-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--gray-50); color: var(--gray-900); }
.sub-shell__bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); }
.sub-shell__label { font-size: 13px; color: var(--gray-600); }
.sub-shell__main { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: var(--space-4) var(--space-4) var(--space-8, 48px); }

.sub-page { display: flex; flex-direction: column; gap: var(--space-4); }
.sub-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--gray-900); }
.sub-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: 13px; color: var(--gray-600); }
.sub-meta span { display: inline-flex; align-items: center; gap: 4px; }
.sub-hint { margin: 0; font-size: 13px; color: var(--gray-600); }
.sub-status { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--gray-100); color: var(--gray-900); }
.sub-status--open { background: var(--green-100); color: var(--green-600); border-color: var(--green-border); }
.sub-status--declined { background: var(--red-100); color: var(--red-600); border-color: var(--red-border); }

.sub-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); }
.sub-card h2, .sub-card h3 { margin: 0; font-size: 16px; color: var(--gray-900); }
.sub-section-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--gray-900); }
.sub-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.sub-files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sub-plain { white-space: pre-line; overflow-wrap: anywhere; color: var(--gray-900); }
.sub-answer { padding-left: var(--space-3); border-left: 3px solid var(--gold-300); }
.sub-notice { padding: var(--space-2) var(--space-3); border-radius: var(--r-md); font-size: 13px;
  background: var(--blue-100); color: var(--blue-700); border: 1px solid var(--blue-300); }
.sub-error { padding: var(--space-2) var(--space-3); border-radius: var(--r-md); font-size: 13px;
  background: var(--red-100); color: var(--red-600); border: 1px solid var(--red-border); }

.sub-form { display: flex; flex-direction: column; gap: var(--space-2); }
.sub-form label, .sub-label { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.sub-input { width: 100%; padding: 10px 12px; border-radius: var(--r-md); font: inherit; font-size: 14px;
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); color: var(--gray-900); }
.sub-input:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 1px; }
.sub-question-input { min-height: 120px; resize: vertical; }
.sub-counter { align-self: flex-end; font-size: 12px; color: var(--gray-600); }
.sub-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }

/* S06: the quote form — one column of cards, fields at full width (mobile first). */
.sub-quote__current { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--gray-50); }
.sub-quote__line { display: flex; flex-direction: column; gap: 2px; padding-bottom: var(--space-2); border-bottom: 1px solid var(--ds-color-border, var(--gray-200)); }
.sub-quote__item { display: flex; flex-direction: column; gap: var(--space-2); margin: 0; padding: var(--space-3); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); min-width: 0; }
.sub-quote__item legend { padding: 0 var(--space-1); }
.sub-quote__notes { min-height: 88px; resize: vertical; }
.sub-check { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; color: var(--gray-900); }
.sub-check input { width: 20px; height: 20px; accent-color: var(--gold-500); }

@media (max-width: 640px) {
  .sub-shell__main { padding: var(--space-3); }
  .sub-actions .auth-btn { flex: 1 1 auto; }
}

/* S11: «Mis tareas» — a simple kanban (one column per stage; columns stack on mobile) and the task's page. Tokens only. */
.sub-links { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: 14px; }
.sub-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); align-items: start; }
.sub-board__col { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--gray-100); min-width: 0; }
.sub-board__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sub-board__title { margin: 0; font-size: 14px; font-weight: 700; color: var(--gray-900); }
.sub-board__count { min-width: 24px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; text-align: center;
  background: var(--ds-color-surface-1, var(--white)); color: var(--gray-600); border: 1px solid var(--ds-color-border, var(--gray-200)); }
.sub-board__card a { display: flex; flex-direction: column; gap: 2px; color: var(--gray-900); text-decoration: none; overflow-wrap: anywhere; }
.sub-board__card a:hover strong, .sub-board__card a:focus-visible strong { text-decoration: underline; }
.sub-board__key { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.sub-status--kind { background: var(--blue-100); color: var(--blue-700); border-color: var(--blue-300); }
.sub-actions--start { justify-content: flex-start; align-items: center; }
.sub-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; font-weight: 600;
  color: var(--gold-500); cursor: pointer; overflow-wrap: anywhere; text-align: left; }
.sub-link:disabled { opacity: .6; cursor: default; }
.sub-mentions { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin: 0; padding: 0; border: 0; }

@media (max-width: 640px) {
  .sub-board { grid-template-columns: 1fr; }
}

/* S14 (SEG-222): «Mis facturas» — the purchase orders it may invoice, its invoices (cards, one column on mobile) and the upload dialog, which takes the
   whole screen on a phone. Tokens only. */
.sub-invoice-order, .sub-invoice { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--gray-50); min-width: 0; overflow-wrap: anywhere; }
.sub-invoice__money { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-1) var(--space-3); margin: 0; }
.sub-invoice__money div { display: flex; flex-direction: column; gap: 2px; }
.sub-invoice__money dt { font-size: 12px; color: var(--gray-600); }
.sub-invoice__money dd { margin: 0; font-weight: 600; color: var(--gray-900); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .crm-modal-overlay:has(.sub-modal-sheet) { padding: 0; }
  .crm-modal.sub-modal-sheet { max-width: 100vw; width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .crm-modal.sub-modal-sheet .crm-modal__body { flex: 1 1 auto; overflow-y: auto; }
  .sub-invoice__money { grid-template-columns: 1fr 1fr; }
}

/* S15 (SEG-223): «Mis pagos» — the lines a payment covers (what and the amount; stacked on the phone). The cards reuse .sub-invoice. Tokens only. */
.sub-payment-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.sub-payment-lines li { display: flex; justify-content: space-between; gap: var(--space-2); padding-top: var(--space-1); min-width: 0;
  border-top: 1px solid var(--ds-color-border, var(--gray-200)); overflow-wrap: anywhere; }
.sub-payment-lines strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 640px) {
  .sub-payment-lines li { flex-direction: column; gap: 2px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   S19 (SEG-228): the portal as an installable app, phone first (375 px). The bar
   (name, language, install, sign out), the navigation — fixed at the bottom of the
   phone with «Más» for the rest, a row of tabs from 768 px —, the start page, «Mis
   documentos», the camera buttons and the upload queue. Tokens only (light and dark).
   ═══════════════════════════════════════════════════════════════════════════ */

.sub-shell { min-height: 100dvh; }
.sub-shell__bar { position: sticky; top: 0; z-index: 30; padding-top: max(var(--space-3), env(safe-area-inset-top)); flex-wrap: wrap; }
.sub-shell__logo { text-decoration: none; }
.sub-shell__tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.sub-shell__me { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--gray-900); }
.sub-tool { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; min-width: 40px; padding: 0 var(--space-2); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); color: var(--gray-900);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; justify-content: center; }
.sub-tool:hover { border-color: var(--gold-500); }
.sub-tool:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 1px; }
.sub-tool:disabled { opacity: .6; cursor: default; }
.sub-tool i { font-size: 18px; }
.sub-shell__body { display: contents; }

.sub-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around;
  padding: 0 0 env(safe-area-inset-bottom); border-top: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); }
.sub-nav__link { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--space-1) 2px; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--gray-600);
  text-decoration: none; cursor: pointer; }
.sub-nav__link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-nav__link i { font-size: 22px; }
.sub-nav__link.active, .sub-nav__link[aria-expanded="true"] { color: var(--gold-500); }
.sub-nav__link:focus-visible { outline: 2px solid var(--gold-500); outline-offset: -2px; }
.sub-nav__link--secondary { display: none; }
.sub-more { position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 41;
  display: flex; flex-direction: column; padding: var(--space-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); }
.sub-more__link { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-3); border-radius: var(--r-md);
  color: var(--gray-900); text-decoration: none; font-weight: 600; }
.sub-more__link i { font-size: 20px; color: var(--gold-500); }
.sub-more__link:hover, .sub-more__link:focus-visible { background: var(--gray-100); outline: none; }
.sub-shell__main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

@media (min-width: 768px) {
  .sub-nav { position: static; bottom: auto; justify-content: center; gap: var(--space-1); padding: 0 var(--space-4);
    border-top: 0; border-bottom: 1px solid var(--ds-color-border, var(--gray-200)); z-index: 29; }
  .sub-nav__link { flex: 0 0 auto; flex-direction: row; min-height: 48px; padding: 0 var(--space-3); font-size: 14px; gap: var(--space-2);
    border-bottom: 2px solid transparent; }
  .sub-nav__link i { font-size: 18px; }
  .sub-nav__link.active { border-bottom-color: var(--gold-500); }
  .sub-nav__link--secondary { display: flex; }
  .sub-nav__more, .sub-more { display: none; }
  .sub-shell__main { padding-bottom: var(--space-8, 32px); }
}

@media (max-width: 480px) {
  .sub-shell__label, .sub-tool__text { display: none; }
  .sub-shell__me { max-width: 110px; }
}

/* The start page: one card per section. */
.sub-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.sub-tile { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-3); border-radius: var(--r-md);
  border: 1px solid var(--ds-color-border, var(--gray-200)); background: var(--ds-color-surface-1, var(--white)); color: var(--gray-900); text-decoration: none; }
.sub-tile > i:first-child { font-size: 26px; color: var(--gold-500); }
.sub-tile__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sub-tile__text span { font-size: 13px; color: var(--gray-600); }
.sub-tile__go { color: var(--gray-500); }
.sub-tile:hover, .sub-tile:focus-visible { border-color: var(--gold-500); outline: none; }
@media (min-width: 768px) { .sub-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* «Mis documentos»: how the W-9 and the insurance stand, and the camera / file buttons (the input is the whole button: a tap opens the camera). */
.sub-health { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.sub-health .sub-card { align-items: flex-start; }
.sub-pick { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sub-pick__button { position: relative; flex: 1 1 160px; justify-content: center; overflow: hidden; cursor: pointer; }
.sub-pick__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.sub-pick__button:focus-within { outline: 2px solid var(--gold-500); outline-offset: 2px; }

/* The upload queue: above the bottom navigation on the phone, under the content on a wide screen. */
.sub-queue { position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 35;
  display: flex; flex-direction: column; gap: var(--space-1); max-height: 40dvh; overflow-y: auto; padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); border: 1px solid var(--ds-color-border, var(--gray-200));
  background: var(--ds-color-surface-1, var(--white)); color: var(--gray-900); font-size: 13px; }
.sub-queue__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.sub-queue__item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-width: 0; }
.sub-queue__name { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sub-queue__item--retrying i { color: var(--orange-500); }
.sub-queue__item--failed i, .sub-queue__item--failed .sub-queue__state { color: var(--red-600); }
.sub-queue__item--sending i { color: var(--gold-500); }
@media (min-width: 768px) { .sub-queue { left: auto; right: var(--space-4); bottom: var(--space-4); width: 380px; } }

.sub-spin { display: inline-block; animation: sub-spin 1s linear infinite; }
@keyframes sub-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sub-spin { animation: none; } }
