:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #1f2937;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e5e7eb;
  --line-strong: #d6dbe4;
  --text: #1f2937;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --blue: #3498db;
  --blue-dark: #2278b8;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1080px;
  background:
    radial-gradient(circle at 10% -10%, rgba(52, 152, 219, .10), transparent 28rem),
    linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
}
button, input, select { font: inherit; }
button {
  border: 1px solid #2388cc;
  border-radius: 10px;
  padding: 9px 14px;
  background: linear-gradient(180deg, #4ab0ee, #2f95d8);
  color: white;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(52, 152, 219, .22);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(52, 152, 219, .28);
}
button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: #374151;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .06);
}
button.secondary:hover:not(:disabled) { background: #f3f6fa; }
button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
input, select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .12);
}
label { font-size: 13px; font-weight: 650; color: #4b5563; }

.app {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}
.hidden { display: none !important; }
.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-card {
  max-width: 430px;
  margin: 12vh auto;
  padding: 30px;
}
.auth-card h1, .topbar h1 {
  margin: 0 0 8px;
  color: #111827;
  letter-spacing: -.03em;
}
.auth-card h1 { font-size: 28px; }
.topbar h1 { font-size: 26px; }
.muted { margin: 0; color: var(--muted); }
.error { color: #dc2626; min-height: 20px; }
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;
  min-width: 220px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, .16);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -18px) scale(.96);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.toast.success {
  border-color: #b8efd5;
  background: rgba(236, 253, 245, .96);
  color: #047857;
}
.toast.error {
  border-color: #fecdd3;
  background: rgba(255, 241, 242, .96);
  color: #dc2626;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }
.filters {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr)) 100px auto auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
}
.table-card {
  max-width: 1400px;
  overflow: hidden;
  border-radius: 18px;
}
.table-wrap {
  overflow-x: auto;
  padding: 16px 16px 0;
}
table {
  width: 100%;
  min-width: 1550px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
th, td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
tbody tr {
  background: #ffffff;
  transition: background .15s ease;
}
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(1), th:nth-child(1),
td:nth-child(9), th:nth-child(9) { text-align: center; }
td:nth-child(2) {
  color: #374151;
  font-weight: 650;
}
th.two-factor-column,
td.two-factor-cell,
th.password-column,
td.password-cell {
  width: 90px;
  min-width: 90px;
  max-width: 90px;
}
td.two-factor-cell,
td.password-cell {
  padding-right: 0;
  padding-left: 0;
}
.two-factor-value {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: #0f766e;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.two-factor-value:hover:not(:disabled) {
  transform: none;
  background: transparent;
  box-shadow: none;
  color: #0369a1;
  text-decoration: underline;
}
.two-factor-value:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}
.two-factor-empty { color: #94a3b8; }
.password-value { color: #7c3aed; }
th.sold-date,
td.sold-date,
th.import-date,
td.import-date {
  width: 150px;
  max-width: 150px;
}
td.sold-date,
td.import-date {
  overflow: hidden;
  text-overflow: ellipsis;
}
th.sticky-actions,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 374px;
  background: inherit;
  box-shadow: -12px 0 18px -18px rgba(15, 23, 42, .45);
}
th.sticky-actions {
  z-index: 3;
  background: #f7f9fc;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .7);
}
.badge.normal, .badge.available {
  background: #e9f9f1;
  color: #059669;
  border-color: #b8efd5;
}
.badge.abnormal {
  background: #fff7e6;
  color: #b7791f;
  border-color: #fde3a7;
}
.badge.banned, .badge.sold {
  background: #fff1f2;
  color: #dc2626;
  border-color: #fecdd3;
}
.health-status {
  display: grid;
  justify-items: start;
  gap: 5px;
  min-width: 170px;
}
.health-abnormal-time {
  color: #64748b;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}
.badge.high-quota {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.badge.ordinary-quota {
  background: #eef6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}
.badge.plus-offer {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.row-actions select {
  min-width: 92px;
  margin-top: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: #f9fafb;
}
.row-actions button {
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 9px;
  box-shadow: none;
}
.quota-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 88px;
  border: 1px solid #b7e4d1;
  background: linear-gradient(180deg, #ecfdf5, #dff8ec);
  color: #047857;
  box-shadow: 0 4px 10px rgba(16, 185, 129, .12);
}
.quota-refresh-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #dff8ec, #d0f2e2);
  box-shadow: 0 7px 14px rgba(16, 185, 129, .16);
}
.quota-refresh-btn:disabled {
  opacity: .8;
  color: #059669;
}
.btn-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(5, 150, 105, .22);
  border-top-color: #059669;
  border-radius: 50%;
}
.quota-refresh-btn.loading .btn-spinner {
  display: inline-block;
  animation: spin .7s linear infinite;
}
.health-test-btn {
  min-width: 58px;
  border: 1px solid #bfdbfe;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(59, 130, 246, .12);
}
.health-test-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  box-shadow: 0 7px 14px rgba(59, 130, 246, .16);
}
.page-quota-refresh {
  min-width: 136px;
}
.sms-query-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(59, 130, 246, .12);
}
.sms-query-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  box-shadow: 0 7px 14px rgba(59, 130, 246, .16);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.quota { min-width: 170px; }
.quota-track {
  height: 8px;
  background: #e8edf4;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 7px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
}
.quota-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .2s ease;
}
.quota-fill.green { background: linear-gradient(90deg, #10b981, #34d399); }
.quota-fill.yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.quota-fill.red { background: linear-gradient(90deg, #ef4444, #fb7185); }
.quota-text { font-size: 12px; color: #64748b; font-weight: 650; }
.quota-checked { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.quota-expired {
  margin-top: 6px;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 650;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 18px 18px;
  color: #64748b;
  font-size: 13px;
}
.pager button { min-width: 82px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, .42);
  opacity: 0;
  transition: opacity .18s ease;
}
.modal-backdrop.show { opacity: 1; }
.health-modal {
  width: min(850px, calc(100vw - 48px));
  overflow: hidden;
  border: 1px solid #d7dce5;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  transform: translateY(14px) scale(.98);
  transition: transform .18s ease;
}
.inspect-modal {
  width: 70%;
  min-width: min(960px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid #d7dce5;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  transform: translateY(14px) scale(.98);
  transition: transform .18s ease;
}
.sms-query-modal {
  width: min(920px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid #d7dce5;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  transform: translateY(14px) scale(.98);
  transition: transform .18s ease;
}
.inspect-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
}
.sms-query-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
}
.sms-query-config,
.sms-query-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
}
.sms-query-toolbar {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  margin-top: 16px;
}
.sms-query-toolbar .sms-query-btn { min-height: 42px; }
.sms-query-summary {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}
.sms-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.sms-list-heading h3 {
  margin: 0;
  color: #111827;
  font-size: 18px;
}
.sms-list-heading h3 span { color: #64748b; font-size: 14px; }
.sms-missing-list-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.sms-query-table {
  min-width: 100%;
  border: 0;
  border-radius: 0;
}
.sms-query-table th,
.sms-query-table td { white-space: normal; }
.sms-query-table th:last-child,
.sms-query-table td:last-child {
  position: static;
  min-width: 92px;
  width: 92px;
  box-shadow: none;
}
.sms-copy-btn { min-width: 64px; padding: 7px 10px; }
.inspect-toolbar {
  display: flex;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
}
.inspect-toolbar label {
  width: 160px;
}
.inspect-progress {
  margin-bottom: 16px;
}
.inspect-progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
}
.inspect-progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width .2s ease;
}
.inspect-progress-text {
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
  font-weight: 750;
}
.inspect-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.inspect-summary {
  color: #334155;
  font-size: 14px;
  font-weight: 850;
}
.inspect-list-title {
  margin: 0 0 10px;
  color: #111827;
  font-size: 18px;
}
.inspect-error-list-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.inspect-high-quota-wrap {
  overflow: auto;
  margin-bottom: 18px;
  border: 1px solid #b8efd5;
  border-radius: 12px;
  background: #f7fefb;
}
.inspect-high-quota-table {
  min-width: 720px;
  border: 0;
  border-radius: 0;
}
.inspect-high-quota-table th,
.inspect-high-quota-table td {
  white-space: normal;
}
.inspect-high-quota-table td:last-child,
.inspect-high-quota-table th:last-child {
  position: static;
  min-width: 0;
  box-shadow: none;
}
.inspect-high-quota-table td:nth-child(1),
.inspect-high-quota-table th:nth-child(1) { text-align: left; }
.inspect-refresh-countdown {
  display: inline-block;
  margin-left: 8px;
  color: #047857;
  font-size: 12px;
  font-weight: 800;
}
.inspect-error-table {
  min-width: 720px;
  border: 0;
  border-radius: 0;
}
.inspect-error-table th,
.inspect-error-table td {
  white-space: normal;
}
.inspect-error-table td:last-child,
.inspect-error-table th:last-child {
  position: static;
  min-width: 0;
  box-shadow: none;
}
.inspect-error-table td:nth-child(1),
.inspect-error-table th:nth-child(1) { text-align: left; }
button.danger {
  border-color: #fecdd3;
  background: linear-gradient(180deg, #fff1f2, #ffe4e6);
  color: #dc2626;
  box-shadow: 0 4px 10px rgba(239, 68, 68, .12);
}
.modal-backdrop.show .health-modal,
.modal-backdrop.show .inspect-modal,
.modal-backdrop.show .sms-query-modal { transform: translateY(0) scale(1); }
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafc;
}
.modal-header h2 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  letter-spacing: -.03em;
}
.modal-close {
  border: 0;
  background: transparent;
  color: #64748b;
  box-shadow: none;
  font-size: 30px;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  color: #111827;
}
.modal-body { padding: 20px 22px; }
.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.health-status-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}
.model-select {
  width: 260px;
  margin-top: 0;
}
.transport-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}
.transport-badge.confirmed {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}
.transport-badge.unknown {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}
.test-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}
.test-status::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: #cbd5e1;
}
.test-status.success { color: #10b981; }
.test-status.success::before { background: #22c55e; }
.test-status.running { color: #2563eb; }
.test-status.running::before {
  border: 2px solid rgba(37, 99, 235, .18);
  border-top-color: #2563eb;
  border-radius: 50%;
  background: transparent;
  animation: spin .7s linear infinite;
}
.test-status.error { color: #dc2626; }
.test-status.error::before { background: #ef4444; }
.test-output {
  min-height: 110px;
  margin: 0 0 20px;
  padding: 18px;
  border: 1px solid #d7dce5;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font: 700 15px/1.8 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}
.test-notice {
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 750;
}
.test-notice.success {
  border: 1px solid #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
}
.test-notice.error {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #dc2626;
}

@media (max-width: 1200px) {
  body { min-width: 0; }
  .app { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr; }
  .topbar, .filters, .table-wrap { padding: 14px; }
  .actions button { width: 100%; }
  .inspect-modal { width: calc(100vw - 32px); min-width: 0; }
  .sms-query-modal { width: calc(100vw - 32px); }
  .inspect-toolbar, .inspect-summary-row { align-items: stretch; flex-direction: column; }
  .inspect-toolbar label { width: 100%; }
  .sms-query-config, .sms-query-toolbar { grid-template-columns: 1fr; }
  .modal-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
  .model-select { width: 100%; }
}
