:root {
  --bg: #081019;
  --panel: #151c26;
  --panel-soft: #111923;
  --panel-deep: #0d141d;
  --border: #263444;
  --border-soft: #1d2a38;
  --text: #eef4fb;
  --muted: #9aadc2;
  --soft: #6f8094;
  --red: #c62a31;
  --red-deep: #661b20;
  --green: #45c58d;
  --blue: #4aa3ff;
  --shadow: rgba(0, 0, 0, 0.36);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(circle at 32% 0%, rgba(42, 68, 99, 0.24), transparent 34%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.app-shell { min-height: 100vh; padding: 14px; display: grid; grid-template-rows: auto 1fr auto; gap: 12px; }
.app-header, .panel, .modal-card {
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.012)), var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px var(--shadow);
}
.app-header { min-height: 72px; padding: 10px 18px; display: grid; grid-template-columns: 220px minmax(0,1fr) auto; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .02em; }
.brand p, .app-footer, .modal-text { color: var(--muted); }
.brand-mark { width: 34px; height: 36px; display: flex; align-items: center; gap: 5px; }
.brand-mark span { width: 6px; border: 2px solid var(--red); border-radius: 2px; position: relative; }
.brand-mark span::before { content: ""; position: absolute; left: 50%; top: -8px; bottom: -8px; width: 2px; transform: translateX(-50%); background: var(--text); opacity: .7; }
.brand-mark span:nth-child(1) { height: 15px; } .brand-mark span:nth-child(2) { height: 28px; } .brand-mark span:nth-child(3) { height: 21px; }
.active-ticker { border: 1px solid var(--border-soft); background: rgba(8,12,18,.38); border-radius: 12px; padding: 16px 18px; text-transform: uppercase; font-weight: 750; }
.active-ticker strong { color: var(--red); }
.header-actions { display: flex; justify-content: flex-end; gap: 10px; }

.icon-btn, .settings-btn, .small-btn, .tab, select, input, .danger-btn {
  color: var(--text); border: 1px solid var(--border); background: rgba(9,14,20,.42); border-radius: 10px;
}
.icon-btn { width: 42px; height: 42px; }
.settings-btn, .small-btn, .tab, .danger-btn { min-height: 38px; padding: 0 14px; font-weight: 750; }
.tab.active, #addTickerBtn, .upload-button { background: linear-gradient(180deg, rgba(198,42,49,.78), rgba(102,27,32,.86)); border-color: var(--red); }
.danger-btn { width: 100%; background: rgba(198,42,49,.18); border-color: var(--red); margin-top: 16px; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) 400px; gap: 12px; }
.main-column { min-width: 0; display: grid; grid-template-rows: minmax(520px, 1fr) auto; gap: 12px; }
.right-sidebar { min-width: 0; display: grid; grid-template-rows: auto auto minmax(360px, 1fr); gap: 12px; }
.panel { padding: 16px; min-width: 0; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; }

