/* TOXI Finance — public demo styles. Palette: dark slate (#0f172a) + pink (#ec4899) + indigo (#6366f1). */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #0f172a; --bg-1: #131c30; --bg-2: #1e293b; --bg-3: #263347;
  --bg-card: #1a2336; --bg-row: #182135;
  --border: #2a3650; --border-strong: #3a486a;
  --text: #f1f5f9; --text-dim: #94a3b8; --text-muted: #64748b;
  --pink: #ec4899; --pink-soft: rgba(236, 72, 153, 0.14);
  --indigo: #6366f1; --indigo-soft: rgba(99, 102, 241, 0.14);
  --teal: #2dd4bf; --green: #10b981; --amber: #f59e0b; --red: #ef4444;
  --radius: 14px; --radius-sm: 10px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.25); --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.35);
  --tx: 0.22s ease;
}

html { -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg-0); color: var(--text); min-height: 100vh; line-height: 1.55; font-size: 14.5px; }
a { color: var(--pink); text-decoration: none; }
a:hover { color: #f472b6; }

/* ===== Top demo banner ===== */
.demo-banner { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 9px 16px; background: linear-gradient(90deg, rgba(236, 72, 153, 0.18), rgba(99, 102, 241, 0.18)); border-bottom: 1px solid var(--border); font-size: 0.83rem; color: var(--text); text-align: center; }
.demo-banner strong { color: #fff; }
.demo-banner a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.demo-banner__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 8px var(--pink); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.7); } }

/* ===== App shell + sidebar ===== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 38px); }
.sidebar { background: var(--bg-1); border-right: 1px solid var(--border); padding: 22px 14px 90px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 38px; align-self: start; height: calc(100vh - 38px); }
.sidebar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); padding: 4px 8px; }
.sidebar__brand:hover { color: var(--text); }
.sidebar__logo { width: 30px; height: 30px; border-radius: 7px; }
.sidebar__brand .accent { background: linear-gradient(135deg, var(--pink), var(--indigo)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: transparent; border: 1px solid transparent; color: var(--text-dim); border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 500; text-align: left; transition: all var(--tx); }
.nav-link:hover { background: rgba(255, 255, 255, 0.03); color: var(--text); }
.nav-link.is-active { background: linear-gradient(135deg, var(--pink-soft), var(--indigo-soft)); border-color: rgba(236, 72, 153, 0.25); color: var(--text); }
.nav-link.is-active svg { color: var(--pink); }
.sidebar__hint { margin-top: auto; padding: 14px; background: rgba(99, 102, 241, 0.06); border: 1px dashed rgba(99, 102, 241, 0.3); border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--text-dim); line-height: 1.5; }
.hint-eyebrow { display: inline-block; margin-bottom: 6px; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--indigo); }
.sidebar__hint strong { color: var(--text); }

/* ===== Main / views ===== */
.main { padding: 28px 32px 110px; min-width: 0; }
.view { display: none; animation: view-in 0.3s ease; }
.view.is-active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.view__header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.view__header h1 { font-size: clamp(1.5rem, 2.5vw, 1.85rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.view__subtitle { color: var(--text-dim); font-size: 0.92rem; margin-top: 4px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: 0.85rem; border: 1px solid transparent; cursor: pointer; transition: all var(--tx); white-space: nowrap; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-primary { background: linear-gradient(135deg, var(--pink), var(--indigo)); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(236, 72, 153, 0.3); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--bg-3); border-color: var(--text-muted); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }
.btn-ghost-icon { background: transparent; border: none; padding: 6px; border-radius: 6px; color: var(--text-muted); cursor: pointer; transition: all var(--tx); }
.btn-ghost-icon:hover { color: var(--text); background: var(--bg-3); }

/* ===== Cards ===== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 22px; box-shadow: var(--shadow-card); }
.card__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 14px; }
.card__head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.card__hint { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ===== Stat row ===== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0; opacity: 0.07; pointer-events: none; background: var(--stat-color, var(--indigo)); }
.stat__label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat__value { font-size: 1.7rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; margin-top: 6px; color: var(--text); }
.stat__sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.stat--pink { --stat-color: var(--pink); } .stat--indigo { --stat-color: var(--indigo); }
.stat--green { --stat-color: var(--green); } .stat--amber { --stat-color: var(--amber); }

/* ===== Project grid (dashboard) ===== */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.proj-card { padding: 14px 16px; background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--tx); display: flex; flex-direction: column; gap: 10px; }
.proj-card:hover { border-color: var(--pink); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.proj-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.proj-card__name { font-weight: 700; font-size: 0.95rem; }
.proj-card__meta { font-size: 0.78rem; color: var(--text-dim); display: flex; gap: 10px; flex-wrap: wrap; }
.proj-card__bar { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.proj-card__fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--pink), var(--indigo)); transition: width 0.6s ease; }

