:root {
  --bg-deep: #0f0e0c;
  --bg: #161412;
  --bg-elevated: #1e1b17;
  --bg-surface: rgba(30, 27, 23, 0.9);
  --border: rgba(201, 168, 76, 0.1);
  --border-strong: rgba(201, 168, 76, 0.22);
  --text: #e6ddd0;
  --muted-color: #8a7e6d;
  --text-dim: #5f5649;
  --gold: #c9a84c;
  --gold-soft: rgba(201, 168, 76, 0.12);
  --emerald: #6b9f82;
  --copper: #b87333;
  --danger: #c2524a;
  --danger-soft: rgba(194, 82, 74, 0.12);
  --accent: #c9a84c;
  --accent-2: #b87333;
  --accent-3: #6b9f82;
  --font-display: "Crimson Pro", "Georgia", serif;
  --font-body: "Outfit", "Helvetica Neue", sans-serif;
  --font-sans: "Outfit", "Helvetica Neue", sans-serif;
  --font-serif: "Crimson Pro", "Georgia", serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(201, 168, 76, 0.08);
  --chart-line: #c9a84c;
  --chart-fill: rgba(201, 168, 76, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(201, 168, 76, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, rgba(107, 159, 130, 0.05) 0%, transparent 40%);
  min-height: 100vh;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 10000;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
}

::selection {
  background: rgba(201, 168, 76, 0.25);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid rgba(201, 168, 76, 0.5);
  outline-offset: 2px;
}

input::placeholder {
  color: var(--text-dim);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 168, 76, 0.25);
}

/* Layout */

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 36px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

@media (min-width: 1600px) {
  .app {
    max-width: 1600px;
    padding: 44px 56px 88px;
  }
}

/* Header */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand__mark {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 24px rgba(201, 168, 76, 0.12);
  animation: markSpin 1.2s ease both;
}

.brand__mark::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(201, 168, 76, 0.6);
  transform: rotate(45deg);
}

.brand__mark::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.muted {
  color: var(--muted-color);
  margin: 2px 0 0;
  font-size: 13px;
}

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

/* Chips & Tags */

.chip {
  background: rgba(201, 168, 76, 0.06);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted-color);
  letter-spacing: 0.02em;
}

.tag {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: rgba(184, 115, 51, 0.12);
  border: 1px solid rgba(184, 115, 51, 0.3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--copper);
}

/* Navigation */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 20px;
  color: var(--muted-color);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* Panels */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  animation: panelReveal 0.45s ease both;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.2;
  border-radius: 1px;
}

.panel__header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.panel__header h2 {
  margin: 0 0 2px;
  font-size: 24px;
  font-weight: 500;
}

.panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel__subsection {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.panel__subsection h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
}

/* Price Status */

.price-status {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted-color);
}

.status-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.status-chip.ok {
  border-color: rgba(107, 159, 130, 0.5);
  color: var(--emerald);
}

.status-chip.partial {
  border-color: rgba(184, 115, 51, 0.5);
  color: var(--copper);
}

.status-chip.error {
  border-color: rgba(194, 82, 74, 0.5);
  color: var(--danger);
}

.status-chip.manual {
  border-color: rgba(138, 126, 109, 0.5);
  color: var(--muted-color);
}

/* Metric Cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 110px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  animation: cardReveal 0.5s ease both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 10%, rgba(201, 168, 76, 0.3) 50%, transparent 90%);
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.card.highlight {
  border-color: rgba(201, 168, 76, 0.35);
  background: linear-gradient(160deg, var(--bg-elevated), rgba(201, 168, 76, 0.04));
  box-shadow: var(--shadow-glow);
}

.card.highlight .card__value {
  color: var(--gold);
}

.card__label {
  color: var(--muted-color);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card__value {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* Tables */

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

.grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.grid th,
.grid td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.grid th {
  background: rgba(201, 168, 76, 0.03);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-color);
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 2px solid var(--border-strong);
}

.grid--compact th,
.grid--compact td {
  padding: 10px 14px;
  font-size: 13px;
}

.grid--compact th {
  font-size: 10px;
}

.note-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted-color);
  font-size: 12px;
}

.grid tr:last-child td {
  border-bottom: none;
}

.grid tbody tr {
  transition: background 0.15s ease;
}

.grid tbody tr:hover {
  background: rgba(201, 168, 76, 0.03);
}

.grid .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.grid .num input {
  text-align: right;
}

.grid input,
.grid select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.grid input[readonly] {
  cursor: not-allowed;
  color: var(--muted-color);
  background: rgba(255, 255, 255, 0.015);
}

.grid input:focus,
.grid select:focus {
  outline: none;
  border-color: rgba(201, 168, 76, 0.4);
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
}

.grid th[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.grid th[data-sort]:hover {
  color: var(--gold);
}

.grid th.sort-active {
  color: var(--gold);
}

.sort-arrow {
  font-size: 12px;
  margin-left: 2px;
}

.grid th.actions,
.grid td.actions {
  text-align: right;
  white-space: nowrap;
}

/* Buttons */

button.primary,
button.ghost {
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

button.primary {
  background: var(--gold);
  color: var(--bg-deep);
  font-weight: 600;
}

button.primary:hover {
  background: #d4b35a;
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.25);
  transform: translateY(-1px);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted-color);
}

button.ghost:hover {
  border-color: var(--gold);
  color: var(--gold);
}

button.danger {
  border-color: rgba(194, 82, 74, 0.35);
  color: var(--danger);
  background: transparent;
}

button.danger:hover {
  border-color: rgba(194, 82, 74, 0.6);
  background: var(--danger-soft);
}

/* History / Chart */

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.chart-card {
  background: rgba(201, 168, 76, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.chart-card__header h3 {
  margin: 0;
  font-size: 18px;
}

.chart-card__body {
  width: 100%;
  height: 360px;
}

#history-chart {
  width: 100%;
  height: 100%;
  display: block;
}

/* Shares / Ownership */

.shares-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.share-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: center;
}

.share-form input,
.share-form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.share-form input:focus,
.share-form select:focus {
  outline: none;
  border-color: rgba(201, 168, 76, 0.4);
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 9, 7, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
}

.modal__content {
  position: relative;
  max-width: 420px;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal__content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.3;
}

.modal__content h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Animations */

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes markSpin {
  from {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* Responsive */

@media (max-width: 720px) {
  .app {
    padding: 24px 16px 48px;
  }

  .grid {
    min-width: 600px;
  }

  .panel {
    padding: 20px;
    border-radius: var(--radius-md);
  }

  .topbar {
    gap: 16px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .card__value {
    font-size: 22px;
  }

  .tab {
    padding: 12px 14px;
    font-size: 12px;
  }
}
