:root {
  --bg: var(--tg-theme-bg-color, #08111f);
  --surface: var(--tg-theme-secondary-bg-color, #111f34);
  --surface-2: #1a2d48;
  --line: #2a4468;
  --text: var(--tg-theme-text-color, #f3f7fc);
  --muted: var(--tg-theme-hint-color, #9cafc6);
  --accent: var(--tg-theme-button-color, #8ebcf0);
  --accent-text: var(--tg-theme-button-text-color, #102039);
  --success: #87d8bc;
  --shadow: 0 18px 48px rgba(1, 7, 16, .32);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  background: radial-gradient(circle at 8% 0%, rgba(95, 153, 220, .16), transparent 36%), var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  line-height: 1.45;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
}
.app-header { display: flex; align-items: center; padding: 8px 2px 18px; }
.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; font-size: clamp(18px, 4.5vw, 24px); letter-spacing: -.5px; }
.brand-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.section-block {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tab {
  padding: 11px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tab.active { background: var(--accent); color: var(--accent-text); }
.tab:disabled { opacity: .65; cursor: wait; }
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0; }
.section-head h2 { margin: 0; font-size: 20px; }
.section-head button { min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
#priceNotice { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
#priceNotice:empty { display: none; }
.price-list { display: grid; gap: 12px; }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); align-items: center; gap: 8px; padding: 22px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.price-row strong { font-size: clamp(16px, 3.6vw, 24px); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.price-row strong:last-child { color: var(--accent); text-align: right; }
.price-row small { font-size: 13px; margin-left: 5px; color: var(--muted); white-space: nowrap; }
.price-arrow { text-align: center; color: var(--muted); }
.section-block { margin-top: 16px; padding: 18px; }
.section-title, .section-title > div { display: flex; align-items: center; gap: 9px; }
.section-title { justify-content: space-between; margin-bottom: 15px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-meta { color: var(--muted); font-size: 12px; }
.step {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 900;
}

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-layout { display: grid; gap: 16px; }
.admin-section { margin-top: 16px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-card {
  min-height: 76px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
}
.admin-card-wide { grid-column: 1 / -1; }
.admin-card:active { transform: scale(.985); }
.admin-card:disabled { opacity: .6; cursor: wait; }
.admin-result-section { min-width: 0; }
.admin-result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.admin-result-heading h2 { margin: 3px 0 0; font-size: 20px; }
.admin-result-kicker { color: var(--accent); font-size: 11px; font-weight: 800; }
.admin-result-content { min-width: 0; }
.admin-metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-metric-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #0d192b; }
.admin-metric-card span { display: block; color: var(--muted); font-size: 11px; }
.admin-metric-card strong { display: block; margin-top: 6px; font-size: 20px; letter-spacing: -.35px; }
.wallet-balance-grid { grid-template-columns: 1fr; }
.admin-checked-at { margin: 13px 2px 0; color: var(--muted); font-size: 11px; text-align: right; }
.admin-list { display: grid; gap: 10px; }
.admin-list-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #0d192b; }
.admin-list-card.compact { padding-bottom: 13px; }
.admin-list-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.admin-list-top > strong { min-width: 0; font-size: 13px; word-break: keep-all; }
.admin-list-card > p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.admin-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(42, 68, 104, .72); font-size: 11px; }
.admin-detail-row span { color: var(--muted); }
.admin-detail-row strong { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.fee-card > strong { display: block; font-size: 13px; word-break: keep-all; }
.fee-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.fee-values > div { padding: 10px 8px; border-radius: 11px; background: var(--surface-2); text-align: center; }
.fee-values span { display: block; color: var(--muted); font-size: 10px; }
.fee-values strong { display: block; margin-top: 4px; font-size: 13px; }
.fee-values .total { background: rgba(142, 188, 240, .14); }
.fee-values .total strong { color: var(--accent); }
.fee-editor { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(42, 68, 104, .72); }
.fee-editor label { margin-top: 0; }
.fee-editor > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.fee-input { min-width: 0; width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface-2); color: var(--text); }
.fee-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 188, 240, .12); }
.fee-save-button { padding: 9px 15px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-weight: 800; }
.fee-save-button:disabled { opacity: .55; cursor: wait; }
.wallet-alert-card { display: grid; gap: 14px; }
.wallet-alert-fields { display: grid; grid-template-columns: 1fr; gap: 12px; }
.wallet-alert-fields label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.wallet-alert-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.wallet-alert-input-row span { color: var(--muted); font-size: 11px; font-weight: 800; }
.wallet-alert-help { margin: 0 !important; color: var(--muted); font-size: 11px; }
.wallet-alert-save { min-height: 42px; }
.product-card {
  min-width: 0;
  min-height: 92px;
  padding: 14px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s ease, transform .12s ease, background .15s ease;
}
.product-card:active { transform: scale(.985); }
.product-card.selected { border-color: var(--accent); background: #203958; box-shadow: inset 0 0 0 1px var(--accent); }
.product-card-copy { min-width: 0; }
.product-card-heading { display: grid; gap: 3px; }
.product-card-copy strong { display: block; min-width: 0; font-size: 14px; line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
.product-card-heading b { display: block; color: var(--accent); font-size: 11px; font-weight: 800; }
.product-card-copy small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.product-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #44617c, #263d55);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: -.35px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .13);
}
.product-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.product-icon-google img {
  padding: 7px;
  background: #fff;
  object-fit: contain;
}
.product-icon-cultureland { color: #5b2d91; background: linear-gradient(145deg, #fff, #e9dcff); }
.product-icon-lotte { background: linear-gradient(145deg, #ef3056, #a80e2d); }
.product-icon-starbucks { background: linear-gradient(145deg, #168264, #075542); }
.product-icon-booknlife { background: linear-gradient(145deg, #438de7, #2354a4); }
.product-icon-culturegift { color: #d9424f; background: linear-gradient(145deg, #fff, #ffe2e4); }
.product-icon-teencash { background: linear-gradient(145deg, #4f75dc, #7544bd); }
.product-icon-google { background: conic-gradient(from 45deg, #34a853, #fbbc04, #ea4335, #4285f4, #34a853); }
.product-icon-transport { color: #13585f; background: linear-gradient(145deg, #bcefe9, #95cde2); font-size: 9px; }
.product-icon-department { color: #76562d; background: linear-gradient(145deg, #fff8e8, #e8d1a6); font-size: 9px; }

.selected-product { margin-bottom: 15px; padding: 13px; border-radius: 12px; background: var(--surface-2); }
.selected-product strong { font-size: 13px; }
.product-guide { padding: 16px; }
.product-guide-heading { display: flex; align-items: center; gap: 12px; }
.product-guide-heading > div { min-width: 0; }
.product-guide-heading strong { display: block; font-size: 17px; line-height: 1.4; }
.product-guide-subtitle { margin: 4px 0 0; color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.55; }
.product-guide-subtitle:empty { display: none; }
.product-guide-lines { display: grid; gap: 8px; margin-top: 15px; padding-top: 14px; border-top: 1px solid rgba(142, 188, 240, .18); }
.product-guide-line { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 7px; color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.55; }
.product-guide-icon { color: var(--success); font-weight: 900; }
.contact-section { margin-top: 2px; }
.contact-button { display: block; text-align: center; text-decoration: none; }
label { display: block; margin: 2px 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: #0c1829;
  color: var(--text);
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 188, 240, .12); }
.pin-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  align-items: stretch;
  gap: 8px;
}
.pin-segment-grid {
  min-width: 0;
  display: grid;
  gap: 7px;
}
.pin-segment-grid[data-group-count="1"] { grid-template-columns: minmax(0, 1fr); }
.pin-segment-grid[data-group-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pin-segment-grid[data-group-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pin-segment-grid[data-group-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pin-segment-grid[data-group-count="5"] { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.7fr); }
.pin-segment-input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #0c1829;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.pin-segment-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142, 188, 240, .12); }
.pin-segment-input::placeholder { color: var(--muted); font-size: 11px; font-weight: 600; }
.pin-segment-input.is-secondary { border-color: color-mix(in srgb, var(--success) 55%, var(--line)); }
.pin-add-button {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(135, 216, 188, .48);
  border-radius: 11px;
  color: #0c201a;
  background: var(--success);
  font-weight: 850;
}
.pin-add-button:disabled { opacity: .42; cursor: default; }
.registered-pin-list {
  margin: 0 0 14px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  overflow: hidden;
  background: rgba(8, 17, 31, .34);
}
.registered-pin-list.empty { min-height: 72px; display: grid; place-items: center; }
.registered-pin-list.empty p { margin: 0; color: var(--muted); font-size: 11px; }
.registered-pin-row {
  min-width: 0;
  min-height: 50px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
}
.registered-pin-row + .registered-pin-row { border-top: 1px solid var(--line); }
.registered-pin-row > span { color: var(--muted); font-size: 9px; font-weight: 800; text-align: center; }
.registered-pin-row code { min-width: 0; color: var(--text); font-size: 12px; overflow-wrap: anywhere; user-select: text; }
.registered-pin-row button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
}
.registered-pin-row button:active { color: #ffdce2; background: rgba(255, 119, 139, .12); }
.input-help { display: flex; justify-content: space-between; gap: 10px; margin: 7px 2px 14px; color: var(--muted); font-size: 11px; }
.primary-button, .secondary-button, .text-button { border: 0; border-radius: 12px; font-weight: 800; }
.primary-button { width: 100%; padding: 13px 16px; background: var(--accent); color: var(--accent-text); }
.secondary-button { padding: 13px 16px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.text-button { padding: 7px 9px; background: transparent; color: var(--accent); }
.primary-button:disabled { opacity: .55; cursor: wait; }

.orders-heading { display: flex; align-items: center; justify-content: space-between; margin: 20px 3px 12px; }
.orders-heading h2 { margin: 0; font-size: 18px; }
.order-list { display: grid; gap: 11px; }
.order-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-top strong { min-width: 0; font-size: 14px; word-break: keep-all; }
.order-product, .admin-product-title, .fee-product-title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.order-product > strong, .admin-product-title > strong, .fee-product-title > strong { min-width: 0; word-break: keep-all; }
.order-product .product-icon, .admin-product-title .product-icon, .fee-product-title .product-icon { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; font-size: 8px; }
.status-badge { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: rgba(142, 188, 240, .14); color: var(--accent); font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-badge.done { background: rgba(135, 216, 188, .14); color: var(--success); }
.order-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.transaction { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.transaction strong { display: block; margin-bottom: 5px; font-size: 12px; }
.transaction code { display: block; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.empty-card { padding: 36px 18px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.error-card { color: #ffdce2; border-color: #71404b; background: #3b222b; }
.loading-card { display: flex; align-items: center; justify-content: center; gap: 10px; }
.small-spinner { width: 28px; height: 28px; border: 3px solid rgba(142, 188, 240, .2); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }

.modal-layer, .loading-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 8, 17, .76);
  backdrop-filter: blur(8px);
}
.modal-card { width: min(100%, 430px); max-height: calc(100vh - 40px); overflow: auto; padding: 22px; border: 1px solid #385a84; border-radius: 21px; background: #12223a; box-shadow: 0 24px 70px rgba(0, 0, 0, .48); }
.modal-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 13px; background: rgba(135, 216, 188, .14); color: var(--success); font-size: 20px; font-weight: 900; }
.modal-card h2 { margin: 0 0 15px; font-size: 19px; }
.modal-content { padding: 14px; border-radius: 13px; background: #0d192b; color: var(--muted); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
.modal-content strong { color: var(--text); }
.modal-actions { display: grid; grid-template-columns: .75fr 1.25fr; gap: 9px; margin-top: 16px; }
.modal-actions .primary-button { padding: 13px; }
.modal-actions button:disabled { opacity: .45; cursor: not-allowed; }

.loading-layer { z-index: 80; color: var(--muted); align-content: center; gap: 15px; }
.loading-layer p { margin: 0; font-size: 13px; text-align: center; }
.spinner { width: 38px; height: 38px; border: 3px solid rgba(142, 188, 240, .2); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 90; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 36px); transform: translateX(-50%); padding: 12px 15px; border: 1px solid #396088; border-radius: 12px; background: #172b47; color: var(--text); font-size: 12px; font-weight: 700; box-shadow: var(--shadow); }
.toast.error { border-color: #71404b; background: #3b222b; color: #ffdce2; }
.hidden { display: none !important; }
.session-recovery {
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  display: grid;
  place-items: center;
  padding: 20px;
}
.session-card {
  width: min(100%, 390px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.session-card h1 { margin: 0 0 18px; text-align: center; font-size: 20px; }
.session-card p { margin: -7px 0 18px; color: var(--muted); text-align: center; font-size: 13px; }
@media (min-width: 720px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: minmax(250px, .72fr) minmax(0, 1.5fr); align-items: start; }
  .admin-result-section { position: sticky; top: 16px; }
  .admin-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wallet-balance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallet-alert-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .section-block { padding: 14px; }
  .product-card { padding: 12px; }
  .admin-metric-card { padding: 13px; }
  .admin-metric-card strong { font-size: 18px; }
}
@media (max-width: 560px) {
  .pin-entry-row { grid-template-columns: minmax(0, 1fr); }
  .pin-add-button { width: 100%; }
  .pin-segment-grid[data-group-count="5"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pin-segment-grid[data-group-count="5"] .pin-segment-input:last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Connection reports contain only allowlisted non-identifying launch metadata. */
.launch-diagnostics { width: min(100% - 32px, 560px); margin: 16px auto; padding: 14px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.launch-diagnostics summary { cursor: pointer; font-size: 14px; }
.launch-diagnostics button { margin-top: 12px; }
.launch-diagnostics pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.65 monospace; user-select: text; }
.launch-diagnostics p { font-size: 14px; }
#groupAccessError:not(.hidden) { min-height: auto; padding-bottom: 8px; }
