:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17201d;
  --muted: #68736f;
  --line: #dbe3e0;
  --accent: #0f766e;
  --accent-dark: #0a4f49;
  --gain: #0f8a5f;
  --loss: #c2413a;
  --gold: #b38322;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(24, 38, 35, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 92px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

.top-actions,
.row,
.panel-heading.horizontal,
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.tab,
.delete-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.tab {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.tab {
  min-height: 36px;
  padding: 0 12px;
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
  word-break: keep-all;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 22px;
  position: sticky;
  top: 16px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.asset-form,
.settings {
  display: grid;
  gap: 12px;
}

.capture-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.upload-box {
  min-height: 78px;
  place-items: center;
  border: 1px dashed #9db4ae;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  text-align: center;
}

.upload-box span {
  font-size: 14px;
}

.upload-box input {
  display: none;
}

.capture-preview {
  display: none;
  overflow: hidden;
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.capture-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scan-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.settings {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.row {
  align-items: start;
}

.row label {
  flex: 1;
}

.wide {
  width: 100%;
  margin-top: 4px;
}

.holdings-panel {
  min-width: 0;
  padding: 22px;
}

.panel-heading.horizontal {
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.allocation {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(160px, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 202px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.profit-chart {
  min-height: 328px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
}

.chart-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.chart-heading h3 {
  margin: 0;
  font-size: 17px;
}

.chart-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

canvas {
  width: 100%;
  max-width: 420px;
  height: 180px;
}

#profitChart {
  max-width: none;
  height: 260px;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.legend-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 750;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 14px;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.asset-name strong {
  display: block;
  font-size: 15px;
}

.asset-name span {
  display: inline-block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.gain {
  color: var(--gain);
  font-weight: 800;
}

.loss {
  color: var(--loss);
  font-weight: 800;
}

.neutral {
  color: var(--muted);
  font-weight: 800;
}

.delete-button {
  min-width: 42px;
  padding: 0 10px;
  background: #fff5f4;
  border-color: #f5c7c2;
  color: var(--loss);
}

.empty-state {
  display: none;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .topbar,
  .panel-heading.horizontal {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions,
  .filter-tabs {
    flex-wrap: wrap;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .summary-grid,
  .allocation {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
  }

  .top-actions > button,
  .filter-tabs > button {
    flex: 1;
  }
}
