:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #e7e2d8;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e6f4f1;
  --up: #15803d;
  --up-soft: #e8f6ec;
  --down: #c2410c;
  --down-soft: #fdeee6;
  --gold: #d97706;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(29, 36, 51, .05), 0 8px 24px rgba(29, 36, 51, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(246, 244, 239, .9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 18px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px 16px 110px; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card h3 { margin: 0; font-size: 16px; }
.section-title { font-size: 20px; font-weight: 800; margin: 8px 0 4px; }

/* Hero */
.hero { background: linear-gradient(135deg, #0f766e, #115e59 60%, #134e4a); color: #fff; border: none; }
.hero .label { opacity: .8; font-size: 14px; }
.hero .big { font-size: clamp(34px, 9vw, 48px); font-weight: 900; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.hero .pill { background: rgba(255,255,255,.16); color: #fff; }
.pill.up { background: var(--up-soft); }
.pill.down { background: var(--down-soft); }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.hero-stats div { background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px; }
.hero-stats b { display: block; font-size: 16px; }
.hero-stats span { font-size: 12px; opacity: .8; }

/* Buttons & forms */
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; cursor: pointer; background: var(--brand); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; text-decoration: none; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.sell { background: var(--down-soft); color: var(--down); }
.btn.wa { background: #25d366; color: #fff; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.field + .field { margin-top: 10px; }
.input-money { position: relative; }
.input-money span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.input-money input { padding-left: 26px; font-size: 22px; font-weight: 800; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.error { color: var(--down); font-weight: 700; font-size: 14px; min-height: 1em; }

/* Tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center; gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.tab { flex: 1; max-width: 140px; border: 0; background: none; padding: 6px 4px; border-radius: 12px; font-weight: 700; font-size: 12px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab .ico { font-size: 20px; }
.tab.active { color: var(--brand); background: var(--brand-soft); }

/* Holdings / assets */
.asset { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.asset:first-child { border-top: 0; }
.asset-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; }
.asset-main { flex: 1; min-width: 0; }
.asset-main b { display: block; }
.asset-right { text-align: right; }
.alloc { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 10px 0 6px; }
.alloc div { height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.risk { display: inline-flex; gap: 3px; vertical-align: middle; }
.risk i { width: 8px; height: 14px; border-radius: 2px; background: var(--line); }
.risk i.on { background: var(--down); }
.perf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.perf div { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.perf span { display: block; font-size: 12px; color: var(--muted); }

/* Charts */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 4px 8px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translateX(-50%); }

/* Lists */
.tx { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.tx:first-child { border-top: 0; }
.tx-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); flex: none; }
.tx-main { flex: 1; min-width: 0; }
.news { padding: 10px 12px; border-radius: 12px; background: #fffbea; border: 1px solid #f6e7a8; font-size: 14px; }
.news + .news { margin-top: 8px; }
.tip-card { background: var(--brand-soft); border: 1px solid #c5e6df; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }

/* Modal */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }
.modal h2 { margin: 0 0 12px; }
.whatif { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.whatif div { border-radius: 12px; padding: 10px; font-size: 14px; }

/* Lessons */
details.lesson { border-top: 1px solid var(--line); padding: 12px 0; }
details.lesson:first-of-type { border-top: 0; }
details.lesson summary { cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.lesson summary::after { content: '+'; color: var(--muted); }
details.lesson[open] summary::after { content: '–'; }
details.lesson p { margin: 8px 0 0; color: #374151; }

/* Login */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; font-size: 22px; margin-bottom: 6px; }

/* Admin */
.user-card { cursor: pointer; transition: transform .1s; }
.user-card:hover { transform: translateY(-1px); }
.admin-badge { font-size: 12px; background: var(--ink); color: #fff; border-radius: 6px; padding: 2px 6px; font-weight: 700; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple td, table.simple th { padding: 8px 4px; border-top: 1px solid var(--line); text-align: left; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); }
