@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ==========================================================================
   Geist Dark Design System — Crumbs Admin Workspace
   ========================================================================== */

:root,
body.cm-admin {
  color-scheme: dark;

  /* Surfaces */
  --bg: #000000;
  --panel: #0a0a0a;
  --surface: #111111;
  --surface-hover: #171717;
  --surface-inset: #050505;

  /* Crisp 1px hairlines */
  --line: #1f1f1f;
  --line-strong: #2e2e2e;
  --line-hover: #454545;

  /* Text hierarchy */
  --text: #ededed;
  --muted: #a1a1a1;
  --subtle: #666666;

  /* Primary high-contrast CTA */
  --accent: #ededed;
  --accent-hover: #ffffff;
  --on-accent: #0a0a0a;

  /* Semantic tokens */
  --focus: #52a8ff;
  --focus-strong: #0070f3;
  --green: #00e599;
  --amber: #f5a623;
  --red: #ff6166;

  /* Typography */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Override shared design-system.css tokens cleanly */
  --ui-bg: var(--bg);
  --ui-surface: var(--panel);
  --ui-raised: var(--surface);
  --ui-border: var(--line);
  --ui-text: var(--text);
  --ui-muted: var(--muted);
  --ui-accent: var(--accent);
  --ui-on-accent: var(--on-accent);
  --ui-danger: var(--red);
  --ui-radius: 8px;
  --ui-font: var(--sans);
  --ui-serif: var(--sans);
  --theme-page: var(--bg);
  --theme-page-raised: var(--panel);
  --theme-surface: var(--panel);
  --theme-surface-raised: var(--surface);
  --theme-surface-overlay: var(--surface-hover);
  --theme-surface-inset: var(--surface-inset);
  --theme-primary: var(--accent);
  --theme-on-primary: var(--on-accent);
  --cm-bg: var(--bg);
  --cm-text: var(--text);
  --cm-muted: var(--muted);
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-padding-top: 72px;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body,
body.cm-admin {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  scroll-margin-top: 76px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

img,
svg {
  max-width: 100%;
}

code,
pre,
kbd {
  font-family: var(--mono);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background-color: #171717;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
}

/* Focus states — override design-system.css !important with Geist focus ring */
:focus-visible,
body.cm-admin :focus-visible,
body.cm-admin button:focus-visible,
body.cm-admin a:focus-visible,
body.cm-admin input:focus-visible,
body.cm-admin textarea:focus-visible,
body.cm-admin select:focus-visible,
body.cm-admin summary:focus-visible {
  outline: 2px solid var(--focus) !important;
  outline-offset: 2px;
}

/* Screen reader & skip links */
.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;
}

.skip-link,
body.cm-admin .ui-skip {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background-color: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 500;
  transition: top 140ms var(--ease);
}

.skip-link:focus,
body.cm-admin .ui-skip:focus {
  top: 12px;
}

/* ==========================================================================
   Typography Scale
   ========================================================================== */

h1 {
  font-family: var(--sans);
  font-size: clamp(24px, 2.2vw, 28px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--text);
  margin: 0;
}

h2 {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
  text-wrap: balance;
  color: var(--text);
  margin: 0;
}

h3 {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--text);
  margin: 0;
}

p {
  margin: 0;
}

.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--subtle);
  margin: 0 0 4px;
}

/* ==========================================================================
   Sidebar Navigation Rail (.admin-sidebar)
   ========================================================================== */

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: var(--surface-inset);
  z-index: 60;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 140ms ease;
}

.sidebar-brand:hover {
  opacity: 0.88;
}

.sidebar-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 6px;
  background-color: var(--text);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.sidebar-mark svg {
  width: 14px;
  height: 14px;
  display: block;
}

.sidebar-brand-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar-brand strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}

