/* ============================================================
   Sentry — Wallet Monitor  |  Application styles
   Dark, committed identity matching the product brand.
   ============================================================ */

:root {
  --bg:        #0a0e27;
  --bg-2:      #0c1230;
  --panel:     #111836;
  --panel-2:   #141c40;
  --panel-hi:  #1a2450;
  --border:    #1e3a5f;
  --border-2:  #26325c;

  --text:      #e6ebf5;
  --text-dim:  #8b95b0;
  --text-mute: #5f6b8c;

  --cyan:      #22d3ee;
  --blue:      #3b82f6;
  --blue-2:    #60a5fa;
  --accent:    #38bdf8;
  --grad:      linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);

  --success:   #22c55e;
  --success-b: rgba(34,197,94,0.14);
  --danger:    #f43f5e;
  --danger-b:  rgba(244,63,94,0.14);
  --warning:   #fbbf24;
  --warning-b: rgba(251,191,36,0.14);

  --shadow:    0 10px 30px -12px rgba(0,0,0,0.55);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,0.7);
  --radius:    14px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --topbar-h:  66px;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--sans);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ambient background glows */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(34,211,238,0.10), transparent 60%),
    radial-gradient(800px 520px at 8% 110%, rgba(59,130,246,0.10), transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.mono { font-family: var(--mono); }
.num  { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.05rem; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--panel-2); color: var(--text);
  font-size: 0.9rem; font-weight: 600; white-space: nowrap;
  transition: transform .12s ease, border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: #33507e; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: var(--grad); border: none; color: #05122a; font-weight: 700;
  box-shadow: 0 8px 22px -10px rgba(34,211,238,0.6);
}
.btn-primary:hover { box-shadow: 0 12px 28px -8px rgba(34,211,238,0.75); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(244,63,94,0.35); background: var(--danger-b); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid transparent;
}
.pill-green  { background: var(--success-b); color: var(--success); border-color: rgba(34,197,94,0.3); }
.pill-red    { background: var(--danger-b);  color: var(--danger);  border-color: rgba(244,63,94,0.3); }
.pill-cyan   { background: rgba(34,211,238,0.12); color: var(--cyan); border-color: rgba(34,211,238,0.3); }
.pill-amber  { background: var(--warning-b); color: var(--warning); border-color: rgba(251,191,36,0.3); }
.pill-mute   { background: rgba(139,149,176,0.12); color: var(--text-dim); border-color: rgba(139,149,176,0.25); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }

/* ============================================================
   App shell
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-row: 1 / -1;
  background: linear-gradient(180deg, #0b1130 0%, #0a0e27 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 1.15rem 1.25rem; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
}
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand b { font-family: var(--display); font-size: 1.35rem; letter-spacing: -0.02em; }
.nav { padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.11em;
  color: var(--text-mute); font-weight: 700; padding: 0.9rem 0.75rem 0.4rem;
}
.nav a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.62rem 0.8rem; border-radius: 10px;
  color: var(--text-dim); font-weight: 500; font-size: 0.92rem;
  transition: background .15s, color .15s; position: relative;
}
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav a.active { background: rgba(56,189,248,0.12); color: #cfe9ff; }
.nav a.active::before {
  content: ""; position: absolute; left: -0.75rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.sidebar-foot { padding: 1rem; border-top: 1px solid var(--border); }
.plan-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem;
}
.plan-card .tier { font-family: var(--display); font-weight: 700; text-transform: capitalize; }
.meter { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; margin: 0.55rem 0 0.35rem; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--grad); }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.4rem; border-bottom: 1px solid var(--border);
  background: rgba(10,14,39,0.82); backdrop-filter: blur(12px);
}
.hamburger { display: none; background: transparent; border: 1px solid var(--border-2); border-radius: 9px; padding: 0.4rem; color: var(--text); }
.hamburger svg { width: 20px; height: 20px; display: block; }
.search {
  flex: 1; max-width: 440px; display: flex; align-items: center; gap: 0.55rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 0.5rem 0.85rem;
}
.search svg { width: 17px; height: 17px; color: var(--text-mute); flex-shrink: 0; }
.search input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 0.9rem; outline: none; min-width: 0; }
.search input::placeholder { color: var(--text-mute); }
.topbar-spacer { flex: 1; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  transition: color .15s, border-color .15s; position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .badge-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--panel); }
.avatar {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad); color: #05122a; font-weight: 800; font-family: var(--display);
  border: none; font-size: 0.95rem;
}

/* ---------- Content ---------- */
.content { padding: 1.6rem 1.6rem 3rem; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head h1 { font-family: var(--display); font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.page-head p { color: var(--text-dim); font-size: 0.92rem; margin-top: 0.15rem; }
.page-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Cards / panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 130%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-family: var(--display); font-size: 1.05rem; font-weight: 600; }
.panel-head .sub { color: var(--text-dim); font-size: 0.82rem; }
.panel-body { padding: 1.25rem; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.3rem; }
.stat {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 140%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.25rem;
  position: relative; overflow: hidden; transition: border-color .18s, transform .18s;
}
.stat:hover { border-color: var(--border-2); transform: translateY(-2px); }
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); opacity: 0; transition: opacity .2s; }
.stat:hover::after { opacity: 1; }
.stat .label { display: flex; align-items: center; gap: 0.5rem; color: var(--text-dim); font-size: 0.82rem; font-weight: 600; }
.stat .label svg { width: 16px; height: 16px; }
.stat .value { font-family: var(--display); font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.55rem; line-height: 1; }
.stat .foot { margin-top: 0.55rem; font-size: 0.78rem; color: var(--text-mute); display: flex; align-items: center; gap: 0.35rem; }
.stat.accent-green .value { color: var(--success); }
.stat.accent-cyan .value { color: var(--cyan); }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); }

/* ---------- Grid rows ---------- */
.row { display: grid; gap: 1.3rem; margin-bottom: 1.3rem; }
.row.chart-split { grid-template-columns: 1.7fr 1fr; }

/* ---------- Chart ---------- */
.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 1.2rem; font-size: 0.8rem; color: var(--text-dim); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 520px; }
table.data th {
  text-align: left; padding: 0.7rem 1rem; color: var(--text-mute);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 0.85rem 1rem; border-bottom: 1px solid rgba(30,58,95,0.5); vertical-align: middle; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: rgba(255,255,255,0.025); }
.addr { font-family: var(--mono); font-size: 0.83rem; color: var(--blue-2); }
.hash { font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); }
.amt-pos { color: var(--success); font-family: var(--mono); font-weight: 600; }
.amt-neg { color: var(--danger); font-family: var(--mono); font-weight: 600; }

/* ---------- List rows (wallets, keys, webhooks) ---------- */
.list { display: flex; flex-direction: column; gap: 0.7rem; }
.list-row {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.15rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, transform .12s;
}
.list-row:hover { border-color: var(--border-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.list-row .title svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.list-row .meta { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.2rem; overflow: hidden; text-overflow: ellipsis; }
.chain-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 0.75rem; flex-shrink: 0; background: rgba(56,189,248,0.12); color: var(--accent); border: 1px solid rgba(56,189,248,0.25); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-dim); }
.empty .ico { width: 54px; height: 54px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 16px; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.2); }
.empty .ico svg { width: 26px; height: 26px; color: var(--accent); }
.empty h3 { font-family: var(--display); font-size: 1.1rem; margin-bottom: 0.35rem; color: var(--text); }
.empty p { max-width: 380px; margin: 0 auto 1.2rem; font-size: 0.9rem; }

