:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c0f;
  --surface: #121318;
  --surface-elevated: #171920;
  --surface-subtle: #181a22;
  --surface-hover: #1c1e27;
  --border: #23252f;
  --border-strong: #323544;
  --ink: #f4f5f7;
  --ink-secondary: #b2b8c6;
  --muted: #8b93a5;

  --accent: #ff5001;
  --accent-hover: #ff6723;
  --accent-soft: rgba(255, 80, 1, 0.14);

  --success-bg: rgba(34, 197, 94, 0.13);
  --success-ink: #4ade80;
  --success-dot: #22c55e;

  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-ink: #fbbf24;
  --warning-dot: #f59e0b;

  --danger-bg: rgba(239, 68, 68, 0.13);
  --danger-border: rgba(239, 68, 68, 0.34);
  --danger-row: rgba(239, 68, 68, 0.045);
  --danger-ink: #f87171;
  --danger-dot: #ef4444;

  --neutral-bg: rgba(148, 163, 184, 0.12);
  --neutral-ink: #b2b8c6;
  --neutral-dot: #6b7280;

  --topbar-bg: rgba(14, 15, 19, 0.9);
  --backdrop: rgba(4, 5, 8, 0.68);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.48), 0 0 0 1px var(--border-strong);
  --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.55);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-subtle: #f1f2f4;
  --surface-hover: #f5f6f8;
  --border: #e4e5e9;
  --border-strong: #cfd2da;
  --ink: #111216;
  --ink-secondary: #4b5262;
  --muted: #5c6370;

  --accent: #ff5001;
  --accent-hover: #e54700;
  --accent-soft: rgba(255, 80, 1, 0.1);

  --success-bg: #ecfdf3;
  --success-ink: #067647;
  --success-dot: #12b76a;

  --warning-bg: #fffaeb;
  --warning-ink: #b54708;
  --warning-dot: #f79009;

  --danger-bg: #fef3f2;
  --danger-border: #fecdca;
  --danger-row: #fffafa;
  --danger-ink: #b42318;
  --danger-dot: #ef4444;

  --neutral-bg: #f2f3f6;
  --neutral-ink: #3f4654;
  --neutral-dot: #8c95a6;

  --topbar-bg: rgba(255, 255, 255, 0.92);
  --backdrop: rgba(15, 23, 42, 0.42);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-float: 0 12px 32px rgba(16, 24, 40, 0.14), 0 0 0 1px var(--border-strong);
  --shadow-drawer: -8px 0 32px rgba(16, 24, 40, 0.14);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

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

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tone-danger {
  color: var(--danger-ink) !important;
}
.tone-warning {
  color: var(--warning-ink) !important;
}
.tone-success {
  color: var(--success-ink) !important;
}
.tone-neutral {
  color: var(--muted) !important;
}

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

.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes slideInRight {
  from {
    transform: translateX(36px);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(16px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    transform: translateY(-4px);
  }
  to {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spin,
  .drawer-panel,
  .palette-panel,
  .popover-menu {
    animation: none !important;
  }
}

/* --- Login screen --- */
.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.login-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
}

.loading-note {
  color: var(--muted);
  font-size: 13px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-sm);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-svg {
  flex-shrink: 0;
  display: block;
}

.login-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.login-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.login-dev-divider {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

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

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.error-box {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 13px;
  border: 1px solid var(--danger-border);
}

/* --- Buttons & Inputs --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

@media (hover: hover) {
  .btn:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--muted);
  }
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

@media (hover: hover) {
  .btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }
}

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

.btn-block {
  width: 100%;
  height: 40px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-quiet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: nowrap;
}

@media (hover: hover) {
  .icon-btn:hover,
  .btn-quiet:hover {
    background: var(--surface-hover);
    color: var(--ink);
    border-color: var(--border);
  }
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

@media (hover: hover) {
  .text-link:hover {
    background: var(--surface-hover);
    color: var(--ink);
  }
}

.status-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.status-text {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.status-quiet {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.3;
}

/* --- Main Layout & Topbar --- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.topbar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.live-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-center {
  display: flex;
  align-items: center;
}

.clock-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.clock-strip strong {
  color: var(--ink-secondary);
  font-weight: 500;
}

.clock-sep {
  color: var(--border-strong);
}

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

.container {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 16px 32px;
}

@media (max-width: 780px) {
  .hide-md {
    display: none !important;
  }
}
@media (max-width: 600px) {
  .hide-sm {
    display: none !important;
  }
}
@media (max-width: 480px) {
  .hide-xs {
    display: none !important;
  }
  .topbar-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .container {
    padding: 10px 12px 28px;
  }
}

/* --- Banners --- */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 13px;
}

.alert-banner.warning {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--warning-ink);
}