.brand-badge,
.sidebar-brand small {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  color: var(--muted);
  background-color: #141414;
  border: 1px solid #262626;
  margin: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.sidebar-nav:not(:has(.nav-group)) {
  gap: 2px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--subtle);
  padding: 0 10px;
  margin: 0 0 4px;
  line-height: 1.3;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.sidebar-nav a:hover {
  background-color: var(--surface);
  color: var(--text);
}

.sidebar-nav a.active,
.sidebar-nav a[aria-current="page"] {
  background-color: #161616;
  border-color: #262626;
  color: var(--text);
  font-weight: 500;
}

.sidebar-nav .nav-icon,
.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  color: var(--subtle);
  display: block;
  transition: color 140ms ease;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a:hover svg {
  color: var(--muted);
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a.active svg,
.sidebar-nav a[aria-current="page"] .nav-icon,
.sidebar-nav a[aria-current="page"] svg {
  color: var(--text);
}

.sidebar-note {
  display: none;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link,
.sidebar-bottom .sidebar-store {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: background-color 140ms ease, color 140ms ease;
}

.sidebar-link:hover,
.sidebar-bottom .sidebar-store:hover {
  background-color: var(--surface);
  color: var(--text);
}

.sidebar-signout,
.sidebar-bottom .button {
  width: 100%;
  justify-content: flex-start;
  height: 32px;
  padding: 0 10px;
  margin-top: 4px;
  background-color: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.sidebar-signout:hover:not(:disabled),
.sidebar-bottom .button:hover:not(:disabled) {
  background-color: var(--surface);
  border-color: #262626;
  color: var(--text);
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background-color: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 55;
}

/* ==========================================================================
   Main Workspace Shell & Sticky Glass Topbar
   ========================================================================== */

.admin,
body.cm-admin .admin {
  --admin-pad: clamp(20px, 3.2vw, 44px);
  margin-left: 236px;
  padding: 0 var(--admin-pad);
  max-width: none !important;
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.admin > :not(.workspace-topbar) {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
}

.workspace-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 56px;
  margin-inline: calc(-1 * var(--admin-pad));
  padding-inline: var(--admin-pad);
  background-color: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-menu-toggle {
  display: none;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.breadcrumb i {
  font-style: normal;
  color: #3a3a3a;
  user-select: none;
}

.breadcrumb strong {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  margin-left: 4px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background-color: var(--surface);
  border: 1px solid #262626;
  flex-shrink: 0;
}

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 196px;
  height: 32px;
  padding: 0 8px 0 10px;
  background-color: var(--panel);
  border: 1px solid #262626;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.cmdk-trigger:hover {
  background-color: var(--surface);
  border-color: #3a3a3a;
  color: var(--text);
}

.cmdk-placeholder {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--muted);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.workspace-account:hover {
  background-color: var(--surface);
  border-color: #262626;
  color: var(--text);
}

.account-dot {
  display: block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  background-color: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 229, 153, 0.14);
}

/* ==========================================================================
   Buttons, Chips & Form Controls
   ========================================================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background-color: var(--surface);
  border: 1px solid #262626;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

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

.button:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: #3a3a3a;
  color: #ffffff;
}

.button:active:not(:disabled) {
  background-color: #1c1c1c;
}

.cm-admin .button.primary,
.button.primary {
  background-color: var(--accent) !important;
  color: var(--on-accent) !important;
  border-color: var(--accent) !important;
  font-weight: 500;
}

.cm-admin .button.primary:hover:not(:disabled),
.button.primary:hover:not(:disabled) {
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #000000 !important;
}

.button.ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--muted);
}

.button.ghost:hover:not(:disabled) {
  background-color: var(--surface);
  border-color: #262626;
  color: var(--text);
}

.button.danger {
  color: var(--red);
  border-color: rgba(255, 97, 102, 0.28);
  background-color: rgba(255, 97, 102, 0.08);
}

.button.danger:hover:not(:disabled) {
  color: #ff8084;
  border-color: rgba(255, 97, 102, 0.48);
  background-color: rgba(255, 97, 102, 0.15);
}

.button.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
  gap: 5px;
}

.button.sm svg {
  width: 14px;
  height: 14px;
}

.button.is-loading,
.button[data-loading="true"] {
  opacity: 0.65;
  pointer-events: none;
}

.copy-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background-color: #141414;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.copy-chip:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: var(--line-hover);
  color: var(--text);
}

/* Inputs, Selects & Textareas */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
select,
textarea {
  min-width: 0;
  max-width: 100%;
  border: 1px solid #262626;
  border-radius: 6px;
  background-color: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  transition: border-color 140ms ease, background-color 140ms ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
select {
  height: 36px;
  padding: 0 12px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23a1a1a1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

select option {
  background-color: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  border-color: #3a3a3a;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  background-color: #0d0d0d;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
  opacity: 1;
}

input[type="file"] {
  width: 100%;
  padding: 5px;
  border: 1px solid #262626;
  border-radius: 6px;
  background-color: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

input[type="file"]::file-selector-button {
  height: 26px;
  padding: 0 10px;
  margin-right: 10px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background-color: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

input[type="file"]::file-selector-button:hover {
  background-color: var(--surface-hover);
  border-color: var(--line-hover);
}

input[type="color"] {
  width: 56px;
  height: 36px;
  padding: 3px;
  border: 1px solid #262626;
  border-radius: 6px;
  background-color: var(--panel);
  cursor: pointer;
}

#checkRedeemInput,
#redeemRecipient {
  font-family: var(--mono);
  font-size: 13px;
}

body.cm-admin input[aria-invalid="true"],
body.cm-admin textarea[aria-invalid="true"],
body.cm-admin select[aria-invalid="true"] {
  border-color: var(--red) !important;
}

.field-error {
  color: var(--red);
  font-size: 12px;
  margin: 4px 0 0;
}

/* ==========================================================================
   Page Heading, Notices & Status Telemetry
   ========================================================================== */

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 28px 0 20px;
}

.page-heading > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.page-heading > div > p:last-child,
.page-heading p:not(.eyebrow) {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 68ch;
  margin: 0;
}

.page-heading > .button,
.head-actions {
  flex-shrink: 0;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px !important;
  border: 1px solid var(--line) !important;
  background-color: var(--panel) !important;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted) !important;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.notice::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background-color: var(--subtle);
}

.notice[data-state="connected"]::before {
  background-color: var(--green);
}

.notice[data-state="error"],
.notice[data-state=error] {
  color: var(--amber) !important;
  background-color: rgba(245, 166, 35, 0.06) !important;
  border-color: rgba(245, 166, 35, 0.25) !important;
}

.notice[data-state="error"]::before,
.notice[data-state=error]::before {
  background-color: var(--amber);
}

.status {
  min-height: 20px;
  margin: 4px 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.panel .status:empty,
.alerts-panel .status:empty {
  display: none;
}

/* ==========================================================================
   Overview KPI Grid, Alerts & Compact Resource Cards
   ========================================================================== */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--panel);
}

.metric {
  padding: 16px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  background-color: var(--panel);
  box-shadow: 1px 0 0 0 var(--line), 0 1px 0 0 var(--line);
}

.metric > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

.metric strong {
  display: block;
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.metric a {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--subtle);
  transition: color 140ms ease;
}

.metric a:hover {
  color: var(--text);
}

#deploymentCountNote {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--subtle);
}

.alerts-panel {
  margin: 24px 0 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
}

.alerts-panel:first-child {
  margin-top: 0;
}

.alerts-panel + .alerts-panel {
  margin-top: 16px;
}

.alerts-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.alerts-heading h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

.alerts-list {
  display: grid;
  gap: 8px;
}

.admin-alert {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: var(--surface-inset);
  transition: border-color 140ms ease;
}

.admin-alert:hover {
  border-color: var(--line-strong);
}

.admin-alert strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.admin-alert .hint {
  margin: 2px 0 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.alert-warning {
  border-left: 2px solid var(--amber);
}

.alert-error {
  border-left: 2px solid var(--red);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 28px 0 12px;
}

.section-heading h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

.section-heading > span {
  font-size: 12px;
  color: var(--subtle);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-card {
  padding: 18px 20px;
  min-height: 158px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.dashboard-card:hover {
  border-color: var(--line-hover);
  background-color: #0d0d0d;
}

.dashboard-card.featured {
  border-color: var(--line-strong);
  background-color: #0c0c0c;
}

.dashboard-card.featured:hover {
  border-color: var(--line-hover);
}

.dashboard-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #262626;
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.dashboard-icon svg {
  width: 16px;
  height: 16px;
}

.dashboard-card h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
}

.dashboard-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.dashboard-card b {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  transition: color 140ms ease;
}

.dashboard-card:hover b {
  color: var(--text);
}

.dashboard-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
  margin-top: 16px;
  padding: 16px 20px;
}

.dashboard-tools strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.dashboard-tools p {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 0;
}

/* ==========================================================================
   Status Pills & Semantic Dots
   ========================================================================== */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid #262626;
  background-color: #141414;
  color: var(--muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-published,
.status-live,
.status-approved,
.status-active {
  background-color: rgba(0, 229, 153, 0.1);
  border-color: rgba(0, 229, 153, 0.25);
  color: var(--green);
}

.status-library,
.status-neutral {
  background-color: #141414;
  border-color: #262626;
  color: var(--muted);
}

.status-draft,
.status-pending,
.status-redeemed,
.status-warning {
  background-color: rgba(245, 166, 35, 0.1);
  border-color: rgba(245, 166, 35, 0.25);
  color: var(--amber);
}

.status-rejected,
.status-danger,
.status-invalid,
.status-error {
  background-color: rgba(255, 97, 102, 0.1);
  border-color: rgba(255, 97, 102, 0.25);
  color: var(--red);
}

/* ==========================================================================
   Workspace Panels, Catalog Rows & Forms
   ========================================================================== */

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
  min-width: 0;
  overflow: hidden;
}

.panel:not(:has(> .panel-head)):not(:has(> .panel-body)) {
  padding: 20px 24px;
}

.panel-body {
  padding: 20px 24px;
}

.panel + .panel {
  margin-top: 16px;
}

.panel h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 15px;
  margin: 0;
}

.panel-head .hint {
  margin: 2px 0 0;
  font-size: 13px;
}

.panel > div:not(.panel-head):not(.panel-body):has(> #refreshReceipts) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--muted) !important;
  font-size: 13px;
  line-height: 1.5;
  margin: 4px 0 0;
}

.layout {
  display: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

form {
  padding: 20px 24px;
}

.panel:not(:has(> .panel-head)) > form {
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

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

.field.full,
.full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.field > strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.field input,
.field textarea,
.field select {
  width: 100%;
}

#imagePreview,
#previewImageDesktopPreview,
#previewImageTabletPreview,
#previewImageMobilePreview,
.upload-preview,
.preview-thumb,
.image-preview {
  max-width: 200px;
  max-height: 128px;
  width: auto;
  height: auto;
  object-fit: cover;
  border: 1px solid #262626;
  border-radius: 6px;
  margin-top: 6px;
  background-color: var(--surface-inset);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.field .form-actions {
  justify-content: flex-start;
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}

.input-row,
.inline-row,
.control-row,
div:has(> #redeemTemplate),
div:has(> #checkRedeemInput) {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

div:has(> #redeemTemplate) > select,
div:has(> #checkRedeemInput) > input {
  flex: 1 1 240px;
}

/* Catalog Filters & Template Rows */
.catalog-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface-inset);
}

.panel:not(:has(> .panel-head)) .catalog-filters {
  padding: 0 0 16px;
  margin-bottom: 16px;
  background-color: transparent;
}

.catalog-filters input {
  flex: 1 1 220px;
}

.catalog-filters select {
  width: auto;
  min-width: 180px;
  max-width: 240px;
}

.template-list {
  padding: 0;
}

.template-list:has(#sitesList),
.template-list:has(#reposList),
.panel > #sitesList,
.panel > #reposList {
  padding: 16px 20px;
}

.template-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  transition: background-color 140ms ease;
}

.template-row:last-child {
  border-bottom: 0;
}

.template-row:hover {
  background-color: #0d0d0d;
}

.template-thumb {
  width: 64px;
  height: 44px;
  object-fit: cover;
  border: 1px solid #262626;
  border-radius: 6px;
  background-color: var(--surface);
  display: block;
}

.template-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  overflow-wrap: anywhere;
}

.template-meta {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted) !important;
  margin-top: 4px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.template-price {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 500;
}

.template-tag,
.meta-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background-color: #141414;
  border: 1px solid #262626;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions .button:not(.primary):not(.lg) {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.empty {
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.catalog-tools {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

/* ==========================================================================
   Device Mockup Preview Stage
   ========================================================================== */

.preview-picker {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface-inset);
  display: none;
  gap: 12px;
  align-items: center;
}

.preview-picker label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.preview-picker select {
  max-width: 360px;
  flex: 1;
}

.mockup-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.mockup-header-row > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mockup-header-row strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.mockup-header-row .hint {
  margin: 0;
}

body[data-admin-page=preview] .mockup-header-row {
  border-top: 0;
  padding-top: 0;
}

.mockup-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mockup-actions .button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mockup-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 12px;
}

.mockup-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background-color: var(--surface-inset);
  border: 1px solid #262626;
  border-radius: 8px;
}

.mockup-tabs .button {
  height: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.mockup-tabs .button:hover:not(:disabled) {
  background-color: transparent;
  border-color: transparent;
  color: var(--text);
}

.mockup-tabs .button[aria-pressed="true"],
.mockup-tabs .button[aria-pressed=true] {
  background-color: #1c1c1c;
  border-color: var(--line-strong);
  color: var(--text);
}

.mockup-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.mockup-control label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.mockup-control select {
  height: 34px;
}

.mockup-stage {
  min-height: 340px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--surface-inset);
  background-image: radial-gradient(#1f1f1f 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 28px;
}

.mockup-viewport {
  position: relative;
  overflow: hidden;
  background-color: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 4px #141414, 0 16px 40px rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  width: 100%;
  transition: border-color 140ms ease, opacity 140ms ease;
}

.device-desktop {
  max-width: 720px;
  height: 380px;
}

.device-tablet {
  max-width: 420px;
  height: 520px;
  border-radius: 12px;
}

.device-mobile {
  max-width: 248px;
  height: 448px;
  border-radius: 24px;
}

.mockup-image {
  width: 100%;
  height: 100%;
  display: block;
}

.mockup-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 28px;
  text-align: center;
  color: var(--subtle);
  font-size: 13px;
}

/* ==========================================================================
   Redeem Terminal Output & Receipt Review Cards
   ========================================================================== */

.code-output {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background-color: var(--surface-inset);
}

.code-output:not(:has(> :not([hidden]))) {
  display: none;
}

.code-output code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--green);
  word-break: break-all;
  letter-spacing: 0.02em;
  flex: 1 1 220px;
}

#receiptQueue,
#receiptHistory {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

#receiptQueueStatus + div,
.receipt-history-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.receipt-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--surface-inset);
  transition: border-color 140ms ease;
}