/* skeleton loading */
.skel { position: relative; overflow: hidden; background: var(--panel); border-radius: 8px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 8px 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.7rem 0.85rem; color: var(--text); font-size: 0.92rem; font-family: inherit; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.field .hint { font-size: 0.78rem; color: var(--text-mute); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 2.2rem; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 0.65rem; justify-content: center; margin-bottom: 1.6rem; }
.auth-brand img { width: 34px; height: 34px; border-radius: 8px; }
.auth-brand b { font-family: var(--display); font-size: 1.5rem; }
.auth-card h1 { font-family: var(--display); font-size: 1.45rem; text-align: center; margin-bottom: 0.3rem; }
.auth-card .sub { text-align: center; color: var(--text-dim); font-size: 0.9rem; margin-bottom: 1.6rem; }
.auth-switch { text-align: center; margin-top: 1.2rem; font-size: 0.88rem; color: var(--text-dim); }
.auth-switch a { color: var(--accent); font-weight: 600; }
.form-error { background: var(--danger-b); border: 1px solid rgba(244,63,94,0.35); color: #ffb4c0; padding: 0.65rem 0.85rem; border-radius: 10px; font-size: 0.85rem; margin-bottom: 1rem; }

/* ---------- Plans / billing ---------- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.plan {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 140%);
  border: 1px solid var(--border); border-radius: 16px; padding: 1.6rem; display: flex; flex-direction: column;
}
.plan.featured { border-color: rgba(56,189,248,0.5); box-shadow: 0 0 0 1px rgba(56,189,248,0.25), var(--shadow); }
.plan .pname { font-family: var(--display); font-size: 1.15rem; font-weight: 700; }
.plan .price { font-family: var(--display); font-size: 2.1rem; font-weight: 700; margin: 0.6rem 0 0.2rem; }
.plan .price small { font-size: 0.9rem; color: var(--text-dim); font-weight: 500; }
.plan ul { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin: 1.2rem 0; flex: 1; }
.plan li { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.9rem; color: var(--text); }
.plan li svg { width: 17px; height: 17px; color: var(--success); flex-shrink: 0; margin-top: 2px; }

/* ---------- Code block ---------- */
.code {
  background: #060a1e; border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.15rem; overflow-x: auto; font-family: var(--mono); font-size: 0.83rem; line-height: 1.7; color: #cbd5e1;
  white-space: pre; tab-size: 2;
}
.code .k { color: var(--cyan); } .code .s { color: #a5e88a; } .code .c { color: var(--text-mute); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 1.3rem; right: 1.3rem; z-index: 100; display: flex; flex-direction: column; gap: 0.6rem; max-width: min(92vw, 380px); }
.toast {
  display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.85rem 1rem;
  background: var(--panel-hi); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: slidein .25s ease; font-size: 0.88rem;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.ok svg { color: var(--success); } .toast.err svg { color: var(--danger); } .toast.info svg { color: var(--accent); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(4,7,20,0.7); backdrop-filter: blur(4px); z-index: 80; display: grid; place-items: center; padding: 1.2rem; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .22s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--display); font-size: 1.15rem; }
.modal-body { padding: 1.4rem; }
.modal-foot { display: flex; gap: 0.7rem; justify-content: flex-end; padding: 1rem 1.4rem; border-top: 1px solid var(--border); }
.close-x { background: transparent; border: none; color: var(--text-dim); font-size: 1.4rem; line-height: 1; padding: 0.2rem; }
.close-x:hover { color: var(--text); }
.reveal-key { display: flex; gap: 0.5rem; align-items: center; background: #060a1e; border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.85rem; font-family: var(--mono); font-size: 0.8rem; word-break: break-all; }

/* ---------- Drawer scrim (mobile) ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(4,7,20,0.6); z-index: 39; backdrop-filter: blur(2px); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
  .row.chart-split { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: min(82vw, 300px); height: 100vh;
    transform: translateX(-102%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .app.drawer-open .scrim { display: block; }
  .hamburger { display: grid; place-items: center; }
  .search { max-width: none; }
  .content { padding: 1.1rem 1rem 3rem; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .stat { padding: 0.95rem 1rem; }
  .stat .value { font-size: 1.55rem; }
  .page-head h1 { font-size: 1.4rem; }
  .form-row { grid-template-columns: 1fr; }
  .search input { font-size: 0.85rem; }
  .topbar { padding: 0 0.9rem; gap: 0.6rem; }
  .hide-xs { display: none !important; }
  .content { padding: 1rem 0.85rem 3rem; }
  .panel-body { padding: 1rem; }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