/* --- Unified Stat-Tab Console Rail --- */
.stat-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px 12px;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.stat-cell:last-child {
  border-right: none;
}

@media (hover: hover) {
  .stat-cell:hover {
    background: var(--surface-hover);
  }
}

.stat-cell.active {
  background: var(--surface-elevated);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-cell.active .stat-label {
  color: var(--ink-secondary);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--ink);
}

.stat-denom {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  .stat-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 10px;
  }

  .stat-cell {
    padding: 8px 8px 9px;
    gap: 2px;
    border-bottom: none;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-denom {
    font-size: 11px;
  }

  .stat-sub {
    display: none;
  }
}

/* --- Search & Filter Controls --- */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 760px) {
  .controls-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  border-color: var(--accent);
  outline: none;
}

.pills-shell {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.pills-shell::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
}

@media (min-width: 760px) {
  .pills-shell::after {
    display: none;
  }
}

.pills-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-right: 24px;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 760px) {
  .pills-row {
    padding-right: 0;
  }
}

.pills-row::-webkit-scrollbar {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (hover: hover) {
  .pill:hover {
    border-color: var(--border-strong);
    color: var(--ink);
  }
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pill.has-alert {
  border-color: var(--danger-border);
  color: var(--danger-ink);
}

.pill-label,
.pill-count {
  line-height: 1;
}

.pill-count {
  font-size: 12px;
  opacity: 0.72;
}

.pill.active .pill-count {
  opacity: 0.92;
}

/* --- Dots & Badges --- */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.dot.success {
  background: var(--success-dot);
}
.dot.warning {
  background: var(--warning-dot);
}
.dot.danger {
  background: var(--danger-dot);
}
.dot.neutral {
  background: var(--neutral-dot);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.badge.success {
  background: var(--success-bg);
  color: var(--success-ink);
}
.badge.warning {
  background: var(--warning-bg);
  color: var(--warning-ink);
}
.badge.danger {
  background: var(--danger-bg);
  color: var(--danger-ink);
}
.badge.neutral {
  background: var(--neutral-bg);
  color: var(--neutral-ink);
}

/* --- Sections & Cards --- */
.section {
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 0 2px;
}

.section-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-visible-overflow {
  overflow: visible;
}

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

.empty-ok {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--success-ink);
  font-weight: 500;
}

/* --- Live Orders --- */
.order-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-row:last-child {
  border-bottom: none;
}

.order-row.attention {
  background: var(--danger-row);
}

.order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-id-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
}

.order-shop {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
}

@media (hover: hover) {
  .order-shop:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

.order-num {
  font-size: 12px;
  color: var(--muted);
}

.order-right {
  display: grid;
  grid-template-columns: 78px 192px;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.order-amount {
  font-weight: 600;
  font-size: 13.5px;
  text-align: right;
  white-space: nowrap;
}

.order-links-grid {
  display: grid;
  grid-template-columns: 58px 60px 64px;
  align-items: center;
  gap: 4px;
}

.order-link-slot {
  display: inline-flex;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .order-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .order-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
  }

  .order-amount {
    text-align: left;
  }

  .order-links-grid {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
  }

  .order-link-slot:empty {
    display: none;
  }
}

.order-lifecycle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stepper-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  width: 112px;
  flex-shrink: 0;
}

.stepper-seg {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.stepper-seg.done {
  background: var(--success-dot);
}
.stepper-seg.active {
  background: var(--accent);
}
.stepper-seg.warn {
  background: var(--warning-dot);
}
.stepper-seg.danger {
  background: var(--danger-dot);
}

.lifecycle-text {
  font-size: 12px;
  color: var(--ink-secondary);
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 10px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

.meta-chunk {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Shops Aligned Table --- */
.shop-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 168px 190px;
  align-items: center;
  gap: 14px;
  padding: 7px 14px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.tablet-table-head {
  grid-template-columns: minmax(0, 1.35fr) 156px 124px 136px;
}

.shop-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 168px 190px;
  align-items: center;
  gap: 14px;
}

.tablet-row {
  grid-template-columns: minmax(0, 1.35fr) 156px 124px 136px;
}

.shop-row:last-child {
  border-bottom: none;
}

.shop-row.has-issue {
  background: var(--danger-row);
}

@media (hover: hover) {
  .shop-row:hover {
    background: var(--surface-hover);
  }
}

.shop-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-name-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.shop-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
}

.stripe-check {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.shop-gmv-chunk {
  color: var(--ink-secondary);
  font-weight: 500;
}

.shop-mobile-only {
  display: none;
}

.shop-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.shop-col-right {
  text-align: right;
}

.shop-col-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 4-pip launch readiness meter */
.readiness-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 100%;
}

.readiness-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.readiness-pips {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.readiness-pip {
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.readiness-pip.done {
  background: var(--success-dot);
}

.shop-mobile-row2 {
  display: none;
}

@media (max-width: 760px) {
  .shop-row,
  .tablet-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px 10px;
    padding: 10px 12px;
  }

  .shop-mobile-only {
    display: inline-block;
  }

  .shop-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.3;
  }

  .shop-desktop-only {
    display: none !important;
  }

  .shop-mobile-row2 {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--muted);
    padding-top: 2px;
  }
}

/* --- Problems & Snooze Popover --- */
.problem-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.problem-row:first-child {
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.problem-row:last-child {
  border-bottom: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.problem-row.critical {
  background: var(--danger-row);
}

.problem-row.muted {
  opacity: 0.72;
}

.problem-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.problem-title-grid {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
}

.problem-dot {
  position: relative;
  top: -1px;
}

.problem-title-text {
  line-height: 1.4;
}

.problem-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}

.problem-summary-group {
  display: inline;
}

.problem-sep {
  color: var(--muted);
}

.problem-summary {
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-secondary);
}

.problem-age {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.problem-detail {
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.problem-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .problem-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .problem-summary-group {
    display: block;
    margin-top: 2px;
  }

  .problem-sep {
    display: none;
  }

  .problem-actions {
    width: 100%;
    padding-left: 16px;
  }
}

.snooze-wrap {
  position: relative;
  display: inline-flex;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 5px);
  z-index: 40;
  min-width: 240px;
  padding: 5px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-float);
  animation: popIn 100ms ease-out;
}

