/* =========================================================================
   Arrange — dashboard styles
   Reuses the tokens from styles.css (colours, fonts, radius). Only the
   dashboard-specific pieces live here, so the landing page stays untouched.
   ========================================================================= */

.dash-body {
  background: var(--ink-900);
  min-height: 100vh;
}

/* The dashboard canvas sits behind the content, like the hero on the landing
   page, but calmer and full-height. */
.dash {
  position: relative;
  min-height: calc(100vh - 72px);
  padding: 3rem 1.25rem 4rem;
  max-width: var(--maxw);
  margin: 0 auto;
}

.dash__canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

.dash__gate,
.dash__main {
  position: relative;
  z-index: 1;
}

/* ---------- Sign-in gate ---------- */
.dash__gate {
  display: grid;
  place-items: center;
  min-height: 60vh;
}

.dash__gate-inner {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  backdrop-filter: blur(8px);
}

.dash__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  margin: 0 0 0.4rem;
}

.dash__title em { color: var(--amber); font-style: italic; }

.dash__lede { color: var(--muted); font-size: 0.96rem; margin: 0 0 1.4rem; }
.dash__link { color: var(--amber); }
.dash__link:hover { text-decoration: underline; }
.dash__fine { color: var(--faint); font-size: 0.8rem; margin: 1rem 0 0; }

/* Advanced: paste an API key instead of signing in. */
.gate__advanced { margin-top: 1.2rem; }
.gate__advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.3rem 0;
}
.gate__advanced summary:hover { color: var(--text); }
.gate__advanced .form { margin-top: 0.9rem; }

/* ---------- Head: email + balance ---------- */
.dash__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

.dash__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--faint);
  margin: 0 0 0.3rem;
}

.dash__email {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.9rem;
  margin: 0;
  word-break: break-all;
}

.balance {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 176, 87, 0.06);
}

.balance__num {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.balance__label { color: var(--muted); font-size: 0.85rem; }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  background: rgba(255, 255, 255, 0.02);
}

.stat__num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat__label { color: var(--muted); font-size: 0.82rem; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  padding: 1.6rem;
  margin-bottom: 1.4rem;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.card__title { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin: 0; }
.card__note { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.1rem; }

.pill {
  font-size: 0.72rem;
  color: var(--amber);
  border: 1px solid rgba(255, 176, 87, 0.4);
  background: rgba(255, 176, 87, 0.08);
  border-radius: 999px;
  padding: 0.25em 0.7em;
  white-space: nowrap;
}

/* ---------- Plans ---------- */
.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.plan {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.015);
  display: grid;
  gap: 0.35rem;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.plan:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.plan__name { font-weight: 600; }
.plan__credits { color: var(--cyan); font-size: 0.9rem; }
.plan__price { color: var(--muted); font-size: 0.85rem; }
.plan button { margin-top: 0.4rem; }

/* ---------- Custom top-up ---------- */
.topup {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.field--inline { flex: 1 1 220px; }

/* ---------- Select (matches the text inputs) ---------- */
.select {
  width: 100%;
  padding: 0.75rem 2.2rem 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 4px rgba(255, 176, 87, 0.15); }
.select option { background: var(--ink-700); color: var(--text); }

/* ---------- Try-a-call output ---------- */
#tryOut { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
#tryQuality.quality-badge { padding: 0.25em 0.7em; }

/* ---------- Keys table ---------- */
.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.keys th {
  text-align: left;
  font-weight: 500;
  color: var(--faint);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.6rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.keys td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  vertical-align: middle;
}

.keys td:first-child code { color: var(--text); }

.keybox--inline { margin: 0 0 1rem; padding: 0.7rem 0.9rem; }

/* ---------- Activity ---------- */
.activity { list-style: none; margin: 0; padding: 0; }

.activity li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.activity li:last-child { border-bottom: none; }

.act__left { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.act__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.act__dot--purchase { background: var(--ok); }
.act__dot--usage { background: var(--amber); }
.act__what { color: var(--text); }
.act__when { color: var(--faint); font-size: 0.82rem; white-space: nowrap; }
.act__amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.act__amount--add { color: var(--ok); }
.act__amount--spend { color: var(--muted); }

.empty { color: var(--faint); font-size: 0.9rem; margin: 0.4rem 0 0; }

/* ---------- Footer (slim) ---------- */
.foot--slim { margin-top: 0; }
.foot--slim .foot__inner { justify-content: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--ink-600);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
  max-width: 90vw;
}

.toast--ok { border-color: rgba(111, 227, 160, 0.5); }
.toast--err { border-color: rgba(255, 122, 122, 0.5); }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .dash__head { align-items: flex-start; }

  /* Turn the keys table into stacked cards so no column is lost on a phone.
     Each cell shows its own heading via the data-label attribute that
     dashboard.js sets, so "Created" / "Last used" stay readable. */
  .keys thead { display: none; }
  .keys, .keys tbody, .keys tr, .keys td { display: block; width: 100%; }
  .keys tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.6rem;
  }
  .keys td { border: none; padding: 0.25rem 0; display: flex; justify-content: space-between; gap: 1rem; }
  .keys td::before {
    content: attr(data-label);
    color: var(--faint);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .keys td:last-child { justify-content: flex-end; margin-top: 0.3rem; }
}
