/* Portal pages (login, admin, top bar). Builds on the dashboard tokens in /dash/style.css. */

/* ---------- auth ---------- */
.auth-body { background: var(--soft); min-height: 100vh; }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 9vh 18px 40px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin: 0 4px 22px; }
.auth-brand b { display: block; font-size: 16px; letter-spacing: -0.01em; }
.auth-brand span { font-size: 12.5px; color: var(--muted); }
.auth-card { padding: 30px 30px 26px; box-shadow: var(--shadow-2); }
.auth-title { font-size: 24px; margin: 0 0 6px; font-weight: 720; letter-spacing: -0.02em; }
.auth-lead { margin: 0 0 22px; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.auth-alt { margin: 18px 0 0; font-size: 13.5px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 22px; }
a { color: var(--series-ink); text-underline-offset: 2px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.field input, .field select { font: inherit; font-size: 15px; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; transition: border-color 0.12s, box-shadow 0.12s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--series); box-shadow: 0 0 0 3px var(--series-soft); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.field small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; flex-wrap: wrap; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--series-ink); }
.err { margin: -6px 0 0; color: var(--bad); font-size: 13px; font-weight: 560; }
.btn-primary { display: inline-flex; justify-content: center; align-items: center; background: var(--series-ink); color: #fff; border: 0; border-radius: var(--r-sm); padding: 11px 18px; font-size: 15px; font-weight: 620; cursor: pointer; text-decoration: none; transition: background 0.12s; }
.btn-primary:hover { background: #174f96; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.flash { border-radius: var(--r-sm); padding: 10px 13px; font-size: 13.5px; margin-bottom: 18px; }
.flash.ok { background: var(--good-bg); color: var(--good); font-weight: 560; }

/* ---------- portal bar ---------- */
:root { --pbar-h: 56px; }   /* portal bar height; the dashboard header sticks right below it */
.pbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; height: var(--pbar-h); padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pbar-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 15px; }
.ui42-logo { display: block; flex: none; border-radius: 50%; }   /* the real ui42 logo (copy of fluidum/public/assets/ui42-logo.svg) */
.pbar-nav { display: flex; gap: 4px; flex: 1; align-items: center; }
.pbar-nav a { color: var(--ink-2); text-decoration: none; font-weight: 540; padding: 6px 11px; border-radius: 8px; }
.pbar-nav a:hover { background: var(--soft); color: var(--ink); }
.pbar-nav a.on { background: var(--series-tint); color: var(--series-ink); }
.pbar-switch select { font: inherit; font-weight: 560; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); }
.pbar-user { display: flex; align-items: center; gap: 12px; }
.pbar-name { color: var(--ink-2); font-size: 13px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar-user form { margin: 0; }
.pflash { max-width: 1240px; margin: 16px auto 0; padding: 0 28px; }

/* ---------- admin pages ---------- */
.pmain { max-width: 1240px; margin: 0 auto; padding: 24px 28px 60px; }
.pmain.narrow { max-width: 760px; }
.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.phead h1 { font-size: 28px; margin: 0; font-weight: 720; letter-spacing: -0.025em; }
.crumb { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.psearch input { min-width: 260px; margin: 0; }
.ptable { padding: 8px 14px; }
.ptable table.data { margin-top: 0; }
.ptable td.row-actions { white-space: nowrap; text-align: right; }
.ptable td.row-actions .btn + .btn { margin-left: 8px; }
.pgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.secs { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.secs legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.sec { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.sec:hover { border-color: var(--axis); }
.sec:has(input:checked) { border-color: #c9ddf6; background: var(--series-tint); }
.sec input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--series-ink); flex: none; }
.sec b { display: block; font-size: 13.5px; font-weight: 620; }
.sec small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 1px; }
.secs.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.secs.compact .sec { padding: 8px 10px; }
.user { border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.user > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.user > summary::-webkit-details-marker { display: none; }
.user[open] > summary { border-bottom: 1px solid var(--line-2); }
.u-main b { display: block; font-size: 14px; color: var(--ink); }
.u-main small { color: var(--muted); font-size: 12.5px; }
.ustate { font-size: 11.5px; font-weight: 620; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.ustate.active { color: var(--good); background: var(--good-bg); }
.ustate.pending { color: var(--series-ink); background: var(--series-tint); }
.ustate.expired { color: var(--bad); background: var(--bad-bg); }
.u-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.u-body .sub { margin: 0; }
.u-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.u-actions form { margin: 0; }
.mailframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 10px; margin-top: 16px; background: var(--soft); }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pcard { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); transition: border-color 0.12s, box-shadow 0.12s; }
.pcard:hover { border-color: var(--axis); box-shadow: var(--shadow-2); }
.pcard b { font-size: 16px; }
.pcard span { color: var(--muted); font-size: 13px; }

.baskets { margin-top: 20px; }
.baskets-row { display: flex; flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.baskets-row .field { flex: 0 0 240px; }
.baskets-row .hint { margin: 0 0 12px; }
.baskets-row .btn-primary:disabled { background: var(--axis); cursor: not-allowed; }
.baskets-status { margin: 14px 0 8px; font-size: 14px; min-height: 1.4em; }
.baskets-status.done { color: var(--good); }
.baskets-status.running { color: var(--series-ink); }
.baskets-status.stopped, .baskets-status.error { color: var(--bad); }

/* ---------- dashboard inside the portal ---------- */
body.in-portal .layout { min-height: auto; }
body.in-portal .top { top: var(--pbar-h); }
body.in-portal .sidebar { top: var(--pbar-h); height: calc(100vh - var(--pbar-h)); }

@media print {
  .pbar { position: static; padding: 0 0 12px; margin-bottom: 8px; }
  .pbar-nav, .pbar-user, .pflash { display: none !important; }
  body.in-portal .top { top: 0; }
}

@media (max-width: 860px) {
  body.in-portal .sidebar { height: auto; }
  .pbar { position: static; height: auto; padding: 10px 16px; gap: 12px; flex-wrap: wrap; }   /* the dashboard header is not sticky on phones either */
  .pbar-name { display: none; }
  .pmain { padding: 18px 16px 44px; }
  .pgrid, .form-2, .secs.compact { grid-template-columns: minmax(0, 1fr); }
  .psearch input { min-width: 0; width: 100%; }
  body.in-portal .top { top: 0; }
}

/* admin: load bought-together right from the stats page */
.together-load { display: inline; margin-left: 6px; }
.together-load .btn { padding: 4px 12px; font-size: 13px; }

/* management page with the project's left menu (same as the stats page) */
.pmanage .pmain { margin: 0; max-width: 1240px; width: 100%; }
.pages button.side-manage { margin-top: 10px; border-top: 1px solid var(--line-2); border-radius: 0 0 var(--r-sm) var(--r-sm); padding-top: 12px; }

/* project list: results per client (data/summary/clients.json) */
.ptable .pdomain { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; text-decoration: none; }
.ptable th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.ptable th[aria-sort="ascending"]::after { content: " ↑"; }
.ptable th[aria-sort="descending"]::after { content: " ↓"; }
.ptable td.delta { white-space: nowrap; color: var(--ink-2); }
.ptable td.delta.up { color: var(--series-ink); font-weight: 600; }
.ptable td.delta.down { color: var(--ink); font-weight: 600; }

/* admins page */
.admin-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.admin-row:first-of-type { border-top: 0; }
.admin-row .u-main { flex: 1; min-width: 0; }
.admin-row .u-actions { display: flex; gap: 8px; margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 4px 0 14px; }
@media (max-width: 720px) { .admin-row { flex-wrap: wrap; } }
.ptable th.st, .ptable td.st { text-align: left; }
