/* Кудрявый Банк — стили клиентского PWA. Тёмная/светлая тема через prefers-color-scheme. */
*,*::before,*::after { box-sizing: border-box; }
/* HTML-атрибут hidden должен срабатывать даже на flex/grid-контейнерах */
[hidden] { display: none !important; }

/* По умолчанию — тёмная (как было). data-theme="light" / "pink" — переопределяют. */
:root {
  --bg: #0c1424;
  --bg-elev: #141d33;
  --fg: #eef1f7;
  --fg-muted: #97a0b6;
  --accent: #6446ff;
  --accent-2: #3aa1ff;
  --line: #1f2a44;
  --danger: #ff6464;
  --ok: #57d985;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0,0,0,.4);
}
/* Светлая = розовая палитра: #622d89, #da2187, #ea599c. */
:root[data-theme="light"] {
  --bg: #fff0f7;
  --bg-elev: #ffffff;
  --fg: #2a0a3a;
  --fg-muted: #7a3a5a;
  --accent: #622d89;
  --accent-2: #da2187;
  --line: #f7c8de;
  --danger: #b51b1b;
  --ok: #1f9d57;
  --shadow: 0 6px 24px rgba(98,45,137,.12);
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 16px 0 8px; color: var(--fg-muted); font-weight: 600; }
.muted { color: var(--fg-muted); font-size: 14px; }
.error { color: var(--danger); margin: 0; }
.ok    { color: var(--ok);     margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.list  { display: flex; flex-direction: column; gap: 10px; }

input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); outline: none; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--fg-muted); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
fieldset legend { padding: 0 6px; font-size: 13px; color: var(--fg-muted); }

.btn {
  padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); cursor: pointer; transition: transform .05s, background .15s;
  text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover  { background: color-mix(in srgb, var(--bg-elev) 85%, var(--accent) 15%); }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.btn.ghost   { background: transparent; }

.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card h1 { margin-top: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 16px;
  border-right: 1px solid var(--line); background: var(--bg-elev);
  display: flex; flex-direction: column; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand-name { font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  padding: 10px 12px; border-radius: 10px; color: var(--fg);
}
.nav a.active { background: color-mix(in srgb, var(--accent) 18%, var(--bg-elev)); }
.logout {
  margin-top: auto;
  width: 100%;
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
}

.view { padding: 24px; max-width: 920px; width: 100%; }

.bottombar { display: none; }
.mhead { display: none; }

@media (max-width: 720px) {
  /* На мобиле — простая колоночная раскладка без grid, чтобы пустые ряды
     не «надували» пространство между шапкой и контентом. */
  .app { display: flex; flex-direction: column; min-height: 100dvh; }
  .sidebar { display: none; }
  .view { padding: 12px 14px 96px; flex: 1 1 auto; }
  .mhead {
    display: flex !important; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-elev); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 5;
  }
  .mhead-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; display: grid; place-items: center; font-size: 18px; text-decoration: none;
  }
  .mhead-brand {
    display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none;
    font-weight: 700;
  }
  .mhead-logo {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; display: grid; place-items: center; font-size: 16px;
  }
  .mhead-name { font-size: 14px; color: var(--fg-muted); }

  .bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-elev); border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 5;
  }
  .bottombar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px;
    color: var(--fg-muted); font-size: 11px; text-decoration: none;
  }
  .bottombar a.active { color: var(--accent); }
  .bottombar a span.dot {
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  }
}

/* Balance card */
.balance-amount { font-size: 32px; font-weight: 700; margin: 4px 0 12px; }
.balance-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Account / card items */
.item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
}
.item .meta { font-size: 13px; color: var(--fg-muted); }
.item .right { text-align: right; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-elev)); color: var(--accent);
}
.badge.warn { background: color-mix(in srgb, var(--danger) 20%, var(--bg-elev)); color: var(--danger); }

/* History */
.history-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.history-row .amount.debit  { color: var(--danger); }
.history-row .amount.credit { color: var(--ok); }
.history-row .meta { color: var(--fg-muted); font-size: 12px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

/* PIN keypad */
.auth { max-width: 380px; margin: 8vh auto 0; }
.pin-form { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.pin-display { display: flex; gap: 14px; }
.pin-display span {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line);
}
.pin-display span.on { background: var(--accent); border-color: var(--accent); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 280px; }
.pin-keys button {
  padding: 16px 0; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); font-size: 20px;
}
.pin-keys button:active { background: color-mix(in srgb, var(--bg-elev) 80%, var(--accent) 20%); }

/* PIN-инпуты — крупно и моноширинно.
   type="password" — маска (•/*) для скрытых форм (выпуск карты, терминал).
   type="text" inputmode="numeric" — видимый PIN при оплате по QR. */
