:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe3ef;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #047857;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; max-width: 100%; }
button {
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 7px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
}
button.secondary { background: #e2e8f0; color: #0f172a; }
button.danger { background: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 74px; resize: vertical; }
label { display: grid; gap: 6px; color: #334155; font-size: 13px; font-weight: 700; }
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 42px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-size: 22px; font-weight: 900; letter-spacing: 0; color: var(--brand); }
.identity { min-width: 0; }
.subtle { color: var(--muted); font-size: 14px; }
.page { width: min(1160px, 100%); margin: 0 auto; padding: 24px clamp(14px, 3vw, 24px) 96px; }
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #ecfeff 47%, #eef2ff 100%);
}
.auth-panel { width: min(460px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 18px 40px rgba(15,23,42,.09); }
.auth-panel h1, .page h1 { margin: 0 0 8px; font-size: 28px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.tabs {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 24px));
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15,23,42,.14);
  z-index: 6;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 112px;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  white-space: nowrap;
}
.tabs button.active { background: #e0f2fe; color: #075985; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.stat { display: grid; gap: 5px; }
.stat strong { font-size: 30px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.list { display: grid; gap: 10px; }
.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 800;
  font-size: 12px;
}
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #ffedd5; color: #9a3412; }
.pill.danger { background: #fee2e2; color: #991b1b; }
.notice { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: #f8fafc; }
.notice.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.notice.ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 16px;
}
.modal { width: min(620px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: 8px; padding: 18px; }
.popup-img { display: block; width: 100%; max-height: 340px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid #e2e8f0; background: #eef2ff; }
.qr { display: block; width: min(360px, 100%); margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.payment-card {
  padding-top: 10px;
}
.payment-meta {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}
.payment-meta strong {
  color: var(--ink);
  font-size: 18px;
}
.pay-link {
  display: block;
  text-decoration: none;
}
.pay-link button {
  width: 100%;
}
.hidden { display: none !important; }
@media (max-width: 720px) {
  body { font-size: 15px; }
  button { width: 100%; padding-inline: 10px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .auth { align-items: start; padding: 14px; }
  .auth-panel { padding: 18px; margin-top: 16px; }
  .auth-panel h1, .page h1 { font-size: 24px; }
  .page { padding: 18px 12px calc(150px + env(safe-area-inset-bottom)); }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; }
  .topbar {
    align-items: flex-start;
    padding: 12px;
    gap: 10px;
  }
  .brand { font-size: 20px; }
  .subtle { font-size: 13px; overflow-wrap: anywhere; }
  .row, .actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .tabs {
    bottom: 8px;
    width: calc(100% - 16px);
    padding: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    gap: 4px;
  }
  .tabs button {
    flex-basis: 92px;
    min-height: 44px;
    font-size: 12px;
  }
  .card, .item { padding: 13px; }
  .actions button { min-width: 0; }
  .qr { width: min(100%, 310px); }
  .payment-card { gap: 12px; }
  .stat strong { font-size: 26px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: 88vh; padding: 14px; }
  .avatar { width: 82px; height: 82px; }
}
