* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

.header {
  padding: 1rem 1.5rem;
  background: #020617;
  border-bottom: 1px solid #1e293b;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.header-sub {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: #94a3b8;
}

.layout {
  display: flex;
  min-height: calc(100vh - 4rem);
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #0f172a;
  border-right: 1px solid #1e293b;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-accounts {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  padding: 0.6rem 1rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  margin-left: 0;
  border-radius: 0.35rem;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: #1e293b;
  color: #e2e8f0;
}

.nav-item.active,
.nav-item-all.active {
  background: #1e293b;
  color: #e2e8f0;
  border-left-color: #64748b;
}

.nav-bank {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.15rem;
}

.nav-label {
  display: block;
  font-weight: 500;
}

/* Подсказка в сайдбаре */
.sidebar-hint {
  margin: 0 1rem 0.5rem;
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.3;
}

/* Блок группы (GLAZARS, GLAZ3, GLAZ6) */
.nav-window {
  margin-top: 0.75rem;
  padding: 0;
}

.nav-window:first-of-type {
  margin-top: 0.5rem;
}

/* Заголовок группы: ссылка на список + кнопка свернуть */
.nav-window-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.25rem 0;
  margin: 0;
  gap: 0.25rem;
}

.nav-window-title-link {
  flex: 1;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0.35rem;
  transition: background 0.15s, color 0.15s;
}

.nav-window-title-link:hover {
  background: #1e293b;
  color: #e2e8f0;
}

.nav-window--current .nav-window-title-link {
  color: #e2e8f0;
  background: #1e293b;
}

.nav-window-toggle-btn {
  padding: 0.25rem 0.4rem;
  font-size: 0.65rem;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

.nav-window-toggle-btn:hover {
  color: #94a3b8;
  background: #1e293b;
}

.nav-window--collapsed .nav-window-body {
  display: none;
}

.nav-window-body {
  padding: 0.35rem 0 0.5rem;
}

/* Карточка одного профиля (аккаунта) — белая, тёмный текст */
.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.2rem 0.6rem;
  background: #ffffff;
  color: #0f172a;
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0.35rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: background 0.15s, border-color 0.15s;
}

.profile-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.profile-card--active {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.profile-card-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: #0f172a;
}

.profile-card-balance {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: #475569;
}

.profile-card--active .profile-card-balance {
  color: #334155;
}

