/* ==========================================================================
   Thorix Client Portal — reuses the site's brand tokens (css/styles.css) and
   the admin dashboard's layout language (.admin-shell/.admin-panel/etc, see
   admin/css/admin.css) so the two internal tools read as siblings. Portal-
   only rules (stage tracker, draft cards, ticket list) live here.
   ========================================================================== */

[hidden] { display: none !important; }

.admin-body { background: var(--panel); min-height: 100vh; }
.admin-body--centered { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

.login-card {
  width: 100%; max-width: 24rem;
  background: var(--black); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 2.5rem;
}

.admin-form { display: flex; flex-direction: column; gap: 1.1rem; }
.admin-field { display: flex; flex-direction: column; gap: 0.4rem; }
.admin-field label { font-family: var(--font-body); font-weight: 600; font-size: 0.85rem; color: var(--paper); }
.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field input[type="password"],
.admin-field textarea {
  padding: 0.7rem 0.85rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--black);
  color: var(--paper); font-family: var(--font-body); font-size: 0.95rem;
}
.admin-field textarea { min-height: 6rem; resize: vertical; }
.admin-field input:focus, .admin-field textarea:focus { outline: 2px solid var(--copper); outline-offset: 1px; }
.admin-field input:focus-visible, .admin-field textarea:focus-visible { outline: 2px solid var(--copper); outline-offset: 1px; }
.admin-error { color: #FF6B6B; font-size: 0.85rem; min-height: 1.2em; }
.admin-success { color: var(--success); font-size: 0.85rem; min-height: 1.2em; }

.admin-gate {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.75rem; text-align: center; padding: 1.5rem;
}
.admin-gate__text { font-size: 0.9rem; }

.admin-topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--black); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
}
.admin-topbar__actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.admin-btn-sm { padding: 0.6rem 1.1rem; font-size: 0.85rem; }

.admin-shell { max-width: 48rem; margin-inline: auto; padding: 2rem 1.5rem 5rem; display: flex; flex-direction: column; gap: 1.75rem; }

.admin-panel { background: var(--black); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 1.75rem; }
.admin-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.admin-panel__head h2 { font-size: 1.05rem; font-family: var(--font-display); }
.admin-panel__lede { font-size: 0.88rem; color: var(--muted); margin-top: -0.75rem; margin-bottom: 1.25rem; }

/* ---- Stage tracker — the portal's signature element. A horizontal rail on
   desktop, a vertical one on mobile; filled = done, ringed = current, dim =
   ahead. Encodes something real (the client's actual build stage), not a
   decorative 01/02/03. ---- */
.stage-tracker { display: flex; flex-direction: column; gap: 0; }
@media (min-width: 640px) { .stage-tracker { flex-direction: row; align-items: flex-start; } }

.stage-tracker__step {
  flex: 1; display: flex; flex-direction: row; gap: 0.85rem; position: relative; padding-bottom: 1.5rem;
}
@media (min-width: 640px) { .stage-tracker__step { flex-direction: column; gap: 0.6rem; padding-bottom: 0; padding-right: 0.85rem; } }

.stage-tracker__rail {
  width: 2px; align-self: stretch; background: var(--line-strong); flex-shrink: 0;
  margin-left: 11px;
}
@media (min-width: 640px) {
  .stage-tracker__rail { width: auto; height: 2px; align-self: auto; margin-left: 0; margin-top: 11px; }
}
.stage-tracker__step:last-child .stage-tracker__rail { display: none; }

.stage-tracker__dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--line-strong); background: var(--black);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted);
  position: absolute; top: 0; left: 0;
}
@media (min-width: 640px) { .stage-tracker__dot { position: static; } }
.stage-tracker__row { display: flex; align-items: flex-start; gap: 0.85rem; }
@media (min-width: 640px) { .stage-tracker__row { flex-direction: column; gap: 0.6rem; } }
.stage-tracker__label { padding-left: 2.7rem; font-size: 0.85rem; color: var(--muted); }
@media (min-width: 640px) { .stage-tracker__label { padding-left: 0; } }

.stage-tracker__step--done .stage-tracker__dot { border-color: var(--copper); background: var(--copper); color: var(--black); }
.stage-tracker__step--done .stage-tracker__rail { background: var(--copper); }
.stage-tracker__step--done .stage-tracker__label { color: var(--paper); }

.stage-tracker__step--current .stage-tracker__dot {
  border-color: var(--copper); color: var(--copper-light);
  box-shadow: 0 0 0 4px rgba(217, 130, 59, 0.18);
}
.stage-tracker__step--current .stage-tracker__label { color: var(--paper); font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .stage-tracker__step--current .stage-tracker__dot { animation: stage-pulse 2.4s ease-in-out infinite; }
}
@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(217, 130, 59, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(217, 130, 59, 0.10); }
}

