/* ============================================================
   LendVault dApp — crimson & ice "risk & collateral" theme
   First-time crimson primary, deep charcoal backdrop.
   Layout v6: vault counter — utilization band + three-panel
   supply / position (health arc) / borrow counter.
   Static background; motion on elements only.
   ============================================================ */

:root {
  --bg: #0f0d0e;
  --bg-2: #171214;
  --card: rgba(23, 18, 20, 0.94);
  --card-border: rgba(148, 163, 184, 0.14);
  --text: #f4edef;
  --muted: #9a8d92;
  --accent-1: #ef4444;  /* crimson */
  --accent-2: #e2e8f0;  /* ice */
  --accent-grad: linear-gradient(135deg, #ef4444 0%, #f8fafc 140%);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius: 14px;
  --font-ui: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  /* static backdrop — no background animation */
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(239, 68, 68, 0.09), transparent 60%),
    radial-gradient(900px 500px at 92% 10%, rgba(226, 232, 240, 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.center { text-align: center; }
.small { font-size: 12.5px; }
.danger { color: var(--accent-1); }

/* ===================== TOP BAR ===================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 26px;
  background: rgba(15, 13, 14, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--accent-grad);
  color: #1a0a0c;
  animation: markIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
@keyframes markIn {
  from { opacity: 0; transform: scale(0.6) rotate(-10deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; display: block; }
.brand-tag { font-size: 10px; color: #fff; background: var(--accent-1); padding: 2px 8px; border-radius: 999px; letter-spacing: 1px; }
.brand-sub { font-size: 10.5px; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chain-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--muted);
}
.chain-badge.ok { color: var(--success); border-color: rgba(34, 197, 94, 0.4); }

/* ===================== VAULT ===================== */

.vault { max-width: 1120px; margin: 0 auto; padding: 24px 22px 0; }

/* ===================== BUTTONS & FORMS ===================== */

.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:not(:disabled):active { transform: translateY(0) scale(0.99); }

.btn-primary { background: var(--accent-grad); color: #1a0a0c; box-shadow: 0 6px 16px rgba(239, 68, 68, 0.25); }
.btn-ghost { background: rgba(148, 163, 184, 0.08); border: 1px solid var(--card-border); color: var(--text); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.15); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.full { width: 100%; }

input, select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  background: rgba(148, 163, 184, 0.07);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.13); }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===================== BANNERS ===================== */

.banner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.banner-icon { font-size: 26px; }
.banner h3 { font-family: var(--font-display); margin-bottom: 4px; }
.banner p { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.banner code, .settings-panel code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--accent-1);
}

.pause-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  animation: pauseIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes pauseIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
.pause-ico { font-size: 26px; }
.pause-banner h3 { font-family: var(--font-display); color: #fca5a5; }
.pause-banner p { font-size: 13px; color: var(--muted); }

.settings-panel { margin-bottom: 16px; }
.settings-panel h3 { font-family: var(--font-display); margin-bottom: 14px; }
.settings-panel .row { margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  animation: cardIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: rgba(239, 68, 68, 0.3); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================== UTILIZATION BAND ===================== */

.util-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px 14px;
  margin-bottom: 16px;
  animation: cardIn 0.5s ease both;
}
@media (max-width: 860px) { .util-band { grid-template-columns: repeat(2, 1fr); } }

.util-stat { display: flex; flex-direction: column; gap: 3px; }
.util-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); }
.util-value { font-family: var(--font-mono); font-size: 17px; font-weight: 600; }
.util-value.bump { animation: numBump 0.5s ease; }
@keyframes numBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); color: var(--accent-1); }
  100% { transform: scale(1); }
}

.util-bar-wrap { grid-column: 1 / -1; margin-top: 6px; }
.util-bar { height: 10px; border-radius: 999px; background: rgba(148, 163, 184, 0.13); overflow: hidden; }
.util-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  transition: width 0.9s cubic-bezier(0.3, 0.8, 0.4, 1);
  position: relative;
}
.util-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: fillShine 2.6s linear infinite;
}
@keyframes fillShine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ===================== COUNTER PANELS ===================== */

.counter {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 900px) { .counter { grid-template-columns: 1fr; } }

.counter-panel { display: flex; flex-direction: column; }

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.panel-head h2 { font-family: var(--font-display); font-size: 18px; }
.panel-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(239, 68, 68, 0.1);
  font-size: 15px;
}

.field-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.field-row input { flex: 1; }
.unit { font-family: var(--font-mono); font-size: 12px; color: var(--muted); min-width: 40px; text-align: right; }

.divider { height: 1px; background: var(--card-border); margin: 16px 0 2px; }

/* position panel */
.hf-wrap { position: relative; margin: 14px auto 4px; width: 200px; }
.hf-svg { width: 100%; display: block; }
.hf-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 2px;
  gap: 2px;
}
.hf-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.hf-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.hf-value.bump { animation: hfBump 0.6s ease; }
@keyframes hfBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); color: var(--accent-1); }
  100% { transform: scale(1); }
}

.pos-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.pos-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.pos-row .mono { color: var(--text); }
.tick-note { font-size: 10.5px; font-style: normal; color: var(--accent-1); }

.limit-meter { margin-top: 14px; }
.limit-track { position: relative; height: 10px; border-radius: 999px; background: rgba(148, 163, 184, 0.13); overflow: hidden; }
.limit-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width 0.9s cubic-bezier(0.3, 0.8, 0.4, 1);
}
.limit-ltv {
  position: absolute;
  top: -3px;
  left: 66%;
  width: 2px;
  height: 16px;
  background: var(--warning);
  transform: translateX(-50%);
  border-radius: 2px;
}
.limit-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--muted); }

/* ===================== PARAMS ===================== */

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 860px) { .bottom-grid { grid-template-columns: 1fr; } }

.param-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.param-table td { padding: 7px 0; border-bottom: 1px dashed var(--card-border); }
.param-table tr:last-child td { border-bottom: none; }
.param-table td:first-child { color: var(--muted); }
.param-table .mono { text-align: right; }

/* ===================== ACTIVITY ===================== */

.ev-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.ev-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: 12.5px;
  animation: evIn 0.35s ease both;
}
@keyframes evIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.ev-item .ev-detail { flex: 1; }
.ev-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ev-Deposited { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.ev-Borrowed { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.ev-Repaid { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.ev-Withdrawn { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
.ev-Liquidated { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.ev-Paused, .ev-Unpaused { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

/* ===================== FOOTER ===================== */

.site-footer {
  margin-top: 34px;
  padding: 18px 0 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer a { color: var(--accent-1); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
#footer-address { font-family: var(--font-mono); }

/* ===================== TOASTS ===================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: rgba(23, 18, 20, 0.97);
  border: 1px solid var(--card-border);
  border-bottom: 3px solid var(--accent-1);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25);
  word-break: break-word;
}
.toast.success { border-bottom-color: var(--success); }
.toast.error { border-bottom-color: var(--danger); }
.toast.info { border-bottom-color: var(--accent-2); }
.toast a { color: #fca5a5; }
.toast.out { opacity: 0; transform: translateY(10px); transition: all 0.25s ease; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(24px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================== MISC ===================== */

[hidden] { display: none !important; }

.spin { display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::selection { background: rgba(239, 68, 68, 0.35); }