.chart-panel { display: grid; grid-template-rows: auto 1fr; }
.chart-actions { display: flex; gap: 8px; }
.chart-actions select { min-width: 92px; padding: 0 12px; }
.chart-surface { position: relative; min-height: 470px; border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 50% 50%, rgba(45,65,91,.18), transparent 35%), var(--panel-deep); }
#chartCanvas { width: 100%; height: 100%; display: block; }
.empty-chart { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; pointer-events: none; }
.empty-chart.hidden { display: none; }
.empty-icon { width: 74px; height: 74px; display: grid; place-items: center; border: 2px dashed #718399; border-radius: 22px; color: #8ea0b5; font-size: 2rem; }
.empty-chart h3 { font-size: 1.35rem; }
.empty-chart p { color: var(--muted); }

.quick-list { overflow: hidden; border: 1px solid var(--border-soft); border-radius: 12px; }
.quick-item { width: 100%; display: flex; gap: 12px; align-items: center; color: var(--text); background: rgba(10,16,23,.22); border: 0; border-bottom: 1px solid var(--border-soft); padding: 13px 14px; text-align: left; font-weight: 700; }
.quick-item:last-child { border-bottom: 0; }
.quick-item span { width: 20px; color: var(--muted); }
.quick-item.active span { color: var(--red); }
.quick-item.active { background: rgba(198,42,49,.13); }
.ticker-panel { display: grid; gap: 14px; align-content: start; }
.ticker-panel select, .ticker-panel input { width: 100%; min-height: 44px; padding: 0 12px; }
.add-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
#addTickerBtn { min-height: 44px; border: 1px solid var(--red); color: var(--text); border-radius: 10px; font-weight: 800; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.upload-panel { display: grid; align-content: start; gap: 14px; }
.drop-zone { min-height: 250px; border: 1px dashed #526379; border-radius: 12px; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center; background: rgba(9,14,20,.18); padding: 22px; }
.drop-zone.drag-over { border-color: var(--red); background: rgba(198,42,49,.12); }
.drop-zone input { display: none; }
.upload-icon { color: #8294aa; font-size: 2.2rem; }
.drop-zone em, .drop-zone small, .selected-file span { color: var(--muted); font-style: normal; }
.upload-button { border: 1px solid var(--red); border-radius: 9px; padding: 9px 34px; font-weight: 800; }
.selected-file { border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px; display: grid; gap: 4px; }
.selected-file strong { overflow-wrap: anywhere; }

.folder-map { border: 1px solid var(--border-soft); border-radius: 12px; min-height: 230px; background: rgba(9,14,20,.18); padding: 14px; display: grid; grid-template-rows: auto 1fr; gap: 12px; }
.folder-map-title { width: fit-content; min-width: 170px; border: 1px solid #7f8d9f; background: rgba(9,14,20,.42); padding: 8px 10px; color: var(--text); font-weight: 750; }
.folder-tree { border: 1px solid #7f8d9f; min-height: 170px; padding: 14px; color: #cfe0f2; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: .9rem; line-height: 1.8; overflow: auto; }
.folder-line.root { color: var(--text); font-weight: 800; }
.folder-line.branch { color: #b8cadf; }
.folder-line.file { color: var(--muted); overflow-wrap: anywhere; }

.stats-panel { min-height: 250px; }
.stats-header { align-items: start; }
.tabs { display: flex; gap: 8px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat-card { min-height: 86px; border: 1px solid var(--border-soft); border-radius: 12px; background: rgba(9,14,20,.3); padding: 14px 16px; display: grid; align-content: space-between; gap: 16px; }
.stat-card span { color: #b9c9da; }
.stat-card strong { font-size: 1.15rem; overflow-wrap: anywhere; }

.table-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-bottom: 10px; color: var(--muted); }
.data-table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border-soft); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.data-table th { position: sticky; top: 0; background: #121a24; color: var(--text); font-weight: 800; }
.data-table td { color: #cad7e5; }
.empty-cell { text-align: center !important; color: var(--muted) !important; }

.app-footer { display: flex; gap: 16px; padding: 0 4px; }
.modal { position: fixed; inset: 0; display: none; place-items: center; background: rgba(0,0,0,.56); padding: 16px; }
.modal.open { display: grid; }
.modal-card { width: min(520px, 100%); padding: 18px; }
body.light { --bg: #f4f6f9; --panel: #ffffff; --panel-soft: #f6f8fb; --panel-deep: #f7f9fc; --border: #d4dce6; --border-soft: #e1e7ef; --text: #111a24; --muted: #5f7082; --shadow: rgba(39,57,76,.13); }

@media (max-width: 1180px) { .workspace { grid-template-columns: 1fr; } .right-sidebar { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .app-header { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: 1fr; } .tabs { width: 100%; } .tab { flex: 1; } }

.app-tabs { display: flex; gap: 8px; justify-content: flex-end; }
.app-tab { min-height: 40px; padding: 0 18px; color: var(--text); border: 1px solid var(--border); background: rgba(9,14,20,.42); border-radius: 10px; font-weight: 800; }
.app-tab.active { background: linear-gradient(180deg, rgba(198,42,49,.78), rgba(102,27,32,.86)); border-color: var(--red); }
.app-view { display: none; min-height: 0; }
.app-view.active { display: grid; gap: 12px; }
#graphView.active { grid-template-rows: minmax(520px, 1fr) auto; }
#transactionsView.active { grid-template-rows: 1fr; }
.main-column { min-width: 0; display: block; }
.stats-grid-wide { grid-template-columns: repeat(5, minmax(0,1fr)); }
.transaction-panel { min-height: 100%; display: grid; grid-template-rows: auto auto 1fr; gap: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.summary-card { min-height: 82px; border: 1px solid var(--border-soft); border-radius: 12px; background: rgba(9,14,20,.3); padding: 14px 16px; display: grid; align-content: space-between; gap: 14px; }
.summary-card span { color: #b9c9da; }
.summary-card strong { font-size: 1.08rem; overflow-wrap: anywhere; }
.transaction-table-wrap { max-height: none; min-height: 360px; }
@media (max-width: 1440px) { .stats-grid-wide { grid-template-columns: repeat(3, minmax(0,1fr)); } .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .stats-grid-wide, .summary-grid { grid-template-columns: 1fr; } .app-tabs { justify-content: stretch; } .app-tab { flex: 1; } }
.app-shell { grid-template-rows: auto auto 1fr auto; }