/* ---- Draft links ---- */
.draft-list { display: flex; flex-direction: column; gap: 0.75rem; }
.draft-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 1rem 1.1rem;
}
.draft-card__label { font-family: var(--font-display); font-size: 0.95rem; color: var(--paper); }
.draft-card__note { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.draft-card__empty, .ticket-list__empty { font-size: 0.88rem; color: var(--muted); }

/* ---- Tickets ---- */
.ticket-list { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 1.5rem; }
.ticket-card {
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.ticket-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.ticket-card__subject { font-family: var(--font-display); font-size: 0.95rem; color: var(--paper); }
.ticket-card__message { font-size: 0.88rem; color: var(--muted); white-space: pre-wrap; }
.ticket-card__reply {
  border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: 0.2rem;
  font-size: 0.88rem; color: var(--paper); white-space: pre-wrap;
}
.ticket-card__reply-label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--copper-light); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; }

.status-badge {
  font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem; border-radius: 100px; border: 1px solid var(--line-strong); color: var(--muted);
  flex-shrink: 0;
}
.status-badge--open { color: var(--copper-light); border-color: var(--copper); }
.status-badge--in_progress { color: var(--paper); border-color: var(--line-strong); }
.status-badge--resolved { color: var(--success); border-color: var(--success); }
.status-badge--current { color: var(--success); border-color: var(--success); }
.status-badge--failed { color: #FF6B6B; border-color: #FF6B6B; }
.status-badge--cancelled { color: var(--muted); border-color: var(--line-strong); }
.status-badge--fast { color: var(--success); border-color: var(--success); }
.status-badge--normal { color: var(--copper-light); border-color: var(--copper); }
.status-badge--slow { color: #FF6B6B; border-color: #FF6B6B; }

/* ---- Sub-nav (portal/js/dashboard.js buildPortalSubnav) ---- */
.portal-subnav {
  position: sticky; top: 5.5rem; z-index: 15;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  background: var(--black); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0.6rem;
}
.portal-subnav__link {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted);
  padding: 0.4rem 0.75rem; border-radius: 6px; border: 1px solid transparent;
  text-decoration: none; min-height: 44px; display: inline-flex; align-items: center;
}
.portal-subnav__link:hover, .portal-subnav__link:focus-visible {
  color: var(--paper); border-color: var(--line-strong); outline: none;
}
.portal-subnav__link:focus-visible { outline: 2px solid var(--copper); outline-offset: 1px; }
@media (max-width: 640px) { .portal-subnav { position: static; } }

/* ---- Site health tiles ---- */
.health-grid { display: flex; flex-direction: column; gap: 1.1rem; }
.health-card {
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 1.1rem;
}
.health-card__label { font-family: var(--font-display); font-size: 0.95rem; color: var(--paper); margin-bottom: 0.85rem; }
.health-tile-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 560px) { .health-tile-row { grid-template-columns: repeat(4, 1fr); } }
.health-tile {
  background: var(--black); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.85rem 1rem;
}
.health-tile__value { font-family: var(--font-display); font-size: 1.3rem; color: var(--paper); }
.health-tile__unavailable { font-family: var(--font-body); font-size: 0.85rem; color: var(--muted); }
.health-tile__label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.2rem; }
.health-storage { margin-top: 0.85rem; }
.health-storage__bar { height: 8px; border-radius: 4px; background: var(--black); border: 1px solid var(--line); overflow: hidden; margin-top: 0.4rem; }
.health-storage__fill { height: 100%; background: var(--copper); border-radius: 4px; }
.health-countries { margin-top: 0.85rem; }
.health-countries .client-card__head { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.health-countries .client-card__head:last-child { border-bottom: none; }

/* ---- Billing ---- */
.billing-overdue-banner {
  background: rgba(193, 68, 58, 0.12); border: 1px solid #FF6B6B; border-radius: 8px;
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
}
.billing-overdue-banner__title { font-family: var(--font-display); font-size: 1rem; color: var(--paper); }
.billing-overdue-banner__details { font-size: 0.9rem; color: var(--muted); }

.invoice-list { display: flex; flex-direction: column; gap: 0.6rem; }
.invoice-row {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 0.85rem 1rem;
}
.invoice-row__desc { flex: 1; min-width: 10rem; }
.invoice-row__desc p:first-child { font-size: 0.9rem; color: var(--paper); }
.invoice-row__amount { font-family: var(--font-mono); font-size: 0.88rem; color: var(--paper); }

@media (max-width: 600px) {
  .admin-topbar { flex-direction: column; align-items: stretch; }
}
