:root {
  color-scheme: dark;
  --bg: #202124;
  --panel: #303134;
  --ink: #e8eaed;
  --muted: #9aa0a6;
  --line: #5f6368;
  --soft-line: #3c4043;
  --teal: #81c995;
  --blue: #8ab4f8;
  --amber: #fdd663;
  --red: #f28b82;
  --green: #81c995;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(129, 201, 149, 0.06), transparent 34%),
    linear-gradient(315deg, rgba(138, 180, 248, 0.06), transparent 30%),
    var(--bg);
}

.login-panel {
  width: min(100%, 390px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 6px;
  width: 54px;
  height: 42px;
  margin-bottom: 20px;
}

.brand-mark span {
  display: block;
  border-radius: 5px 5px 0 0;
  background: var(--teal);
}

.brand-mark span:nth-child(1) {
  height: 50%;
  background: var(--blue);
}

.brand-mark span:nth-child(2) {
  height: 78%;
}

.brand-mark span:nth-child(3) {
  height: 36%;
  background: var(--amber);
}

h1,
h2,
p {
  margin: 0;
}

.login-panel h1 {
  font-size: 32px;
  line-height: 1.1;
}

.login-copy {
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 24px;
}

.login-panel label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-panel input,
.form-grid input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #292a2d;
  outline: none;
}

.login-panel input:focus,
.form-grid input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(138, 180, 248, 0.2);
}

.login-panel label + label,
.login-panel input + label {
  margin-top: 16px;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 22px;
  background: var(--blue);
  color: #202124;
}

.primary-button.small {
  width: auto;
  margin-top: 0;
  min-height: 32px;
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 6px;
}

.primary-button:hover {
  background: #aecbfa;
}

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

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.icon-button:hover,
.ghost-button:hover {
  border-color: var(--line);
  background: #3c4043;
}

.icon-button.small {
  width: 38px;
  height: 38px;
  min-height: 38px;
}

.form-error {
  min-height: 22px;
  margin-top: 12px;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}



.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 16px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: var(--soft-line);
  color: var(--ink);
}

.nav-tab.active {
  background: rgba(138, 180, 248, 0.14);
  color: var(--blue);
}

.notes-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 220px;
  font-size: 13px;
  color: var(--muted);
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(32, 33, 36, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-footer {
  margin-top: 24px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(32, 33, 36, 0.6);
}

.app-footer .actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}



.app-footer .actions .status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
  border: 1px solid var(--soft-line);
}

.status-text {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: rgba(129, 201, 149, 0.08);
  border: 1px solid rgba(129, 201, 149, 0.15);
  border-radius: 8px;
  color: var(--teal);
  font-size: 14px;
  font-weight: 700;
}

.status-strip > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.status-dot.warning {
  background: var(--amber);
}

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

.metric-card,
.allocation-panel,
.holdings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.04);
}