/* ===== Status pills ===== */
.status-pill { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-collecting { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.pill-ready { background: rgba(45, 212, 191, 0.15); color: var(--teal); }
.pill-settling { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.pill-finished { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.pill-good, .pill-warn { padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.pill-good { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.pill-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* ===== Balance list (dashboard) ===== */
.bal-list { display: flex; flex-direction: column; gap: 8px; }
.bal-row { display: grid; grid-template-columns: 36px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.bal-row__avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 0.88rem; }
.bal-row__name { font-weight: 600; }
.bal-row__amount { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.92rem; }
.bal-row__amount.is-positive { color: var(--green); }
.bal-row__amount.is-negative { color: var(--red); }
.bal-row__currency { font-size: 0.7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; padding: 3px 7px; background: var(--bg-3); border-radius: 4px; }

/* ===== Project table ===== */
.proj-table { display: flex; flex-direction: column; gap: 6px; }
.proj-table__head, .proj-table__row { display: grid; grid-template-columns: 1.7fr 0.6fr 1.1fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; }
.proj-table__head { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding-bottom: 6px; }
.proj-table__row { background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--tx); }
.proj-table__row:hover { border-color: var(--pink); transform: translateX(2px); }
.proj-table__row .name { font-weight: 600; }
.proj-table__row .num { font-family: 'JetBrains Mono', monospace; font-size: 0.86rem; }

/* ===== Project detail ===== */
.link-back { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px 0; font: inherit; font-size: 0.85rem; margin-bottom: 12px; }
.link-back:hover { color: var(--pink); }
.pd-header { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.pd-header h2 { font-size: 1.4rem; font-weight: 800; }
.pd-meta { display: flex; gap: 20px; flex-wrap: wrap; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 18px; }
.pd-meta .num { font-family: 'JetBrains Mono', monospace; color: var(--text); font-weight: 600; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; }
.pd-block { background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.pd-block__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pd-block__head h3 { font-size: 0.95rem; font-weight: 700; }
.pd-table { display: flex; flex-direction: column; gap: 6px; }
.pd-table__row { display: grid; gap: 10px; align-items: center; padding: 8px 10px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 8px; font-size: 0.84rem; }
.pd-table__row.role { grid-template-columns: 1fr auto auto; }
.pd-table__row.expense, .pd-table__row.payment { grid-template-columns: 1fr 90px auto; }
.pd-table__row.debt { grid-template-columns: 1fr auto auto; }
.pd-table__row .num { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.pd-table__row.is-settled { opacity: 0.55; }
.pd-table__row.is-settled .num { text-decoration: line-through; }
.role-tag { font-size: 0.68rem; padding: 2px 7px; border-radius: 4px; font-weight: 600; }
.role-tag.fixed { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.role-tag.absolute { background: rgba(236, 72, 153, 0.15); color: #f9a8d4; }
.role-tag.variable { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.tiny-avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.66rem; font-weight: 700; color: #fff; margin-right: 6px; vertical-align: middle; }

/* ===== Participants table ===== */
.part-table { display: flex; flex-direction: column; gap: 6px; }
.part-table__head, .part-table__row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; }
.part-table__head { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.part-table__row { background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.part-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.part-name__email { display: block; font-size: 0.74rem; color: var(--text-muted); font-weight: 400; }
.part-num { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }
.part-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ===== Debts view ===== */
.netting-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.netting-tab { background: transparent; border: 1px solid var(--border); color: var(--text-dim); padding: 7px 16px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.82rem; transition: all var(--tx); }
.netting-tab:hover { color: var(--text); border-color: var(--border-strong); }
.netting-tab.is-active { background: var(--pink-soft); border-color: var(--pink); color: var(--pink); }
.netting-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; margin-bottom: 22px; }
.netting-card { margin-bottom: 0; }
.balance-list { display: flex; flex-direction: column; gap: 8px; }
.bal-pill { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 9px 12px; background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.86rem; }
.bal-pill__avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.8rem; }
.bal-pill__amount { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.bal-pill__amount.is-positive { color: var(--green); }
.bal-pill__amount.is-negative { color: var(--red); }
.bal-pill__amount.is-zero { color: var(--text-muted); }

/* ===== Debt graph SVG ===== */
.graph-wrap { width: 100%; aspect-ratio: 600 / 460; min-height: 360px; background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.06), transparent 70%); border-radius: var(--radius-sm); }
#debtGraph { width: 100%; height: 100%; display: block; }
.g-node circle { fill: var(--bg-1); stroke: var(--border-strong); stroke-width: 2; transition: stroke var(--tx), fill var(--tx); }
.g-node:hover circle { stroke: var(--pink); }
.g-node text { fill: var(--text); font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif; }
.g-node .g-node-sub { font-size: 10.5px; font-weight: 500; fill: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.g-edge { stroke: var(--pink); stroke-width: 2.5; fill: none; marker-end: url(#g-arrow); transition: opacity var(--tx); opacity: 0.85; }
.g-edge:hover { opacity: 1; stroke-width: 3.2; }
.g-label-bg { fill: var(--bg-2); stroke: var(--border-strong); stroke-width: 1; }
.g-label-text { fill: var(--text); font-size: 11.5px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* ===== Raw debts list ===== */
.debt-list { display: flex; flex-direction: column; gap: 6px; }
.debt-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto auto; gap: 12px; align-items: center; padding: 10px 14px; background: var(--bg-row); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.86rem; }
.debt-row.is-settled { opacity: 0.5; }
.debt-row.is-settled .num { text-decoration: line-through; }
.debt-row .num { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.debt-row .arrow { color: var(--text-muted); }
.debt-row .who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ===== Settings ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--text-dim); }
.field input, .field select { background: var(--bg-1); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; color: var(--text); font: inherit; font-size: 0.88rem; }
.field input:disabled, .field select:disabled { cursor: not-allowed; opacity: 0.7; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.setting-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.setting-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg-row); border: 1px solid var(--border); border-radius: 8px; font-size: 0.86rem; }

/* ===== Toasts ===== */
.toast-host { position: fixed; right: 20px; bottom: 64px; z-index: 9988; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(236, 72, 153, 0.95)); color: #fff; border-radius: var(--radius-sm); font-size: 0.84rem; font-weight: 500; box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 10px; animation: toast-in 0.3s ease, toast-out 0.3s ease 3.4s forwards; max-width: 320px; }
.toast .badge { background: rgba(255, 255, 255, 0.2); padding: 2px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .demo-banner__dot, .view { animation: none; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .pd-grid, .netting-grid, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 14px; gap: 10px; }
  .sidebar__brand { flex-basis: 100%; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; gap: 6px; flex: 1; }
  .sidebar__hint { display: none; }
  .nav-link span { display: none; }
  .nav-link { padding: 8px 10px; }
  .main { padding: 18px 16px 100px; }
  .proj-table__head, .proj-table__row { grid-template-columns: 1.4fr 0.6fr 1fr auto; }
  .proj-table__row .col-budget, .proj-table__head .col-budget,
  .proj-table__row .col-collected, .proj-table__head .col-collected { display: none; }
  .part-table__head, .part-table__row { grid-template-columns: 1fr auto auto; }
  .part-table__row .col-projects, .part-table__head .col-projects,
  .part-table__row .col-debts, .part-table__head .col-debts { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
