:root {
  --ink: #10201c;
  --muted: #60706b;
  --surface: #f4f7f5;
  --panel: #ffffff;
  --line: #dce6df;
  --line-strong: #cbd9d1;
  --green: #126f54;
  --green-dark: #0d4f40;
  --teal: #1b7f8f;
  --gold: #c58b2b;
  --rose: #b45769;
  --blue: #2f66b1;
  --shadow: 0 18px 60px rgba(23, 43, 37, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface);
}

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

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  padding: 20px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 840;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #ffffff;
  background: var(--green-dark);
  border-radius: 8px;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 6px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 790;
}

.nav-item:hover,
.nav-item.active {
  background: #e6f1ec;
  color: var(--green-dark);
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: var(--green-dark);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 850;
}

.nav-svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.nav-item:nth-child(2) .nav-icon {
  color: var(--green-dark);
  background: #e6f1ec;
}

.nav-item:nth-child(3) .nav-icon {
  color: var(--blue);
  background: #eef4fb;
}

.nav-item:nth-child(4) .nav-icon {
  color: var(--rose);
  background: #fbf0f3;
}

.nav-item:nth-child(5) .nav-icon {
  color: var(--gold);
  background: #fbf5e8;
}

.nav-item:nth-child(6) .nav-icon {
  color: var(--teal);
  background: #eaf5f7;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar,
.panel-heading,
.score-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1,
.panel h2,
.panel h3,
.eyebrow,
.panel p,
dl {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.05;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel,
.action-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.compact-panel {
  display: grid;
  gap: 12px;
  box-shadow: none;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.panel h2 {
  font-size: 15px;
  letter-spacing: 0;
}

.panel h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bulk-bar strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.bulk-bar p {
  margin: 0;
}

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

.panel-heading span,
.status-text,
.panel p,
.muted-line,
dt {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid #cfdad3;
  border-radius: 8px;
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}

input:focus {
  outline: 3px solid rgba(27, 127, 143, 0.2);
  border-color: var(--teal);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.button.primary {
  color: #ffffff;
  background: var(--green);
}

.button.secondary {
  color: var(--ink);
  background: #ffffff;
  border-color: rgba(16, 32, 28, 0.18);
}

.button.text-button {
  min-height: auto;
  margin-top: 12px;
  padding: 0;
  color: var(--green);
  background: transparent;
  border: 0;
}

.button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.metric-panel {
  margin-top: auto;
  box-shadow: none;
}

.credit-number {
  margin: 8px 0 4px;
  font-size: 44px;
  font-weight: 850;
  line-height: 1;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
}

.url-field {
  min-width: 0;
}

.small-field {
  width: 120px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.25fr);
  gap: 18px;
  min-width: 0;
}

.detail-grid {
  grid-template-columns: minmax(420px, 1.2fr) minmax(300px, 0.8fr);
}

.billing-grid {
  grid-template-columns: minmax(360px, 0.8fr) minmax(360px, 1.2fr);
}

.admin-grid {
  grid-template-columns: minmax(520px, 1.35fr) minmax(320px, 0.65fr);
}

.billing-plans-panel {
  margin-top: 18px;
}

.product-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-fields div {
  min-height: 76px;
  padding: 12px;
  background: #fbfcfb;
}

dt {
  margin-bottom: 5px;
  font-weight: 760;
}

dd {
  margin: 0;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.description-block {
  margin-top: 16px;
  padding: 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score-row {
  gap: 20px;
  align-items: stretch;
}

.score-ring {
  display: flex;
  flex: 0 0 132px;
  width: 132px;
  height: 132px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(circle at center, #ffffff 0 58%, transparent 59%),
    conic-gradient(var(--green) 0 calc(var(--score) * 1%), #dfe8e2 calc(var(--score) * 1%) 100%);
  border-radius: 50%;
}

.loading-ring {
  animation: pulse-ring 1s ease-in-out infinite;
  background:
    radial-gradient(circle at center, #ffffff 0 58%, transparent 59%),
    conic-gradient(var(--teal) 0 22%, #dfe8e2 22% 100%);
}

@keyframes pulse-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(27, 127, 143, 0.16);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(27, 127, 143, 0.05);
  }
}

.small-ring {
  flex-basis: 116px;
  width: 116px;
  height: 116px;
}

.score-ring strong {
  font-size: 34px;
  line-height: 1;
}

.small-ring strong {
  font-size: 30px;
}

.score-ring span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.recommendation {
  flex: 1;
  min-width: 0;
  padding: 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score-bars {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.skeleton-row span,
.skeleton-row strong,
.skeleton-card {
  min-height: 16px;
  background: linear-gradient(90deg, #edf3ef, #dfe8e2, #edf3ef);
  background-size: 220% 100%;
  border-radius: 7px;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-card {
  min-height: 62px;
}

.skeleton-row .bar-track {
  opacity: 0.55;
}

@keyframes skeleton-pulse {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: -220% 0;
  }
}

.score-bar {
  display: grid;
  grid-template-columns: 190px 40px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  background: #dfe8e2;
  border-radius: 999px;
}

.bar-fill {
  display: block;
  width: var(--width);
  height: 100%;
  background: var(--green);
}

.detail-fields,
.optimizer-grid,
.billing-stats {
  display: grid;
  gap: 0;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

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

.product-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 2px;
  padding: 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-context span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.product-context strong {
  display: block;
  max-width: 860px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.product-context p {
  margin-top: 4px;
}

.product-context-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.info-card,
.billing-stats div {
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.info-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.optimizer-grid .info-card {
  padding-right: 18px;
}

.info-card p {
  overflow-wrap: anywhere;
}

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

.store-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 14px;
  text-align: left;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.store-card:hover,
.store-card.selected {
  border-color: rgba(18, 111, 84, 0.45);
  box-shadow: inset 3px 0 0 var(--green);
}

.store-card strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.store-badge {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.store-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.copy-button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--green-dark);
  background: #e6f1ec;
  border: 1px solid rgba(18, 111, 84, 0.24);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.copy-button:hover {
  background: #dcebe5;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #edf2ef;
  vertical-align: top;
}

.select-col {
  width: 42px;
  text-align: center;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  color: var(--ink);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f7faf8;
}

.selected-row,
.selected-row:hover {
  background: #e6f1ec;
  box-shadow: inset 3px 0 0 var(--green);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  color: var(--muted);
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.status-pill.high {
  color: #8a3e4f;
  background: #fbf0f3;
  border-color: rgba(180, 87, 105, 0.28);
}

.status-pill.medium {
  color: #8a5c16;
  background: #fbf5e8;
  border-color: rgba(197, 139, 43, 0.28);
}

.status-pill.low {
  color: var(--green-dark);
  background: #e6f1ec;
  border-color: rgba(18, 111, 84, 0.28);
}

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

.mini-button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 820;
  cursor: pointer;
  white-space: nowrap;
}

.mini-button:hover {
  color: var(--green-dark);
  border-color: rgba(18, 111, 84, 0.45);
}

.primary-mini {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.primary-mini:hover {
  color: #ffffff;
  background: var(--green-dark);
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.history-item.selected,
.history-item:hover {
  border-color: rgba(18, 111, 84, 0.45);
  box-shadow: inset 3px 0 0 var(--green);
}

.history-item strong {
  font-size: 13px;
}

.history-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.query-list {
  display: grid;
  gap: 12px;
}

.query-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.query-card > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--green-dark);
  background: #e6f1ec;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
}

.query-card h3 {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.query-card strong {
  display: block;
  margin-top: 8px;
  color: var(--green-dark);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.billing-card {
  display: grid;
  align-content: start;
  gap: 16px;
}

.billing-card h2 {
  font-size: 26px;
}

.admin-credit-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.admin-summary-panel,
.admin-leads-panel,
.admin-requests-panel,
.admin-journeys-panel,
.admin-events-panel {
  grid-column: 1 / -1;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.admin-summary-grid div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.admin-summary-grid strong {
  font-size: 28px;
  line-height: 1;
}

.admin-top-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.admin-top-grid div {
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.admin-top-grid h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.admin-top-grid ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-top-grid li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.admin-top-grid li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-top-grid li strong {
  color: var(--ink);
}

.journey-list {
  display: grid;
  gap: 12px;
}

.journey-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.journey-head p,
.journey-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.journey-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.journey-sequence span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  color: var(--green-dark);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.admin-table th,
.admin-table td {
  white-space: nowrap;
}

.compact-select {
  display: grid;
  gap: 6px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.compact-select select {
  min-height: 36px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
}

.admin-events-panel .admin-table td:nth-child(6),
.admin-events-panel .admin-table td:nth-child(7) {
  min-width: 240px;
  max-width: 520px;
  white-space: normal;
}

.admin-leads-panel .admin-table td:nth-child(2) {
  max-width: 420px;
  white-space: normal;
  word-break: break-word;
}

.billing-stats {
  margin-top: 0;
}

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.billing-plan-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.billing-plan-card.featured {
  background: #ffffff;
  border-color: rgba(18, 111, 84, 0.35);
  box-shadow: inset 3px 0 0 var(--green);
}

.billing-plan-card h3 {
  font-size: clamp(26px, 3vw, 36px);
  letter-spacing: 0;
}

.billing-plan-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.billing-plan-card .button {
  width: 100%;
  margin-top: 4px;
}

.request-list {
  margin-top: 22px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.credit-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 1px;
  margin-top: 18px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.credit-rules div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 16px;
  background: #ffffff;
}

.credit-rules strong {
  color: var(--green-dark);
}

.credit-rules span {
  color: var(--muted);
  line-height: 1.45;
}

.usage-meter {
  height: 16px;
  overflow: hidden;
  background: #dfe8e2;
  border-radius: 999px;
}

.usage-meter span {
  display: block;
  width: var(--width);
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .app-shell,
  .grid,
  .detail-grid,
  .admin-grid,
  .admin-summary-grid,
  .admin-top-grid,
  .billing-grid,
  .billing-plan-grid,
  .credit-rules {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-panel {
    margin-top: 0;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .bulk-bar,
  .panel-heading,
  .bulk-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .action-panel,
  .product-fields,
  .store-list,
  .optimizer-grid {
    grid-template-columns: 1fr;
  }

  .product-context {
    align-items: stretch;
    flex-direction: column;
  }

  .product-context-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .score-row {
    display: grid;
  }

  .score-bar {
    grid-template-columns: 1fr 38px;
  }

  .score-bar .bar-track {
    grid-column: 1 / -1;
  }

  .button {
    width: 100%;
  }

  .small-field {
    width: 100%;
  }
}
