:root {
  --bg-0: #0F1420;
  --bg-1: #1A2233;
  --bg-2: #232D42;
  --border: #2E3A54;
  --border-hover: #3F4E6E;
  --text: #F2F4F8;
  --text-dim: #9AA5BC;
  --muted: #6C7692;
  --accent: #6E8FC4;
  --accent-hover: #86A3D4;
  --accent-text: #0B1220;
  --ok: #7CC48F;
  --err: #E0708A;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
}

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== App bar ===== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: rgba(15, 20, 32, .92);
  backdrop-filter: blur(10px);
  border-bottom: 0.5px solid var(--border);
}

.app-bar .back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
}
.app-bar .back-btn:active { background: var(--bg-2); }
.app-bar .back-btn svg { width: 20px; height: 20px; }

.app-bar h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

.app-bar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-bar .brand img { width: 28px; height: 28px; border-radius: 8px; display: block; }

.app-bar-action { margin-left: auto; display: flex; }
.app-bar-action button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
}
.app-bar-action button:active { background: var(--bg-2); }
.app-bar-action button svg { width: 20px; height: 20px; }

/* ===== Main ===== */
main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
  min-height: calc(100vh - 56px);
}

/* ===== Search ===== */
.search-wrap { margin-bottom: 14px; }
.search-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font-size: 15px;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); }

/* ===== Client list ===== */
.client-list { display: flex; flex-direction: column; gap: 10px; }

.client-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-1);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease;
}
.client-card:active { transform: scale(.98); border-color: var(--border-hover); }

.client-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border-hover);
}
.client-avatar svg { display: block; width: 100%; height: 100%; }

.client-info { flex: 1; min-width: 0; }
.client-info .name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-info .phone { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.points-pill {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(110, 143, 196, .12);
  border: 1px solid rgba(110, 143, 196, .35);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 12px; color: var(--err); margin-top: 6px; display: none; }
.field.invalid input { border-color: var(--err); }
.field.invalid .hint { display: block; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:active { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 0.5px solid var(--border); }
.btn-danger { background: transparent; color: var(--err); border: 0.5px solid rgba(224, 112, 138, .35); }
.btn + .btn { margin-top: 10px; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}
.fab:active { background: var(--accent-hover); transform: scale(.96); }
.fab svg { width: 26px; height: 26px; }

/* ===== Client profile hub ===== */
.profile-header {
  text-align: center;
  padding: 28px 20px;
  background: var(--bg-1);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  margin-bottom: 20px;
}

.profile-photo {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-hover);
  box-shadow: var(--shadow);
}
.profile-photo svg { display: block; width: 100%; height: 100%; }

.profile-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.profile-phone { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.profile-points {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border);
}
.profile-points .value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.profile-points .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== Menu list ===== */
.menu-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg-2); }

.menu-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: var(--accent);
  display: flex;
}
.menu-icon svg { width: 100%; height: 100%; }

.menu-label { flex: 1; }

.menu-chevron { flex: 0 0 18px; width: 18px; height: 18px; color: var(--muted); }
.menu-chevron svg { width: 100%; height: 100%; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin: 20px 0 10px;
}

.inline-summary {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.hint-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 16px;
}

.readonly-value {
  padding: 13px 14px;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 16px;
}

/* ===== Points confirmation ===== */
.confirm-box {
  background: var(--bg-1);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
}
.confirm-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
.confirm-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
}
.confirm-text strong { color: var(--text); }

.confirm-balances {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.confirm-balances > div {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 0.5px solid var(--border);
}
.confirm-balances .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.confirm-balances .value {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 0.5px solid var(--border);
  border-radius: 12px;
}
.history-item .delta { font-weight: 700; font-family: var(--font-display); }
.history-item .delta.positive { color: var(--ok); }
.history-item .delta.negative { color: var(--err); }
.history-item .meta { text-align: right; }
.history-item .note { font-size: 13px; }
.history-item .when { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--bg-2);
  border: 0.5px solid var(--border-hover);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { border-color: rgba(124, 196, 143, .5); color: var(--ok); }
.toast.error { border-color: rgba(224, 112, 138, .5); color: var(--err); }

/* ===== NFC waiting overlay ===== */
.nfc-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(6px);
  text-align: center;
}

.nfc-pulse {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nfc-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: nfc-pulse-ring 1.8s ease-out infinite;
}
.nfc-ring:nth-child(2) { animation-delay: .9s; }

@keyframes nfc-pulse-ring {
  0% { transform: scale(.55); opacity: .8; }
  100% { transform: scale(1); opacity: 0; }
}

.nfc-icon {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid var(--border-hover);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.nfc-icon svg { width: 36px; height: 36px; }

.nfc-overlay-text {
  max-width: 280px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}

.nfc-overlay .btn { width: auto; padding: 12px 28px; }

@media (prefers-reduced-motion: reduce) {
  .nfc-ring { animation: none; opacity: .45; }
}

/* ===== Misc ===== */
.stack { display: flex; flex-direction: column; }
