:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f3f8f5;
  --surface-blue: #eef8ff;
  --text: #202231;
  --muted: #7b8292;
  --line: #e7edf3;
  --line-strong: #d9e4ee;
  --brand: #20b86f;
  --brand-dark: #07884c;
  --blue: #2297d8;
  --blue-soft: #e9f7ff;
  --mint: #ddf8ea;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #20b86f;
  --shadow: 0 14px 34px rgba(29, 39, 62, .08);
  --shadow-soft: 0 8px 22px rgba(29, 39, 62, .06);
  --radius: 18px;
}

* { box-sizing: border-box; }
html {
  background: var(--bg);
  touch-action: manipulation;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0, #f6f8fb 260px, #f6f8fb 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}
body:before { display: none; }
button, input, textarea, select { font: inherit; }
button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  padding: 11px 18px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 10px 22px rgba(32, 184, 111, .22);
  transition: transform .08s ease, opacity .08s ease, filter .08s ease;
}
button:active:not(:disabled) { transform: scale(.985); filter: brightness(.98); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
}
button.danger { background: var(--danger); color: #fff; box-shadow: 0 10px 22px rgba(239, 68, 68, .18); }
button.compact { min-height: 38px; padding: 8px 14px; border-radius: 999px; }
button.icon-btn { width: auto; min-width: 58px; }
input, textarea, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(21, 31, 51, .02);
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(32, 184, 111, .72);
  box-shadow: 0 0 0 4px rgba(32, 184, 111, .12);
}
input[type=file] { padding: 10px; }
textarea { min-height: 92px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; font-size: 13px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 6vw, 34px); line-height: 1.05; letter-spacing: 0; }
h2 { font-size: 22px; letter-spacing: 0; }
h3 { font-size: 16px; letter-spacing: 0; }
.muted { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #effbf4, #fff 42%, #f6f8fb);
}
.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; gap: 13px; align-items: center; }
.auth-support {
  display: inline-flex;
  justify-content: center;
  color: var(--blue);
  font-size: 14px;
  font-weight: 850;
}
.brand-title {
  font-size: 28px;
  font-weight: 950;
  color: var(--text);
}
.logo, .top-logo, .profile-logo {
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.logo { width: 58px; height: 58px; border-radius: 18px; }
.app-shell { min-height: 100vh; min-height: 100dvh; }
.main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(116px + env(safe-area-inset-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.title-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-block h1 { color: var(--text); }
.top-logo { width: 50px; height: 50px; border-radius: 16px; flex: 0 0 auto; }

.card, .item, .metric, .hero-card, .earn-card, .bottom-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.card { border-radius: var(--radius); padding: 16px; }
.stack { display: grid; gap: 13px; }
.grid { display: grid; gap: 12px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.notice {
  padding: 11px 13px;
  border: 1px solid rgba(34, 151, 216, .26);
  border-radius: 14px;
  background: var(--blue-soft);
  color: #155e86;
  margin-bottom: 12px;
}
.notice.error { border-color: rgba(239,68,68,.36); color: #b91c1c; background: #fff1f2; }
.notice.ok { border-color: rgba(32,184,111,.36); color: #04784a; background: #ecfdf3; }

.order-push {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 120;
  width: min(430px, calc(100% - 28px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid rgba(32, 184, 111, .26);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(29,39,62,.18);
  transform: translate(-50%, -130%);
  animation: orderPushIn .36s ease forwards;
}
.order-push.leaving { animation: orderPushOut .28s ease forwards; }
.order-push-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--mint);
  color: var(--brand-dark);
  font-weight: 950;
}
.order-push strong { display: block; font-size: 15px; margin-bottom: 4px; }
.order-push p { color: var(--muted); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.order-push span {
  display: inline-flex;
  margin-top: 7px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--brand-dark);
  font-weight: 900;
  font-size: 12px;
}
.order-push-close {
  min-height: 32px;
  width: 32px;
  padding: 0;
  border-radius: 999px;
  background: #f2f5f8;
  color: var(--text);
  box-shadow: none;
}
@keyframes orderPushIn {
  from { opacity: 0; transform: translate(-50%, -130%); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes orderPushOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -130%); }
}

.hero-card {
  min-height: 150px;
  border-radius: 24px;
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 8px;
  background:
    radial-gradient(circle at 88% 18%, rgba(255,255,255,.62) 0 32px, transparent 33px),
    linear-gradient(135deg, #fff4d2 0%, #ffe7a6 48%, #ffd48b 100%);
  color: #2a2433;
  overflow: hidden;
  position: relative;
  border-color: #ffe2a7;
}
.hero-card:after {
  content: "";
  position: absolute;
  right: -24px;
  top: -34px;
  width: 144px;
  height: 144px;
  border-radius: 999px;
  background: rgba(255,255,255,.26);
}
.hero-card p { font-weight: 900; color: #dd5b16; opacity: 1; }
.hero-card h2 { font-size: 32px; line-height: 1.05; color: #1f2430; }
.hero-card span { font-weight: 850; color: #7a5b34; opacity: 1; }
.admin-hero {
  background:
    radial-gradient(circle at 90% 18%, rgba(255,255,255,.55) 0 32px, transparent 33px),
    linear-gradient(135deg, #eaf8ff, #f5fbff 44%, #e4fff0);
  border-color: #d8f0fb;
}
.admin-hero p { color: var(--blue); }
.admin-hero h2 { color: var(--text); }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.metric {
  min-height: 94px;
  border-radius: 18px;
  padding: 17px;
  display: grid;
  align-content: center;
  gap: 10px;
}
.metric span { color: var(--muted); font-size: 13px; font-weight: 850; }
.metric strong { font-size: 24px; overflow-wrap: anywhere; color: var(--brand); }
.info-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: #eef1f4;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 18px;
}
.info-strip div {
  padding: 16px;
  background: #fff7ef;
}
.info-strip b, .earn-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.info-strip strong { color: var(--brand); font-size: 22px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
}
.section-head.inline { margin: 0; }
.list, .updates-list { display: grid; gap: 11px; }
.item {
  border-radius: 18px;
  padding: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.item p { color: var(--muted); margin-top: 5px; overflow-wrap: anywhere; }
.item.api-error { border-color: rgba(239,68,68,.28); }
.action-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wide-action { width: 100%; margin-top: 4px; }
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #526071;
  font-size: 12px;
  font-weight: 850;
}
.pill.ok { background: #e8fbf0; color: #07884c; }
.pill.warn { background: #fff7e6; color: #a15c00; }
.pill.danger { background: #fff1f2; color: #b91c1c; }
.empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}
.empty.tight { padding: 12px; }
.status-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.status-tabs button {
  min-height: 42px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  border-radius: 999px;
}
.status-tabs button.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.history-search { margin-bottom: 12px; }
.order-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 8px; }
.order-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 10px;
  align-items: center;
  padding: 13px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.order-line span { color: var(--muted); }
.order-line small { grid-column: 1 / -1; color: var(--muted); }

.profile-head {
  display: flex;
  gap: 14px;
  align-items: center;
}
.profile-logo {
  width: 78px;
  height: 78px;
  border-radius: 24px;
}
.profile-head h2 { font-size: 26px; }
.profile-head span { color: var(--blue); font-weight: 900; }
.earn-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-radius: 20px;
  overflow: hidden;
  background: #eef1f4;
}
.earn-card div {
  padding: 18px;
  background: #fff;
}
.earn-card div + div { border-left: 0; padding-left: 18px; }
.earn-card b { font-size: 27px; color: var(--brand); }
.service-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.service-grid button {
  min-height: 94px;
  display: grid;
  place-items: center;
  gap: 7px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  border-radius: 18px;
  padding: 10px 6px;
}
.service-grid span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--brand-dark);
  font-weight: 950;
}
.service-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.service-row:last-child { border-bottom: 0; }
.service-row span { color: var(--blue); font-weight: 850; }
.update-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.update-item img { max-width: 100%; border-radius: 12px; margin-bottom: 8px; }
.update-item small { color: var(--muted); display: block; margin-top: 5px; }
.table-tools {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 8px;
  margin-bottom: 12px;
}
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.user-card {
  display: grid;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.user-card.mini_admin { border-color: rgba(34, 151, 216, .32); }
.user-card.is-frozen { border-color: rgba(245, 158, 11, .42); }
.user-card.referral-card { border-color: rgba(32, 184, 111, .32); }
.user-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}
.user-head h3 { font-size: 17px; overflow-wrap: anywhere; }
.user-head p { color: var(--muted); margin-top: 4px; }
.user-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: var(--brand-dark);
  font-weight: 950;
  background: var(--mint);
}
.role-pill { justify-self: end; }
.user-meta {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfd;
}
.user-meta span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.user-meta b { color: var(--text); overflow-wrap: anywhere; text-align: right; }
.user-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.user-stats div {
  min-height: 66px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
}
.user-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  margin-bottom: 6px;
}
.user-stats b {
  color: var(--brand);
  font-size: 16px;
  overflow-wrap: anywhere;
}
.compact-stats {
  min-width: 190px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.referral-panel input[readonly] {
  color: var(--brand-dark);
  font-weight: 850;
  background: #f8fffb;
}
.user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}
.switch-control input { display: none; }
.switch-control span {
  position: relative;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(32, 184, 111, .22);
  border: 1px solid rgba(32, 184, 111, .38);
}
.switch-control span:after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 4px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
  box-shadow: 0 2px 7px rgba(29,39,62,.14);
}
.switch-control input:checked + span {
  background: rgba(245, 158, 11, .24);
  border-color: rgba(245, 158, 11, .46);
}
.switch-control input:checked + span:after { transform: translateX(23px); }
.switch-control b { font-size: 13px; }
.order-notification {
  border-color: rgba(34, 151, 216, .24);
  background: var(--blue-soft);
}
.order-notification h3 { color: var(--blue); margin-bottom: 5px; }
.api-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.api-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.api-switch label { display: inline-block; position: relative; width: 56px; height: 32px; }
.api-switch input { display: none; }
.api-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #fee2e2;
  border: 1px solid rgba(239,68,68,.2);
}
.api-switch span:after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 4px;
  transition: .16s ease;
  box-shadow: 0 2px 7px rgba(29,39,62,.14);
}
.api-switch input:checked + span { background: #dff8ea; border-color: rgba(32,184,111,.34); }
.api-switch input:checked + span:after { transform: translateX(23px); }
.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.checkline input { width: 18px; min-height: 18px; accent-color: var(--brand); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 36, 49, .55);
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 40;
}
.confirm-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 36, 49, .55);
  padding: 16px;
  z-index: 80;
}
.confirm-card {
  width: min(380px, 100%);
  border-radius: 22px;
}
.modal { width: min(720px, 100%); max-height: 92vh; overflow: auto; }
.modal-card { border-radius: 24px; }
.modal-title { display: flex; gap: 12px; align-items: flex-start; }
.bulk-row {
  background: #fbfcfd;
  box-shadow: none;
}
.update-preview {
  max-width: 100%;
  max-height: 220px;
  border-radius: 14px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #fff;
}
.mini-account-card {
  border-color: rgba(32, 184, 111, .26);
}
.mini-order-summary {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfd;
}