.receipt-card:hover {
  border-color: var(--line-strong);
}

.receipt-card strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.receipt-card .hint {
  font-size: 12px;
  margin-top: 4px;
}

.receipt-card code,
.receipt-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.receipt-card .receipt-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.receipt-card .receipt-actions select {
  height: 28px;
  font-size: 12px;
  padding-inline: 10px 28px;
  min-width: 185px;
}

.receipt-card details {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #080808;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
}

.receipt-card summary {
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 140ms ease, background-color 140ms ease;
}

.receipt-card summary::-webkit-details-marker {
  display: none;
}

.receipt-card summary::before {
  content: "▸";
  font-size: 11px;
  color: var(--subtle);
  transition: transform 140ms ease;
}

.receipt-card details[open] summary::before {
  transform: rotate(90deg);
}

.receipt-card details[open] summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background-color: #0d0d0d;
}

.receipt-card summary:hover {
  color: var(--text);
}

.receipt-card pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: #c8c8c8;
  max-height: 260px;
  overflow-y: auto;
}

/* ==========================================================================
   Deployments Subnav & Deployment Cards (Sites / Repositories)
   ========================================================================== */

.deployment-subnav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: fit-content;
}

.deployment-subnav .button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background-color: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.deployment-subnav .button:hover:not(:disabled) {
  background-color: var(--surface);
  border-color: transparent;
  color: var(--text);
}

