:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --line: #e2e9e5;
  --line-strong: #cfdad4;
  --text: #10231b;
  --muted: #63796f;
  --faint: #8b9d94;
  --green: #25d366;
  --green-deep: #128c4a;
  --radius: 18px;
  --shadow: 0 18px 44px -24px rgba(16, 35, 27, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 620px at 10% -12%, rgba(37, 211, 102, .16), transparent 62%),
    radial-gradient(760px 540px at 98% 108%, rgba(37, 211, 102, .12), transparent 60%),
    var(--bg);
}

.app {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 32px) 40px;
}

/* ── header ─────────────────────────────── */
.head { margin-bottom: clamp(20px, 3vw, 32px); }

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 42px; height: 42px;
  flex: none;
  color: var(--green-deep);
  filter: drop-shadow(0 6px 14px rgba(18, 140, 74, .22));
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 650;
  letter-spacing: -.02em;
}

.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* ── layout ─────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(16px, 2.4vw, 28px);
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 2.6vw, 30px);
}

.qr-panel {
  position: sticky;
  top: clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── form ───────────────────────────────── */
.field { margin-bottom: 20px; }

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.hint { color: var(--faint); font-weight: 400; }

.input-wrap { position: relative; display: flex; align-items: center; }

.prefix {
  position: absolute;
  left: 15px;
  color: var(--faint);
  font-size: 16px;
  pointer-events: none;
}

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fbfdfc;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 13px 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

#msisdn { padding-left: 30px; letter-spacing: .04em; }

textarea { resize: vertical; min-height: 108px; line-height: 1.6; }

input:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, .2);
}

input::placeholder, textarea::placeholder { color: #a8b8b1; }

.counter { margin-top: 6px; font-size: 12px; color: var(--faint); text-align: right; }

.err { margin: 7px 0 0; font-size: 12.5px; color: #c2352f; }

.url-row { display: flex; gap: 8px; }

#url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
  background: #f3f7f5;
  border-color: var(--line);
  overflow-x: auto;
  white-space: nowrap;
}

/* ── buttons ────────────────────────────── */
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}

.btn:hover { background: #f2f7f4; border-color: #b9c9c1; }
.btn:active { transform: translateY(1px); }

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  color: #fff;
  background: var(--green-deep);
  border-color: var(--green-deep);
  box-shadow: 0 10px 22px -12px rgba(18, 140, 74, .9);
}

.btn-primary:hover { background: #0f7b41; border-color: #0f7b41; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: #f2f7f4; }

.btn-sm { padding: 10px 13px; font-size: 13px; color: var(--muted); }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .45;
  pointer-events: none;
}

.saved { margin: 16px 0 0; font-size: 12px; color: var(--faint); min-height: 1.2em; }

/* ── QR ─────────────────────────────────── */
.qr-frame {
  width: 100%;
  aspect-ratio: 1;
  max-width: 460px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(14px, 2.4vw, 24px);
  box-shadow: 0 16px 40px -26px rgba(16, 35, 27, .5);
}

.qr-stage { width: 100%; height: 100%; display: none; }
.qr-stage svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }

.qr-frame.ready .qr-stage { display: block; }
.qr-frame.ready .qr-empty { display: none; }

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--faint);
}

.qr-empty svg { width: 54px; height: 54px; color: #d3ded8; }
.qr-empty p { margin: 0; font-size: 14px; max-width: 15em; }

.qr-cap {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
}

/* ── footer + toast ─────────────────────── */
.foot {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #10231b;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 14px 34px -14px rgba(16, 35, 27, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── responsive ─────────────────────────── */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .qr-panel { position: static; order: -1; }
  .qr-frame { max-width: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
