/* Fin Freedom — look & feel */
:root {
  --brand: #6B0A4A;
  --brand-2: #8E1A66;
  --accent: #2A9D8F;
  --bg: #F7F2F5;
  --bg-grad: linear-gradient(180deg, #FBF6F9 0%, #F1F5F6 100%);
  --card: #FFFFFF;
  --card-2: #FAF5F8;
  --text: #221A20;
  --muted: #6D6069;
  --line: #E8DDE4;
  --good: #1E7F4F;
  --bad: #B3261E;
  --shadow: 0 1px 2px rgba(60, 10, 40, .06), 0 6px 20px rgba(60, 10, 40, .06);
  --radius: 18px;
  --chart-1: #6B0A4A; --chart-2: #2A9D8F; --chart-3: #D08C2E; --chart-4: #4F6BD8;
  --chart-5: #C04A7E; --chart-6: #6A994E; --chart-7: #8C6D5A; --chart-8: #7A5AB8;
  --chart-9: #3D8FB5; --chart-10: #A3A3A3;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161115;
  --bg-grad: linear-gradient(180deg, #1B1319 0%, #121618 100%);
  --card: #221A20;
  --card-2: #2A2028;
  --text: #F3ECF0;
  --muted: #B6A8B1;
  --line: #3A2E37;
  --good: #5BC98C;
  --bad: #F2867D;
  --brand-2: #E27DB9;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  --chart-1: #E27DB9; --chart-2: #4CC2B2; --chart-3: #E8A94F; --chart-4: #8099F0;
  --chart-5: #F08FB8; --chart-6: #93C47D; --chart-7: #C4A28C; --chart-8: #A98BE3;
  --chart-9: #6BB9DB; --chart-10: #8A8A8A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); background-image: var(--bg-grad);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5;
}
h1, h2, .display { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 2.4rem; margin: .2rem 0 .1rem; }
h2 { font-size: 1.5rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--brand-2); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.8rem; font-weight: 600; text-decoration: none; color: var(--text); }
.logo span { background: linear-gradient(90deg, var(--brand-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: .5rem; align-items: center; }
.who { font-size: .9rem; color: var(--muted); margin-right: .25rem; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

/* Layout */
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 7rem; }
.page-head { margin: .5rem 0 1rem; }
.page-head .rule { width: 56px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--brand-2), var(--accent)); margin: .3rem 0 .5rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }

.hero {
  color: #fff; border: none; padding: 1.4rem 1.4rem 1.2rem;
  background: radial-gradient(120% 140% at 100% 0%, #2A9D8F55 0%, transparent 45%), linear-gradient(135deg, #4A0633 0%, #6B0A4A 55%, #8E1A66 100%);
}
.hero .label { letter-spacing: .12em; font-size: .8rem; font-weight: 600; opacity: .9; display: flex; align-items: center; gap: .45rem; }
.hero .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5EEAD4; }
.hero .big { font-family: "Cormorant Garamond", Georgia, serif; font-size: clamp(2.4rem, 8vw, 3.6rem); font-weight: 600; line-height: 1.1; margin: .3rem 0 .6rem; }
.pill { display: inline-flex; gap: .35rem; align-items: center; padding: .25rem .7rem; border-radius: 999px; background: rgba(255,255,255,.15); font-weight: 600; font-size: .92rem; }
.hero .row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.hero .btn { background: rgba(255,255,255,.95); color: #6B0A4A; }
.hero .muted { color: rgba(255,255,255,.8); }

.stat .label { font-size: .78rem; letter-spacing: .1em; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.stat .value { font-size: clamp(1.3rem, 2.3vw, 1.7rem); overflow-wrap: anywhere; font-weight: 700; margin: .2rem 0; }
.bar { height: 10px; background: var(--card-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-2), var(--accent)); border-radius: 99px; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem;
  border-radius: 999px; border: 1px solid transparent; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--card); color: var(--brand-2); border-color: var(--line); }
.btn.danger { background: var(--card); color: var(--bad); border-color: var(--line); }
.btn.small { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.link-btn { background: none; border: none; color: var(--brand-2); font-weight: 600; cursor: pointer; padding: .3rem; }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .8rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  display: block; width: 100%; margin-top: .3rem; min-height: 46px; padding: .55rem .8rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2);
}
input:focus, select:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; }
.check input { width: 22px; height: 22px; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .4rem; }
.error { color: var(--bad); font-weight: 600; min-height: 1.4em; }
.notice { background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: .9rem 1rem; margin-bottom: 1rem; }
.code-box { font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; letter-spacing: .15em; font-weight: 700; padding: .6rem 1rem; background: var(--card-2); border: 1px dashed var(--brand-2); border-radius: 12px; display: inline-block; user-select: all; }

/* Lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; }
.list .rank { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow-wrap: anywhere; }
.list .right { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; background: var(--card-2); border: 1px solid var(--line); }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 14px; font-family: inherit; }
.chart .grid-line { stroke: var(--line); }
.donut-wrap { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: 1rem; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; } .donut-wrap svg { max-width: 220px; margin: 0 auto; } }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; font-size: .92rem; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: .1rem .5rem; align-items: center; }
.legend li > span:nth-child(2) { min-width: 0; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .v { color: var(--muted); font-size: .85rem; text-align: right; }
.hbar { margin: .5rem 0; }
.hbar .top { display: flex; justify-content: space-between; font-size: .92rem; gap: .5rem; }
.caption { font-size: .88rem; color: var(--muted); margin: .6rem 0 0; }
.tooltip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); padding: .35rem .6rem; border-radius: 8px; font-size: .85rem; z-index: 50; }

/* Bottom navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: .2rem;
  padding: .4rem .4rem calc(.4rem + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1 1 0; min-width: 0; max-width: 120px; display: flex; white-space: nowrap; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem .2rem;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; border-radius: 14px;
}
.tabbar a svg { width: 24px; height: 24px; padding: 3px; border-radius: 9px; }
.tabbar a.active { color: var(--brand-2); }
.tabbar a.active svg { background: color-mix(in srgb, var(--brand-2) 16%, transparent); }

/* Dialog */
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(20, 5, 15, .45); }
dialog form { padding: 1.2rem 1.3rem; }

/* Sign-in screen */
.auth { max-width: 460px; margin: 6vh auto; padding: 0 1rem 3rem; }
.auth-brand { text-align: center; margin-bottom: 1.2rem; }
.auth-icon { display: block; margin: 0 auto .5rem; border-radius: 20px; box-shadow: var(--shadow); }
.auth .logo { display: block; text-align: center; font-size: 2.8rem; line-height: 1.1; }
.auth .tagline { text-align: center; color: var(--muted); margin: .2rem 0 0; }
.seg { display: flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 1rem; }
.seg button { flex: 1; min-height: 42px; border: none; background: none; border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--brand-2); box-shadow: var(--shadow); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; z-index: 60; font-weight: 600; max-width: calc(100vw - 32px); }
[data-mt] { margin-top: 1rem; }
.chart .center-val { fill: var(--text); font-size: 22px; }
.chart .center-lbl { font-size: 11px; }
#people-card, #inv-card { margin-top: 1rem; }
@media (max-width: 480px) { .tabbar a { font-size: .66rem; } .tabbar a svg { width: 22px; height: 22px; } .who { display: none; } }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.dl-list { display: grid; gap: .6rem; margin: 1rem 0; }
.dl-opt { display: flex; flex-direction: column; gap: .1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); color: var(--text); text-decoration: none; }
.dl-opt:hover, .dl-opt:focus-visible { border-color: var(--brand-2); }
.dl-opt strong { color: var(--brand-2); }
.auth .actions { align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-icon { flex: none; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand .logo { font-size: 1.7rem; line-height: 1.05; }
.brand-tag { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .brand-tag { display: none; } .brand .logo { font-size: 1.5rem; } }
.tag.live { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-weight: 600; }
.seg-field { border: none; padding: 0; margin: 0 0 .8rem; }
.seg-field legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; padding: 0; }
.seg-field .seg { margin-bottom: 0; }
.seg-field .seg button { font-size: .9rem; padding: 0 .4rem; }
.card-head .actions { margin-top: 0; }
