:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #141925;
  --muted: #748094;
  --line: #dfe6f0;
  --soft-line: #edf1f6;
  --accent: #2f6fed;
  --accent-dark: #2057c6;
  --danger: #c9342b;
  --warning: #996515;
  --ok-bg: #e8f7ef;
  --ok: #168052;
  --shadow-sm: 0 8px 24px rgba(17, 24, 39, .06);
  --shadow-md: 0 18px 48px rgba(17, 24, 39, .09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

button,
input,
textarea,
select {
  letter-spacing: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 111, 237, .18);
  outline-offset: 2px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

.lookup-page {
  min-height: 100vh;
  padding: 72px 20px;
  background:
    radial-gradient(circle at 24% 0%, rgba(47, 111, 237, .10), transparent 28%),
    linear-gradient(180deg, #ffffff 0, #f7f9fd 48%, #edf2f8 100%);
}

.lookup-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.lookup-hero {
  margin: 0 auto 32px;
  text-align: center;
}

.brand,
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 20px;
  padding: 0 18px;
  border: 1px solid rgba(47, 111, 237, .16);
  border-radius: 999px;
  color: #18335f;
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-sm);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.lookup-hero h1 {
  margin: 0 0 12px;
  font-size: 42px;
  line-height: 1.12;
}

.lookup-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.hero-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4d5a70;
  background: rgba(255, 255, 255, .7);
  font-size: 13px;
  font-weight: 750;
}

.lookup-box {
  margin: 0 auto;
}

.lookup-card {
  padding: 10px;
  border: 1px solid rgba(223, 230, 240, .92);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-md);
}

.query-form {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.query-form input {
  min-width: 0;
  min-height: 56px;
  border: 0;
  outline: 0;
  padding: 0 20px;
  color: var(--text);
  background: transparent;
  font-size: 17px;
  font-weight: 650;
}

.query-form button,
.button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #3c7af0 0%, var(--accent) 100%);
  cursor: pointer;
  font-weight: 750;
  box-shadow: 0 10px 22px rgba(47, 111, 237, .22);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.query-form button {
  min-height: 56px;
}

.query-form button.loading {
  cursor: wait;
  opacity: .72;
  transform: none;
}

.query-form button:hover,
.button:hover {
  background: var(--accent-dark);
  box-shadow: 0 12px 26px rgba(47, 111, 237, .26);
  transform: translateY(-1px);
}

.query-message {
  margin: 10px 4px 2px;
  color: var(--ok);
  text-align: center;
}

.query-message:empty {
  display: none;
}

.captcha-box {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 12px 4px 0;
}

.captcha-box img {
  width: 150px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.captcha-box input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.query-message.error,
.flash.error {
  color: var(--danger);
}

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

.result-card {
  margin-top: 18px;
  padding: 26px;
  text-align: left;
  box-shadow: var(--shadow-md);
}

.hidden {
  display: none;
}

.status-pill {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ok);
  background: var(--ok-bg);
  font-weight: 800;
  font-size: 14px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.result-card h2 {
  margin: 14px 0 0;
  font-size: 24px;
}

.result-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--soft-line);
  text-align: left;
}

.copy-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #bdd2fb;
  border-radius: 8px;
  color: var(--accent);
  background: #f4f7ff;
  cursor: pointer;
  font-weight: 800;
}

.result-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.result-row strong {
  overflow-wrap: anywhere;
}

.code-row strong {
  color: #6f3bd8;
  font-size: 36px;
  letter-spacing: 0;
}

.secondary-button,
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
}

.secondary-button {
  color: var(--accent);
  border: 1px solid #c8d6f7;
  background: #eef4ff;
  box-shadow: none;
}

.lookup-footer {
  margin-top: 32px;
  text-align: center;
}

.lookup-footer a {
  display: inline-block;
  padding: 10px 28px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.lookup-footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(47, 111, 237, .06);
}

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

.panel {
  padding: 22px;
}

.panel.narrow {
  width: min(420px, 100%);
}

.panel h1,
.panel h2 {
  margin: 0 0 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.stack-form input,
.stack-form textarea,
.stack-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus,
.filter-form input:focus,
.filter-form select:focus,
.inline-form input:focus,
.inline-form select:focus {
  border-color: rgba(47, 111, 237, .58);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, .10);
  outline: 0;
}

.stack-form textarea {
  resize: vertical;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--ok);
  border: 1px solid #cdebd9;
  background: #f0fbf5;
  font-weight: 700;
}

.admin-app {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f6f8fb 0, #edf2f8 100%);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  border-right: 1px solid #dfe6f0;
  background: #ffffff;
  box-shadow: 8px 0 30px rgba(17, 24, 39, .03);
}

.admin-brand {
  padding: 10px 12px 22px;
  border-bottom: 1px solid var(--line);
}

.admin-brand strong {
  display: block;
  font-size: 23px;
  font-weight: 900;
  color: #172033;
}

.admin-brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-nav {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.admin-nav a {
  display: grid;
  gap: 3px;
  padding: 12px 13px;
  border-radius: 8px;
  color: #4b5565;
  font-weight: 750;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}

.admin-nav a span {
  line-height: 1.2;
}

.admin-nav a small {
  color: #9aa5b6;
  font-size: 12px;
  font-weight: 700;
}

.admin-nav a:hover,
.admin-nav a.active {
  color: var(--accent);
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.admin-main {
  min-width: 0;
  padding: 28px;
}

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

.admin-topbar h1 {
  margin: 0;
  color: #121826;
  font-size: 30px;
  line-height: 1.18;
}

.admin-topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.admin-topbar nav {
  display: flex;
  gap: 10px;
}

.admin-topbar a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4b5565;
  background: #fff;
  font-weight: 750;
  box-shadow: var(--shadow-sm);
}

.stats-grid,
.admin-grid,
.two-column {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.stats-grid {
  grid-template-columns: repeat(4, 1fr);
}

.stats-grid div {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.stats-grid em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
}

.stats-grid .warn-card {
  border-color: #f4c16d;
  background: #fffaf0;
}

.stats-grid div::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(47, 111, 237, .18), rgba(22, 128, 82, .12));
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stats-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1;
}