.deployment-subnav .button.active,
.deployment-subnav .button[aria-current="page"] {
  background-color: #191919;
  color: var(--text);
  border-color: var(--line-strong);
  font-weight: 500;
}

#sitesList,
#reposList {
  display: grid;
  gap: 12px;
}

.deployment-card {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--surface-inset);
  margin: 0;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.deployment-card:hover {
  border-color: var(--line-strong);
  background-color: #080808;
}

.deployment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.deployment-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.deployment-title svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.deployment-title strong {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.deployment-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  line-height: 1;
  white-space: nowrap;
}

.badge-live {
  background-color: rgba(0, 229, 153, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 229, 153, 0.25);
}

.badge-repo {
  background-color: #141414;
  color: var(--muted);
  border: 1px solid #262626;
}

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

.deployment-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.deployment-link-text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
  transition: color 140ms ease;
}

.deployment-link-text:hover {
  color: var(--focus);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.deployment-user-box {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  padding: 12px 14px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.user-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-meta-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--subtle);
}

.user-meta-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow-wrap: anywhere;
}

.user-meta-code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.user-meta-code a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   Command Menu Dialog (dialog.cmdk-dialog#adminCmdk)
   ========================================================================== */

dialog.cmdk-dialog {
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: var(--panel);
  color: var(--text);
  width: min(560px, calc(100vw - 24px));
  max-height: min(460px, calc(100dvh - 64px));
  margin: min(14vh, 96px) auto auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.03);
  overflow: hidden;
  overscroll-behavior: contain;
}

