/* The reseller portal: the TBX kit's roomy ("comfortable") density, phone first. 16 px text, 48 px controls,
   56 px rows, one column at most 720 px wide; a tab bar at the bottom on a phone, a rail at the left from 1,024 px. */
.portal { font-size: 16px; line-height: 1.5; background: var(--panel); }
.portal h1 { font-size: 28px; line-height: 1.2; }
.portal .btn, .portal .status-pill { min-height: 48px; padding: 0 20px; }
.portal input[type="text"], .portal input[type="password"], .portal input[type="search"],
.portal input[type="number"], .portal select { min-height: 48px; }
.portal .btn-wide { min-height: 48px; }
.portal .badge { font-size: 14px; }
.portal .dialog { width: min(480px, calc(100vw - 1.5rem)); }

#toasts { bottom: 76px; }

.p-app { min-height: 100vh; display: flex; flex-direction: column; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px;
  padding: 0 1rem; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0;
  z-index: 10; }
.p-brand { display: flex; align-items: center; gap: 0.6rem; font-size: 20px; font-weight: 500; }
.p-credits { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--pill); font-weight: 600; text-decoration: none; }
.p-credits.low { background: var(--warn-bg); color: var(--warn-text); }

.p-main { width: min(720px, 100%); margin: 0 auto; padding: 1.25rem 1rem 7rem; }
.p-stack { display: flex; flex-direction: column; gap: 1.25rem; }
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.p-head h1 { margin: 0; }
.p-head .btn { display: none; }
.p-grid { display: grid; gap: 1rem; }
.p-title, .p-rail-brand { display: none; }

/* The tab bar: five targets, each at least 48 px high. */
.p-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid;
  grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.p-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; color: var(--muted); text-decoration: none; font-size: 13px; }
.p-tabs a.active { color: var(--text); font-weight: 600; }

/* A soft grey group of key figures with hairlines between them: two columns on a phone. */
.p-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.p-stats > div { padding: 1.1rem 1.25rem; background: var(--card); border-radius: var(--radius); }
.p-label { color: var(--muted); font-size: 15px; }
.p-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; }
.p-sub { color: var(--muted); font-size: 14px; }

/* A row that is a link: the whole card is the target, with a chevron. */
.p-card { display: flex; align-items: center; gap: 1rem; min-height: 62px; padding: 0.8rem 1.1rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px; color: var(--text);
  text-decoration: none; }
.p-card:hover { background: var(--card); }
.p-card > .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.p-panel { padding: 1.25rem 1.5rem; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; }
.p-panel h2 { margin-bottom: 0.25rem; }
.p-panel .p-card { min-height: 58px; padding: 0.6rem 0; background: none; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--line); }
.p-panel .p-card:last-child { border-bottom: 0; }
.p-panel .p-card:hover { background: var(--card); }
.p-notice { padding: 1rem; border-radius: 12px; background: var(--tint-warn); }
.p-notice.ok { background: var(--tint-ok); }
.p-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.p-chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 0;
  border-radius: 999px; background: var(--pill); color: var(--text); font: inherit; cursor: pointer; }
.p-chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.p-choice { display: flex; align-items: center; gap: 0.75rem; min-height: 56px; padding: 0.5rem 1rem;
  background: var(--card); border-radius: var(--radius); cursor: pointer; }
.p-choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--accent); background: var(--bg); }
.p-choice .grow { flex: 1; }
.p-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0;
  border-bottom: 1px solid var(--line); }
.p-row:last-child { border-bottom: 0; }
.p-top-line { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.p-top-line h1 { margin: 0; }
.p-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.p-actions .btn { flex: 1 1 auto; }

.p-rail-foot { display: none; }
.p-limit { max-width: 560px; }

@media (min-width: 1024px) {
  #toasts { bottom: 1rem; }
  .p-grid { grid-template-columns: 1fr 1fr; align-items: start; gap: 1.75rem; }
  .p-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0.75rem; }
  .p-stats { grid-template-columns: repeat(4, 1fr); }
  .p-stats.two { grid-template-columns: repeat(2, 1fr); }
  .p-value { font-size: 30px; }
  .p-head .btn { display: inline-flex; }
  .p-head + .p-stats + .p-notice, .p-head ~ .p-notice { margin-top: -0.25rem; }
  .p-actions.col { flex-direction: column; }
  .p-brand { display: none; }
  .p-rail-brand { display: flex; position: absolute; top: 0; left: 0; right: 0; height: 64px; align-items: center;
    padding: 0 1.5rem; }
  .p-rail-brand .p-brand { display: flex; }
  .p-title { display: inline; font-size: 18px; font-weight: 600; }
  .p-top { justify-content: space-between; margin-left: 248px; }
  /* The rail: the pages at the top, who is signed in and Log out at the bottom. */
  .p-tabs { top: 0; right: auto; bottom: 0; width: 248px; display: flex; flex-direction: column; gap: 0.25rem;
    padding: 5rem 0.75rem 1rem; background: var(--shell); border: 0; }
  .p-tabs > a { position: relative; flex-direction: row; justify-content: flex-start; gap: 0.75rem; min-height: 44px;
    padding: 0 0.75rem; border-radius: 10px; font-size: 16px; color: var(--text); }
  .p-tabs > a.active, .p-user.active { background: var(--bg);
    box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.06); }
  .p-tabs > a[data-path="/account"] { display: none; }
  .p-rail-foot { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; padding-top: 0.75rem; }
  .p-tabs .p-user { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.7rem;
    min-height: 56px; padding: 0.5rem 0.75rem; border-radius: 12px; color: var(--text); font-size: 15px;
    text-decoration: none; }
  .p-user:hover { background: rgba(0, 0, 0, 0.05); text-decoration: none; }
  .p-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
  .p-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  .p-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .p-logout { width: 100%; justify-content: flex-start; background: transparent; }
  .p-logout:hover:not(:disabled) { background: var(--pill); }
  .p-signout { display: none; }
  /* The pages use the whole width beside the rail. */
  .p-main { width: auto; max-width: none; margin: 0 0 0 248px; padding: 2rem 2.5rem 3rem; }
}
