/* The application shell: top bar, main column, page headers, and the
 * responsive rules that hold them together from 320px to a wide desktop. */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ------------------------------------------------------------- top bar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: var(--space-2) var(--space-5);
  /* min-height, not height: the bar wraps to a second row when the brand, the
   * nav and the account controls no longer fit across one. */
  min-height: var(--topbar-height);
  padding: var(--space-2) var(--space-6);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand:hover { color: var(--text); }

.brand__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex: none;
}

.brand--lg { font-size: var(--text-2xl); gap: var(--space-3); }
.brand--lg .brand__mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  font-size: var(--text-lg);
}

.nav { display: flex; flex-wrap: wrap; gap: var(--space-1); }

.nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.is-active { background: var(--accent-soft); color: var(--accent); }

.topbar__end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.account-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 22ch;
  padding: var(--space-1) var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}
.account-trigger:hover { background: var(--surface-2); color: var(--text); }
.account-trigger[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }

.avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex: none;
  text-transform: uppercase;
}

/* ---------------------------------------------------------- main column -- */

.main {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-7) var(--space-6) var(--space-10);
}

.main--narrow { max-width: var(--page-narrow); }

.page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.page__head-text { min-width: 0; }
.page__head h1 { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page__lede {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-base);
  max-width: 72ch;
}
.page__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }

/* A row of controls above a table: search, filters, and a bulk-action strip. */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.toolbar__search { flex: 1 1 17rem; min-width: 0; }
.toolbar__spacer { flex: 1 1 auto; }

.toolbar--selection {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.toolbar--selection .toolbar__count {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
}

/* ------------------------------------------------------------ login page -- */

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-6);
}
.login { width: 100%; max-width: 400px; }
.login__brand { display: flex; justify-content: center; margin-bottom: var(--space-6); }
.login__note {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  line-height: var(--leading-relaxed);
}
.login__footer {
  margin-top: var(--space-5);
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.login__footer a { color: var(--text-faint); }

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

/* The link detail page: facts on the left, QR on the right, stacking early
 * because the QR has a hard minimum width worth scanning. */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 760px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); justify-items: start; }
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: var(--space-6);
}

.split--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* `minmax(0, 1fr)`, not `1fr`. A bare `1fr` is `minmax(auto, 1fr)`, whose
 * automatic minimum is min-content -- so a single column would refuse to
 * shrink below the widest unbreakable thing inside it and push the page
 * sideways. Every one-column fallback in this file uses the explicit zero. */
@media (max-width: 800px) {
  .split--sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .topbar { padding: var(--space-2) var(--space-4); gap: var(--space-2); }
  .main { padding: var(--space-6) var(--space-4) var(--space-9); }
  .page__head { flex-direction: column; align-items: stretch; }
  .page__actions .button { flex: 1; }
  thead th,
  tbody td { padding-left: var(--space-4); padding-right: var(--space-4); }
  .card__head,
  .card__body,
  .card__foot { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal__head,
  .modal__body,
  .modal__foot { padding-left: var(--space-4); padding-right: var(--space-4); }
}

/* The signed-in address is the first thing to go: the menu it opens repeats
 * it, so nothing is lost. */
@media (max-width: 860px) {
  .account-trigger__email { display: none; }
}

/* Below this the brand, nav and account cluster cannot share a row at any
 * sane size, so the nav takes one of its own rather than the brand shrinking
 * to its mark. */
@media (max-width: 560px) {
  .nav { order: 3; flex-basis: 100%; justify-content: space-between; }
  .nav a { flex: 1; justify-content: center; padding: var(--space-2); }
  .toolbar { gap: var(--space-2); }
  .toolbar__search { flex-basis: 100%; }
  .pager { justify-content: center; }
  .pager__label { flex-basis: 100%; text-align: center; }
}

/* Print: the chrome is noise on paper, and a table is the only thing worth
 * carrying across. */
@media print {
  .topbar,
  .toolbar,
  .pager,
  .page__actions,
  .skip-link,
  .toasts { display: none !important; }
  .card { box-shadow: none; border-color: #999; }
  body { background: #fff; }
}