dialog.cmdk-dialog:not([open]) {
  display: none;
}

dialog.cmdk-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: cmdk-enter 140ms var(--ease) both;
}

dialog.cmdk-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.cmdk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background-color: var(--panel);
  transition: border-color 140ms ease;
}

.cmdk-head:focus-within {
  border-bottom-color: var(--line-hover);
}

.cmdk-head svg {
  width: 16px;
  height: 16px;
  color: var(--subtle);
  flex-shrink: 0;
}

body.cm-admin .cmdk-input,
.cmdk-input {
  flex: 1;
  height: 46px;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

body.cm-admin .cmdk-input:focus,
body.cm-admin .cmdk-input:focus-visible,
.cmdk-input:focus,
.cmdk-input:focus-visible {
  outline: none !important;
  border: 0 !important;
  background: transparent !important;
}

.cmdk-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  max-height: 332px;
}

.cmdk-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmdk-group + .cmdk-group {
  margin-top: 6px;
}

.cmdk-group-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--subtle);
  letter-spacing: 0;
  text-transform: none;
  user-select: none;
}

.cmdk-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background-color: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}

.cmdk-item:hover,
.cmdk-item[aria-selected="true"],
.cmdk-item[aria-selected=true],
.cmdk-item.active {
  background-color: var(--surface-hover);
  color: var(--text);
}

