:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #657080;
  --line: #d9dee7;
  --green: #177245;
  --blue: #2455c3;
  --amber: #9a5b00;
  --shadow: 0 18px 42px rgba(27, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
}

.query-panel {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.auth-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(27, 31, 36, 0.36);
}

.auth-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-tabs,
.code-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
}

.auth-card h1 {
  font-size: 28px;
}

.form-message,
.muted-line {
  margin: 0;
  color: var(--muted);
}

.contact-line {
  margin: -2px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.contact-line button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.contact-line button:hover {
  color: var(--accent);
}

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

.account-bar span {
  margin-left: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.compact-button {
  width: auto;
  padding: 0 14px;
}

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

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-header h2 {
  margin: 0;
}

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

.admin-search {
  display: block;
  margin-top: 12px;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.user-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr 2fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.credentials-panel {
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.credentials-panel summary {
  cursor: pointer;
  font-weight: 700;
}

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

.credential-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.credential-group legend {
  padding: 0 6px;
  font-weight: 800;
}

.credential-group label {
  display: grid;
  gap: 4px;
}

.credential-group span {
  margin-top: 0;
}

.credential-group input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}

.credential-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.clear-credential {
  height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.credentials-save {
  grid-column: 1 / -1;
}

.credential-test-result {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
}

.test-line {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.test-line strong {
  color: inherit;
}

.test-line span {
  color: inherit;
}

.test-line.ok {
  background: #ecfdf3;
  border: 1px solid #b7ebc8;
  color: #116329;
}

.test-line.fail {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
}

.test-line.pending {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.user-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.credential-group span {
  margin-top: 0;
  color: var(--text);
  font-size: 12px;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.user-actions .ghost {
  height: 34px;
  padding: 0 10px;
}

.days-input {
  width: 86px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.duration-unit {
  width: 70px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.danger {
  color: #b42318;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.country-field {
  position: relative;
}

.suggest-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(560px, calc(100vw - 48px));
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(27, 31, 36, 0.14);
}

.suggest-panel button {
  display: grid;
  grid-template-columns: max-content minmax(160px, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
  height: auto;
  min-height: 36px;
  padding: 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.suggest-panel strong {
  white-space: nowrap;
}

.suggest-panel button:hover {
  background: #eef4ff;
  color: var(--blue);
}

.suggest-panel span {
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

input,
select,
button {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  background: var(--ink);
  color: white;
}

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

.summary {
  min-height: 108px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary span,
.summary small {
  display: block;
  color: var(--muted);
}

.summary strong {
  display: block;
  margin: 8px 0;
  font-size: 26px;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sort-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.ghost {
  width: auto;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.ghost.active {
  border-color: var(--blue);
  color: var(--blue);
}

.status {
  margin-bottom: 12px;
  color: var(--muted);
}

.provider-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 620px;
  margin: 0;
  padding: 0;
  background: transparent;
}

.provider-jump {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.provider-jump:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.provider-jump.active {
  border-color: var(--blue);
  background: #eef4ff;
  color: var(--blue);
}

.provider-jump span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.provider-jump strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-search {
  display: block;
  margin: -4px 0 12px;
}

.channel-search input {
  max-width: 100%;
}

.provider-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.provider-chip {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 13px;
}

.provider-chip.ok {
  border-color: #b8dfca;
  background: #eef8f3;
  color: var(--green);
}

.provider-chip.warn {
  border-color: #f0d6a5;
  background: #fff8ea;
  color: var(--amber);
}

.provider-chip.bad {
  border-color: #edb8b8;
  background: #fff1f1;
  color: #9d2626;
}

.provider-progress {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.provider-progress-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef2f7;
  color: #64748b;
  font-weight: 900;
  line-height: 1;
  margin: 0;
  font-size: 16px;
}

.provider-progress strong,
.provider-progress > div > span {
  display: block;
}

.provider-progress strong {
  color: var(--ink);
  font-size: 14px;
}

.provider-progress > div > span {
  margin-top: 3px;
  font-size: 12px;
}

.provider-progress.running {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.provider-progress.running .provider-progress-icon {
  background: #2563eb;
  color: #fff;
}

.provider-progress.ok {
  border-color: #b8dfca;
  background: #eef8f3;
}

.provider-progress.ok .provider-progress-icon {
  background: #137547;
  color: #fff;
}

.provider-progress.warn {
  border-color: #f0d6a5;
  background: #fff8ea;
}

.provider-progress.warn .provider-progress-icon {
  background: #b7791f;
  color: #fff;
}

.provider-progress.bad {
  border-color: #edb8b8;
  background: #fff1f1;
}

.provider-progress.bad .provider-progress-icon {
  background: #b42318;
  color: #fff;
}

.results {
  display: grid;
  gap: 14px;
}

.quote-section {
  scroll-margin-top: 72px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quote-section.favorites {
  border-color: #f2cf6b;
  background: #fffaf0;
}

.quote-section.empty {
  padding: 18px;
  color: var(--muted);
}

.quote-section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.quote-section-header h2 {
  margin: 0;
  font-size: 18px;
}

.quote-section-header span {
  color: var(--muted);
  font-size: 13px;
}

.quote-list {
  display: grid;
}

.quote {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 120px 120px 90px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 16px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}

.quote:last-child {
  border-bottom: 0;
}

.quote.is-favorite {
  background: #fffdf5;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f3ee;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

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

.price {
  color: var(--green);
  font-size: 22px;
  font-weight: 800;
}

.price-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.provider-error {
  padding: 12px 16px;
  border: 1px solid #f0d6a5;
  border-radius: 8px;
  background: #fff8ea;
  color: var(--amber);
}

.star-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #a0a8b4;
  font-size: 22px;
  line-height: 1;
}

.star-button.active {
  border-color: #f2c14e;
  background: #fff7dd;
  color: #b77900;
}

.star-button:hover {
  border-color: #f2c14e;
  color: #b77900;
}

@media (max-width: 900px) {
  .query-panel,
  .form-grid,
  .summary-grid,
  .provider-nav,
  .provider-status,
  .auth-tabs,
  .code-row,
  .admin-form,
  .user-row,
  .credentials-grid,
  .credential-group,
  .quote {
    grid-template-columns: 1fr;
  }

  .account-bar,
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .account-actions,
  .user-actions {
    justify-content: flex-start;
  }

  .provider-nav {
    position: static;
  }
}
