/* PipsVault admin page: dark, neon accents, cards. */
:root {
  color-scheme: dark;
  --bg: #060912;
  --bg-2: #0a0f1d;
  --card: rgba(16, 22, 38, 0.78);
  --card-solid: #101626;
  --card-hover: rgba(22, 30, 50, 0.9);
  --field: #0b1120;
  --text: #e8edf7;
  --muted: #8a96ad;
  --line: rgba(148, 163, 184, 0.13);
  --line-strong: rgba(148, 163, 184, 0.24);
  --cyan: #22d3ee;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --green: #22c55e;
  --red: #f43f5e;
  --gold: #facc15;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-text: #ffffff;
  --grad: linear-gradient(135deg, var(--cyan), var(--violet) 55%, var(--pink));
  --side: rgba(8, 12, 24, 0.86);
  --side-text: #e8edf7;
  --side-muted: #8a96ad;
  --side-hover: rgba(139, 92, 246, 0.12);
  --ok-bg: rgba(34, 197, 94, 0.12);
  --ok-text: #86efac;
  --error-bg: rgba(244, 63, 94, 0.12);
  --error-text: #fda4af;
  --danger: #f43f5e;
  --tg-bg: #0e1621;
  --tg-bubble: #182533;
  --tg-button: #22364b;
  --tg-button-text: #cfe3ff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(700px 420px at -10% 10%, rgba(34, 211, 238, 0.11), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(236, 72, 153, 0.08), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; overflow-wrap: anywhere; }
code { background: rgba(148, 163, 184, 0.1); padding: 0.05rem 0.35rem; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.ok-text { color: var(--ok-text); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
::selection { background: rgba(139, 92, 246, 0.4); }

/* --- Side menu (a top bar on phones) --- */
.brand { display: flex; align-items: center; gap: 0.7rem; font-weight: 800; font-size: 1.08rem; letter-spacing: -0.01em; }
.brand small { display: block; font-weight: 600; font-size: 0.68rem; color: var(--side-muted); letter-spacing: 0.16em; text-transform: uppercase; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: block; filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.45)); }
.top { padding: 1rem 16px; }
.side {
  background: var(--side); color: var(--side-text);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 0.9rem; padding: 0.9rem 16px;
  position: sticky; top: 0; z-index: 10;
}
.nav { display: flex; gap: 0.2rem; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 0.65rem; white-space: nowrap;
  padding: 0.55rem 0.8rem; border-radius: 11px; color: var(--side-muted); font-weight: 550;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--side-hover); color: var(--side-text); text-decoration: none; }
.nav a[aria-current="page"] {
  color: #fff;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(139, 92, 246, 0.3));
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45), 0 0 18px rgba(139, 92, 246, 0.18);
}
.nav-icon { width: 1.4em; text-align: center; font-size: 1.05em; }
.nav-more { display: block; margin: 1rem 0.8rem 0.3rem; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--side-muted); opacity: 0.7; }
.nav a.nav-small { font-size: 0.88rem; }
.signout { margin: 0; }
.side .btn-quiet { color: var(--side-muted); border-color: var(--line); }
.side .btn-quiet:hover { color: var(--side-text); }
.side-foot { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--side-muted); padding: 0 0.3rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); } 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.main { min-width: 0; }
@media (min-width: 900px) {
  body.with-side { display: grid; grid-template-columns: 250px 1fr; }
  .side { height: 100vh; padding: 1.4rem 1rem; border-bottom: 0; border-right: 1px solid var(--line); }
  .side .nav { flex-direction: column; overflow: visible; flex: 1; }
  .side .signout { margin-top: auto; }
}
@media (max-width: 899px) { .side .signout, .side-foot, .nav-more { display: none; } }

.page { max-width: 1160px; margin: 0 auto; padding: 1.8rem 16px 3rem; }
.foot { display: none; }