.cmdk-item svg {
  width: 16px;
  height: 16px;
  color: var(--subtle);
  flex-shrink: 0;
  transition: color 100ms ease;
}

.cmdk-item:hover svg,
.cmdk-item[aria-selected="true"] svg,
.cmdk-item[aria-selected=true] svg {
  color: var(--text);
}

.cmdk-shortcut {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--subtle);
  flex-shrink: 0;
}

.cmdk-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--subtle);
}

.cmdk-foot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background-color: var(--surface-inset);
  font-size: 11px;
  color: var(--subtle);
}

.cmdk-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cmdk-foot kbd {
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
}

/* ==========================================================================
   Footer & Skeleton Harmonization
   ========================================================================== */

.workspace-footer {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: auto;
  padding: 20px 0 28px;
  color: var(--subtle);
  font-size: 12px;
}

.workspace-footer a,
.workspace-footer .sidebar-store {
  color: var(--muted);
  font-size: 12px;
  transition: color 140ms ease;
}

.workspace-footer a:hover,
.workspace-footer .sidebar-store:hover {
  color: var(--text);
}

body.cm-admin .sk-shimmer,
body.cm-admin .sk-line,
body.cm-admin .sk-avatar {
  background-color: #171717;
}

body.cm-admin .sk-metric {
  width: 56px;
  height: 28px;
  border-radius: 6px;
}

