:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #687385;
  --line: #dde3ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --soft: #eef7f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 96px;
  display: block;
  padding: 20px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

p,
small,
td,
li {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.35fr) minmax(320px, 0.95fr);
  gap: 16px;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.input-panel,
.holdings-panel,
.result-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.row {
  align-items: start;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 156px;
  padding: 18px;
  text-align: center;
  border: 1px dashed #9aa8b7;
  border-radius: 8px;
  background: #f8fbfc;
  cursor: pointer;
}

.dropzone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 26px;
  line-height: 1;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.thumb-grid figure {
  position: relative;
  margin: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.thumb-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.thumb-grid figcaption {
  overflow: hidden;
  padding: 6px;
  padding-right: 30px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-delete {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  color: #526071;
  background: rgba(238, 242, 246, 0.94);
  border: 1px solid #d4dce5;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
}

label {
  display: grid;
  gap: 6px;
  color: #3a4656;
  font-size: 13px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
}

select {
  min-height: 40px;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  padding: 0 34px 0 11px;
  color: var(--ink);
  background: #fff;
}

.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;
}

input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.input-suffix {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  background: #fff;
}

.input-suffix:focus-within {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.input-suffix input {
  border: 0;
  outline: 0;
}

.input-suffix b {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  border-left: 1px solid var(--line);
  font-weight: 800;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.ghost {
  color: var(--ink);
  background: #eef2f6;
}

.report-download {
  flex: 0 0 auto;
  color: var(--accent);
  border: 1px solid #b8ded7;
  background: #edf8f6;
}

.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-note {
  margin: -8px 0 14px;
  font-size: 12px;
  line-height: 1.45;
}

.export-status {
  display: none;
  margin: -4px 0 14px;
  padding: 9px 11px;
  color: #0f5132;
  background: #e7f8ee;
  border: 1px solid #b7e2c9;
  border-radius: 6px;
  font-size: 12px;
}

.export-status.show {
  display: block;
}

.api-note {
  margin-top: 10px;
  min-height: 20px;
  font-size: 12px;
}

#searchFundBtn {
  margin-top: 18px;
}

.upload-status {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #0f5132;
  background: #e7f8ee;
  border: 1px solid #b7e2c9;
  font-size: 13px;
  line-height: 1.45;
}

.upload-status.show {
  display: block;
}

.search-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.result-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  text-align: left;
  background: #f2f7f7;
  border: 1px solid #c9e1de;
}

.result-item small {
  grid-column: 1 / -1;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.holding-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.compact-field {
  display: block;
}

.filter-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.analysis-notice {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  color: #7c2d12;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.analysis-notice.show {
  display: block;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-strip div {
  min-height: 58px;
  padding: 10px;
  background: #f6f8fa;
  border-radius: 6px;
}

.summary-strip b {
  display: block;
  font-size: 18px;
}

.summary-strip span {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: #465366;
  background: #f7f9fb;
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-row td {
  height: 160px;
  text-align: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #365057;
  background: #e9eef2;
  font-size: 12px;
  white-space: nowrap;
}

.tag.warn {
  color: var(--warn);
  background: #fff4df;
}

.tag.danger {
  color: var(--danger);
  background: #fee2e2;
}

.tag.ok {
  color: var(--ok);
  background: #e7f8ee;
}

.action-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-bar button {
  min-height: 30px;
  padding: 0 9px;
  color: #243244;
  background: #edf1f5;
  font-size: 12px;
}

.risk-meter {
  margin-bottom: 16px;
}

.issue-meter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: var(--soft);
  border-radius: 8px;
}

.issue-meter div {
  min-height: 64px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #cbe7e2;
  border-radius: 8px;
}

.issue-meter strong {
  display: block;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.issue-meter span,
.issue-meter p {
  color: var(--muted);
  font-size: 12px;
}

.issue-meter p {
  grid-column: 1 / -1;
  margin-top: 0;
}

.result-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.chart {
  display: grid;
  gap: 12px;
}

.pie-wrap {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 16px;
}

.pie {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(#dbe4ec 0deg 360deg);
}

.pie::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.pie-total {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

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

.legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(74px, 96px) 1fr 48px;
  align-items: center;
  gap: 10px;
  min-height: 30px;
}

.chart-label,
.chart-value,
.chart-empty {
  color: var(--muted);
  font-size: 13px;
}

.chart-track {
  height: 10px;
  overflow: hidden;
  background: #edf2f6;
  border-radius: 999px;
}

.chart-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.chart-row:nth-child(2) .chart-fill {
  background: var(--accent-2);
}

.chart-row:nth-child(3) .chart-fill {
  background: #7c3aed;
}

.chart-row:nth-child(4) .chart-fill {
  background: #d97706;
}

.result-block ul {
  margin: 0;
  padding-left: 18px;
}

.result-block li {
  margin: 8px 0;
  line-height: 1.45;
}

.cards {
  display: grid;
  gap: 9px;
}

.mini-card {
  position: relative;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  line-height: 1.5;
}

.mini-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 30px;
  padding: 0 10px;
  color: #0f766e;
  background: #e6f4f1;
  border: 1px solid #b8ded7;
  font-size: 12px;
}

.mini-card.has-action {
  padding-right: 76px;
}

.mini-card.muted {
  color: var(--muted);
}

.compliance {
  padding: 12px;
  border-radius: 8px;
  color: #5a3b05;
  background: #fff7e6;
  font-size: 13px;
  line-height: 1.45;
}

.edit-dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(20, 31, 46, 0.28);
}

.edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.edit-card {
  padding: 20px;
  background: #fff;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 1160px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .topbar,
  .layout {
    padding: 12px;
  }

  h1 {
    font-size: 21px;
  }

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

  .holding-tools {
    grid-template-columns: 1fr;
  }

  .report-actions {
    justify-content: flex-start;
  }

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

  .form-grid.two-col {
    grid-template-columns: 1fr;
  }

  .pie-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .pie-legend {
    width: 100%;
  }
}