.popover-menu.align-right {
  right: 0;
}

.popover-menu.align-left {
  left: 0;
}

.popover-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  text-align: left;
}

@media (hover: hover) {
  .popover-item:hover {
    background: var(--surface-hover);
  }
}

.popover-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.popover-item.danger {
  color: var(--danger-ink);
}

.popover-hint {
  font-size: 11px;
  color: var(--muted);
}

.popover-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}

/* --- Activity Feed --- */
.feed-day-label {
  padding: 6px 14px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.feed-row {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  display: grid;
  grid-template-columns: 70px 10px minmax(0, 1fr) 16px;
  align-items: start;
  gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.feed-row:last-child {
  border-bottom: none;
}

.feed-row-clickable {
  cursor: pointer;
}

.feed-time {
  font-size: 11.5px;
  line-height: 19px;
  color: var(--muted);
  white-space: nowrap;
}

.feed-dot-cell {
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feed-msg {
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
}

.feed-chevron {
  height: 19px;
  display: flex;
  align-items: center;
  color: var(--muted);
  opacity: 0;
}

@media (hover: hover) {
  .feed-row-clickable:hover {
    background: var(--surface-hover);
  }
  .feed-row-clickable:hover .feed-chevron {
    opacity: 0.85;
  }
}

@media (max-width: 480px) {
  .feed-row {
    grid-template-columns: 62px 10px minmax(0, 1fr) 14px;
    gap: 8px;
    padding: 7px 12px;
  }
}

/* --- System Heartbeat Footer --- */
.heartbeat-footer {
  border-top: 1px solid var(--border);
  background: transparent;
  font-size: 11.5px;
  color: var(--muted);
}

.heartbeat-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.heartbeat-metrics,
.heartbeat-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .heartbeat-footer {
    font-size: 11px;
  }
  .heartbeat-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .heartbeat-metrics,
  .heartbeat-right {
    gap: 8px;
  }
}

.hb-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.hb-item strong {
  color: var(--ink-secondary);
  font-weight: 600;
}

/* --- Shop Detail Drawer --- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--backdrop);
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}

.drawer-panel {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  max-height: 100dvh;
  overflow: hidden;
  animation: slideInRight 160ms ease-out;
}

@media (max-width: 640px) {
  .drawer-backdrop {
    align-items: flex-end;
  }

  .drawer-panel {
    max-width: 100%;
    max-height: 90dvh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    animation: slideInUp 160ms ease-out;
  }
}

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-head-main {
  min-width: 0;
  flex: 1;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.drawer-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.drawer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

@media (hover: hover) {
  .link-chip:hover {
    background: var(--surface-hover);
    color: var(--ink);
    border-color: var(--border-strong);
  }
}

.drawer-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-divider {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.drawer-heading {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-alert-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.drawer-alert-card.warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--warning-bg);
}

.drawer-alert-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-alert-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}

.drawer-alert-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.drawer-alert-detail {
  font-size: 12px;
  color: var(--ink-secondary);
  flex: 1;
  min-width: 180px;
}

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

.check-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 12.5px;
  color: var(--muted);
}

.check-pill.done {
  background: var(--success-bg);
  color: var(--success-ink);
  font-weight: 500;
}

/* Clean definition list (replaces nested bordered cards) */
.def-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.def-item {
  min-width: 0;
}

.def-span-2 {
  grid-column: 1 / -1;
}

.def-item dt {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.def-item dd {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}

.drawer-empty {
  font-size: 12.5px;
  color: var(--muted);
}

.drawer-orders-list {
  display: flex;
  flex-direction: column;
}

.drawer-order-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-order-row:first-child {
  padding-top: 0;
}

.drawer-order-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.drawer-order-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-order-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-order-num {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-order-amt {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-order-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.drawer-order-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drawer-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-footer-note {
  font-size: 12px;
  color: var(--muted);
}

/* --- Command Palette (⌘K) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--backdrop);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}

.palette-panel {
  width: 100%;
  max-width: 540px;
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  animation: slideInUp 140ms ease-out;
}

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.palette-search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.palette-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.palette-input:focus-visible {
  outline: none;
}

.palette-input::placeholder {
  color: var(--muted);
}

.palette-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}

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

.palette-empty-hint {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.palette-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.palette-item.selected {
  background: var(--surface-hover);
}

.palette-item-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.palette-item.selected .palette-item-icon {
  color: var(--accent);
}

.palette-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.palette-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-item-sub {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
}

.palette-footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
