/* Partner portal — docs/qcf-ui-ux.md §6.
   Tokens and shared components come from /qcf.css; this is layout only.

   §11: mobile-first. The partner mostly opens this on a phone right after an
   alert lands, so the single-column phone layout is the base case and the desk
   layout is the enhancement — not the other way round. */

/* ------------------------------------------------------------------ header */

.portal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.portal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  max-width: 940px;
  margin: 0 auto;
  padding: var(--s2) var(--s3);
}
.logo {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.identity {
  font-size: var(--text-small);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.portal-main {
  max-width: 940px;
  margin: 0 auto;
  padding: var(--s3) var(--s3) var(--s6);
}

/* ------------------------------------------------------------- sign-in */

.signin {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  max-width: 420px;
  margin: var(--s5) auto;
  text-align: center;
}
.signin .lede {
  font-size: var(--text-body);
}

/* --------------------------------------------------------- device header
   §6.1: top = the Status Light + live check-in. Sticks under the app bar so
   the live state stays visible while the partner scrolls a long report. */

.device-bar {
  position: sticky;
  top: 61px;
  z-index: 15;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.device-bar-text {
  min-width: 0;
}
.device-bar h1 {
  font-size: var(--text-h2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-bar .muted {
  margin-top: 2px;
}
.device-picker {
  grid-column: 1 / -1;
}
.device-picker select {
  margin-top: 0;
}

/* ------------------------------------------------------------------ tabs
   Horizontally scrollable on a phone rather than wrapping into three rows —
   keeps the content above the fold where the partner expects it. */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--s2);
  padding-bottom: var(--s1);
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tabs button {
  flex: none;
  min-height: 40px;
  padding: 0 var(--s2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--text-small);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tabs button:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.tabs button.active {
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-text);
}

/* ---------------------------------------------------------------- panels */

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.panel-intro {
  color: var(--text-muted);
  font-size: var(--text-small);
  max-width: 68ch;
}
.section-title {
  margin-top: var(--s2);
  font-size: var(--text-small);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Request / rule / charge cards. §6.3 — enough identity to make a safe call. */
.card.request-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card.request-card h3 {
  font-size: 1.0625rem;
}
.card.request-card p {
  color: var(--text-muted);
  font-size: var(--text-small);
  overflow-wrap: anywhere;
}
/* Paths, publishers, and domains are data — mono earns its place here (§2). */
.card.request-card p.identity {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
}
.card.request-card .actions {
  margin-top: var(--s1);
}

/* A VPN/proxy app or an invalid signature has to be impossible to miss — §6.3
   says these cannot be waved through on a broad approval. */
.card.request-card p.error {
  margin-top: 2px;
}

.card.event {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  padding: 12px var(--s3);
}
.card.event strong {
  font-weight: 500;
}
.card.event span {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  color: var(--text-muted);
  white-space: nowrap;
}
/* Tamper events read coral; everything else stays calm. */
.card.event.tamper {
  border-left: 3px solid var(--alert);
}
.card.event.warn {
  border-left: 3px solid var(--warm);
}

/* ---------------------------------------------------------------- forms */

.form-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.form-card.danger {
  border-color: color-mix(in srgb, var(--alert) 40%, var(--border));
}
.form-card h2 {
  font-family: var(--font-display);
}
label.inline {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-weight: 400;
}
label.inline input[type='checkbox'] {
  margin-top: 0;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s2);
  margin-top: var(--s2);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s1);
  margin-top: var(--s2);
}
.check-grid label {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 400;
  text-transform: capitalize;
  cursor: pointer;
}
.check-grid label:hover {
  background: var(--surface-sunken);
}
.check-grid input {
  margin-top: 0;
}

/* Live status line inside a form (enrollment, checkout). Matches #notice so a
   result reads the same wherever it appears. */
#enrollment-status,
#checkout-status {
  min-height: 1.25rem;
  font-size: var(--text-small);
  color: var(--text-muted);
}
#enrollment-status:not(:empty) {
  padding: 10px var(--s2);
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  color: var(--accent-text);
}
#enrollment-status.error {
  background: var(--alert-wash);
  color: var(--alert-text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
}

/* --------------------------------------------------- weekly time grid
   §6.4: a visual weekly grid the partner paints. 7 rows x 48 half-hour
   slots. Scrolls horizontally on a phone; the day label stays pinned so
   you always know which row you're painting. */

.week-grid {
  margin-top: var(--s2);
  overflow-x: auto;
  padding-bottom: var(--s1);
}
.week-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 2px;
}
.week-row strong {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  width: 42px;
  padding-right: var(--s1);
  background: var(--surface);
  font-size: var(--text-mono);
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-muted);
}
/* The slots are drawn as filled squares rather than checkboxes: 336 native
   checkboxes is visual noise, and the grid should read as a painted shape.
   They remain real inputs, so keyboard and screen-reader access is intact. */
.week-row input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 14px;
  height: 22px;
  margin: 0;
  border: 0;
  border-radius: 2px;
  background: var(--alert-wash);
  cursor: pointer;
  transition: background-color 0.1s ease;
}
.week-row input[type='checkbox']:checked {
  background: var(--accent);
}
.week-row input[type='checkbox']:hover {
  outline: 1px solid var(--accent-text);
}
/* Every 4th slot (each 2 hours) gets a subtle gap so the eye can count time. */
.week-row input[type='checkbox']:nth-child(4n + 1) {
  margin-left: 4px;
}

/* -------------------------------------------------------------- licenses */

.card.request-card .key {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------ responsive */

@media (min-width: 720px) {
  .device-bar {
    grid-template-columns: auto 1fr auto;
  }
  .device-picker {
    grid-column: auto;
    min-width: 200px;
  }
  .device-bar h1 {
    font-size: var(--text-h1);
  }
}

@media (max-width: 560px) {
  .portal-main {
    padding: var(--s2) var(--s2) var(--s5);
  }
  .portal-bar {
    padding: var(--s2);
  }
  .device-bar {
    top: 57px;
    padding: var(--s2);
  }
  .card {
    padding: var(--s2);
  }
  /* §11: thumb-reachable Allow/Deny — full width, stacked, nothing to mis-tap. */
  .card.request-card .actions {
    flex-direction: column;
  }
  .card.request-card .actions .button {
    width: 100%;
  }
  .toolbar {
    align-items: stretch;
  }
  .toolbar .actions {
    flex-direction: column;
  }
  .toolbar .actions .button {
    width: 100%;
  }
}
