/*
 * Admin + demo styling.
 *
 * A neutral scale with a slight cool bias rather than pure grey, and a single
 * indigo accent. Semantic colours (success / warning / danger) are kept separate
 * from the accent so a status pill never reads as a call to action.
 */

:root {
  --canvas: #f7f8f9;
  --surface: #ffffff;
  --muted: #f1f3f5;

  --border: #e4e7ea;
  --border-strong: #d3d8dd;

  --ink: #1c2024;
  --ink-soft: #5c6570;
  --ink-faint: #8b939d;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;

  --success: #14804a;
  --success-soft: #e7f5ed;
  --warning: #9a6400;
  --warning-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;

  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Digits line up in tables. */
.tabular {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--ink-soft);
}
.small {
  font-size: 0.8125rem;
}

/* --- Layout -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(255 255 255 / 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: 4px;
  font-size: 0.875rem;
}

.topnav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
}

.topnav a:hover {
  background: var(--muted);
  color: var(--ink);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.backlink {
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-decoration: none;
}
.backlink:hover {
  color: var(--ink);
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}
.btn:hover {
  background: var(--accent-hover);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover {
  background: var(--muted);
  color: var(--ink);
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

/* --- Cards / stats ------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-head {
  padding: 18px 20px 10px;
}
.card-body {
  padding: 0 20px 20px;
}

.grid {
  display: grid;
  gap: 12px;
}
.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat-value {
  margin: 6px 0 0;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat-value.warning {
  color: var(--warning);
}
.stat-value.danger {
  color: var(--danger);
}
.stat-hint {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--muted);
  color: var(--ink-soft);
}
.badge-success {
  background: var(--success-soft);
  color: var(--success);
}
.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}

.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}

.log-wrap {
  max-height: 28rem;
  overflow: auto;
}
.log-url {
  font-family: var(--mono);
  font-size: 0.75rem;
  word-break: break-all;
}

/* --- Forms --------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 460px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"] {
  height: 36px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  width: 100%;
}

.hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
}
.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}
.alert-ok {
  background: var(--success-soft);
  color: var(--success);
}
.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.search-row {
  display: flex;
  gap: 8px;
  max-width: 420px;
}

/* --- Empty state --------------------------------------------------------- */

.empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty p {
  margin: 0 auto;
  max-width: 42ch;
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.875rem;
}

/* --- Code ---------------------------------------------------------------- */

pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* --- Store cards --------------------------------------------------------- */

.store-card {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}
.store-card:hover {
  border-color: var(--border-strong);
}

.store-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.store-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 0;
  font-size: 0.75rem;
}
.store-card dt {
  color: var(--ink-faint);
}
.store-card dd {
  margin: 2px 0 0;
  font-weight: 500;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.875rem;
}
.rows > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.rows dt {
  color: var(--ink-faint);
}
.rows dd {
  margin: 0;
}

/* --- Landing ------------------------------------------------------------- */

/* The landing page brings its own stylesheet (static/landing.css), which
   re-points the tokens above and supplies its own layout. What stays here are
   the pieces shared with the pages that do not: the eyebrow and lede below,
   which not_found.html and maintenance.html also use. */

/* Sign-in and sign-up centre a card in the viewport and have no header of
   their own, so the picker gets a strip of its own rather than being dropped
   into that layout. */
.auth-topbar {
  display: flex;
  justify-content: flex-end;
  max-width: 928px;
  margin: 0 auto;
  padding: 20px 24px 0;
}

/* --- Language picker ------------------------------------------------------ */

.lang-picker {
  position: relative;
}
.lang-picker > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 6px 0 3px;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
  color: var(--ink-soft);
}
/* Safari renders a disclosure triangle from a pseudo-element the standard
   `list-style: none` above does not reach. */
.lang-picker > summary::-webkit-details-marker {
  display: none;
}
.lang-picker > summary:hover {
  background: var(--muted);
}
.lang-picker > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lang-flag {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  /* The flags are light; without this the white bands bleed into a white page
     and the circle loses its edge. */
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
}
.lang-caret {
  width: 12px;
  height: 12px;
  flex: none;
  transition: transform 0.15s ease;
}
.lang-picker[open] > summary .lang-caret {
  transform: rotate(180deg);
}
@media (prefers-reduced-motion: reduce) {
  .lang-caret {
    transition: none;
  }
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 160px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(15 23 42 / 0.12);
}
.lang-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--ink);
}
.lang-menu a:hover {
  background: var(--muted);
}
.lang-menu a[aria-current="true"] {
  font-weight: 600;
}

.eyebrow {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.lede {
  margin: 20px 0 0;
  max-width: 54ch;
  font-size: 1.0625rem;
  color: var(--ink-soft);
}

/* --- Auth ---------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth .card {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}
.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Rule with a centred label, separating the OAuth button from the form. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--ink-faint);
  font-size: 0.8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Demo storefront ----------------------------------------------------- */

.demo-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.demo-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.demo-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.product-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-top: 24px;
}
.product-tile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}
.product-tile:hover {
  border-color: var(--border-strong);
}
.product-tile .thumb {
  aspect-ratio: 1;
  background: var(--muted);
}
.product-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-tile .meta {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.product-tile .name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
}
.product-tile .price {
  margin: auto 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
