/* Registration + dashboard styles.
 *
 * Palette, type scale, spacing scale and base element styles come from
 * tokens.css, which the marketing site uses too - link that first. Everything
 * here is on those scales, so the app and the site that sells it read as one
 * product rather than two.
 */

/* ---------- App header ---------- */
/* Deliberately the same shape as the marketing header: same logo height, same
   44px controls, same hairline. Moving between doc-vault.dev and the dashboard
   should not feel like changing sites. */
header {
  padding: var(--sp-3) var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
header a.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
header a.logo img { height: 26px; width: auto; display: block; }

header nav {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
/* Header links are real targets, matching the marketing nav. They used to be
   0.9rem text with a 16px left margin - about 20px tall, well under a finger. */
header nav a, header nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
}
header nav a:hover, header nav button:hover { background: var(--ink); color: var(--white); }

/* ---------- Layout ---------- */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-12) var(--gutter) var(--sp-20);
}
main.wide { max-width: 720px; }
main.dash { max-width: 960px; }

h1 { font-size: var(--fs-3xl); margin: 0 0 var(--sp-2); }
.lede {
  color: var(--slate);
  font-size: var(--fs-md);
  margin: 0 0 var(--sp-8);
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--sp-7);
}
.card + .card { margin-top: var(--sp-5); }

.section-title { font-size: var(--fs-xl); margin: var(--sp-8) 0 var(--sp-3); }
.section-title:first-child { margin-top: 0; }
.help-text { font-size: var(--fs-xs); color: var(--slate); margin-top: var(--sp-2); }

/* ---------- Forms ---------- */
label {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-sm);
  margin: var(--sp-5) 0 var(--sp-2);
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  /* 16px minimum, or iOS Safari zooms the page on focus - which on this form
     is exactly the kind of thing that produces a sideways-scrolling page. */
  font-size: var(--fs-base);
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
}
input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.domain-hint {
  font-size: var(--fs-xs);
  color: var(--slate);
  margin-top: var(--sp-2);
  /* The preview grows as the customer types and can outrun a phone's width. */
  overflow-wrap: anywhere;
}

.packages { display: grid; gap: var(--sp-2); margin-top: var(--sp-2); }
.package {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: var(--sp-3) var(--sp-4);
  min-height: var(--tap);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.package:hover { border-color: #B9CDE8; }
.package:has(input:checked) { border-color: var(--blue); background: #EEF4FF; }
.package:has(input:focus-visible) { outline: 2px solid var(--blue-deep); outline-offset: 2px; }
.package input { margin: 0; flex-shrink: 0; accent-color: var(--blue); }
.package .name { font-weight: 500; font-size: var(--fs-sm); }
.package .detail {
  color: var(--slate);
  font-size: var(--fs-xs);
  margin-left: auto;
  text-align: right;
}

/* ---------- Buttons ---------- */
button[type="submit"], .btn-primary, .btn-secondary {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-xs);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: inherit;
  line-height: var(--lh-snug);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
button[type="submit"], .btn-primary {
  margin-top: var(--sp-7);
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--white);
}
button[type="submit"]:disabled, .btn-primary.disabled {
  background: var(--slate);
  border-color: var(--slate);
  cursor: not-allowed;
}
button[type="submit"]:not(:disabled):hover,
.btn-primary:not(.disabled):hover { background: var(--blue-deep); border-color: var(--blue-deep); }

.btn-secondary {
  border: 1px solid var(--line-dark);
  background: var(--white);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--ink); color: var(--white); }

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

.error {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-xs);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: var(--fs-sm);
  display: none;
}

/* ---------- Result / key-value rows ---------- */
.result h2 { font-size: var(--fs-2xl); margin: 0 0 var(--sp-1); }
.result .warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-xs);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  margin: var(--sp-4) 0;
}
.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.field-row:last-child { border-bottom: none; }
.field-row .k { color: var(--slate); flex-shrink: 0; }
.field-row .v {
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: right;
  /* Usernames, emails and one-time passwords are all long unbroken strings;
     without this they widen the card past the viewport. */
  overflow-wrap: anywhere;
  min-width: 0;
}

.links { margin-top: var(--sp-5); display: grid; gap: var(--sp-2); }
.links a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--blue);
  text-decoration: none;
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.links a:hover { border-color: var(--blue); }

/* ---------- Dashboard ---------- */
.dash-user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.dash-user .who {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  min-width: 0;
}
.dash-user .who > span:not(.avatar) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--blue-tint);
  color: var(--blue-deep);
  display: grid;
  place-items: center;
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}
.btn-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
}
.btn-quiet:hover { background: var(--ink); color: var(--white); }

.dash-hero { margin-bottom: var(--sp-10); }
.dash-hero h1 { font-size: var(--fs-3xl); margin-bottom: var(--sp-3); }
.dash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  color: var(--slate);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.dash-meta .mono { font-family: var(--font-mono); color: var(--ink-soft); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin: 0 0 var(--sp-4);
}
.section-head h2 { font-size: var(--fs-xl); margin: 0; }
.section-head .count { font-size: var(--fs-xs); color: var(--slate); white-space: nowrap; }
.dash-section + .dash-section { margin-top: var(--sp-12); }

