:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --green: #147d64;
  --green-strong: #0f6b55;
  --red: #b42318;
  --red-soft: #fff1f0;
  --blue-soft: #e8f0ff;
  --shadow: 0 18px 60px rgba(27, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef3f8 0, transparent 260px),
    radial-gradient(circle at 10% 0%, rgba(20, 125, 100, 0.08), transparent 32rem),
    var(--bg);
  overflow-x: hidden;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 32px 16px;
}

.layout {
  width: min(1220px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
  gap: 18px;
}

.auth-gate {
  width: min(520px, 100%);
  margin: 9vh auto 0;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-gate h1 {
  margin-bottom: 10px;
  font-size: 38px;
}

.auth-gate p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-grid input {
  grid-column: span 2;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
}

.session-bar .auth-state {
  min-width: 220px;
  margin-right: auto;
  color: #344054;
  font-size: 14px;
  font-weight: 800;
}

.button-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #c8cfda;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  border-color: #98a2b3;
  background: #f9fafb;
}

.workspace {
  min-width: 0;
}

.mast {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 18px;
}

.mast-title {
  min-width: max-content;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.product-selectors {
  width: min(496px, 100%);
  flex: 0 1 496px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}

.product-select {
  min-width: 0;
  position: relative;
}

.select-shell {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 12px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #c8cfda;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(27, 36, 48, 0.06);
  text-align: left;
}

.select-icon {
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
}

.openai-icon {
  color: #0f6b55;
  background: #e7f6f1;
}

.openai-icon::before {
  content: "AI";
  font-size: 12px;
  font-weight: 900;
}

.claude-icon {
  color: #b65f2b;
  background: #fbefe6;
}

.claude-icon::before {
  content: "C";
  font-size: 14px;
  font-weight: 900;
}

.gemini-icon {
  color: #3157d5;
  background: #eef3ff;
}

.gemini-icon::before {
  content: "G";
  font-size: 14px;
  font-weight: 900;
}

.empty-icon {
  background: #edf1f5;
  border: 1px solid #d0d5dd;
}

.empty-icon::before {
  width: 12px;
  height: 12px;
  content: "";
  border: 2px solid #98a2b3;
  border-radius: 50%;
}

.flag-icon {
  width: 30px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 3px;
  overflow: hidden;
  background-color: #eef2f6;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.flag-generic {
  background:
    linear-gradient(180deg, #98a2b3 0 33%, #ffffff 33% 66%, #147d64 66% 100%);
}

.flag-empty {
  background:
    linear-gradient(135deg, #edf1f5 0 45%, #c8cfda 45% 52%, #edf1f5 52% 100%);
}

.select-caption {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.select-value {
  min-width: 0;
  grid-column: 2;
  grid-row: 2;
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  width: 9px;
  height: 9px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  transform: rotate(45deg) translateY(-2px);
}

.notes {
  margin: 12px 0;
  padding: 16px 18px;
  color: var(--ink);
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notes h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.notes ol {
  margin: 0;
  padding-left: 22px;
}

.notes li {
  padding: 3px 0;
  color: #344054;
  line-height: 1.55;
}

.notes strong {
  font-weight: 800;
}

.seo-section {
  margin-top: 12px;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.seo-section h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
}

.seo-section p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seo-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: #0f513f;
  background: #eef8f4;
  border: 1px solid #b8e6d4;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.seo-links a:hover {
  border-color: var(--green);
  background: #e3f3ed;
}

.copy-token {
  display: inline-block;
  padding: 0 4px;
  color: var(--green-strong);
  border-bottom: 1px dashed currentColor;
  border-radius: 4px;
  cursor: copy;
  font-weight: 900;
  user-select: all;
}

.copy-token:hover {
  background: rgba(20, 125, 100, 0.08);
}

.panel,
.tile,
.pass-rate,
.frequency-panel,
.drawer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > label,
.tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px auto;
  align-items: stretch;
  gap: 8px;
}

.account-meter {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: #102a43;
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.captcha-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.captcha-row span {
  color: #344054;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #c8cfda;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.card-input-row input {
  min-height: 52px;
}

textarea {
  min-height: 150px;
  padding: 12px;
  margin-top: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.16);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #c8cfda;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  border-color: #98a2b3;
  background: #f9fafb;
}

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

button.primary {
  color: #fff;
  border-color: var(--green-strong);
  background: var(--green);
}

button.primary:hover:not(:disabled) {
  border-color: #0a5845;
  background: var(--green-strong);
}

button.danger,
.refund-button {
  color: var(--red);
  border-color: #ffc9c2;
  background: var(--red-soft);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.tile {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 16px;
}

.tile strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.code-tile {
  background: var(--blue-soft);
  border-color: #c7d7fe;
}

.code-tile strong {
  font-size: 34px;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #513b12;
  background: #fff7e6;
  border: 1px solid #f2d088;
  overflow-wrap: anywhere;
}

.notice.error {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffc9c2;
}

.sidebar {
  position: sticky;
  top: 32px;
  display: grid;
  gap: 12px;
}

.help-button {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--green-strong);
  background: #ffffff;
  border: 1px solid #b8e6d4;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-weight: 800;
  text-decoration: none;
}

.help-button:hover {
  border-color: var(--green);
  background: #f6fbf9;
}

.pass-rate {
  width: 100%;
  display: grid;
  justify-items: start;
  gap: 5px;
  padding: 12px 14px;
  color: #0f513f;
  border-color: #b8e6d4;
}

.pass-rate strong {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.frequency-panel {
  padding: 16px;
}

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

.price-rule {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.choice-search {
  width: 100%;
  height: 38px;
  margin-bottom: 10px;
  border-radius: 8px;
  font-size: 13px;
}

.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  margin-bottom: 12px;
}

.choice-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
  color: #344054;
  background: #f9fafb;
}

.choice-pill small {
  color: currentColor;
  opacity: 0.7;
  font-size: 11px;
  font-weight: 800;
}

.choice-pill.active {
  color: #fff;
  border-color: var(--green-strong);
  background: var(--green);
}

.country-choice-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.country-choice {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.country-choice span {
  font-weight: 800;
}

.country-choice strong {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
}

.country-choice.active {
  color: #0f513f;
  border-color: #91d9bf;
  background: #eef8f4;
}

.sidebar-head {
  margin-bottom: 12px;
}

.pass-rate span,
.sidebar-head span {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

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

.frequency-row {
  display: grid;
  gap: 6px;
}

.frequency-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.frequency-line span {
  color: #344054;
  font-size: 14px;
}

.frequency-track {
  height: 8px;
  overflow: hidden;
  background: #edf1f5;
  border-radius: 999px;
}

.frequency-fill {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.frequency-empty {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.drawer {
  width: min(1220px, 100%);
  margin: 18px auto 0;
  padding: 18px;
}

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

.drawer h2,
.drawer h3 {
  margin: 0 0 12px;
}

.drawer h3 {
  margin-top: 18px;
}

.summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px;
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.summary-card {
  min-height: 76px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

.table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

.empty {
  padding: 14px;
  color: var(--muted);
}

.mini-action {
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.mini-action.danger {
  border-color: rgba(191, 38, 38, 0.35);
  color: #b42318;
}

.cdk-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.cdk-filter-tabs button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f9fafb;
}

.cdk-filter-tabs button.active {
  color: #fff;
  border-color: var(--green-strong);
  background: var(--green);
}

.table .mini-action + .mini-action {
  margin-left: 6px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-form button {
  grid-column: span 4;
}

.admin-shell {
  display: block;
}

.admin-page {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
}

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

.admin-section {
  width: 100%;
  margin-top: 18px;
}

.article-shell {
  min-height: 100dvh;
  display: grid;
  place-items: start center;
  padding: 32px 16px;
}

.article-page {
  width: min(820px, 100%);
  padding: 28px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.article-back {
  color: var(--green-strong);
  font-weight: 900;
  text-decoration: none;
}

.article-page h1 {
  margin-top: 18px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

.article-page h2 {
  margin: 28px 0 10px;
  font-size: 22px;
}

.article-page p,
.article-page li {
  color: #344054;
  font-size: 16px;
  line-height: 1.75;
}

.article-page ol {
  padding-left: 22px;
}

@media (max-width: 720px) {
  .shell {
    align-items: start;
    min-height: 100dvh;
    padding: 12px 10px 20px;
  }

  .layout {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .workspace[data-panel="home"] {
    min-width: 0;
    display: flex;
    flex-direction: column;
    order: 1;
    gap: 10px;
  }

  .mast {
    align-items: start;
    flex-direction: column;
    order: 1;
    gap: 10px;
    margin-bottom: 0;
  }

  .mast-title {
    min-width: 0;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  .auth-grid,
  .actions,
  .captcha-row,
  .admin-form,
  .summary-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .product-selectors {
    width: 100%;
    flex: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 0;
  }

  .select-shell {
    min-height: 52px;
    grid-template-columns: 26px minmax(0, 1fr) 10px;
    column-gap: 8px;
    padding: 8px 10px;
  }

  .select-icon {
    width: 26px;
    height: 26px;
  }

  .flag-icon {
    width: 26px;
    height: 19px;
  }

  .select-caption {
    font-size: 11px;
  }

  .select-value {
    font-size: 15px;
  }

  .sidebar {
    position: static;
    order: 2;
    margin-top: 0;
  }

  .country-panel {
    padding: 12px;
  }

  .sidebar-head {
    margin-bottom: 8px;
  }

  .sidebar-head span {
    font-size: 17px;
  }

  .price-rule {
    margin-bottom: 8px;
  }

  .choice-search {
    min-height: 40px;
    margin-bottom: 8px;
  }

  .choice-list {
    max-height: 118px;
    margin-bottom: 10px;
  }

  .country-choice-list {
    max-height: 236px;
  }

  .choice-pill,
  .country-choice {
    min-height: 42px;
  }

  .notes {
    order: 5;
    margin: 0;
    padding: 12px 14px;
  }

  .notes h2 {
    font-size: 18px;
  }

  .notes ol {
    padding-left: 18px;
  }

  .notes li {
    font-size: 13px;
    line-height: 1.45;
  }

  .seo-section {
    order: 6;
    margin-top: 0;
    padding: 12px 14px;
  }

  .seo-section h2 {
    font-size: 18px;
  }

  .seo-section p {
    font-size: 13px;
    line-height: 1.5;
  }

  .seo-links {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
    padding: 12px;
  }

  .card-input-row {
    grid-template-columns: minmax(0, 1fr) 66px;
    gap: 6px;
  }

  .account-meter {
    grid-column: 1 / -1;
    min-height: 38px;
    justify-content: flex-start;
    padding: 0 10px;
    font-size: 13px;
  }

  .captcha-row {
    grid-template-columns: minmax(0, 1fr) 66px;
    gap: 6px;
  }

  .captcha-row span {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  input,
  select,
  textarea,
  button {
    min-height: 42px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .card-input-row input {
    min-height: 48px;
  }

  .actions {
    gap: 8px;
    margin-top: 10px;
  }

  .notice {
    order: 3;
    margin-top: 0;
    padding: 10px 12px;
    font-size: 13px;
  }

  .status-grid {
    order: 4;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 0;
  }

  .tile {
    min-height: 92px;
    gap: 10px;
    padding: 12px;
  }

  .tile span {
    font-size: 12px;
  }

  .tile strong {
    font-size: 18px;
  }

  .code-tile {
    grid-column: 1 / -1;
    min-height: 96px;
  }

  .code-tile strong {
    font-size: 30px;
  }

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

  .article-shell {
    padding: 12px 10px 20px;
  }

  .article-page {
    padding: 18px;
  }

  .article-page p,
  .article-page li {
    font-size: 14px;
    line-height: 1.65;
  }
}

@media (max-width: 360px) {
  .product-selectors {
    grid-template-columns: 1fr;
  }

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

  .code-tile {
    grid-column: auto;
  }
}

@media (min-width: 721px) and (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .product-selectors {
    width: min(520px, 100%);
  }

  .session-bar {
    grid-template-columns: 1fr 1fr 1fr auto auto;
  }

  .sidebar {
    position: static;
    margin-top: 0;
  }
}