.metric-card {
  min-height: 118px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric-card span {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1.1;
}

.portfolio-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

.panel-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2,
.dialog-heading h2 {
  font-size: 22px;
  line-height: 1.2;
  margin-top: 3px;
}

.donut-wrap {
  position: relative;
  flex: 1 0 auto;
  min-width: 120px;
  max-width: 280px;
  aspect-ratio: 1;
}

.donut {
  flex: 1 1 0;
  min-width: 120px;
  max-width: 280px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  background: var(--soft-line);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.donut svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-flex {
  display: flex;
  align-items: center;
  gap: 24px;
}

.chart-flex .legend-list {
  flex: 0 0 230px;
  min-width: 0;
  margin-top: 0;
}

@media (max-width: 720px) {
  .chart-flex .legend-list {
    flex-basis: 180px;
  }
}

@media (max-width: 600px) {
  .chart-flex {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .chart-flex .legend-list {
    flex: 0 0 auto;
    width: 100%;
  }
  .donut {
    flex: 0 0 180px;
    max-width: none;
  }
}

.donut-center {
  position: absolute;
  inset: 29%;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  z-index: 1;
}

.donut-center span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.donut-center strong {
  font-size: 22px;
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.legend-item .legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.legend-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.legend-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

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

.secondary-value {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  opacity: 0.8;
}

th,
td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-weight: 600;
}

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

.asset-name {
  display: grid;
  gap: 4px;
}

.asset-name strong {
  overflow-wrap: anywhere;
}

.asset-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ticker-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(138, 180, 248, 0.12);
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.value-cell {
  display: grid;
  gap: 3px;
}

.value-cell small {
  color: var(--muted);
  font-size: 12px;
}

.weight-bar {
  display: grid;
  gap: 6px;
  min-width: 104px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #3c4043;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

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

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

.edit-dialog {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

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

.edit-dialog form {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.dialog-actions .primary-button {
  width: auto;
  margin-top: 0;
}

/* ── Chart ─────────────────────────────────────────────────── */

.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  padding: 18px;
  margin-bottom: 18px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.legend-item:last-child {
  border-bottom: none;
}

.chart-scroll {
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 4px;
}

.chart-area {
  display: block;
  min-height: 180px;
}

.chart-area svg {
  /* Let inline styles dictate dimensions for horizontal scrolling */
}

.chart-area svg text {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 36px;
  flex: 1;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  width: 100%;
}

.chart-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.bar-income {
  background: var(--blue);
}

.bar-spent {
  background: var(--amber);
}

.bar-empty {
  background: var(--soft-line);
}

.chart-label {
  font-size: 11px;
  font-weight: 500;
  fill: var(--muted);
  color: var(--muted);
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1040px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portfolio-grid {
    display: flex;
    flex-direction: column;
  }
}

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

  .app-shell {
    padding: 18px 12px 28px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar > div:first-child {
    width: 100%;
    order: 1;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .nav-tabs {
    order: 2;
  }

  .topbar-actions {
    order: 3;
    margin-left: auto;
  }

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

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

  .metric-card {
    min-height: 88px;
    padding: 14px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .chart-panel {
    padding: 14px;
  }

  .chart-bars {
    height: 120px;
  }

  .allocation-panel,
  .holdings-panel {
    padding: 14px;
  }

  .panel-heading {
    flex-wrap: wrap;
    gap: 10px;
  }

  .panel-heading h2 {
    font-size: 18px;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--soft-line);
    border-radius: 8px;
    padding: 12px;
    background: var(--panel);
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid var(--soft-line);
    padding: 10px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

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

  td.actions-cell {
    display: flex;
    justify-content: flex-end;
  }

  td.actions-cell::before {
    content: "";
  }

  .notes-cell {
    max-width: none;
  }

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

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .primary-button,
  .dialog-actions .ghost-button {
    width: 100%;
  }
}

/* ── Sidebar & Charts ───────────────────────────────────────── */



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

.lots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.lots-header h3 {
  font-size: 14px;
  color: var(--fg);
  margin: 0;
}

.lots-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lot-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr auto;
  gap: 8px;
  align-items: end;
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--soft-line);
}

.lot-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.lot-row input {
  background: var(--panel);
  border: 1px solid var(--soft-line);
  color: var(--fg);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  outline: none;
}
.lot-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15);
}

.form-grid select {
  background: var(--bg);
  border: 1px solid var(--soft-line);
  color: var(--fg);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.form-grid select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15);
}

/* ----- Portfolio público (galería) ----- */
.portfolio-screen {
  min-height: 100vh;
  padding: 72px 24px 96px;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.portfolio-header {
  text-align: center;
  display: grid;
  gap: 12px;
  padding: 24px 0 8px;
}

.portfolio-header h1 {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin: 0;
}

.portfolio-subtitle {
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.06em;
  font-style: italic;
  margin: 0;
}

/* Grid base: 2 columnas. Las horizontales ocupan las 2 columnas (1 por fila),
   las verticales/cuadradas ocupan 1 columna (2 por fila). */
.portfolio-grid-photos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  grid-auto-flow: dense;
}

.portfolio-photo {
  margin: 0;
  overflow: hidden;
  border-radius: 4px;
  background: var(--panel);
  cursor: zoom-in;
  position: relative;
  aspect-ratio: var(--ar, 3 / 4);
}

.portfolio-photo.is-landscape {
  grid-column: span 2;
  aspect-ratio: var(--ar, 3 / 2);
}

.portfolio-photo.is-portrait {
  grid-column: span 1;
  aspect-ratio: var(--ar, 3 / 4);
}

.portfolio-photo.is-square {
  grid-column: span 1;
  aspect-ratio: var(--ar, 1 / 1);
}

.portfolio-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease, opacity 0.4s ease;
  opacity: 0.94;
}

.portfolio-photo:hover img {
  transform: scale(1.03);
  opacity: 1;
}

.portfolio-footer {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.portfolio-social {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 18px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.portfolio-social:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.portfolio-social svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 600px) {
  .portfolio-grid-photos {
    gap: 10px;
  }
  .portfolio-screen {
    padding: 40px 14px 64px;
    gap: 36px;
  }
}

/* ----- Lightbox ----- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 18, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
  cursor: zoom-out;
}

.lightbox-image {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  cursor: default;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  padding: 0;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
}

.lightbox-close {
  top: 20px;
  right: 20px;
}

.lightbox-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 600px) {
  .lightbox {
    padding: 16px;
  }
  .lightbox-close,
  .lightbox-nav {
    width: 38px;
    height: 38px;
  }
  .lightbox-close { top: 12px; right: 12px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