/* Service cards */
.service-grid {
  display: grid;
  /* 240px rather than 260px: at 320px viewport minus gutters a 260px minimum
     forces the track wider than the column and the row scrolls sideways. */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
}
.service {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.service:hover { border-color: #C3D5EC; box-shadow: var(--shadow-sm); }
.service.is-active { border-color: var(--blue-tint); }
.service-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--bg-2);
  color: var(--blue-deep);
  display: grid;
  place-items: center;
  margin-bottom: var(--sp-4);
}
.service.is-active .service-icon { background: var(--blue-tint); }
.service-icon svg { width: 21px; height: 21px; }
.service h3 {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: var(--lh-snug);
  margin: 0 0 var(--sp-1);
}
.service .vendor { font-size: var(--fs-xs); color: var(--slate); margin: 0 0 var(--sp-4); }
.service .blurb {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: var(--lh-normal);
  margin: 0 0 var(--sp-4);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  font-weight: 500;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  color: var(--slate);
  align-self: flex-start;
  margin-bottom: var(--sp-4);
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
  flex-shrink: 0;
}
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.pending { background: var(--warn-bg); color: var(--warn-fg); }

.service-url {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-4);
  min-width: 0;
}
.service-url code {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.icon-btn {
  background: none;
  border: none;
  /* 32px is below the 44px ideal, but this sits inside a fixed-height URL row
     next to truncated text; forcing 44 would break the row. It is a
     convenience duplicate of a link, never the only way to do anything. */
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--slate);
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--blue); background: var(--blue-tint); }
.icon-btn svg { width: 15px; height: 15px; }

.service-actions {
  margin-top: auto;
  display: flex;
  gap: var(--sp-2);
}
.service-actions .btn-open,
.service-actions .btn-add,
.service-actions .btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-xs);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  border: 1px solid transparent;
  white-space: nowrap;
}
.service-actions .btn-open { flex: 1; background: var(--blue); border-color: var(--blue); color: var(--white); }
.service-actions .btn-open:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.service-actions .btn-add { flex: 1; background: var(--white); border-color: var(--blue); color: var(--blue); }
.service-actions .btn-add:hover { background: var(--blue-tint); }
.service-actions .btn-remove {
  background: var(--white);
  border-color: var(--line);
  color: var(--slate);
  padding: 0 var(--sp-3);
  flex-shrink: 0;
}
.service-actions .btn-remove:hover { color: var(--danger); border-color: var(--danger); }
.service-actions button:disabled { opacity: .55; cursor: progress; }

.provisioning-note {
  display: flex;
  gap: var(--sp-3);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-xs);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  margin-bottom: var(--sp-5);
}

/* Account rows */
.account-card .field-row { padding: var(--sp-4) 0; }
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}
.link-out {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0 var(--sp-4);
  background: var(--white);
}
.link-out:hover { border-color: var(--blue); color: var(--blue); }
.link-out svg { width: 14px; height: 14px; flex-shrink: 0; }

.danger-zone {
  border: 1px solid #F0C9C7;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: var(--sp-6) var(--sp-7);
}
.danger-zone h3 {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--danger);
  margin: 0 0 var(--sp-2);
}
.danger-zone p { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; line-height: var(--lh-normal); }
.danger-zone button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  margin-top: var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-xs);
  background: var(--white);
  color: var(--danger);
  border: 1px solid var(--danger);
  cursor: pointer;
}
.danger-zone button:hover:not(:disabled) { background: var(--danger-bg); }
.danger-zone button:disabled { opacity: .5; cursor: not-allowed; border-color: var(--line); color: var(--slate); }

/* ---------- Loading skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, #F2F6FD 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: var(--radius-xs);
  color: transparent !important;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- Modal ---------- */
dialog.modal {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  max-width: 440px;
  width: calc(100% - var(--sp-8));
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(12, 28, 53, .45); }
.modal-body { padding: var(--sp-7); }
.modal-body h2 { font-size: var(--fs-2xl); margin: 0 0 var(--sp-3); }
.modal-body p { font-size: var(--fs-sm); line-height: var(--lh-normal); color: var(--ink-soft); margin: 0 0 var(--sp-2); }
.modal-body label { margin-top: var(--sp-5); }
.modal-warn {
  background: var(--danger-bg);
  border-radius: var(--radius-xs);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--danger);
  margin: var(--sp-4) 0 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-7) var(--sp-6);
}
.modal-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-xs);
  cursor: pointer;
  border: 1px solid var(--line-dark);
  background: var(--white);
  color: var(--ink);
}
.modal-actions button:hover { border-color: var(--blue); color: var(--blue); }
.modal-actions .confirm {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}
.modal-actions .confirm:hover:not(:disabled) { background: #8C1E1A; border-color: #8C1E1A; color: var(--white); }
.modal-actions .confirm:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  transform: translateX(-50%);
  display: grid;
  gap: var(--sp-2);
  z-index: 50;
  width: max-content;
  max-width: calc(100% - var(--sp-8));
}
.toast {
  background: var(--ink);
  color: var(--white);
  font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-xs);
  box-shadow: 0 6px 20px rgba(12, 28, 53, .25);
  animation: toast-in .18s ease-out;
}
.toast.bad { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  /* The header wraps to two rows rather than letting the identity block
     squeeze the sign-out button off the edge. */
  header { padding: var(--sp-3) var(--gutter); }
  header a.logo img { height: 23px; }
  .dash-user { width: 100%; justify-content: space-between; }

  /* One action per row: two full-width buttons side by side leave no room for
     either label. */
  .service-actions { flex-wrap: wrap; }
  .service-actions .btn-open, .service-actions .btn-add { flex: 1 1 100%; }
  .service-actions .btn-remove { flex: 1 1 100%; }

  .account-actions .link-out { flex: 1 1 100%; justify-content: center; }

  /* Plan name and price stop competing for one line - side by side, the price
     wrapped to two lines and squeezed "Business Pro" onto two of its own. */
  .package { display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); }
  .package input { grid-row: span 2; align-self: center; }
  .package .name { grid-column: 2; }
  .package .detail { grid-column: 2; margin-left: 0; text-align: left; }

  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}
