/* ============================================================
 * Card Manager — Premium dark UI
 * ============================================================ */
:root {
  --bg: #0a0e1a;
  --bg-2: #0d1220;
  --surface: #131829;
  --surface-2: #1a2138;
  --surface-3: #232b48;
  --border: #232b48;
  --border-soft: #1c2238;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --primary-soft: rgba(59,130,246,.15);
  --success: #10b981;
  --success-soft: rgba(16,185,129,.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245,158,11,.12);
  --warning-border: rgba(245,158,11,.45);
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,.12);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,.5);
  --shadow-soft: 0 4px 20px rgba(0,0,0,.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
h1,h2,h3,h4 { margin: 0 0 8px; }
svg { width: 1em; height: 1em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Courier New", monospace; }

/* ============ AUTH ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 0%, rgba(59,130,246,.15), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(139,92,246,.1), transparent 50%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo-circle {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: white;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px rgba(59,130,246,.4);
}
.auth-card h1 { font-size: 24px; font-weight: 700; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.auth-card input {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 15px; outline: none;
  transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--primary); }

/* ============ BUTTONS ============ */
.btn {
  border-radius: var(--radius-sm);
  padding: 13px 18px; font-size: 14px; font-weight: 600;
  transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: var(--surface-3); color: var(--text); }
.btn-secondary:hover { background: #2c365a; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger-outline {
  background: rgba(239,68,68,.08);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.3);
  width: 100%;
}
.btn-danger-outline:hover { background: rgba(239,68,68,.15); }
.icon-btn {
  background: transparent; color: var(--text);
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); }

/* ============ TOPBAR ============ */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h2 { font-size: 17px; font-weight: 700; line-height: 1.1; }
.logo-mini {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 1px solid rgba(59,130,246,.3);
}
.logo-mini svg { width: 22px; height: 22px; }
.topbar-actions { display: flex; gap: 6px; }

/* ============ CONTAINER ============ */
.container {
  padding: 18px;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  min-height: calc(100vh - 80px);
}

/* ============ STATS GRID ============ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.stat-icon {
  width: 38px; height: 38px;
  margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--muted);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-card.active .stat-icon { color: var(--primary); }
.stat-card.stat-ready.active { background: var(--success-soft); border-color: var(--success); }
.stat-card.stat-ready.active .stat-icon { color: var(--success); }
.stat-card.stat-wait.active { background: var(--warning-soft); border-color: var(--warning); }
.stat-card.stat-wait.active .stat-icon { color: var(--warning); }
.stat-num { font-size: 24px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ============ SEARCH ============ */
.search-row { margin-bottom: 18px; }
.search-input {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  display: flex; align-items: center;
  padding: 0 14px;
}
.search-input svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search-input input {
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  padding: 14px 12px;
  flex: 1; min-width: 0;
  font-size: 14px;
}
.search-input input::placeholder { color: var(--muted); }

/* ============ CARD LIST ============ */
.cards-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 100px; }

.card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  transition: all .2s;
}
.card-item.ready { border-color: rgba(16,185,129,.4); }
.card-item.waiting { border-color: var(--warning-border); }

.card-icon-wrap {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-icon-wrap svg { width: 22px; height: 22px; }
.card-item.ready .card-icon-wrap {
  background: var(--success-soft);
  color: var(--success);
}

.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.2; }
.card-sub { font-size: 13px; color: var(--primary); margin-top: 2px; }
.card-holder { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.card-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.card-item.ready .badge {
  background: var(--success-soft);
  border-color: rgba(16,185,129,.4);
  color: var(--success);
}
.row-actions { display: flex; gap: 4px; }
.row-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.row-btn svg { width: 16px; height: 16px; }
.row-btn.view { color: var(--primary); }
.row-btn.view:hover { background: var(--primary-soft); }
.row-btn.edit { color: var(--text-2); }
.row-btn.edit:hover { background: var(--surface-2); color: var(--text); }
.row-btn.delete { color: var(--danger); }
.row-btn.delete:hover { background: var(--danger-soft); }

/* ============ EMPTY ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon {
  width: 80px; height: 80px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.empty-icon svg { width: 36px; height: 36px; }
.empty h3 { font-size: 18px; margin-bottom: 6px; }
.empty p { margin: 0 0 18px; }
.empty .btn { margin: 0 auto; }

/* ============ FAB ============ */
.fab {
  position: fixed;
  right: 22px; bottom: 88px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(59,130,246,.5);
  z-index: 4;
  transition: transform .15s;
}
.fab svg { width: 24px; height: 24px; }
.fab:hover { transform: scale(1.05); background: var(--primary-2); }

/* ============ DETAIL SCREEN ============ */
.detail-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
  animation: slideRight .25s;
}
@keyframes slideRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.detail-top {
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 5;
}
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 16px; font-weight: 600;
  padding: 8px 0;
}
.back-btn svg { width: 20px; height: 20px; }
.detail-body { padding: 18px; max-width: 560px; margin: 0 auto; }
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 18px;
}
.detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}
.label-up {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.bank-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 22px; font-weight: 700;
}
.bank-line .sep { color: var(--muted); font-weight: 400; }
.bank-line .card-name { color: var(--primary); }
.detail-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
  white-space: nowrap;
}
.detail-badge svg { width: 13px; height: 13px; }
.detail-card.ready .detail-badge {
  background: var(--success-soft);
  border-color: rgba(16,185,129,.4);
  color: var(--success);
}
.field-box {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.field-value { font-size: 18px; font-weight: 600; letter-spacing: .03em; }
.field-value-big { font-size: 18px; font-weight: 700; }
.copy-btn {
  background: transparent;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.copy-btn svg { width: 18px; height: 18px; }
.copy-btn:hover { background: var(--surface-3); color: var(--text); }
.grid-2-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.separator { height: 1px; background: var(--border); }
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.detail-actions .btn { width: 100%; }

/* ============ MODAL ============ */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 500px; max-height: 92vh;
  overflow-y: auto;
  animation: slideUp .25s;
}
@media (min-width: 600px) {
  .modal-back { align-items: center; }
  .modal { border-radius: var(--radius); }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0;
  background: var(--surface);
}
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.modal-body input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 14px; outline: none;
  transition: border-color .15s;
}
.modal-body input:focus { border-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 8px;
}

