:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #dce2e9;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #047857;
  --green-soft: #ecfdf5;
  --red: #c0262d;
  --red-soft: #fff1f2;
  --cyan-soft: #ecfeff;
  --shadow: 0 8px 24px rgba(23, 32, 51, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; }
.shell { width: min(920px, calc(100vw - 32px)); margin: 0 auto; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-size: 18px; font-weight: 850; text-decoration: none; }
.provider-tag, .mode-badge {
  display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px;
  border: 1px solid #bae6fd; border-radius: 999px; color: #0369a1; background: #f0f9ff;
  font-size: 12px; font-weight: 800;
}
.user-shell { padding: 36px 0 54px; }
.login-panel { max-width: 440px; margin: 8vh auto 0; padding: 30px; }
.section-heading { margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
label, .field-label { display: block; margin: 14px 0 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink); padding: 10px 12px; outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
.button {
  min-height: 40px; border: 1px solid transparent; border-radius: 7px; padding: 9px 14px;
  font-weight: 800; white-space: nowrap;
}
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--blue); color: #fff; }
.button.secondary { background: #fff; color: #344054; border-color: var(--line); }
.button.danger { background: var(--red-soft); color: var(--red); border-color: #fecdd3; }
.button.full { width: 100%; margin-top: 18px; }
.icon-button {
  width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: #344054; font-size: 20px;
}
.icon-button:disabled { opacity: .4; cursor: not-allowed; }
.alert { margin: 0 0 16px; border: 1px solid #fecdd3; background: var(--red-soft); color: #9f1239; border-radius: 7px; padding: 11px 12px; font-size: 14px; }
.order-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.status-pill.waiting { color: var(--blue); background: var(--blue-soft); border: 1px solid #bfdbfe; }
.status-pill.success { color: var(--green); background: var(--green-soft); border: 1px solid #a7f3d0; }
.status-pill.error { color: var(--red); background: var(--red-soft); border: 1px solid #fecdd3; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.number-main { min-height: 126px; padding: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.number-main .field-label, .code-section .field-label { margin-top: 0; }
.phone-number { font-size: 36px; font-weight: 900; overflow-wrap: anywhere; }
.metadata-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border-top: 1px solid var(--line); }
.metadata-grid > div { min-width: 0; padding: 15px 18px; border-right: 1px solid var(--line); }
.metadata-grid > div:last-child { border-right: 0; }
.metadata-grid dt { color: var(--muted); font-size: 12px; }
.metadata-grid dd { margin: 6px 0 0; font-weight: 800; overflow-wrap: anywhere; }
.code-section { margin-top: 14px; min-height: 142px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.verification-code { min-height: 46px; font-size: 34px; font-weight: 900; color: var(--red); }
.subtle { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.action-bar { display: flex; justify-content: flex-end; gap: 10px; margin: 14px 0; }
.promo { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid #a5f3fc; border-radius: 8px; background: var(--cyan-soft); text-decoration: none; }
.promo strong, .promo small { display: block; }
.promo small { margin-top: 4px; color: #0e7490; }
.notice-band { margin-top: 14px; padding: 17px 20px; border-left: 3px solid #94a3b8; background: #fff; color: #475467; line-height: 1.65; white-space: pre-wrap; }
.toast { position: fixed; z-index: 30; top: 24px; left: 50%; transform: translateX(-50%); padding: 11px 15px; border-radius: 7px; background: #111827; color: #fff; opacity: 0; pointer-events: none; transition: opacity .18s; }
.toast.show { opacity: 1; }

.admin-page { min-height: 100vh; }
.admin-login { width: min(390px, calc(100vw - 32px)); margin: 12vh auto 0; padding: 28px; }
.admin-header { min-height: 84px; padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; border-bottom: 1px solid var(--line); }
.header-actions, .section-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.compact-select { width: auto; min-width: 112px; min-height: 40px; padding: 8px 10px; }
.tabs { position: sticky; top: 0; z-index: 10; display: flex; gap: 2px; padding: 0 28px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); }
.tab { min-height: 46px; flex: 0 0 auto; padding: 0 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 800; white-space: nowrap; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.admin-content { width: min(1240px, calc(100vw - 32px)); margin: 24px auto 54px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.metric { min-width: 0; min-height: 104px; padding: 17px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 9px; font-size: 27px; overflow-wrap: anywhere; }
.data-section { margin-top: 16px; padding: 20px; background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-title { min-height: 44px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid.compact { grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr) auto; }
.form-grid label { margin-top: 0; }
.form-action { display: flex; align-items: end; }
.service-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.toggle-row { min-height: 44px; display: flex; align-items: center; gap: 9px; margin: 0; color: var(--ink); }
.toggle-row input { width: 18px; min-height: 18px; }
.generated-block { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.generated-toolbar { min-height: 48px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.generated-block pre { max-height: 230px; margin: 0; padding: 14px; overflow: auto; background: #111827; color: #e5e7eb; font-family: Consolas, monospace; line-height: 1.55; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 800; background: #f8fafc; }
td code { padding: 3px 5px; border-radius: 4px; background: #f1f5f9; font-family: Consolas, monospace; }
.table-action { min-height: 32px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #344054; font-weight: 700; }
.table-action.danger-action { color: var(--red); border-color: #fecdd3; background: var(--red-soft); }
.status-text { font-weight: 800; }
.status-text.used, .status-text.received { color: var(--green); }
.status-text.disabled, .status-text.failed { color: var(--red); }
.status-text.active, .status-text.pending, .status-text.reserving { color: var(--blue); }
.quote { max-width: 210px; color: #475467; font-size: 12px; line-height: 1.45; }
.market-summary { margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--blue); background: var(--blue-soft); color: #344054; font-size: 13px; line-height: 1.6; }
.detail-list { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.detail-list div { padding: 13px 16px; border-right: 1px solid var(--line); }
.detail-list div:last-child { border-right: 0; }
.detail-list dt { color: var(--muted); font-size: 12px; }
.detail-list dd { margin: 6px 0 0; font-weight: 800; }
.settings-form > .button { margin-top: 16px; }
.credential-status { color: var(--muted); font-size: 13px; }
.credential-status.configured { color: var(--green); }
.credential-status.invalid { color: var(--red); }
.credential-actions { margin-top: 16px; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .service-form { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .shell, .admin-content { width: min(100% - 22px, 920px); }
  .user-shell { padding-top: 20px; }
  .login-panel { margin-top: 4vh; padding: 22px; }
  .order-header, .admin-header, .section-title { align-items: stretch; flex-direction: column; }
  .admin-header { padding: 16px; }
  .tabs { padding: 0 10px; }
  .phone-number { font-size: 27px; }
  .metadata-grid { grid-template-columns: 1fr 1fr; }
  .metadata-grid > div:nth-child(2) { border-right: 0; }
  .metadata-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .code-section { align-items: flex-start; }
  .action-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .action-bar .danger { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid.compact, .service-form, .detail-list { grid-template-columns: 1fr; }
  .detail-list div { border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-list div:last-child { border-bottom: 0; }
}