input[type="password"][inputmode="numeric"],
input[type="text"][inputmode="numeric"][maxlength="4"] {
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 22px; letter-spacing: 6px; text-align: center;
}
input[type="password"][inputmode="numeric"] {
  -webkit-text-security: disc;
}

/* Модалка */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--bg-elev); color: var(--fg);
  padding: 22px; border-radius: 14px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.modal h2 { margin: 0; }

/* Профиль */
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 24px; flex: 0 0 auto;
}
.profile-name { font-weight: 700; font-size: 18px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-btn {
  background: var(--danger); color: #fff; border: 0;
}
.danger-btn:hover { filter: brightness(1.05); }

/* Бейдж непрочитанных сообщений */
.unread-dot {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
  border: 2px solid var(--bg-elev);
}
.mhead-avatar { position: relative; }
.row-item .row-badge {
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; min-width: 22px; text-align: center;
}

/* Тост-уведомления для клиента */
.toast-area {
  position: fixed; right: 16px; top: 70px; display: flex; flex-direction: column;
  gap: 8px; z-index: 200; pointer-events: none; max-width: calc(100% - 32px);
}
.toast {
  background: var(--bg-elev); color: var(--fg); border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow);
  pointer-events: auto; max-width: 320px;
  animation: slideIn .25s ease-out;
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0 } to { transform: none; opacity: 1 } }

/* Тех. поддержка — чат */
.support-modal { max-width: 520px; }
.support-log {
  height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; border-radius: 12px;
  background: color-mix(in srgb, var(--bg-elev) 60%, var(--bg) 40%);
  border: 1px solid var(--line);
}
.support-msg {
  max-width: 80%; padding: 8px 12px; border-radius: 14px;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.support-msg.from-admin { align-self: flex-start; }
.support-msg.from-me    {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0;
}
.support-msg .meta { font-size: 11px; opacity: .7; margin-top: 4px; }

/* Сетка выбора темы */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.theme-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-elev); color: var(--fg);
  cursor: pointer; text-align: left; font: inherit;
}
.theme-card:hover { border-color: var(--accent); }
.theme-card.active { border: 2px solid var(--accent); }
.theme-swatch {
  width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto; border: 1px solid var(--line);
}
.theme-swatch.dark  { background: linear-gradient(135deg, #141d33 50%, #6446ff 50%); }
.theme-swatch.light { background: linear-gradient(135deg, #622d89 50%, #ea599c 50%); }

/* QR */
#qrVideo { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.qr-preview {
  padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--bg-elev) 70%, var(--accent) 30%);
}

/* QR — приветственное состояние */
.qr-card { padding: 16px; }
.qr-scanner-area { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center; padding: 4px 4px 0;
}
.qr-hero h1 { margin: 0; font-size: 19px; }
.qr-hero .muted { max-width: 320px; font-size: 13px; }
.qr-hero-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.qr-hero-icon svg { width: 32px; height: 32px; }
.qr-start-btn { min-width: 200px; padding: 12px 20px; font-size: 15px; margin-top: 4px; }
.qr-hint { margin: 4px 0 0; text-align: center; }

/* === Профиль === */
.profile-page { gap: 12px; }
.profile-hero {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 0 4px;
}
.profile-avatar-big {
  width: 68px; height: 68px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 26px; font-weight: 700; letter-spacing: 1px;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.profile-hero .profile-name { font-size: 18px; font-weight: 700; }
.profile-section { padding: 8px 8px 6px; }
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--fg-muted); padding: 8px 12px 6px;
}
.row-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 14px; width: 100%; padding: 12px 14px; border: 0;
  background: transparent; color: var(--fg); cursor: pointer;
  border-radius: 12px; text-align: left; font: inherit;
}
.row-item + .row-item { border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.row-item:hover { background: color-mix(in srgb, var(--bg-elev) 80%, var(--accent) 20%); }
.row-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-elev));
  color: var(--accent);
  display: grid; place-items: center; font-size: 18px;
  flex: 0 0 auto;
}
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-text .muted { font-size: 12px; }
.row-chevron { color: var(--fg-muted); font-size: 22px; line-height: 1; }

.btn-logout {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font: inherit; font-weight: 600;
}
.btn-logout:hover {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
}


/* Удаление аккаунта — единственное необратимое действие в профиле. */
.row-item.danger-row .row-text b { color: var(--danger, #e5484d); }
.btn.danger-btn {
  background: var(--danger, #e5484d); color: #fff; border: 0;
}
.blocker {
  padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--danger, #e5484d) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #e5484d) 40%, transparent);
}