/* Старые классы для совместимости (если где-то остались) */
.nav-account-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; min-width: 0; }
.nav-balance { flex-shrink: 0; font-size: 0.8rem; color: #64748b; font-weight: 500; }
.nav-item.active .nav-balance { color: #94a3b8; }

.btn-add-in-window {
  display: block;
  margin: 0.4rem 0.6rem 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  text-align: center;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-add-in-window:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-add {
  margin: 1rem 1rem 0;
  padding: 0.75rem 1rem;
  text-align: center;
  background: #f1f5f9;
  color: #0f172a;
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-add:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 720px;
}

.card {
  background: #1e293b;
  border-radius: 0.75rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid #334155;
  margin-bottom: 1.5rem;
}

.card h2,
.card h3 {
  margin-top: 0;
  color: #f1f5f9;
}

.balance-card .balance {
  font-size: 1.75rem;
  font-weight: 700;
  color: #34d399;
  margin: 0.5rem 0;
}

.balance-card .balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.balance-card .balance-header h2 { margin: 0; }
.balance-actions { flex-shrink: 0; }
.btn-refresh {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid #475569;
  background: #334155;
  color: #e2e8f0;
  cursor: pointer;
}
.btn-refresh:hover:not(:disabled) { background: #475569; }
.btn-refresh:disabled { opacity: 0.6; cursor: not-allowed; }
.balance-card .meta {
  font-size: 0.9rem;
  color: #94a3b8;
  margin: 0.25rem 0;
}

.empty-state {
  color: #94a3b8;
}

.empty-state h2 {
  color: #e2e8f0;
}

/* Страница «Список аккаунтов» по группе */
.card-window-list h2 {
  margin-bottom: 0.25rem;
}

.window-list-hint {
  color: #94a3b8;
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.empty-window {
  color: #94a3b8;
  margin: 0;
}

.empty-window a {
  color: #94a3b8;
  text-decoration: underline;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.accounts-table th,
.accounts-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #334155;
}

.accounts-table th {
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.accounts-table td.col-name {
  color: #e2e8f0;
  font-weight: 500;
}

.accounts-table td.col-balance {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.accounts-table .col-actions {
  white-space: nowrap;
}

.col-actions .form-inline {
  display: inline;
}

.col-actions .btn-table {
  margin-right: 0.35rem;
  margin-bottom: 0.25rem;
}

.btn-table {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 0.35rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-table.btn-open {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

.btn-table.btn-open:hover {
  background: #475569;
  color: #fff;
}

.btn-table.btn-edit {
  background: transparent;
  color: #94a3b8;
  border-color: #475569;
}

.btn-table.btn-edit:hover {
  background: #334155;
  color: #e2e8f0;
}

.btn-table.btn-danger {
  background: transparent;
  color: #f87171;
  border-color: #7f1d1d;
}

.btn-table.btn-danger:hover {
  background: #7f1d1d;
  color: #fecaca;
}

.btn-add-secondary {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 0.4rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn-add-secondary:hover {
  background: #475569;
  border-color: #64748b;
}

.window-list-add {
  margin: 0;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.9rem;
  color: #94a3b8;
}

input,
select,
textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-family: inherit;
}

.textarea-json {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  min-height: 200px;
  resize: vertical;
}

.form-hint {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.25rem;
}

select {
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

.btn-primary {
  margin-top: 0.25rem;
  padding: 0.7rem 1.4rem;
  border-radius: 0.5rem;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  color: white;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  border: 1px solid #475569;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: #334155;
  color: #e2e8f0;
}

.btn-danger {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #7f1d1d;
  background: transparent;
  color: #f87171;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-danger:hover {
  background: #7f1d1d;
  color: #fecaca;
}

.form-inline {
  display: inline;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #7f1d1d;
  border: 1px solid #b91c1c;
  color: #fecaca;
}

.alert-success {
  background: #064e3b;
  border: 1px solid #059669;
  color: #a7f3d0;
}

.alert-warning {
  background: #78350f;
  border: 1px solid #b45309;
  color: #fde68a;
}

.alert-link {
  color: #7dd3fc;
  text-decoration: underline;
}

.btn-edit {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #0ea5e9;
  background: #0c4a6e;
  color: #7dd3fc;
  text-decoration: none;
  font-size: 0.875rem;
}

.btn-edit:hover {
  background: #075985;
  color: #bae6fd;
}

.code-block {
  background: #0f172a;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #334155;
  max-height: 320px;
  overflow: auto;
  font-size: 0.85rem;
}

.code-block--compact {
  max-height: 280px;
  font-size: 0.8rem;
  padding: 0.875rem 1rem;
  line-height: 1.4;
}

.card-accounts-json h3 {
  margin-bottom: 0.75rem;
}

.card-receipt {
  padding: 1.25rem 1.5rem;
}

.card-receipt h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.receipt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.receipt-form .receipt-input {
  flex: 1;
  min-width: 220px;
  padding: 0.6rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-family: ui-monospace, monospace;
}

.receipt-form .receipt-input::placeholder {
  color: #64748b;
}

.receipt-form .receipt-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

.receipt-form .btn-primary {
  margin: 0;
  padding: 0.6rem 1.2rem;
}

.card-actions {
  margin-top: 1rem;
}

.ml {
  margin-left: 0.5rem;
}

/* ── Legacy receipt (keep for fallback) ── */
.receipt-box { margin: 1rem 0; padding: 1rem; background: #0f172a; border-radius: 0.5rem; border: 1px solid #334155; }
.receipt-raw { margin-top: 1rem; font-size: 0.9rem; }
.receipt-raw summary { cursor: pointer; color: #94a3b8; }
.receipt-details { margin: 0.5rem 0 0 1rem; padding-left: 1rem; }

/* ── PP-style чек (1:1 с оригиналом Personal Pay) ── */
/* ============================================================================
   PP receipt — pixel-perfect воспроизведение чека Personal Pay (white theme).
   Соответствует скриншоту реального чека: белая карточка, lavender лого,
   крупная синяя сумма с superscript-центами, серые лейблы / тёмные значения.
   ============================================================================ */
/* Точные цвета извлечены из PDF stream (RG operator):
   border/title #073B4C  ← rgb(.0275 .2314 .298)
   divider     #ECEBEB  ← rgb(.9255 .9216 .9216)                                 */
.pp-receipt {
  background: #ffffff;
  border: 1px solid #073b4c;
  border-radius: 12px;
  padding: 2rem 2rem 2.5rem;
  max-width: 480px;
  margin: 0 auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable',
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #073b4c;
  box-shadow: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Логотип «personal pay» (lavender) ───────────────────────────────────── */
.pp-receipt__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0 1rem;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #b4a4ee;       /* lavender как в реальном PP */
  user-select: none;
}
.pp-receipt__logo-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: inline-block;
}
.pp-receipt__logo-icon svg { width: 100%; height: 100%; display: block; }
.pp-receipt__logo-text { color: #b4a4ee; font-weight: 400; }
.pp-receipt__logo-text strong { font-weight: 400; color: #b4a4ee; }

/* ── Тонкий разделитель ──────────────────────────────────────────────────── */
.pp-receipt__divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.5rem 0 1.25rem;
}

/* ── Заголовок «Enviaste dinero» / «Recibiste dinero» ────────────────────── */
.pp-receipt__title {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #073b4c;            /* PDF-derived */
  margin: 1rem 0 0.5rem;
  letter-spacing: -0.005em;
  line-height: 1.3;
}

/* ── Сумма: крупная, очень тонкая, brand blue ────────────────────────────── */
.pp-receipt__amount {
  text-align: center;
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: -1.5px;
  line-height: 1;
  margin: 0.5rem 0 1.75rem;
  font-feature-settings: "tnum" on, "lnum" on;
  font-variant-numeric: tabular-nums lining-nums;
}
.pp-receipt__amount--out { color: #2647d8; }   /* PP brand blue (precise from screenshot) */
.pp-receipt__amount--in  { color: #1ea672; }

/* superscript для центов — маленькие */
.pp-receipt__cents {
  font-size: 0.35em;
  font-weight: 400;
  vertical-align: super;
  letter-spacing: 0;
  margin-left: 1px;
  position: relative;
  top: -0.05em;
}

/* ── Список полей чека ───────────────────────────────────────────────────── */
.pp-receipt__dl {
  margin: 0;
  list-style: none;
  padding: 0;
}

.pp-receipt__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.95rem 0;
  border-bottom: 1px solid #ecebeb;   /* PDF-derived */
  gap: 1.25rem;
}
.pp-receipt__row:last-child { border-bottom: none; }

.pp-receipt__label {
  color: #073b4c;                     /* PDF-derived (text color) */
  opacity: 0.72;                      /* приглушённый — стилистика PP */
  font-size: 0.95rem;
  font-weight: 400;
  flex: 0 0 auto;
  max-width: 42%;
  line-height: 1.35;
  letter-spacing: -0.005em;
}

.pp-receipt__value {
  color: #073b4c;                     /* PDF-derived (text color) */
  font-size: 0.95rem;
  font-weight: 500;
  text-align: right;
  word-break: break-word;
  margin: 0;
  flex: 1 1 auto;
  line-height: 1.35;
  letter-spacing: -0.005em;
}

/* ── Print стили: компактный чёрно-белый вывод ───────────────────────────── */
@media print {
  body, .login-wrap, .nav, .topbar, header, footer { background: #fff !important; color: #000; }
  .nav, .topbar, .receipt-raw, header, footer, .btn-primary, .btn-secondary, .alert,
  details, summary, .receipt-form { display: none !important; }
  .pp-receipt {
    border: none;
    box-shadow: none;
    padding: 1rem 0;
    max-width: 100%;
  }
  .pp-receipt__amount--out { color: #1d4ed8 !important; }
}

.activities-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.activities-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #334155;
}
.activities-list li:last-child {
  border-bottom: none;
}
.activities-list a {
  color: #7dd3fc;
  text-decoration: none;
}
.activities-list a:hover {
  text-decoration: underline;
}

/* История операций: приходы и выводы */
.tx-history .tx-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0;
}
.tx-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}
.tx-badge.tx-incoming {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.tx-badge.tx-outgoing {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}
/* Активное авто-правило — пульсирующий синий бэйдж "🔄 Авто" */
.tx-badge.tx-running {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  animation: tx-running-pulse 2s ease-in-out infinite;
}
@keyframes tx-running-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); }
}

/* Proxy badges */
.proxy-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.proxy-badge--ok       { background: rgba(34, 197, 94, 0.18);  color: #4ade80; }
.proxy-badge--fail     { background: rgba(248, 113, 113, 0.18); color: #f87171; }
.proxy-badge--unknown  { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.proxy-badge--disabled { background: rgba(100, 116, 139, 0.18); color: #64748b; text-decoration: line-through; }
.tx-amount {
  font-weight: 600;
  color: #e2e8f0;
}
.tx-date {
  font-size: 0.875rem;
  color: #94a3b8;
}
.tx-title,
.tx-counterparty {
  flex: 1;
  min-width: 0;
  color: #cbd5e1;
}
.tx-counterparty {
  font-weight: 500;
}
.tx-cheque {
  font-size: 0.875rem;
  color: #7dd3fc;
  margin-left: auto;
}
.tx-cheque-hint {
  font-size: 0.8rem;
  color: #64748b;
  margin-left: auto;
  cursor: help;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

body {
  background: radial-gradient(circle at top, #111f3f 0%, #0b1229 42%, #0a1022 100%);
}

.card {
  box-shadow: 0 12px 26px rgba(3, 7, 18, 0.38);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(460px, 100%);
}

.balance,
.tx-amount,
.col-balance,
.profile-card-balance,
.sidebar-balance,
.list-balance {
  font-variant-numeric: tabular-nums;
}

/* ── Dashboard ─────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.dashboard-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.2s;
}
.dashboard-card:hover { border-color: #334155; }
.dashboard-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.dashboard-card-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e2e8f0;
}
.dashboard-card-type {
  font-size: 0.7rem;
  background: #1e293b;
  color: #64748b;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dashboard-card-balance {
  font-size: 1.35rem;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 0.25rem;
  min-height: 1.8rem;
}
.dashboard-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.balance-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  color: #475569;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Фильтры истории операций ────────────────────── */
.tx-filter-btn {
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  border: 1px solid #334155;
  background: transparent;
  color: #94a3b8;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.tx-filter-btn:hover { border-color: #38bdf8; color: #38bdf8; }
.tx-filter-btn.active { background: #0ea5e9; border-color: #0ea5e9; color: white; }

/* ── Автоправила ─────────────────────────────────── */
.auto-rule-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.auto-rule-done { opacity: 0.55; }
.auto-rule-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.auto-rule-cvu {
  font-family: monospace;
  font-size: 0.82rem;
  color: #94a3b8;
  word-break: break-all;
}
.auto-rule-progress { font-weight: 600; font-size: 0.9rem; color: #e2e8f0; }
.auto-rule-step { font-size: 0.82rem; color: #64748b; }
.auto-rule-limit { font-size: 0.78rem; color: #94a3b8; background: #1e293b; padding: 2px 8px; border-radius: 10px; }
.auto-rule-limit.limit-warn { color: #fbbf24; background: #1c1208; border: 1px solid #78350f; }
.auto-rule-error { color: #f87171; font-size: 0.8rem; }
.auto-rule-bar-wrap {
  background: #1e293b;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.auto-rule-bar {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 4px;
}
.auto-rule-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Skeleton loader ──────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton-line {
  height: 1.4em;
  border-radius: 6px;
  background: linear-gradient(90deg, #1e293b 25%, #2d3f55 50%, #1e293b 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  vertical-align: middle;
}

/* ── Multi-withdraw чекбоксы в сайдбаре ──────────────── */
.profile-card { position: relative; }
.multi-cb {
  flex-shrink: 0;
  width: 16px !important;
  height: 16px !important;
  margin-left: auto !important;
  cursor: pointer;
  accent-color: #0ea5e9;
}

/* ── Toast ────────────────────────────────────────────── */
/* (стили заданы inline в JS для простоты) */

/* ── "Все аккаунты" — визуальный блок ──────────────────── */
.nav-item.nav-item-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 10px;
  border: 1px solid #1e293b;
  background: #0f172a;
  font-weight: 600;
  font-size: 0.92rem;
  color: #94a3b8;
  transition: all 0.15s;
}
.nav-item.nav-item-all:hover {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.nav-item.nav-item-all.active,
.nav-item-all.active {
  background: #0c1a2e;
  border-color: #0ea5e9;
  color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(14,165,233,0.2);
}
.nav-all-icon { font-size: 1rem; opacity: 0.7; }
.nav-all-label { flex: 1; }

/* ── Обзор всех счетов (главный экран) ─────────────────── */
.all-accounts-overview { border: 1px solid #1e3a5f; }
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.overview-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 1rem;
  transition: border-color 0.15s;
}
.overview-card:hover { border-color: #334155; }
.overview-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}
.overview-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #e2e8f0;
  text-decoration: none;
}
.overview-card-name:hover { color: #38bdf8; }
.overview-card-type {
  font-size: 0.68rem;
  background: #1e293b;
  color: #475569;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.overview-card-balance {
  font-size: 1.15rem;
  font-weight: 700;
  color: #34d399;
  min-height: 1.6rem;
  margin-bottom: 0.2rem;
}
.overview-card-meta {
  font-size: 0.75rem;
  color: #475569;
  margin-bottom: 0.75rem;
  min-height: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overview-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Плавающая панель multi-withdraw ────────────────────── */
#mw-float-panel {
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity:0; transform: translateX(-50%) translateY(12px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

.sidebar-balance-error {
  color: #ef4444 !important;
  font-weight: 700;
}

.tx-history .tx-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.8rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid #334155;
}

.tx-history .tx-item .tx-badge {
  grid-row: 1 / span 3;
}

.tx-history .tx-counterparty,
.tx-history .tx-date,
.tx-history .tx-amount {
  font-size: 0.87rem;
}

/* ── Разделитель дат в истории ────────────────────── */
.tx-date-separator {
  list-style: none;
  padding: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  border-bottom: 1px solid #1e293b;
  margin-top: 0.25rem;
}

/* ── Пагинация истории ────────────────────────────── */
#tx-pagination {
  gap: 0.35rem;
}
#tx-pagination button {
  min-width: 2rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
}

/* ── Поиск в истории ──────────────────────────────── */
#tx-search:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.2);
}

/* ── Кнопка чека в строке истории ────────────────── */
.btn-receipt {
  background: none;
  border: 1px solid #334155;
  border-radius: 0.35rem;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.35rem;
  margin-left: 0.4rem;
  line-height: 1.4;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.btn-receipt:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

button[disabled],
.btn-primary[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ======================================================================
   UX IMPROVEMENTS & MOBILE RESPONSIVE
   ====================================================================== */

/* ── Limit progress bar ─────────────────────────────────────────────── */
.limit-bar-wrap {
  background: #0f172a;
  border-radius: 6px;
  height: 7px;
  overflow: hidden;
}
.limit-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 2px;
}
.limit-bar-fill--ok     { background: linear-gradient(90deg, #34d399, #10b981); }
.limit-bar-fill--warn   { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.limit-bar-fill--danger { background: linear-gradient(90deg, #f87171, #ef4444); }

.limit-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #64748b;
}
.limit-counter strong         { color: #94a3b8; }
.limit-counter.warn  strong   { color: #fbbf24; }
.limit-counter.danger strong  { color: #f87171; }

/* ── Primary CTA — full-width prominent variant ─────────────────────── */
.btn-primary-lg {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-size: 0.975rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: white;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.22);
}
.btn-primary-lg:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.32);
}
.btn-primary-lg:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.96);
}
.btn-primary-lg:disabled,
.btn-primary-lg[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: #334155;
}

/* ── Improved focus ring ─────────────────────────────────────────────── */
input:focus,
select:focus,
textarea:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

/* ── Mobile sidebar overlay ─────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
}
.sidebar-backdrop.visible { display: block; }

/* ── Mobile hamburger button ─────────────────────────────────────────── */
.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 9px;
  color: #e2e8f0;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.sidebar-toggle-btn:hover { background: #334155; }

/* ── Sidebar close button (inside drawer on mobile) ──────────────────── */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #334155;
  border-radius: 7px;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.sidebar-close-btn:hover { background: #1e293b; color: #e2e8f0; }

/* ── Card subtle hover ──────────────────────────────────────────────── */
.card { transition: border-color 0.15s; }

/* ── Responsive: tablet / landscape phone (≤768px) ──────────────────── */
@media (max-width: 768px) {
  .header {
    padding: 0.65rem 1rem;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .header h1 { font-size: 1.05rem; }
  .header-sub { display: none; }

  .sidebar-toggle-btn { display: flex; }
  .sidebar-close-btn  { display: flex; }

  /* Slide-in sidebar drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    height: 100vh;
    width: 280px;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid #334155;
    padding-top: 3rem;
  }
  .sidebar.sidebar--open { left: 0; }

  /* Layout */
  .layout { min-height: calc(100vh - 3.25rem); }
  .main { padding: 0.875rem; max-width: 100%; }

  /* Touch targets */
  .btn-primary,
  .btn-primary-lg {
    min-height: 46px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .btn-table       { min-height: 38px; }
  .profile-card    { min-height: 44px; }

  /* Prevent iOS zoom on tap */
  input, select, textarea { font-size: 16px !important; }

  .card { padding: 1rem; margin-bottom: 0.875rem; border-radius: 0.65rem; }

  /* Scrollable table */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .accounts-table { min-width: 360px; font-size: 0.82rem; }
  .accounts-table th,
  .accounts-table td { padding: 0.5rem; }

  .overview-grid  { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }

  /* Float panel */
  #mw-float-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    transform: none;
    bottom: 1rem;
    min-width: unset;
    border-radius: 12px;
  }

  /* Rate widget — hide chart on small screens */
  #rate-widget    { min-width: unset; padding: 0.35rem 0.65rem; }
  #rate-widget canvas { display: none; }

  /* Auto-rule stacking */
  .auto-rule-info { flex-direction: column; align-items: flex-start; }

  /* Receipt */
  .receipt-dl { grid-template-columns: 1fr; gap: 0.1rem; }
  .receipt-dl dt { color: #64748b; font-size: 0.75rem; margin-top: 0.5rem; }
  .receipt-dl dd { font-weight: 500; }

  .balance-card .balance { font-size: 1.4rem; }
  .balance-header { flex-wrap: wrap; gap: 0.5rem; }
}

/* ── Keyboard focus: visible ring только при навигации с клавиатуры ── */
:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}
/* Скрываем outline при клике мышью (браузеры поддерживающие :focus-visible) */
:focus:not(:focus-visible) {
  outline: none;
}

/* ── Skip-to-content link (доступность) ──────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 9999;
  background: #0ea5e9;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ── Responsive: small phones (≤480px) ──────────────────────────────── */
@media (max-width: 480px) {
  .header h1 { font-size: 0.95rem; }

  .col-actions { white-space: normal; }
  .col-actions .btn-table { margin-bottom: 0.25rem; }

  .card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .card-actions .btn-edit,
  .card-actions .btn-danger {
    width: 100%;
    text-align: center;
    margin: 0;
    display: block;
  }
}