/* ============ BANK LIMITS ============ */
.bank-limit-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
}
.bank-limit-row .bank { flex: 1; font-size: 14px; }
.bank-limit-row .days { color: var(--primary); font-size: 13px; }

/* ============ PROFILE ============ */
.profile-avatar {
  width: 88px; height: 88px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 32px rgba(59,130,246,.4);
}
.profile-avatar svg { width: 44px; height: 44px; }
.profile-stats { display: flex; flex-direction: column; gap: 10px; }
.profile-stat {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}
.ps-icon { font-size: 18px; }
.ps-label { flex: 1; font-size: 15px; color: var(--text); }
.ps-value { font-size: 16px; font-weight: 700; color: var(--text); }
.ps-value.ps-ok { color: var(--success); }
.ps-value.ps-warn { color: var(--warning); }
.profile-section { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.ps-title {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  color: var(--muted); margin-bottom: 10px;
}
.banks-list { display: flex; flex-direction: column; gap: 8px; }
.bank-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}
.bank-name-x { font-size: 15px; font-weight: 600; color: var(--text); }
.bank-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.bank-count {
  font-size: 12px; font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 10px;
  border-radius: 999px;
}
.bank-wait {
  font-size: 12px; font-weight: 600;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ============ INLINE DETAIL (expand under card) ============ */
.card-item.expanded {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.inline-detail {
  margin-top: -10px; /* row gap ni qoplash, ustki karta bilan ulanish uchun */
  animation: expandDown .25s ease;
  overflow: hidden;
}
.inline-detail .detail-card {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-top: 1px dashed var(--border);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.inline-detail.ready .detail-card { border-color: rgba(16,185,129,.4); }
@keyframes expandDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: all .25s;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ============ ANIMATIONS ============ */
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0 }
  to { transform: translateY(0); opacity: 1 }
}

/* ============ FAB STACK ============ */
.fab-stack {
  position: fixed;
  right: 22px; bottom: 28px;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center;
  z-index: 4;
}
.fab { position: static; }
.fab-basket {
  background: var(--surface-3);
  color: var(--text);
  width: 50px; height: 50px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  position: relative;
}
.fab-basket:hover { background: #2c365a; }
.fab-basket.active {
  background: var(--warning);
  color: #1a1206;
  box-shadow: 0 6px 24px rgba(245,158,11,.5);
}
.fab-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* ============ CARD ICON CLICKABLE / BASKET STATE ============ */
.card-icon-wrap { cursor: pointer; transition: all .15s; }
.card-icon-wrap:hover { transform: scale(1.05); }
.card-icon-wrap.is-basket {
  background: rgba(239,68,68,.12);
  color: var(--danger);
}
.card-item.in-basket {
  border-color: rgba(245,158,11,.55);
  box-shadow: 0 0 0 1px rgba(245,158,11,.15) inset;
}

/* ============ BANK HINT ============ */
.bank-hint {
  margin-top: 8px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

/* ============ HISTORY BUTTON IN PROFILE ============ */
.history-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  text-align: left;
  font-size: 15px; font-weight: 600;
  transition: all .15s;
}
.history-btn:hover { background: var(--surface-3); border-color: var(--primary); }
.hb-icon { font-size: 18px; }
.hb-text { flex: 1; }
.hb-count {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ============ HISTORY LIST ============ */
.history-group { margin-bottom: 16px; }
.history-date {
  font-size: 13px; font-weight: 700;
  color: var(--primary);
  letter-spacing: .04em;
  padding: 6px 4px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.history-items { display: flex; flex-direction: column; gap: 8px; }
.history-item .history-time {
  font-size: 13px; font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  padding: 5px 10px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
}

/* ============ SETTINGS - INLINE SAVE & BANK ROW ============ */
.inline-save { display: flex; gap: 8px; align-items: stretch; }
.inline-save input { flex: 1; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.bank-limit-row {
  display: flex; gap: 6px; align-items: center;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.bank-limit-row .bank { flex: 1; font-size: 14px; font-weight: 600; }
.bank-limit-row input.bl-days {
  width: 70px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  text-align: center;
}
