:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --brand-soft: #ccfbf1;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 1.5rem; height: 58px; position: sticky; top: 0; z-index: 40;
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; color: var(--ink); }
.brand span { color: var(--brand); }
.nav { display: flex; gap: .25rem; margin-left: .5rem; }
.nav a { padding: .45rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .8rem; }

.container { max-width: 1140px; margin: 0 auto; padding: 1.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.breadcrumbs { font-size: .8rem; color: var(--muted); margin-bottom: .75rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { margin: 0 .4rem; }

/* Cards / panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 1.25rem; }
.panel-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-head h2 { margin: 0; font-size: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* Stat tiles */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); min-width: 180px; flex: 1; }
.stat .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; letter-spacing: -.02em; }
.stat .value.sm { font-size: 1.15rem; }

/* Portfolio cards */
.pcard { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); transition: border-color .12s, transform .12s; color: inherit; }
.pcard:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.pcard .name { font-weight: 700; font-size: 1.05rem; }
.pcard .meta { color: var(--muted); font-size: .78rem; margin-top: .1rem; }
.pcard .val { font-size: 1.5rem; font-weight: 700; margin-top: .7rem; letter-spacing: -.02em; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.chip { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.pos { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip.neg { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 600; font-size: .82rem; cursor: pointer; height: 36px; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-sm { height: 30px; padding: .3rem .6rem; font-size: .75rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.tbl th { text-align: left; background: #f8fafc; color: var(--muted); text-transform: uppercase; font-size: .68rem; letter-spacing: .04em; padding: .6rem .8rem; border-bottom: 2px solid var(--line); }
table.tbl td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
table.tbl tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Forms */
label.fld { display: block; margin-bottom: .8rem; }
label.fld > span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; font-family: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.hint { font-size: .72rem; color: var(--muted); }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
.auth-card .tagline { color: var(--muted); font-size: .85rem; margin-bottom: 1.25rem; }
.auth-error { background: var(--red-soft); color: var(--red); padding: .55rem .7rem; border-radius: 8px; font-size: .8rem; margin-bottom: 1rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: .82rem; color: var(--muted); }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; align-items: flex-start; justify-content: center; padding: 4rem 1rem; overflow-y: auto; }
.modal-bg.show { display: flex; }
.modal { background: var(--panel); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: 0 20px 40px rgba(15,23,42,.2); }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1.25rem; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }
.x { background: none; border: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; width: auto; padding: 0; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.5rem; margin-bottom: .5rem; }

.result-metrics { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.metric { background: var(--bg); border-radius: 8px; padding: .7rem 1rem; min-width: 130px; }
.metric .k { font-size: .68rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.metric .v { font-size: 1.2rem; font-weight: 700; margin-top: .1rem; }
.chart-box { position: relative; height: 320px; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
