/* ==========================================================================
   PATCH STORE — monochrome design system
   Every colour is defined as a token so the two themes stay in sync.
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */

:root {
  color-scheme: dark;

  --bg:            #000000;
  --bg-elevated:   #0a0a0a;
  --surface:       #111111;
  --surface-hover: #171717;
  --border:        #262626;
  --border-strong: #3f3f3f;

  --text:          #fafafa;
  --text-muted:    #a1a1aa;
  --text-subtle:   #71717a;
  --text-inverted: #09090b;

  --accent:        #fafafa;
  --accent-hover:  #e4e4e7;

  --danger:        #f87171;
  --danger-bg:     rgba(248, 113, 113, 0.12);
  --success:       #4ade80;
  --success-bg:    rgba(74, 222, 128, 0.12);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 4px 24px rgba(0, 0, 0, 0.5);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --max-width: 1200px;
  --header-height: 64px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:            #ffffff;
  --bg-elevated:   #ffffff;
  --surface:       #fafafa;
  --surface-hover: #f4f4f5;
  --border:        #e4e4e7;
  --border-strong: #d4d4d8;

  --text:          #09090b;
  --text-muted:    #52525b;
  --text-subtle:   #71717a;
  --text-inverted: #fafafa;

  --accent:        #09090b;
  --accent-hover:  #27272a;

  --danger:        #b91c1c;
  --danger-bg:     rgba(185, 28, 28, 0.08);
  --success:       #15803d;
  --success-bg:    rgba(21, 128, 61, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow:    0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ----------------------------------------------------------------- base -- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 650;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }

img { max-width: 100%; display: block; }

ul { margin: 0; padding: 0; list-style: none; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--text); color: var(--bg); }

/* --------------------------------------------------------------- layout -- */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow { max-width: 780px; }

main { flex: 1 0 auto; }

.section { padding: 40px 0; }
.section-tight { padding: 24px 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 { margin: 0; }

.section-head .link {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.section-head .link:hover { color: var(--text); }

/* --------------------------------------------------------------- header -- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.03em;
  background: var(--surface);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-vendor {
  font-size: 0.68rem;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
}

.site-nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.site-nav a:hover { background: var(--surface); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 0;
}

/* --------------------------------------------------------- theme toggle -- */

.theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle svg { width: 17px; height: 17px; }

/* Only the icon matching the active theme is shown. */
:root[data-theme="dark"] .icon-sun  { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun  { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; }

/* ----------------------------------------------------------------- hero -- */

.hero {
  padding: 56px 0 36px;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 20px;
}

.hero-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  font-weight: 750;
  max-width: 20ch;
  margin-bottom: 14px;
}

.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 56ch;
  margin-bottom: 26px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 30px;
}

.hero-stat { display: flex; flex-direction: column; }
.hero-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

/* --------------------------------------------------------------- search -- */

.search-bar {
  display: flex;
  gap: 8px;
  max-width: 520px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.search-input::placeholder { color: var(--text-subtle); }
.search-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

/* -------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  max-width: 100%;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--surface-hover); border-color: var(--text-subtle); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverted);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverted);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 0.95rem; }

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------------------- chips -- */

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.chip-row::-webkit-scrollbar { height: 4px; }
.chip-row::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[aria-current="page"],
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverted);
  font-weight: 550;
}
.chip-count { opacity: 0.6; font-size: 0.72rem; }

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

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.app-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  position: relative;
  transition: border-color 0.18s ease, background-color 0.18s ease,
              transform 0.18s ease;
}
/* The card title link stretches over the whole tile, so the entire card is a tap
   target on a phone while the markup keeps one link for screen readers. */
.app-card-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.app-card:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.app-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  transform: translateY(-2px);
}

.app-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 13px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--surface);
}

.app-card-body { min-width: 0; flex: 1; }

.app-card-title {
  font-size: 0.95rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 6px;
}
.app-card-meta .dot { opacity: 0.5; }

.app-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--text-subtle);
}

/* ---------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.badge-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverted);
}
.badge-success { color: var(--success); border-color: var(--success); background: var(--success-bg); }
.badge-warn    { color: #fbbf24; border-color: #fbbf24; background: rgba(251,191,36,0.1); }
.badge-danger  { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

/* ------------------------------------------------------------ app detail -- */

.app-hero {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
}

.app-hero-icon {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  border-radius: 22px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--surface);
}

