/* ---- Banners ---- */
.banner {
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid;
}

.banner.error {
  background: var(--red-soft);
  border-color: #fca5a5;
  color: var(--red);
}

.banner.success {
  background: var(--green-soft);
  border-color: #86efac;
  color: var(--green);
}

/* ---- Portfolio Summary ---- */
.card:has(.portfolio-top) {
  display: block;
  padding: 16px 22px;
}

.portfolio-top {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.5rem;
  align-items: start;
}

.portfolio-left {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.summary-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  opacity: 0.7;
}

.summary-boxes {
  display: grid;
  gap: 0.5rem;
}

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

.portfolio-right {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 250px;
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
}

.chart-container-small {
  height: 90px;
  margin-top: 12px;
}

.chart-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 5;
  border-radius: var(--radius);
}

.chart-loader.hidden {
  display: none;
}

.chart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.chart-drag-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(var(--accent-rgb), 0.1);
  border-left: 1px solid rgba(var(--accent-rgb), 0.4);
  border-right: 1px solid rgba(var(--accent-rgb), 0.4);
  pointer-events: none;
}

.chart-drag-label {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 10;
}

.summary-item {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 1rem 0.7rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  min-width: 0;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.summary-item:hover {
  box-shadow: 0 8px 20px -8px rgba(0, 31, 41, 0.2);
}

.summary-item--capital {
  background: linear-gradient(135deg, var(--surface) 0%, #edf3fb 100%);
  border-left-color: #315f93;
}

.summary-item--performance {
  background: linear-gradient(135deg, var(--surface) 0%, var(--green-soft) 100%);
  border-left-color: var(--green);
}

.summary-item--total {
  background: linear-gradient(0deg, var(--accent-soft) 0%, var(--surface) 72%);
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 4px 16px -8px var(--accent-glow);
}

[data-theme="dark"] .summary-item--capital {
  background: linear-gradient(135deg, var(--surface) 0%, #1d334b 100%);
  border-left-color: #66a4e0;
}

.summary-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.summary-item--capital .summary-label,
.summary-item--capital .summary-value {
  color: #183f6b;
}

.summary-item--total .summary-label,
.summary-item--total .summary-value,
.summary-item--total .summary-value.positive {
  color: var(--accent-hover);
}

[data-theme="dark"] .summary-item--capital .summary-label,
[data-theme="dark"] .summary-item--capital .summary-value {
  color: #b8dbff;
}

[data-theme="dark"] .summary-item--total .summary-label,
[data-theme="dark"] .summary-item--total .summary-value {
  color: var(--accent);
}

.summary-value {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-value--with-return {
  display: inline-flex;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.3em;
  white-space: normal;
}

.summary-amount,
.summary-return {
  white-space: nowrap;
}

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

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

.metric-warning {
  display: inline-block;
  margin-left: 4px;
  color: #d97706;
  font-size: 1.1rem;
  cursor: help;
  vertical-align: 0.32em;
  position: relative;
  animation: pulse-warning 1.5s ease-in-out 3;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}



.period-selector {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
  margin-top: 0.4rem;
}

.period-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.period-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- Info Icon Tooltip ---- */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  transition: background 0.2s, color 0.2s;
  text-transform: none;
  letter-spacing: 0;
}

.info-icon:hover {
  background: var(--accent);
  color: #fff;
}


/* ---- Table Enhancements ---- */
.data-table td.loading,
.data-table td.empty {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 2rem;
}

/* ---- Type Badges ---- */
span.buy {
  background: var(--green-soft);
  color: var(--green);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

span.sell {
  background: var(--red-soft);
  color: var(--red);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---- Page Header ---- */
.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-header > div:first-child {
  flex: 1;
}

.page-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.page-header .subtitle {
  font-size: 0.875rem;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  white-space: nowrap;
}

/* ---- Card (generic) ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

/* ---- Source Toggle ---- */
.source-toggle {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.source-toggle.active {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--accent-gradient) border-box;
  color: var(--text);
  border: 2px solid transparent;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.15);
}

.source-toggle:hover:not(.active) {
  color: var(--text);
  border-color: var(--muted);
}

#local-path.struck {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ---- Extracted inline color classes ---- */

/* Method note box (most-dropped page) — color properties only */
.method-note {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--muted);
}

.method-note .text-primary {
  color: var(--text);
}

.method-note .text-accent {
  color: var(--accent);
}

/* Trades page: small muted uppercase labels */
.label-muted {
  color: var(--muted);
}

/* Accent-colored monospace link */
.link-accent-mono {
  color: var(--accent);
}

/* Input styled with surface2 background (google-url, search filter) */
.input-surface {
  border-color: var(--border);
  background: var(--surface2);
  color: var(--text);
}

/* Section heading in muted color */
.section-heading-muted {
  color: var(--muted);
  font-weight: 500;
}

/* Small count indicator */
.count-muted {
  color: var(--muted);
}

/* Sync modal target text */
.sync-target-text {
  color: var(--muted);
}

/* Warning/destructive action alert box */
.warning-box {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

/* Sync row list empty state */
.row-list-empty {
  color: var(--muted);
}

/* Sync row list item bottom border */
.row-list-item {
  border-bottom: 1px solid var(--border);
}

/* Stat box container (sync preview) */
.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
}

/* Stat box label */
.stat-box-label {
  color: var(--muted);
}

/* Stat box value — default color */
.stat-box-value {
  color: var(--text);
}

.stat-box-value.color-green {
  color: var(--green);
}

.stat-box-value.color-red {
  color: var(--red);
}

.stat-box-value.color-muted {
  color: var(--muted);
}

/* Sync diff section headers */
.diff-header-added {
  color: var(--green);
}

.diff-header-removed {
  color: var(--red);
}

/* URL status message states */
#url-status-msg.status-ok {
  background: rgba(63, 185, 80, 0.08);
  border-color: rgba(63, 185, 80, 0.35);
  color: var(--green);
}

#url-status-msg.status-ok #url-status-icon {
  color: var(--green);
}

#url-status-msg.status-error {
  background: rgba(248, 81, 73, 0.08);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red);
}

#url-status-msg.status-error #url-status-icon {
  color: var(--red);
}

#url-status-msg.status-loading {
  background: rgba(210, 153, 34, 0.08);
  border-color: rgba(210, 153, 34, 0.35);
  color: var(--gold);
}

#url-status-msg.status-loading #url-status-icon {
  color: var(--gold);
  animation: spin 1s linear infinite;
}

/* Google URL input border states */
#google-url.border-ok {
  border-color: var(--green);
}

#google-url.border-error {
  border-color: var(--red);
}

#google-url.border-loading {
  border-color: var(--gold);
}