.bottom-nav {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 4px;
  border-radius: 26px;
  padding: 8px;
  background: rgba(255,255,255,.94);
  border-color: var(--line);
  box-shadow: 0 12px 32px rgba(29,39,62,.14);
  backdrop-filter: blur(18px);
}
.bottom-nav button {
  min-height: 58px;
  padding: 6px 4px;
  border-radius: 18px;
  background: transparent;
  border: 1px solid transparent;
  color: #a0a5b2;
  display: grid;
  gap: 3px;
  place-items: center;
  box-shadow: none;
}
.bottom-nav button span {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 12px;
  background: #f2f5f8;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 950;
}
.bottom-nav button small { font-size: 10px; font-weight: 850; }
.bottom-nav button.active {
  background: #edf9f2;
  color: var(--brand-dark);
  border-color: rgba(32,184,111,.2);
}
.bottom-nav button.active span {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.bottom-nav button.plus {
  transform: translateY(-20px);
  min-height: 74px;
  border-radius: 999px;
  background: transparent;
}
.bottom-nav button.plus span {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 8px solid var(--bg);
  font-size: 34px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 14px 30px rgba(32, 184, 111, .32);
}
.bottom-nav button.plus small { display: none; }

@media (min-width: 900px) {
  .bottom-nav { width: min(760px, calc(100% - 24px)); margin: 0 auto; }
}
@media (max-width: 700px) {
  body { background: #f6f8fb; }
  .main { padding: max(18px, env(safe-area-inset-top)) 12px calc(112px + env(safe-area-inset-bottom)); }
  .topbar { align-items: flex-start; }
  .top-logo { width: 44px; height: 44px; }
  .topbar .compact { min-width: 78px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { min-height: 78px; padding: 13px 11px; }
  .metric strong { font-size: 19px; }
  .hero-card { min-height: 138px; padding: 20px; }
  .hero-card h2 { font-size: 30px; }
  .item { grid-template-columns: 1fr; }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-head.inline { flex-direction: row; align-items: center; }
  .two { grid-template-columns: 1fr; }
  .users-grid { grid-template-columns: 1fr; }
  .user-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-actions { justify-content: flex-start; }
  .service-grid { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
  .service-grid button { min-height: 78px; padding: 8px 4px; }
  .table-tools { grid-template-columns: 1fr auto auto; }
  .modal-title { align-items: center; }
}
@media (max-width: 380px) {
  .quick-grid { grid-template-columns: 1fr; }
  .info-strip, .earn-card { grid-template-columns: 1fr; }
  .earn-card div + div { padding-left: 18px; }
  .status-tabs { grid-template-columns: 1fr; }
  .bottom-nav { left: 8px; right: 8px; padding: 6px; }
  .bottom-nav button { min-height: 54px; }
  .bottom-nav button small { font-size: 10px; }
}
