:root {
  color-scheme: light;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-dark: #047857;
  --primary-light: rgba(16, 185, 129, 0.12);
  --primary-subtle: rgba(16, 185, 129, 0.05);

  --bg: #f8fafc;
  --panel: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f1f5f9;
  --surface-hover: #f8fafc;

  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.35);
  --border-focus: #10b981;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --text-inverse: #ffffff;

  --brand: var(--primary);
  --brand-dark: var(--primary-hover);
  --brand-glow: var(--primary-light);
  --tag-bg: rgba(148, 163, 184, 0.12);
  --card-footer-bg: rgba(241, 245, 249, 0.7);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius: var(--radius-lg);

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.25);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-dark: #059669;
  --primary-light: rgba(16, 185, 129, 0.18);
  --primary-subtle: rgba(16, 185, 129, 0.08);

  --bg: #090e1a;
  --panel: #10192e;
  --surface-raised: #10192e;
  --surface-sunken: #0b1222;
  --surface-hover: #16223b;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #10b981;

  --text: #f8fafc;
  --text-2: #cbd5e1;
  --text-3: #64748b;
  --text-inverse: #ffffff;

  --tag-bg: rgba(255, 255, 255, 0.07);
  --card-footer-bg: rgba(11, 18, 34, 0.7);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.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;
}

/* ==========================================================================
   Hero Section (FavsHub Tokens style)
   ========================================================================== */

.hero {
  position: relative;
  padding: 24px 28px 22px;
  background:
    radial-gradient(1000px 280px at 10% -20%, var(--primary-light), transparent 70%),
    radial-gradient(800px 240px at 90% -20%, rgba(13, 148, 136, 0.12), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

:root.embedded .hero {
  padding: 16px 20px 14px;
}

.hero-inner, .page {
  max-width: 1180px;
  margin: 0 auto;
}

.hero-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 860px) {
  .hero-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
}

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

.hero-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 22px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
}

:root[data-theme="dark"] .hero-badge {
  color: var(--primary-hover);
}

.hero-slogan {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 13px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hero Toolbar: Search & Actions */
.hero-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

@media (min-width: 860px) {
  .hero-toolbar {
    flex: 1;
    max-width: 520px;
    justify-content: flex-end;
  }
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
  flex: 1;
  min-width: 220px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  color: var(--text-3);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.search-box:focus-within .search-icon {
  color: var(--primary);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-3);
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.search-clear-btn:hover {
  color: var(--text);
}

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

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.hero-status:empty { display: none; }

.hero-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.hero-status[data-kind="connected"]::before { background: var(--primary); }
.hero-status[data-kind="connecting"]::before { background: #f59e0b; }

.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-3);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.refresh-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-sunken);
}

.refresh-btn:active {
  transform: scale(0.94);
}

