:root {
  /* espresso brown + gold */
  --bg: #140e08;
  --bg-2: #1c140b;
  --card: #261b0f;
  --card-2: #2f2213;
  --line: #45331d;
  --text: #f4ecdc;
  --muted: #b9a684;
  --green: #34d399;
  --green-dim: #1f9d73;
  --gold: #d4af37;
  --gold-soft: #e7c866;
  --danger: #e0a458;
  --radius: 16px;
  --glow-green: 0 0 24px rgba(52, 211, 153, .18);
  --glow-gold: 0 0 24px rgba(212, 175, 55, .16);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(212, 175, 55, .14), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(176, 116, 48, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: .04em; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px var(--green); }
.brand small { color: var(--gold-soft); font-weight: 600; }

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35), var(--glow-gold);
}
.card.gold { box-shadow: 0 10px 30px rgba(0, 0, 0, .35), var(--glow-gold); border-color: rgba(212, 175, 55, .35); }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1rem; color: var(--muted); }

label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 .35rem; letter-spacing: .03em; }
input {
  width: 100%;
  padding: .85rem 1rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.field { margin-bottom: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  padding: .9rem 1.2rem;
  font: inherit; font-weight: 700;
  color: #05231a;
  background: linear-gradient(135deg, var(--green), #6ee7b7);
  border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: var(--glow-green);
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { width: auto; color: var(--text); background: transparent; border: 1px solid var(--line); box-shadow: none; padding: .55rem 1rem; }
.btn.gold { color: #2a2005; background: linear-gradient(135deg, var(--gold), var(--gold-soft)); box-shadow: var(--glow-gold); }

.alert { padding: .75rem 1rem; border-radius: 12px; font-size: .92rem; margin-bottom: 1rem; display: none; }
.alert.show { display: block; }
.alert.error { color: #f6d9a8; background: rgba(224, 164, 88, .12); border: 1px solid rgba(224, 164, 88, .4); }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat { font-size: 2.2rem; font-weight: 700; font-family: var(--mono); letter-spacing: -.02em; }
.stat.up { color: var(--green); }
.stat.down { color: var(--gold); }
.label { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } h1 { font-size: 1.9rem; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0 1.5rem; }

.login-card { width: 100%; max-width: 420px; }
.login-card .brand { margin-bottom: 1.25rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 1rem; text-align: center; }

/* ---------- shared components ---------- */
a { color: var(--gold-soft); }
.muted { color: var(--muted); }
.up { color: var(--green); }
.down { color: var(--gold); }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.hidden { display: none !important; }
.small { font-size: .85rem; }
.btn.sm { padding: .45rem .8rem; font-size: .85rem; }
.btn.auto { width: auto; }
.btn.danger { color: #2a1a05; background: linear-gradient(135deg, var(--danger), #f0c27f); box-shadow: none; }
select, textarea {
  width: 100%; padding: .8rem 1rem; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
textarea { min-height: 90px; resize: vertical; }
input[type="date"], input[type="datetime-local"] { color-scheme: dark; }
.alert.ok { color: #bff3df; background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35); }
.alert.info { color: #f1e2ae; background: rgba(212, 175, 55, .1); border: 1px solid rgba(212, 175, 55, .35); display: block; }
.badge { display: inline-block; min-width: 1.4rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #2a2005; background: var(--gold); text-align: center; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; border: 1px solid var(--line); color: var(--muted); }
.chip.stock { color: #e9b98a; border-color: rgba(233, 185, 138, .4); }
.chip.crypto { color: var(--gold-soft); border-color: rgba(212, 175, 55, .4); }
.chip.off { color: var(--danger); border-color: rgba(224, 164, 88, .5); }

.grid.cols-2 { }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: repeat(2, 1fr); } .grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .grid.split { grid-template-columns: 2fr 1fr; } }

.hero { text-align: center; padding: 1.75rem 1rem; }
.hero .stat { font-size: clamp(2.4rem, 9vw, 3.6rem); }
.hero .pl { font-family: var(--mono); font-size: 1.25rem; margin-top: .25rem; }
.mini .stat { font-size: 1.35rem; }

.banner { padding: .85rem 1.1rem; border-radius: 14px; background: linear-gradient(90deg, rgba(212, 175, 55, .16), rgba(52, 211, 153, .1)); border: 1px solid rgba(212, 175, 55, .35); }

.holding { display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.holding:first-child { border-top: 0; }
.holding .nm { font-weight: 600; }
.holding .val { text-align: right; font-family: var(--mono); font-weight: 700; }
.holding .sub { color: var(--muted); font-size: .82rem; }
.holding .sub.r { text-align: right; font-family: var(--mono); }

.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl li { position: relative; padding: 0 0 1.1rem 1.5rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.tl li::before { content: ""; position: absolute; left: -7px; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, .5); }
.tl li.t-buy::before, .tl li.t-fee::before { border-color: var(--gold); box-shadow: 0 0 10px rgba(212, 175, 55, .5); }
.tl li.t-withdrawal::before { border-color: var(--danger); box-shadow: 0 0 10px rgba(224, 164, 88, .5); }
.tl .head { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; }
.tl .when { color: var(--muted); font-size: .82rem; }
.tl .amt { font-family: var(--mono); white-space: nowrap; }
.tl .note { color: var(--muted); font-size: .85rem; margin-top: .15rem; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.legend { display: flex; gap: 1.2rem; font-size: .8rem; color: var(--muted); margin-top: .5rem; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-right: .4rem; vertical-align: middle; }

.msgs { display: flex; flex-direction: column; gap: .6rem; max-height: 340px; overflow-y: auto; margin-bottom: 1rem; }
.msg { max-width: 85%; padding: .6rem .85rem; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .35); }
.msg .meta { font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }

footer.disc { color: var(--muted); font-size: .78rem; text-align: center; padding: 2rem 0 1rem; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
td.r, th.r { text-align: right; }
tr.deleted td { opacity: .45; text-decoration: line-through; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(255, 255, 255, .025); }

.nav { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.nav a { text-decoration: none; padding: .5rem .9rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.nav a.active { color: var(--green); border-color: var(--green-dim); background: rgba(52, 211, 153, .08); }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(12, 8, 4, .78); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; margin: 2vh auto; }
.results { border: 1px solid var(--line); border-radius: 12px; margin-top: .4rem; overflow: hidden; background: var(--bg-2); }
.results button { display: flex; width: 100%; justify-content: space-between; gap: .5rem; align-items: center; text-align: left; padding: .6rem .8rem; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; }
.results button:last-child { border-bottom: 0; }
.results button:hover, .results button:focus { background: rgba(52, 211, 153, .08); outline: none; }
.secret { font-family: var(--mono); font-size: 1.9rem; letter-spacing: .25em; text-align: center; padding: 1rem; border-radius: 12px; border: 1px dashed var(--gold); color: var(--gold-soft); background: rgba(212, 175, 55, .06); user-select: all; }
.linkbox { font-family: var(--mono); font-size: .8rem; word-break: break-all; padding: .7rem; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); user-select: all; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 80; padding: .7rem 1.1rem; border-radius: 12px; background: var(--card-2); border: 1px solid var(--green-dim); box-shadow: var(--glow-green); }
.spin { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -.15em; }
@keyframes sp { to { transform: rotate(360deg); } }

@media print { body { background: #fff; color: #000; } .no-print { display: none !important; } .card { box-shadow: none; border: 1px solid #ccc; background: #fff; } }

/* ---------- mobile polish ---------- */
input[type="checkbox"] { width: auto; accent-color: var(--green); }
label.inline { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.topbar { flex-wrap: wrap; }
.grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
.mini { padding: 1rem; }
.mini .stat { font-size: 1.15rem; word-break: break-word; }
@media (min-width: 640px) { .grid.cols-4 { grid-template-columns: repeat(4, 1fr); } .mini .stat { font-size: 1.35rem; } }

/* ---------- chart ranges + portfolio mix ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { padding: .35rem .8rem; font: inherit; font-size: .82rem; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { color: #05231a; background: var(--green); font-weight: 700; }
.mixbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--bg-2); margin: .5rem 0 .75rem; }
.mixbar span { display: block; height: 100%; }
.mixlegend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--muted); }
.mixlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