.app-hero-main { min-width: 0; flex: 1; }
.app-hero-main h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin-bottom: 6px; }

.app-hero-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 14px;
}

.app-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 36px;
  align-items: start;
}

.detail-main { min-width: 0; }

.spec-list { border-top: 1px solid var(--border); }
.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.spec-row dt { color: var(--text-subtle); flex-shrink: 0; }
.spec-row dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
  font-weight: 500;
}

.feature-list { display: grid; gap: 9px; }
.feature-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.feature-list li::before {
  content: "";
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--text);
}

.prose {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.75;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.screenshot-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.screenshot-strip img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.aside-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 18px;
  position: sticky;
  top: calc(var(--header-height) + 20px);
}

.aside-card h3 { margin-bottom: 12px; }

.hash-box {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--text-subtle);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  overflow-wrap: anywhere;
  margin-top: 6px;
}

/* ------------------------------------------------------------ page heads -- */

.page-head {
  padding: 32px 0 22px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin-bottom: 6px; }
.page-head p { color: var(--text-muted); font-size: 0.9rem; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-bottom: 10px;
}
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { opacity: 0.5; }

/* ----------------------------------------------------------- pagination -- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.pagination a:hover { background: var(--surface); color: var(--text); }
.pagination .is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverted);
  font-weight: 600;
}
.pagination .gap { border: 0; color: var(--text-subtle); }

/* ---------------------------------------------------------------- empty -- */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.9rem; margin-bottom: 18px; }

/* ---------------------------------------------------------------- forms -- */

.form-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 24px;
}

.field { margin-bottom: 18px; }

.field label,
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.field .hint {
  display: block;
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--text-subtle);
  margin-top: 5px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.input::placeholder,
.textarea::placeholder { color: var(--text-subtle); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--text-subtle);
  background: var(--surface-hover);
}

.input.is-invalid,
.textarea.is-invalid,
.select.is-invalid { border-color: var(--danger); }

.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 11px;
  padding-right: 32px;
}

.field-error {
  display: block;
  color: var(--danger);
  font-size: 0.76rem;
  margin-top: 5px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--text);
  flex-shrink: 0;
  cursor: pointer;
}
.checkbox-row label { margin: 0; font-weight: 500; font-size: 0.85rem; }
.checkbox-row .hint { font-weight: 400; }

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 22px;
}
fieldset legend {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.form-actions .spacer { flex: 1; }

/* ---------------------------------------------------------------- flash -- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.flash-success {
  color: var(--success);
  border-color: var(--success);
  background: var(--success-bg);
}
.flash-error {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}
.flash-info { color: var(--text-muted); background: var(--surface); }

/* ---------------------------------------------------------- admin shell -- */

.admin-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  padding: 28px 0 56px;
}

.admin-side {
  position: sticky;
  top: calc(var(--header-height) + 20px);
}

.admin-side-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 11px;
  margin-bottom: 8px;
}

.admin-nav { display: grid; gap: 2px; margin-bottom: 20px; }

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.admin-nav a:hover { background: var(--surface); color: var(--text); }
.admin-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.admin-nav svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }

.admin-main { min-width: 0; }

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.admin-head h1 { font-size: 1.35rem; }
.admin-head p { color: var(--text-muted); font-size: 0.85rem; margin: 4px 0 0; }

/* ---------------------------------------------------------- stat cards -- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 16px;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat-note { font-size: 0.72rem; color: var(--text-subtle); margin-top: 4px; }

/* --------------------------------------------------------------- panels -- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 22px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 0.95rem; }
.panel-body { padding: 18px; }
.panel-body-flush { padding: 0; }

/* ---------------------------------------------------------------- table -- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table.data th {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  white-space: nowrap;
}

table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface); }

.cell-app { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.cell-app img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}
.cell-app-name { font-weight: 600; line-height: 1.3; }
.cell-app-slug {
  font-size: 0.72rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- filter -- */

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar .search-input { min-width: 200px; }

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

.login-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-height) - 140px);
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-head { text-align: center; margin-bottom: 24px; }
.login-head .brand-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  font-size: 1rem;
}
.login-head h1 { font-size: 1.15rem; margin-bottom: 4px; }
.login-head p { font-size: 0.82rem; color: var(--text-muted); }