body.cm-admin .sk-row {
  border-bottom-color: var(--line);
  padding-inline: 16px;
}

/* ==========================================================================
   Workspace Visibility Rules (Hard Invariants)
   ========================================================================== */

[data-workspace],
.layout,
.catalog-tools {
  display: none;
  margin-bottom: 32px;
}

body[data-admin-page=dashboard] [data-workspace=dashboard],
body[data-admin-page=redeem] [data-workspace=redeem],
body[data-admin-page=check-code] [data-workspace=check-code],
body[data-admin-page=receipts] [data-workspace=receipts],
body[data-admin-page=sites] [data-workspace=sites],
body[data-admin-page=repos] [data-workspace=repos] {
  display: block;
}

body[data-admin-page=templates] .layout,
body[data-admin-page=add-template] .layout,
body[data-admin-page=preview] .layout {
  display: grid;
}

body[data-admin-page=templates] .editor-panel,
body[data-admin-page=add-template] .layout>section:first-child,
body[data-admin-page=preview] .layout>section:first-child {
  display: none;
}

body[data-admin-page=templates] .catalog-tools {
  display: flex;
}

body[data-admin-page=templates] .layout {
  margin-bottom: 0;
}

body[data-admin-page=preview] .preview-picker {
  display: flex;
}

body[data-admin-page=preview] .field,
body[data-admin-page=preview] #templateForm>.form-actions {
  display: none;
}

body[data-admin-page=preview] .field:has(.mockup-stage) {
  display: flex;
}

body[data-admin-page=preview] .field:has(.mockup-stage) > strong {
  border-top: 0;
  padding-top: 0;
}

/* ==========================================================================
   Motion & Keyframes
   ========================================================================== */

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes cmdk-enter {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner,
.btn-spinner {
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 650ms linear infinite;
}

.page-heading,
[data-workspace],
.layout {
  animation: enter 180ms var(--ease) both;
}

/* ==========================================================================
   Responsive Breakpoints (1200px, 940px, 640px) & Reduced Motion
   ========================================================================== */

@media (max-width: 1200px) {
  .admin-sidebar {
    width: 220px;
  }

  .admin,
  body.cm-admin .admin {
    margin-left: 220px;
  }

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

  .section-heading > span {
    display: none;
  }

  .receipt-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) {
  .admin-sidebar {
    transform: translateX(-100%);
    width: 256px;
    transition: transform 180ms var(--ease);
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.85);
  }

  .admin,
  body.cm-admin .admin {
    margin-left: 0;
    --admin-pad: 20px;
  }

  .header-menu-toggle {
    display: inline-flex;
    height: 32px;
    padding: 0 10px;
  }

  .cmdk-trigger {
    min-width: auto;
    gap: 10px;
  }

  .page-heading {
    padding: 22px 0 16px;
  }

  .template-row {
    gap: 12px;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    padding: 12px 16px;
  }

  .template-thumb {
    width: 56px;
    height: 40px;
  }
}

