:root {
  --bg: #0b1020;
  --surface: #ffffff;
  --surface-2: #f4f5fb;
  --ink: #10132a;
  --ink-2: #5a6079;
  --line: #e7e8f2;
  --brand: #6366f1;
  --brand-ink: #4338ca;
  --go: #16a34a;
  --go-ink: #15803d;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 20px;
  --shadow: 0 10px 30px -12px rgba(16, 19, 42, .25);
  --shadow-sm: 0 2px 10px -4px rgba(16, 19, 42, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--surface-2);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.screen { max-width: 460px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ── LOGIN ─────────────────────────────────────────────── */
#screen-login {
  background: radial-gradient(120% 90% at 50% -10%, #1b2350 0%, var(--bg) 55%);
  justify-content: center;
  padding: 24px calc(20px + env(safe-area-inset-left)) 24px calc(20px + env(safe-area-inset-right));
}
.login-wrap { width: 100%; }
.brand { text-align: center; color: #fff; margin-bottom: 26px; }
.brand-mark {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  display: grid; place-items: center; font-size: 30px;
  box-shadow: 0 12px 30px -8px rgba(99, 102, 241, .6);
}
.brand-name { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.brand-sub { font-size: 14px; color: #9aa0c4; margin-top: 2px; }
.login-card { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  width: 100%; padding: 15px 16px; border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 16px; background: var(--surface-2); color: var(--ink); outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand); background: #fff; }
.login-err { color: var(--danger); font-size: 13.5px; text-align: center; min-height: 18px; font-weight: 600; }
.login-foot { text-align: center; color: #7a80a6; font-size: 12.5px; margin-top: 20px; }

/* ── CARDS / BUTTONS ───────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.btn {
  border: 0; border-radius: 14px; padding: 15px 18px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform .08s ease, filter .15s, background .15s; font-family: inherit;
}
.btn:active { transform: scale(.975); }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-go { background: var(--go); color: #fff; }
.btn-go:hover { filter: brightness(1.05); }
.btn-outline { background: var(--surface-2); color: var(--brand-ink); border: 1.5px solid var(--line); }
.btn-outline.receipt-done { background: #eaf7ef; color: var(--go-ink); border-color: #b6e3c6; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ── TOPBAR ────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--bg); color: #fff;
  border-bottom-left-radius: 22px; border-bottom-right-radius: 22px;
}
.topbar-id { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); font-weight: 700; font-size: 18px;
}
.topbar-name { font-weight: 700; font-size: 16px; }
.topbar-status { font-size: 12.5px; color: #9aa0c4; margin-top: 1px; }
.topbar-status.online { color: #4ade80; }
.icon-btn {
  background: rgba(255, 255, 255, .1); color: #fff; border: 0; width: 40px; height: 40px;
  border-radius: 12px; font-size: 18px; cursor: pointer;
}

/* ── CONTENT ───────────────────────────────────────────── */
.content { flex: 1; padding: 16px 16px 32px; display: flex; flex-direction: column; gap: 14px; }

/* Смена */
.shift-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shift-title { font-weight: 700; font-size: 17px; }
.shift-hint { font-size: 13px; color: var(--ink-2); margin-top: 3px; max-width: 230px; }
.switch {
  width: 60px; height: 34px; border-radius: 20px; border: 0; background: #d3d5e4;
  position: relative; cursor: pointer; transition: background .2s; flex: none; padding: 0;
}
.switch[aria-checked="true"] { background: var(--go); }
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: left .2s;
}
.switch[aria-checked="true"] .switch-thumb { left: 29px; }

.bank-picker { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.bank-picker-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.bank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bank-chip {
  border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 13px;
  padding: 12px 14px; font-size: 14.5px; font-weight: 600; cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s; color: var(--ink);
}
.bank-chip.selected { border-color: var(--brand); background: #eef0ff; color: var(--brand-ink); }

/* Заявки */
.orders { display: flex; flex-direction: column; gap: 14px; }
.empty {
  text-align: center; color: var(--ink-2); padding: 40px 20px; display: flex;
  flex-direction: column; align-items: center; gap: 8px;
}
.empty-emoji { font-size: 40px; }
.empty > div:nth-child(2) { font-weight: 700; color: var(--ink); font-size: 16px; }
.empty-sub { font-size: 13px; max-width: 260px; }
.pulse-ring { width: 54px; height: 54px; position: relative; margin-bottom: 4px; }
.pulse-ring span, .pulse-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--brand); opacity: .25; animation: pulse 1.8s ease-out infinite;
}
.pulse-ring span { animation-delay: .9s; }
@keyframes pulse { 0% { transform: scale(.4); opacity: .5; } 100% { transform: scale(1.3); opacity: 0; } }

/* Карточка заявки */
.order-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.order-head { padding: 20px 20px 16px; }
.order-tag { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-ink); background: #eef0ff; padding: 4px 9px; border-radius: 8px; }
.order-amount { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 12px 0 2px; }
.order-amount small { font-size: 22px; font-weight: 700; color: var(--ink-2); }
.order-merchant { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.order-timer { font-size: 13px; color: var(--warn); font-weight: 700; margin-top: 8px; }
.order-actions { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.order-open { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.order-note { font-size: 12px; color: var(--ink-2); text-align: center; padding: 0 20px 16px; }

/* QR в заявке */
.order-qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 20px 14px; }
.order-qr { width: 190px; height: 190px; background: #fff; border-radius: 14px; padding: 10px; border: 1px solid var(--line); }
.order-qr-hint { font-size: 12px; color: var(--ink-2); text-align: center; max-width: 240px; }

/* topbar actions */
.topbar-actions { display: flex; gap: 8px; }
.icon-btn[aria-pressed="false"] { opacity: .55; }

/* ── СТАТИСТИКА (Ф2 #2) ────────────────────────────────── */
.balance-card {
  background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff;
  box-shadow: 0 14px 34px -12px rgba(99, 102, 241, .55);
}
.balance-label { font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .8; }
.balance-value { font-size: 36px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.balance-value small { font-size: 18px; font-weight: 700; opacity: .8; }
.balance-meta { font-size: 12.5px; opacity: .8; margin-top: 4px; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: #e6e8f4; padding: 5px; border-radius: 14px; }
.seg-btn {
  border: 0; background: transparent; border-radius: 10px; padding: 9px 4px;
  font-size: 13.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s;
}
.seg-btn.selected { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-cell { background: var(--surface); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-cell-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.stat-cell-value { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin-top: 4px; }
.stat-cell-value small { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.stat-cell-value.good { color: var(--go-ink); }
.stat-cell-value.bad { color: var(--danger); }
.stat-cell.wide { grid-column: 1 / -1; }

.ledger-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.ledger-list { display: flex; flex-direction: column; }
.ledger-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.ledger-row:first-child { border-top: 0; }
.ledger-kind { font-size: 14px; font-weight: 600; }
.ledger-ref { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.ledger-amt { font-size: 15px; font-weight: 800; color: var(--go-ink); white-space: nowrap; }
.ledger-empty { color: var(--ink-2); font-size: 13.5px; text-align: center; padding: 12px 0; }

/* ── ВЫВОД (Ф2 payout) ── */
.btn-payout { background: rgba(255,255,255,.16); color: #fff; margin-top: 16px; backdrop-filter: blur(4px); }
.btn-payout:hover { background: rgba(255,255,255,.24); }
.payout-hint { font-size: 12px; color: var(--ink-2); text-align: center; margin-top: 10px; }
.payout-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.payout-row:first-child { border-top: 0; }
.payout-amt { font-size: 15px; font-weight: 800; }
.payout-addr { font-size: 12px; color: var(--ink-2); margin-top: 1px; font-family: ui-monospace, monospace; }
.payout-badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; white-space: nowrap; }
.payout-badge.requested { background: #eef0ff; color: var(--brand-ink); }
.payout-badge.sent { background: #eaf7ef; color: var(--go-ink); }
.payout-badge.rejected { background: #fdecec; color: var(--danger); }

/* ── КОМАНДА (тимлид) ── */
.team-list { display: flex; flex-direction: column; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.team-row:first-child { border-top: 0; }
.team-ava { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; color: var(--brand-ink); flex: none; }
.team-info { flex: 1; min-width: 0; }
.team-name { font-weight: 700; font-size: 14.5px; }
.team-meta { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.team-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #cbd0e0; margin-right: 5px; vertical-align: middle; }
.team-dot.online { background: var(--go); }
.team-bal { text-align: right; white-space: nowrap; }
.team-bal-val { font-weight: 800; font-size: 14px; }
.team-bal-sub { font-size: 11px; color: var(--ink-2); }

/* модалка */
.modal-overlay { position: fixed; inset: 0; background: rgba(11,16,32,.5); display: grid; place-items: center; z-index: 60; padding: 20px; animation: toastin .15s ease; }
.modal-card { background: var(--surface); border-radius: 20px; padding: 22px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.modal-title { font-weight: 750; font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ── ДЕСКТОП (≥720px): широкий центрированный кабинет ── */
@media (min-width: 720px) {
  .screen { max-width: 880px; }
  #screen-login { max-width: none; }
  .login-wrap { max-width: 400px; margin: 0 auto; }
  .topbar { border-radius: 0 0 24px 24px; padding-left: 28px; padding-right: 28px; }
  .content { padding: 24px 28px 40px; gap: 18px; }
  /* двухколоночная сетка на широких: смена+заявка слева, вспомогательное справа */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-cell.wide { grid-column: auto; }
  .bank-grid { grid-template-columns: repeat(3, 1fr); }
  .order-card { max-width: 460px; margin: 0 auto; }
  .order-qr { width: 220px; height: 220px; }
  .seg { max-width: 520px; }
  .balance-card { text-align: left; }
  .card { padding: 22px; }
}
@media (min-width: 1024px) {
  .screen { max-width: 1040px; }
  .content { padding: 28px 40px 48px; }
  .bank-grid { grid-template-columns: repeat(4, 1fr); }
}
/* десктоп: показываем hover-состояния мягче */
@media (hover: hover) and (min-width: 720px) {
  .bank-chip:hover { border-color: var(--brand); }
  .team-row:hover { background: var(--surface-2); border-radius: 12px; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 14px; font-size: 14.5px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; text-align: center;
  animation: toastin .2s ease;
}
.toast.ok { background: var(--go-ink); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }
