*{box-sizing:border-box}body{margin:0;background:#f5f7fb;color:#172033;font:14px Arial,sans-serif}aside{position:fixed;left:0;top:0;bottom:0;width:245px;background:#111827;color:#fff;padding:24px 16px}.brand{font-size:16px;padding:0 8px 28px}.brand:first-letter{background:#fff;color:#111827;border-radius:10px;padding:8px}.brand small{display:block;color:#9ca3af;font-size:10px;margin-top:12px}nav{display:grid;gap:5px}nav button{width:100%;background:transparent;color:#aeb7c8;border:0;text-align:left;padding:12px;border-radius:9px;cursor:pointer;font-size:14px}nav button.active,nav button:hover{background:#1f2937;color:#fff}nav span{float:right}.privacy{position:absolute;bottom:20px;color:#8993a5;font-size:11px;line-height:1.5}main{margin-left:245px;padding:30px;max-width:1450px}header{display:flex;justify-content:space-between;align-items:center;margin-bottom:24px}.actions{display:flex;gap:8px}header small{color:#8b95a7;letter-spacing:2px;font-weight:bold}h1{margin:6px 0;font-size:28px}.primary,.secondary,.filter{padding:10px 14px;border-radius:9px;font-weight:bold;cursor:pointer;border:1px solid #dfe4ec;background:#fff}.primary{background:#111827;color:#fff;border-color:#111827;display:inline-block;position:relative}.primary input{position:absolute;inset:0;opacity:0;cursor:pointer}.hero{background:#111827;color:#fff;border-radius:16px;padding:24px}.hero span{display:block;color:#aeb7c8}.hero strong{display:block;font-size:36px;margin:7px 0}.hero em{color:#8ee0b1;font-style:normal}.cards{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin:12px 0}.cards article,.panel{background:#fff;border:1px solid #e3e8ef;border-radius:14px}.cards article{padding:18px;color:#7d8798}.cards strong{display:block;color:#172033;font-size:20px;margin-top:8px}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.panel{padding:20px}.panel h2{margin-top:0;font-size:16px}.tab{display:none}.tab.active{display:block}.drop{text-align:center;padding:70px 20px}.drop p{color:#7d8798}.drop hr{border:0;border-top:1px solid #eee;margin:25px 0}.toolbar{display:flex;gap:10px;margin-bottom:12px;flex-wrap:wrap}.toolbar input{flex:1;min-width:220px;padding:11px;border:1px solid #dfe4ec;border-radius:9px}.filter{font-size:12px;color:#687386}.filter.active{background:#111827;color:#fff}.table{padding:0;overflow:auto}.table h2{padding:20px 20px 0}table{border-collapse:collapse;width:100%;min-width:760px}th,td{text-align:left;padding:13px 15px;border-bottom:1px solid #edf0f4;font-size:12px}th{color:#8b95a7;font-size:10px;text-transform:uppercase}.ok{color:#18794e}.bad{color:#b45309}.issue{padding:12px;margin:8px 0;background:#fff7ed;border:1px solid #fed7aa;border-radius:9px}.muted{color:#8b95a7;font-size:11px;margin-top:20px}#toast{position:fixed;right:20px;bottom:20px;background:#111827;color:#fff;padding:12px 15px;border-radius:9px;display:none;z-index:10}@media(max-width:850px){aside{width:68px}.brand b,.brand small,.privacy{display:none}main{margin-left:68px;padding:18px}.cards{grid-template-columns:1fr 1fr}.two{grid-template-columns:1fr}}@media(max-width:550px){.cards{grid-template-columns:1fr}header{align-items:flex-start}.hero strong{font-size:30px}}
.import-status{margin-top:12px}.file-card{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:15px;border:1px solid #e3e8ef;border-radius:10px;background:#fafbfc}.file-main{display:flex;gap:12px;align-items:center}.file-icon{font-size:28px}.file-name{font-weight:bold}.file-meta{color:#7d8798;font-size:12px;margin-top:4px}.file-ok{color:#18794e;font-weight:bold;font-size:12px}.file-empty{color:#8b95a7;padding:10px 0}.remove-file{border:1px solid #dfe4ec;background:#fff;border-radius:8px;padding:8px 11px;cursor:pointer}
.recent{margin-top:12px}.recent-row{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid #edf0f4}.recent-row:last-child{border-bottom:0}.recent-type{color:#7d8798;font-size:12px}.export-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.export-actions .primary,.export-actions .secondary{display:inline-block}
.currency{padding:10px 12px;border:1px solid #dfe4ec;border-radius:9px;background:#fff;font-weight:bold;cursor:pointer}
.export-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}

/* CryptoLedger MVP v8 — multi CSV library */
.csv-library { margin-top: 14px; display: grid; gap: 8px; }
.csv-file-card { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border:1px solid #ddd; border-radius:10px; cursor:pointer; }
.csv-file-card.active { border-color:#666; box-shadow:0 0 0 1px #666 inset; }
.csv-file-card .csv-meta { min-width:0; flex:1; }
.csv-file-card .csv-name { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.csv-file-card .csv-sub { font-size:12px; opacity:.7; margin-top:3px; }
.csv-file-card button { flex:0 0 auto; }
.csv-status { margin-top:8px; font-size:13px; opacity:.8; }

/* v8 CSV list — the original upload control remains unchanged */
.csv-library { margin-top: 10px; display: grid; gap: 6px; }
.csv-file-card { display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid #ddd; border-radius:8px; cursor:pointer; }
.csv-file-card.active { box-shadow:0 0 0 1px #888 inset; }
.csv-meta { min-width:0; flex:1; }
.csv-name { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.csv-sub { font-size:12px; opacity:.65; margin-top:2px; }
.csv-remove { flex:0 0 auto; }

/* v8.2 multi CSV integration */

/* v8.3 — clear separation of active CSV and file list */
.csv-library-section{
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid rgba(128,128,128,.28);
}
.csv-library-title{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.06em;
  opacity:.6;
  margin-bottom:6px;
}
.csv-current-file{
  display:flex;
  align-items:center;
  min-height:42px;
  padding:9px 12px;
  margin-bottom:14px;
  border:1px solid rgba(80,80,80,.35);
  border-radius:10px;
  font-weight:600;
  background:rgba(128,128,128,.07);
}
.csv-list-divider{
  display:flex;
  align-items:center;
  gap:10px;
  margin:6px 0 9px;
  font-size:12px;
  font-weight:600;
  opacity:.65;
}
.csv-list-divider:after{
  content:"";
  height:1px;
  flex:1;
  background:rgba(128,128,128,.25);
}
.csv-file-card{
  transition:transform .12s ease, box-shadow .12s ease;
}
.csv-file-card.active{
  border-width:2px;
}

/* v9 — portfolio scope controls */
.portfolio-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px}
.portfolio-head h2{margin-bottom:4px}
.portfolio-head .muted{margin:0;opacity:.65;font-size:13px}
.portfolio-switch{display:flex;gap:6px;flex-wrap:wrap}
.portfolio-mode-hint{margin:10px 0 12px;padding:8px 10px;border-radius:8px;background:rgba(128,128,128,.07);font-size:12px;opacity:.75}
.csv-list-divider{margin-top:14px}


/* v9.3 — live FX rate next to currency selector */
.currency-wrap{display:flex;align-items:center;gap:7px}
.fx-rate{min-height:38px;display:flex;align-items:center;gap:7px;padding:0 8px;border:1px solid #dfe4ec;border-radius:9px;background:#fff;white-space:nowrap;font-size:10px;color:#4f5b6d}
.fx-dot{width:7px;height:7px;border-radius:50%;background:#22a06b;box-shadow:0 0 0 3px rgba(34,160,107,.12);flex:0 0 auto}
.fx-rate.loading .fx-dot{background:#9ca3af;box-shadow:0 0 0 3px rgba(156,163,175,.12)}
.fx-rate.error .fx-dot{background:#d97706;box-shadow:0 0 0 3px rgba(217,119,6,.12)}
.fx-rate.error{color:#8a5a14}
.fx-mini-rates{display:flex;align-items:center;gap:10px}
.fx-mini-rates span{display:flex;align-items:center;gap:3px}
.fx-mini-rates b{font-size:10px;color:#6b7280}
.fx-mini-rates strong{font-size:11px;color:#263241}
.fx-mini-rates i{font-style:normal;font-size:9px;color:#22a06b}
.fx-mini-rates i.down{color:#d14b4b}
.fx-time{color:#9aa3b1;font-size:9px}
.fx-refresh{border:0;background:transparent;color:#697586;font-size:16px;line-height:1;padding:2px 3px;cursor:pointer;border-radius:5px}
.fx-refresh:hover{background:#f1f3f6}
@media(max-width:900px){.fx-mini-rates span:nth-child(3){display:none}}
@media(max-width:700px){.currency-wrap{flex-wrap:wrap;justify-content:flex-end}.fx-rate{width:100%;justify-content:center}.actions{flex-wrap:wrap;justify-content:flex-end}}


/* v10 — live cryptocurrency prices */
.crypto-prices-status{display:flex;align-items:center;gap:7px;margin:8px 0 10px;padding:8px 10px;border-radius:8px;background:rgba(34,160,107,.07);font-size:12px;color:#52606f}
.crypto-prices-status .crypto-dot{width:7px;height:7px;border-radius:50%;background:#22a06b;box-shadow:0 0 0 3px rgba(34,160,107,.12);flex:0 0 auto}
.crypto-prices-status.loading .crypto-dot{background:#9ca3af;box-shadow:0 0 0 3px rgba(156,163,175,.12)}
.crypto-prices-status.error{background:rgba(217,119,6,.07);color:#8a5a14}
.crypto-prices-status.error .crypto-dot{background:#d97706;box-shadow:0 0 0 3px rgba(217,119,6,.12)}
.crypto-prices-status button{margin-left:auto;border:0;background:transparent;color:#697586;font-size:16px;line-height:1;padding:2px 5px;cursor:pointer;border-radius:5px}
.crypto-prices-status button:hover{background:rgba(128,128,128,.12)}
.crypto-prices-status.stale{background:rgba(217,119,6,.07);color:#8a5a14}
.crypto-prices-status.stale .crypto-dot{background:#d97706;box-shadow:0 0 0 3px rgba(217,119,6,.12)}

/* v10.2 — portfolio units and accounting clarity */
.portfolio-table-note{margin:8px 0 12px;padding:9px 11px;border-radius:8px;background:rgba(128,128,128,.07);font-size:12px;color:#687386}
.unit-label{font-size:10px;color:#8b95a7;white-space:nowrap}
.unit-value{font-variant-numeric:tabular-nums}
.pnl-positive{color:#18794e}
.pnl-negative{color:#b45309}

/* v10.4 — realized P&L history */
.realized-section{margin-top:22px;padding-top:18px;border-top:1px solid rgba(128,128,128,.16)}
.realized-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:10px}
.realized-head h3{margin:0 0 4px;font-size:16px}
.realized-head .muted{margin:0;opacity:.65;font-size:12px}
.realized-total{font-weight:700;white-space:nowrap}
.realized-table{overflow-x:auto}
.realized-table table{min-width:920px}
.realized-empty{text-align:center;opacity:.65;padding:18px}

/* v11 — visual refresh */
:root{--bg:#f3f5f9;--surface:#fff;--surface2:#f8fafc;--ink:#172033;--muted:#7b8798;--line:#e6eaf0;--nav:#0b1220;--nav2:#151f33;--accent:#6d5dfc;--accent2:#8b7cff;--green:#20a36a;--red:#d34f5d;--shadow:0 10px 30px rgba(15,23,42,.06)}
body{background:var(--bg);color:var(--ink);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;font-size:14px}
aside{width:250px;background:linear-gradient(180deg,#0a1020 0%,#111a2d 100%);padding:25px 14px;box-shadow:8px 0 28px rgba(15,23,42,.06)}
.brand{font-size:17px;padding:0 10px 32px;letter-spacing:.1px}.brand:first-letter{background:linear-gradient(135deg,#fff,#dfe4ff);color:#111827;border-radius:12px;padding:8px 9px}.brand small{color:#7f8ba1;margin-top:13px;letter-spacing:.5px}
nav{gap:6px}nav button{color:#94a0b5;padding:12px 13px;border-radius:10px;font-size:13px;transition:.18s ease}nav button.active,nav button:hover{background:rgba(255,255,255,.09);color:#fff}nav button.active{box-shadow:inset 3px 0 0 var(--accent)}nav span{background:rgba(255,255,255,.1);border-radius:20px;padding:1px 6px;font-size:10px}
.privacy{color:#718096;bottom:22px;padding:0 8px}
main{margin-left:250px;padding:32px 34px 48px;max-width:1540px}header{margin-bottom:26px;align-items:center}header small{font-size:10px;letter-spacing:2.2px;color:#929cad}h1{font-size:30px;letter-spacing:-.7px;margin:5px 0 0}.actions{gap:9px}
.primary,.secondary,.filter,.currency{border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:10px 14px;box-shadow:0 1px 2px rgba(15,23,42,.02);transition:.18s ease}.primary{background:linear-gradient(135deg,#6254e8,#7b6cff);border-color:#6254e8;box-shadow:0 7px 18px rgba(109,93,252,.22)}.primary:hover{transform:translateY(-1px);box-shadow:0 10px 22px rgba(109,93,252,.28)}.secondary:hover,.filter:hover,.currency:hover{border-color:#cdd4df;transform:translateY(-1px)}
.hero{position:relative;overflow:hidden;background:linear-gradient(135deg,#11192c 0%,#202b4a 100%);border-radius:18px;padding:25px 26px;box-shadow:0 14px 35px rgba(15,23,42,.12)}.hero:after{content:"";position:absolute;width:180px;height:180px;border-radius:50%;right:-45px;top:-75px;background:rgba(139,124,255,.18);filter:blur(2px)}.hero span{color:#aeb9cc;font-size:12px}.hero strong{font-size:38px;letter-spacing:-1px;margin:6px 0}.hero em{color:#77e0ae;font-weight:700}
.cards{gap:14px;margin:14px 0}.cards article,.panel{border:1px solid var(--line);border-radius:15px;box-shadow:var(--shadow)}.cards article{padding:18px 19px;background:rgba(255,255,255,.92);font-size:12px}.cards strong{font-size:21px;margin-top:9px;letter-spacing:-.3px}.panel{padding:21px;background:var(--surface)}.panel h2{font-size:16px;letter-spacing:-.2px}.two{gap:14px}
.toolbar{margin-bottom:14px}.toolbar input{border:1px solid var(--line);border-radius:10px;padding:11px 13px;outline:none}.toolbar input:focus{border-color:#a69cff;box-shadow:0 0 0 3px rgba(109,93,252,.1)}.filter{font-size:12px;color:#697586}.filter.active{background:#151d31;border-color:#151d31;color:#fff;box-shadow:0 5px 12px rgba(15,23,42,.12)}
.table{border-radius:13px}.table table{min-width:760px}th{color:#8c96a6;letter-spacing:.7px;font-size:9px;background:#fafbfc}th,td{padding:13px 15px;border-bottom:1px solid #edf0f4}tbody tr:hover{background:#fafbfe}td{font-size:12px}
.import-status{margin-top:14px}.drop{padding:62px 20px;background:linear-gradient(180deg,#fff,#fafbff)}.drop h2{font-size:19px}.drop p{color:#8a95a6}.file-card,.csv-file-card{background:var(--surface2);border-color:var(--line);border-radius:11px}.csv-file-card.active{border-color:#8c81ff;box-shadow:0 0 0 1px #8c81ff inset,0 5px 16px rgba(109,93,252,.08)}
.portfolio-head{margin-bottom:4px}.portfolio-mode-hint,.portfolio-table-note{background:#f7f8fc;border:1px solid #edf0f5;color:#697586;border-radius:10px}.crypto-prices-status{border:1px solid #e7f3ed;background:#f6fbf8;border-radius:10px}.realized-section{border-top-color:#e9edf3}
.export-actions{padding-top:4px}.export-actions .primary,.export-actions .secondary{min-height:40px}.report-filters{display:flex;align-items:end;gap:10px;flex-wrap:wrap;padding:14px;margin-bottom:16px;border:1px solid var(--line);background:#f8fafc;border-radius:12px}.report-field{display:grid;gap:6px}.report-field label{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.6px;color:#8b95a7}.report-field input{height:38px;padding:8px 10px;border:1px solid var(--line);border-radius:9px;background:#fff}.report-reset{height:38px}.report-summary-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin:0 0 15px}.report-metric{padding:14px;border:1px solid var(--line);border-radius:11px;background:#fbfcfe}.report-metric span{display:block;color:#8a95a6;font-size:11px}.report-metric strong{display:block;margin-top:6px;font-size:18px}.report-caption{font-size:12px;color:#7c8798;margin-bottom:13px}.pnl-positive{color:var(--green)}.pnl-negative{color:var(--red)}
@media(max-width:1050px){main{padding:26px 22px}.cards{grid-template-columns:repeat(2,1fr)}.report-summary-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:850px){aside{width:70px;padding:22px 8px}.brand b,.brand small,.privacy{display:none}main{margin-left:70px;padding:20px 16px}.brand:first-letter{padding:7px 8px}.nav{font-size:0;text-align:center!important}.nav span{display:none}.nav:before{content:"•";font-size:20px}.portfolio-head{flex-direction:column}.actions{width:100%}.actions>*{flex:1}.currency-wrap{flex:2}.fx-rate{font-size:9px}}
@media(max-width:600px){header{align-items:flex-start;gap:14px;flex-direction:column}header .actions{width:100%;flex-wrap:wrap}.actions>*{flex:auto}.currency-wrap{width:100%;justify-content:stretch}.currency-wrap .currency{flex:0 0 auto}.fx-rate{flex:1;overflow:hidden}.hero strong{font-size:31px}.cards{grid-template-columns:1fr}.report-summary-grid{grid-template-columns:1fr}.report-filters{align-items:stretch}.report-field{flex:1;min-width:135px}.report-reset{width:100%}}

.report-scope{display:flex;gap:7px;margin-bottom:10px}.report-scope .active{font-weight:700;box-shadow:0 0 0 2px rgba(128,128,128,.2) inset}

.report-total-card{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:0 0 14px;padding:12px 14px;border:1px solid rgba(128,128,128,.22);border-radius:10px;background:rgba(128,128,128,.06)}
.report-total-card span{font-size:12px;opacity:.7}.report-total-card strong{font-size:18px}

.settings-panel{max-width:980px}.settings-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:18px 0}.setting-card{padding:16px;border:1px solid rgba(128,128,128,.18);border-radius:12px;background:rgba(128,128,128,.045)}.setting-card strong,.setting-card span{display:block}.setting-card span{margin-top:7px;font-size:12px;opacity:.68;line-height:1.45}.danger-button{border:1px solid rgba(190,60,60,.45);background:transparent;color:inherit;border-radius:9px;padding:9px 13px;cursor:pointer}@media(max-width:760px){.settings-grid{grid-template-columns:1fr}}

.report-error-row{display:grid;grid-template-columns:100px 90px 1fr minmax(120px,220px);gap:10px;align-items:center;padding:9px 10px;border-bottom:1px solid rgba(128,128,128,.12);font-size:12px}
.report-error-row small{opacity:.62;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media(max-width:760px){.report-error-row{grid-template-columns:1fr 1fr}.report-error-row span:nth-child(3),.report-error-row small{grid-column:1/-1}}

#deleteCurrentCsv{margin:8px 0 12px}