@media (max-width: 640px) {
  .admin,
  body.cm-admin .admin {
    --admin-pad: 16px;
  }

  /* >=44px mobile touch targets & 16px inputs to prevent iOS zoom */
  .button,
  .button.sm,
  .row-actions .button:not(.primary):not(.lg),
  .mockup-tabs .button,
  .deployment-subnav .button,
  .sidebar-nav a,
  .sidebar-link,
  .sidebar-bottom .sidebar-store,
  .sidebar-signout,
  .cmdk-trigger,
  .cmdk-item,
  .copy-chip,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  select {
    min-height: 44px;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  textarea,
  select {
    font-size: 16px !important;
  }

  .workspace-topbar {
    gap: 8px;
    padding-block: 6px;
  }

  .breadcrumb > span:not(.env-badge),
  .breadcrumb > i,
  .env-badge {
    display: none;
  }

  .cmdk-trigger kbd {
    display: none;
  }

  .workspace-account {
    font-size: 0;
    gap: 0;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
  }

  .page-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .page-heading > .button {
    width: 100%;
  }

  h1 {
    font-size: 22px;
  }

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

  .metric {
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 12px;
  }

  .metric strong {
    grid-column: 2;
    grid-row: 1 / 3;
    font-size: 24px;
    margin: 0;
  }

  .metric a {
    grid-column: 1;
    margin-top: 0;
  }

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

  .dashboard-card {
    min-height: 0;
    padding: 16px;
  }

  .dashboard-tools {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  .alerts-panel {
    padding: 16px;
  }

  .alerts-heading,
  .admin-alert {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel:not(:has(> .panel-head)):not(:has(> .panel-body)),
  .panel-body,
  form {
    padding: 16px;
  }

  .panel-head {
    padding: 14px 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .field.full {
    grid-column: auto;
  }

  .catalog-filters {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .catalog-filters select {
    max-width: none;
    width: 100%;
  }

  .template-list:has(#sitesList),
  .template-list:has(#reposList),
  .panel > #sitesList,
  .panel > #reposList {
    padding: 14px 16px;
  }

  .template-row {
    grid-template-columns: 48px minmax(0, 1fr);
    padding: 14px 16px;
  }

  .template-thumb {
    width: 48px;
    height: 36px;
  }

  .row-actions {
    grid-column: 1 / -1;
    padding-top: 4px;
  }

  .deployment-subnav {
    display: flex;
    width: 100%;
  }

  .deployment-subnav .button {
    flex: 1;
  }

  .deployment-card {
    padding: 16px;
  }

  .deployment-actions {
    width: 100%;
  }

  .deployment-actions .button {
    flex: 1;
  }

  .receipt-card {
    padding: 16px;
  }

  .receipt-card .receipt-actions select {
    width: 100%;
  }

  .preview-picker {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }

  .preview-picker select {
    max-width: none;
    width: 100%;
  }

  .mockup-tabs {
    width: 100%;
  }

  .mockup-tabs .button {
    flex: 1;
  }

  .mockup-control {
    flex: 1 1 100%;
  }

  .mockup-stage {
    padding: 14px;
    min-height: 260px;
  }

  .device-desktop {
    height: 220px;
  }

  .device-tablet {
    height: 330px;
  }

  .catalog-tools {
    flex-wrap: wrap;
  }

  .catalog-tools .button {
    flex: 1 1 auto;
  }

  dialog.cmdk-dialog {
    margin: 12px auto auto;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
  }
}

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