.refresh-btn.spinning .refresh-icon {
  animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

/* ==========================================================================
   Main Page & Toolbar
   ========================================================================== */

.page {
  padding: 20px 24px 56px;
}

:root.embedded .page {
  padding: 16px 20px 48px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.filters {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.filter {
  border: 0;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

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

.filter.active {
  background: var(--panel);
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

:root[data-theme="dark"] .filter.active {
  color: var(--primary-hover);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sort-wrap {
  display: inline-flex;
  align-items: center;
}

.sort-select {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sort-select:focus {
  border-color: var(--border-focus);
}

.toolbar-meta {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   Provider Grid & Deal Cards
   ========================================================================== */

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

.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
  position: relative;
}

.card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-body {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Card Head */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}

.card-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.card-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.card-icon-fallback {
  font-size: 18px;
  line-height: 1;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.card-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.card-brand:hover .card-name {
  color: var(--primary-hover);
}

.pin-mark {
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tag {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--tag-bg);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.tag.region-cn {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.tag.region-global {
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

:root[data-theme="dark"] .tag.region-cn {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.2);
}
:root[data-theme="dark"] .tag.region-global {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.2);
}

.card-head-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Quality Badge (FavsHub Deal Quality) */
.card-quality, .modal-quality {
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.q-top {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.15);
}
:root[data-theme="dark"] .q-top {
  color: var(--primary-hover);
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}

.q-high {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border: 1px solid rgba(13, 148, 136, 0.3);
}
:root[data-theme="dark"] .q-high {
  color: #2dd4bf;
  background: rgba(13, 148, 136, 0.15);
}

.q-mid {
  background: var(--surface-sunken);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.card-imported {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1.5px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.28);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  flex-shrink: 0;
  vertical-align: middle;
}
:root[data-theme="dark"] .card-imported {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}
.card-imported::before {
  content: "✓";
  font-size: 10px;
  font-weight: 800;
}

/* Quota Sunken Box */
.card-quota-box {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.card-quota-box:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.quota-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quota-label {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-summary {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Models Section */
.card-models-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.models-head {
  display: flex;
  align-items: center;
}

.models-label {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.card-models {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 52px;
  overflow: hidden;
  position: relative;
}

.card-models li {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.3;
  padding: 2px 7px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-models li.vision::after {
  content: " 👁";
  font-size: 10px;
}

/* Card Actions */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}

.card-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.15s ease;
}

.card-link:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}

.import-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-hover);
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.import-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.import-btn.secondary {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: none;
}

:root[data-theme="dark"] .import-btn.secondary {
  color: var(--primary-hover);
  border-color: rgba(16, 185, 129, 0.45);
}

.import-btn.secondary:hover:not(:disabled) {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary-hover);
}

.import-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Card Community Footer */
.card-community {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--card-footer-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.card-community:hover {
  background: var(--surface-sunken);
}

.community-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.community-divider {
  color: var(--border-strong);
  font-size: 10px;
}

.community-rating {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.community-rating .star-icon {
  color: #f59e0b;
  font-size: 13px;
}

.community-rating .rating-count {
  color: var(--text-3);
  font-size: 11px;
  font-weight: normal;
}

.community-avail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
}

.community-avail .avail-dot {
  font-size: 8px;
  color: var(--text-3);
}

.community-avail.good .avail-dot { color: var(--primary); }
.community-avail.warn .avail-dot { color: #f59e0b; }
.community-avail.bad .avail-dot { color: #ef4444; }

.community-avail .avail-text {
  color: var(--text-2);
}

.community-votes {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
}

.stat-working {
  color: var(--primary);
  font-weight: 600;
}

.stat-failed {
  color: #ef4444;
  font-weight: 600;
}

.open-detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.open-detail-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

:root[data-theme="dark"] .open-detail-btn:hover {
  color: var(--primary-hover);
}

.open-detail-btn .detail-btn-arrow {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
}

.open-detail-btn:hover .detail-btn-arrow {
  transform: translateX(2px);
}

/* Empty State */
.empty-search-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  background: var(--surface-sunken);
}

.empty-search-state .empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.empty-search-state .empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.empty-search-state .empty-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-3);
}

.empty-search-state .empty-reset-btn {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.empty-search-state .empty-reset-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.load-error {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: #ef4444;
  font-size: 14px;
}

.disclaimer {
  margin: 32px 0 0;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

.disclaimer a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Modal: Token Deal Details (TDD Modal)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop[hidden] {
  display: none !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 40px);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.modal-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.modal-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.modal-title-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

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

.modal-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.modal-tags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.modal-verified {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--border-strong);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Facts Grid */
.modal-facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.modal-fact {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.modal-fact .fact-label {
  color: var(--text-3);
  font-size: 11.5px;
}

.modal-fact .fact-value {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-section-title {
  margin: 0 0 2px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-quota-box {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.modal-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

.modal-quick-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.modal-link {
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  text-decoration: none;
  transition: all 0.15s ease;
}

.modal-link:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.modal-import-btn {
  height: 32px;
  padding: 0 16px;
  font-size: 12.5px;
}

/* Health Card in Modal */
.modal-health-card {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.health-score-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.health-score-num {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.health-score-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.health-score-stars {
  color: #f59e0b;
  font-size: 14px;
  letter-spacing: 1.5px;
}

.health-score-label {
  font-size: 11.5px;
  color: var(--text-3);
}

.health-avail-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.health-avail-pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.health-avail-tip {
  font-size: 11px;
  color: var(--text-3);
}

.health-vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}

.health-vote-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.vote-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.vote-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
}

.vote-btn.voted {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

:root[data-theme="dark"] .vote-btn.voted {
  color: var(--primary-hover);
}

/* Lock Banner for external web visitors */
.client-lock-banner {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.22);
  text-align: center;
}

.client-lock-banner .lock-title {
  margin: 0;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.client-lock-banner .lock-desc {
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.client-lock-banner .download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: #2563eb;
  color: #ffffff;
  text-decoration: none;
  transition: background 0.15s ease;
}

.client-lock-banner .download-link:hover {
  background: #1d4ed8;
  text-decoration: none;
}

/* Review Form in Modal */
.review-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.review-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stars-selector {
  display: inline-flex;
  gap: 3px;
}

.stars-selector .star-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: transform 0.1s ease, color 0.15s ease;
}

.stars-selector .star-btn.selected,
.stars-selector .star-btn.hover {
  color: #f59e0b;
}

.stars-selector .star-btn:hover {
  transform: scale(1.2);
}

.client-verified-tag {
  font-size: 11px;
  color: var(--primary-dark);
  font-weight: 600;
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 4px;
}

:root[data-theme="dark"] .client-verified-tag {
  color: var(--primary-hover);
}

.review-form-author {
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.review-form-author:focus {
  border-color: var(--border-focus);
}

.review-form-content {
  min-height: 80px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  outline: none;
}

.review-form-content:focus {
  border-color: var(--border-focus);
}

.review-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-form-actions .form-tip {
  font-size: 11.5px;
  color: var(--text-3);
}

.review-form-submit {
  height: 32px;
  padding: 0 18px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.review-form-submit:hover:not(:disabled) {
  background: var(--primary-hover);
}

.review-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.review-form-status {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.review-form-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.review-form-status.success {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Reviews List in Modal */
.modal-reviews-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.review-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--border);
}

.review-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.review-item-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.review-item-author {
  font-weight: 600;
  color: var(--text);
}

.review-item-badge {
  font-size: 10px;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
}

:root[data-theme="dark"] .review-item-badge {
  color: var(--primary-hover);
}

.review-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.review-item-stars {
  color: #f59e0b;
  font-size: 12px;
  letter-spacing: 1px;
}

.review-item-time {
  color: var(--text-3);
  font-size: 11px;
}

.review-item-content {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
  word-break: break-word;
}

.reviews-empty {
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  padding: 24px 0;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 640px) {
  .hero { padding: 14px 16px; }
  .page { padding: 14px 14px 40px; }
  .grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; }
  .modal-dialog {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  .modal-facts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
