/* ZappWay Investments — приватный дашборд. Premium dark, mobile-first. */
:root {
  --bg: #0a1020;
  --bg-2: #0d1526;
  --card: #131d33;
  --card-2: #16213a;
  --line: rgba(148, 163, 184, 0.16);
  --text: #eaf0fa;
  --muted: #8b98b0;
  --money: #34e08a;          /* «прибыль» — тикающие проценты */
  --money-soft: rgba(52, 224, 138, 0.16);
  --blue: #4b90d8;           /* ZappWay-синий, осветлён для тёмного фона */
  --green-brand: #60ae36;
  --danger: #f4736b;
  --amber: #f3b34d;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-display: "Montserrat", var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 80% -10%, rgba(75, 144, 216, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 0%, rgba(52, 224, 138, 0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green-brand), var(--blue));
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; color: #fff; font-size: 18px;
  box-shadow: 0 6px 18px rgba(75, 144, 216, 0.4);
}
.brand-name { font-family: var(--font-display); font-weight: 800; letter-spacing: .2px; font-size: 17px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: -2px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; display: block; flex: none; box-shadow: 0 6px 18px rgba(28, 82, 144, 0.45); }
.login-brand .brand-logo { width: 40px; height: 40px; }
.brand-name .zapp { color: var(--green-brand); }
.brand-name .way { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.role-chip {
  font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(52, 224, 138, 0.14), transparent 55%),
    linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 30%);
  pointer-events: none;
}
.hero-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
}
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--money); box-shadow: 0 0 0 0 rgba(52, 224, 138, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 224, 138, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(52, 224, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 224, 138, 0); }
}
.hero-amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(38px, 13vw, 60px);
  line-height: 1.04;
  margin: 12px 0 2px;
  color: var(--money);
  text-shadow: 0 0 26px rgba(52, 224, 138, 0.35);
  letter-spacing: -0.5px;
}
.hero-amount .cur { font-size: 0.5em; color: var(--text); opacity: .65; margin-left: 6px; font-weight: 700; }
.hero-exact { font-size: 13px; color: var(--muted); min-height: 18px; }
.hero-sub {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 16px;
}
.hero-sub .pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px; font-size: 13px; color: var(--muted);
}
.hero-sub .pill b { color: var(--text); font-weight: 700; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; text-align: center;
}
.stat-val { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.stat-cap { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.2; }

/* ---------- Section title + admin bar ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 4px 12px;
}
.section-head h2 { font-family: var(--font-display); font-size: 15px; margin: 0; letter-spacing: .3px; }
.section-head .count { color: var(--muted); font-weight: 600; font-size: 13px; }

/* ---------- Loan cards ---------- */
.loan-list { display: flex; flex-direction: column; gap: 12px; }
.loan-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.loan-card.pending { border-style: dashed; opacity: .92; }
.loan-card.repaid { background: var(--bg-2); }
.loan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.loan-title { font-weight: 700; font-size: 15px; }
.loan-track { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.badge {
  flex: none; font-size: 11px; font-weight: 700; padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.delivery { color: var(--blue); border-color: rgba(75, 144, 216, 0.4); background: rgba(75, 144, 216, 0.08); }

.loan-accrued {
  font-family: var(--font-display); font-weight: 800;
  font-size: 30px; color: var(--money); margin: 14px 0 2px;
  text-shadow: 0 0 18px rgba(52, 224, 138, 0.25);
}
.loan-accrued .cur { font-size: 0.55em; color: var(--text); opacity: .6; margin-left: 4px; }
.loan-accrued.frozen { color: var(--text); text-shadow: none; }

.loan-meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px;
  font-size: 12.5px; color: var(--muted);
}
.loan-meta b { color: var(--text); font-weight: 600; }
.loan-rate { color: var(--amber); }

.loan-pending-note {
  margin-top: 12px; font-size: 13px; color: var(--amber);
  display: flex; align-items: center; gap: 8px;
}

.loan-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  color: var(--text); font-family: var(--font); font-weight: 600; font-size: 14px;
  padding: 11px 16px; border-radius: 12px; cursor: pointer; transition: transform .06s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--green-brand), #2fbf6a); border-color: transparent; color: #06210f; font-weight: 800; }
.btn-blue { background: linear-gradient(135deg, var(--blue), #2f6fb0); border-color: transparent; color: #042038; font-weight: 800; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(244, 115, 107, 0.4); background: rgba(244, 115, 107, 0.08); }
.btn-sm { padding: 9px 12px; font-size: 13px; border-radius: 10px; }
.btn-icon { padding: 9px 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.add-fab {
  width: 100%; margin-top: 4px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 640px; background: var(--card);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); max-height: 92dvh; overflow-y: auto;
  animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 660px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 22px; border-bottom: 1px solid var(--line); }
}
.modal h3 { font-family: var(--font-display); margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 16px; font-family: var(--font);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 60px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--green-brand); }
.check span { font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- Misc ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 32px 16px;
  border: 1px dashed var(--line); border-radius: var(--radius); font-size: 14px;
}
.skeleton { color: var(--muted); }
.admin-only.hidden { display: none !important; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 26px; opacity: .7; }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .modal { animation: none; }
}