/* --- Page header --- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.4rem; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 0.3rem; }

/* --- Cards and layout --- */
.card {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.35rem; margin: 0 0 1.1rem; box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.card::before {
  content: ""; position: absolute; inset: 0 1.2rem auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.55), transparent);
}
.card.narrow { max-width: 460px; margin: 2rem auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 0 1.1rem; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 0.55rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row form { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gap-top { margin-top: 0.5rem; }
.steps { padding-left: 1.2rem; }
.steps li { margin: 0.25rem 0; }

/* --- Stat cards --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem; margin-bottom: 1.2rem; }
.stat {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem; box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat::after {
  content: ""; position: absolute; width: 120px; height: 120px; right: -40px; top: -40px; border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.28), transparent 70%);
}
.stat:nth-child(4n+2)::after { background: radial-gradient(circle, rgba(34, 211, 238, 0.26), transparent 70%); }
.stat:nth-child(4n+3)::after { background: radial-gradient(circle, rgba(34, 197, 94, 0.24), transparent 70%); }
.stat:nth-child(4n+4)::after { background: radial-gradient(circle, rgba(236, 72, 153, 0.24), transparent 70%); }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 550; }
.stat .small { display: block; margin-top: 4px; }

/* Quick action tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; }
.tile {
  display: flex; flex-direction: column; gap: 0.35rem; padding: 0.9rem 1rem; border-radius: 14px;
  background: rgba(148, 163, 184, 0.05); border: 1px solid var(--line); color: var(--text); font-weight: 650;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.tile:hover { text-decoration: none; transform: translateY(-2px); border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.1); }
.tile-icon { font-size: 1.4rem; }
.tile small { color: var(--muted); font-weight: 500; }

.todo { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.5rem; }
.todo a {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.9rem; border-radius: 12px;
  background: rgba(250, 204, 21, 0.08); border: 1px solid rgba(250, 204, 21, 0.25); color: var(--text);
}
.todo a::before { content: "●"; color: var(--gold); }

.tag {
  display: inline-flex; align-items: center; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 0.12rem 0.55rem; border-radius: 999px; background: var(--grad); color: #fff;
}
.tag-quiet { background: rgba(148, 163, 184, 0.1); color: var(--muted); border: 1px solid var(--line); }
.tag-buy { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.tag-sell { background: rgba(244, 63, 94, 0.15); color: #fb7185; }

/* --- Messages --- */
.flash { padding: 0.75rem 1rem; border-radius: 12px; margin: 0 0 1.1rem; white-space: pre-wrap; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); border-color: rgba(34, 197, 94, 0.3); }
.flash-error { background: var(--error-bg); color: var(--error-text); border-color: rgba(244, 63, 94, 0.3); }
.flash a { color: inherit; text-decoration: underline; }

/* --- Forms --- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.55rem 0.75rem; width: 100%; max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 6rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--violet); }
input[type="file"] { padding: 0.45rem; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; margin-right: 0.8rem; padding: 0.35rem 0.8rem; border-radius: 8px; border: 0;
  background: var(--grad); color: #fff; cursor: pointer;
}
label { display: block; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem; margin: 0.5rem 0; }
legend { padding: 0 0.3rem; font-weight: 650; }
.checks label { display: flex; gap: 0.55rem; align-items: flex-start; margin: 0.35rem 0; }
.checks input { width: auto; margin-top: 0.3rem; }
.counter { text-align: right; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap;
  padding: 0.6rem 1.05rem; border-radius: 11px; border: 1px solid var(--line-strong);
  background: rgba(148, 163, 184, 0.06); color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.06s, box-shadow 0.15s;
}
.btn:hover { border-color: rgba(139, 92, 246, 0.6); background: rgba(139, 92, 246, 0.1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.1); box-shadow: 0 8px 26px rgba(139, 92, 246, 0.45); }
.btn-danger { background: transparent; border-color: rgba(244, 63, 94, 0.55); color: #fb7185; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-quiet { background: transparent; }
.btn-small { padding: 0.32rem 0.75rem; font-size: 0.84rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.copy-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.copy-row input { flex: 1; min-width: 0; }

.plan-row, .button-row {
  display: grid; grid-template-columns: 1fr; gap: 0.55rem; align-items: end;
  padding: 0.7rem 0; border-top: 1px solid var(--line);
}
@media (min-width: 640px) {
  .plan-row { grid-template-columns: 2fr 1fr 1fr auto; }
  .button-row { grid-template-columns: 1fr 1fr 1.4fr; }
}
.plan-row:first-of-type, .button-row:first-of-type { border-top: 0; }
.plan-remove { margin: 0 0 0.5rem; text-align: right; }
.reset { margin-top: 0.5rem; }

.item {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 0; border-top: 1px solid var(--line);
}
.item:first-of-type { border-top: 0; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; }
.item-actions form { margin: 0; }
.note { margin: 0.4rem 0 0; padding: 0.5rem 0.7rem; background: rgba(148, 163, 184, 0.06); border: 1px solid var(--line); border-radius: 10px; white-space: pre-wrap; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; margin: 0 -0.3rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.74rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(148, 163, 184, 0.05); }
.details { word-break: break-word; max-width: 420px; }

/* --- Telegram-style preview --- */
.tg-preview { background: var(--tg-bg); border-radius: 14px; padding: 0.9rem; border: 1px solid var(--line); }
.tg-bubble { background: var(--tg-bubble); border-radius: 14px; padding: 0.65rem 0.85rem; white-space: pre-wrap; word-break: break-word; margin-bottom: 0.3rem; }
.tg-bubble pre, .tg-bubble code { white-space: pre-wrap; }
.tg-button { background: var(--tg-button); color: var(--tg-button-text); border-radius: 9px; text-align: center; padding: 0.45rem; margin-top: 0.3rem; font-weight: 550; }

/* --- Members, payments --- */
.search { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search input { flex: 1 1 220px; }
.grant-form { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 8px; align-items: end; }
@media (max-width: 720px) { .grant-form { grid-template-columns: 1fr; } }
.card-warn { border-color: rgba(244, 63, 94, 0.4); background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), var(--card)); }
.card-warn h2, .card-warn p { color: var(--error-text); }