.login-foot {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* ---------------------------------------------------------------- notes -- */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.notice strong { color: var(--text); }
.notice-warn { border-left-color: #fbbf24; }

/* -------------------------------------------------------------- activity -- */

.activity-list { display: grid; }

.activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem;
}
.activity-item:last-child { border-bottom: 0; }

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  margin-top: 7px;
  flex-shrink: 0;
}
.activity-body { min-width: 0; flex: 1; }
.activity-action { font-weight: 600; font-family: var(--font-mono); font-size: 0.76rem; }
.activity-detail { color: var(--text-muted); overflow-wrap: anywhere; }
.activity-time { font-size: 0.72rem; color: var(--text-subtle); white-space: nowrap; }

/* --------------------------------------------------------------- footer -- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px 40px;
  flex-wrap: wrap;
}

.footer-info {
  min-width: 0;
  flex: 1 1 260px;
}

.footer-brand {
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.01em;
}

.footer-note {
  font-size: 0.75rem;
  /* --text-subtle falls just below the 4.5:1 AA threshold on black, so the
     small footer copy uses the muted tone instead. */
  color: var(--text-muted);
  max-width: 46ch;
  margin: 6px 0 0;
}
.footer-note a { color: var(--text-muted); }
.footer-note a:hover { color: var(--text); }

/* Right-hand column: links above, copyright below, both flush to the edge so
   the footer keeps a single clean alignment at every width. */
.footer-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  text-align: right;
}

/* Vertical padding gives the links a comfortable tap height without changing
   the visual rhythm, since the gap is reduced to compensate. */
.footer-links { display: flex; gap: 10px 18px; flex-wrap: wrap; }
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--text-muted);
}
.footer-links a:hover { color: var(--text); }

.footer-legal { margin: 0; font-size: 0.72rem; color: var(--text-muted); }

/* Developer credit. Underlined so the link reads as a link even in a line of
   otherwise subdued footer text. */
.footer-credit {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-credit:hover {
  color: var(--text);
}

/* ------------------------------------------------------------ utilities -- */

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 0.8rem; }
.xsmall { font-size: 0.72rem; }
.mono { font-family: var(--font-mono); }
.strong { font-weight: 650; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.stack { display: grid; gap: 20px; }
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 960px) {
  .detail-layout { grid-template-columns: 1fr; gap: 28px; }
  .aside-card { position: static; }
  .admin-shell { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .admin-side { position: static; min-width: 0; }
  .admin-nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
    margin-bottom: 0;
    -webkit-overflow-scrolling: touch;
  }
  .admin-nav a { white-space: nowrap; }
  .admin-side-label { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }

  .container { padding: 0 16px; }

  .nav-toggle { display: grid; }

  /* The nav is absolute when open, so it is out of flow and the toggle and
     actions sit next to the brand. `margin-left: auto` is safe here because the
     conflicting `.site-nav + .header-actions` rule no longer exists. */
  .header-actions { margin-left: auto; }

  /* Tighten the header so the full brand name fits on a 320px phone. */
  .site-header .container { gap: 12px; }
  .brand { min-width: 0; }
  .brand-text { overflow: hidden; }

  .site-nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: 10px 12px; }

  .header-actions { margin-left: auto; }

  .hero { padding: 36px 0 28px; }
  .hero-stats { gap: 20px; }

  .app-hero { flex-direction: column; gap: 16px; }
  .app-hero-icon { width: 76px; height: 76px; border-radius: 17px; }

  .app-grid { grid-template-columns: 1fr; }

  .search-bar { max-width: none; }
  .search-bar .btn { padding: 10px 14px; }

  .form-card { padding: 18px; }
  .login-card { padding: 24px; }
  .panel-body { padding: 15px; }
  .page-head { padding: 22px 0 18px; }

  /* Stacked and left-aligned on phones: right-aligned text in a narrow column
     is harder to scan, and the two-column split would wrap awkwardly. */
  .site-footer { padding: 26px 0; }
  .site-footer .container { gap: 20px; }
  .footer-end {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }

  /* Full-width stacked actions read better than a ragged wrap on a phone. */
  .btn-row > .btn,
  .app-hero-actions > .btn { flex: 1 1 auto; }
}

@media (max-width: 420px) {
  .brand-vendor { display: none; }
  .btn { padding: 9px 13px; }
}

/* Respect a user's reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .app-card:hover { transform: none; }
}

/* ----------------------------------------------------------------- print -- */

@media print {
  .site-header,
  .site-footer,
  .theme-toggle,
  .app-hero-actions,
  .admin-side { display: none; }
  body { background: #fff; color: #000; }
}