.admin-grid {
  grid-template-columns: 1.5fr 1fr;
}

.two-column {
  grid-template-columns: 1fr 1fr;
}

.panel {
  margin-bottom: 18px;
}

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

.panel-title h2 {
  margin: 0;
  color: #182033;
  font-size: 18px;
  line-height: 1.25;
}

.panel-title a,
.panel-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.panel-title a {
  color: var(--accent);
}

.filter-form,
.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px auto auto;
  gap: 10px;
  align-items: center;
}

.inline-form {
  grid-template-columns: 120px auto auto;
}

.filter-form input,
.filter-form select,
.inline-form input:not([type="checkbox"]):not([type="radio"]),
.inline-form select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4b5565;
  background: #fff;
  font-weight: 750;
  transition: border-color .16s ease, color .16s ease;
}

.ghost-button:hover {
  border-color: #bdd2fb;
  color: var(--accent);
}

.inline-check {
  display: inline-grid;
  grid-template-columns: 20px auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-form input[type="checkbox"],
.inline-form input[type="radio"],
.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  box-shadow: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.codes-table {
  min-width: 1280px;
}

.compact table {
  min-width: 640px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #66738a;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

td {
  overflow-wrap: anywhere;
  font-size: 14px;
}

tbody tr {
  transition: background .14s ease;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #24324a;
  background: #f4f7fb;
  border-radius: 6px;
  padding: 2px 5px;
}

.table-link {
  color: var(--accent);
  font-weight: 700;
}

.codes-table .table-link,
.codes-table code {
  white-space: nowrap;
}

.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.bulk-settings {
  display: grid;
  grid-template-columns: 220px 160px 132px;
  gap: 10px;
  align-items: end;
  justify-content: start;
  margin-bottom: 14px;
}

.bulk-settings label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bulk-settings input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.trend-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  min-height: 210px;
  align-items: end;
}

.trend-bars div {
  display: grid;
  grid-template-rows: 22px 150px 22px;
  gap: 8px;
  text-align: center;
}

.trend-bars span,
.trend-bars strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trend-bars b {
  align-self: end;
  width: 100%;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #ef6a5b 0%, #c9342b 100%);
}

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

.rank-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--soft-line);
}

.rank-list strong {
  color: var(--accent);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #fac5bd;
  border-radius: 8px;
  color: #b42318;
  background: #fff7f5;
  cursor: pointer;
  font-weight: 800;
  transition: border-color .16s ease, background .16s ease;
}

.danger-button:hover {
  border-color: #f0988c;
  background: #fff0ed;
}

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #bdd2fb;
  border-radius: 8px;
  color: var(--accent);
  background: #f4f7ff;
  cursor: pointer;
  font-weight: 800;
  transition: border-color .16s ease, background .16s ease;
}

.export-button:hover {
  border-color: #91b5fb;
  background: #eaf2ff;
}

.link-danger {
  border: 0;
  padding: 0;
  color: #b42318;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.link-danger:hover {
  text-decoration: underline;
}

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

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

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: #445064;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.success,
.status-badge.active,
.status-badge.assigned,
.status-badge.available {
  color: #087443;
  background: #e6f7ee;
}

.status-badge.unused,
.status-badge.no_mailbox {
  color: #8a5a00;
  background: #fff4d7;
}

.status-badge.disabled,
.status-badge.provider_error,
.status-badge.not_found,
.status-badge.expired,
.status-badge.max_queries,
.status-badge.rate_limited,
.status-badge.captcha_required {
  color: #b42318;
  background: #fde8e5;
}

.status-badge.cached_code {
  color: #2057c6;
  background: #eaf2ff;
}

.ua-cell {
  max-width: 360px;
}

.info-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.info-list dt {
  color: var(--muted);
  font-weight: 800;
}

.info-list dd {
  margin: 0;
}

.break-text {
  overflow-wrap: anywhere;
}

.deploy-notes {
  display: grid;
  gap: 10px;
  color: #4b5565;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #f8fafc;
}

.deploy-notes p {
  margin: 0;
}

.provider-switch {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}

.provider-switch label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #4b5565;
  font-weight: 750;
  cursor: pointer;
}

.provider-switch label.selected {
  border-color: #9db7f4;
  color: var(--accent);
  background: #eef4ff;
}

@media (max-width: 760px) {
  .lookup-page {
    padding: 38px 16px;
  }

  .brand,
  .brand-mark {
    font-size: 16px;
  }

  .lookup-hero h1 {
    font-size: 32px;
  }

  .query-form {
    grid-template-columns: 1fr;
  }

  .query-form input {
    padding: 14px 12px;
    font-size: 15px;
  }

  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }

  .result-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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

  .admin-app {
    grid-template-columns: 1fr;
  }

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

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

  .admin-main {
    padding: 16px;
  }

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

  .admin-topbar h1 {
    font-size: 25px;
  }

  .panel {
    padding: 16px;
  }

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

  .table-actions {
    width: 100%;
  }

  .table-actions a,
  .table-actions button {
    flex: 1;
  }

  .stats-grid,
  .admin-grid,
  .two-column,
  .filter-form,
  .inline-form,
  .provider-switch,
  .captcha-box,
  .bulk-settings {
    grid-template-columns: 1fr;
  }

  .info-list div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