/* --- Settings: a dropdown card per section --- */
.settings-jump { margin-bottom: 1.1rem; flex-wrap: wrap; }
.settings-jump .btn { border-radius: 999px; }
details.group { padding: 0; overflow: hidden; }
details.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.8rem; padding: 1rem 1.3rem;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.2s; }
details.group[open] > summary::after { transform: rotate(180deg); }
details.group > summary:hover { background: rgba(148, 163, 184, 0.04); }
.group-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(139, 92, 246, 0.25));
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35);
}
.group-title { font-weight: 750; font-size: 1.02rem; }
.group-title small { display: block; color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.group-body { padding: 0 1.3rem 0.6rem; border-top: 1px solid var(--line); }

.set-row {
  display: grid; grid-template-columns: 1fr; gap: 0.5rem; align-items: center;
  padding: 0.85rem 0; border-top: 1px solid var(--line);
}
.set-row:first-child { border-top: 0; }
.set-row > *, .set-control, details.setting > summary { min-width: 0; }
@media (min-width: 760px) { .set-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); } }
.set-label { font-weight: 650; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.set-help { color: var(--muted); font-size: 0.8rem; font-weight: 400; display: block; width: 100%; }
.set-control form { margin: 0; display: flex; gap: 0.5rem; align-items: center; }
.set-control form select, .set-control form input { flex: 1; min-width: 0; }
details.setting > summary {
  cursor: pointer; display: flex; gap: 0.6rem; align-items: center; list-style: none;
  padding: 0.55rem 0.75rem; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field);
}
details.setting > summary::-webkit-details-marker { display: none; }
details.setting > summary::after { content: "✎"; margin-left: auto; color: var(--muted); }
details.setting > summary:hover { border-color: rgba(139, 92, 246, 0.5); }
details.setting[open] > summary { border-color: var(--violet); }
details.setting form { margin-top: 0.55rem; flex-direction: column; align-items: stretch; }
.setting-value { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting-name { font-weight: 650; }

/* APIs page status dot */
.api-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.4rem; background: var(--muted); }
.api-on { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.7); }
.api-wait { background: #f59e0b; }

/* Toggle-style on/off select */
select.switch[data-on="on"] { border-color: rgba(34, 197, 94, 0.55); color: #86efac; }
select.switch[data-on="off"] { color: var(--muted); }

/* --- Branding --- */
.logo-stage {
  display: grid; place-items: center; padding: 1.4rem; border-radius: 14px; border: 1px dashed var(--line-strong);
  background: radial-gradient(circle at 50% 40%, rgba(139, 92, 246, 0.18), transparent 65%), var(--field);
}
.logo-stage img { width: 160px; height: 160px; object-fit: contain; filter: drop-shadow(0 0 24px rgba(139, 92, 246, 0.45)); }
.preview-img { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid var(--line); }

/* --- Sign in --- */
body.login { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 400px; text-align: center; padding: 2.4rem 1.8rem 2rem;
  background: rgba(12, 17, 30, 0.82); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(139, 92, 246, 0.12), 0 0 60px rgba(139, 92, 246, 0.12);
  backdrop-filter: blur(16px); position: relative; overflow: hidden;
}
.login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--grad); }
.login-logo { width: 92px; height: 92px; margin: 0 auto 1rem; display: block; filter: drop-shadow(0 0 22px rgba(139, 92, 246, 0.55)); animation: float 5s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.login-card h1 { font-size: 1.5rem; margin-bottom: 1.6rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.9rem; }
.code-input {
  font: 700 1.6rem/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.32em; text-transform: uppercase;
  text-align: center; padding: 0.95rem 0.5rem 0.95rem 0.82rem; border-radius: 14px; background: rgba(6, 9, 18, 0.9);
}
.code-input::placeholder { color: rgba(138, 150, 173, 0.35); }
.login-card .btn-primary { padding: 0.85rem; font-size: 1rem; border-radius: 14px; }
.login-card .flash { text-align: left; }
.lock-line { margin-top: 1.4rem; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
