/* OptionCharts Home — dark theme */
:root {
  --bg: #1a1d24;
  --bg-card: #22262e;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --border: #3c4043;
  --accent: #8ab4f8;
  --deduct: #ea4335;
  --positive: #81c995;
  --negative: #f28b82;
}

* {
  box-sizing: border-box;
}

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

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.logo {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

/* Portfolio switch — segmented control (RH, AL, BT, DF, EL, 66) */
.portfolio-switch {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border-radius: 10px;
  padding: 3px;
  background: var(--bg);
}

.portfolio-btn {
  padding: 0.5rem 1rem;
  min-width: 2.75rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.portfolio-btn:hover:not(.is-selected) {
  background: rgba(255, 255, 255, 0.1);
}

.portfolio-btn.is-selected {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.portfolio-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.update-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.btn-update {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-update:hover {
  filter: brightness(1.1);
}

.btn-update:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.update-timer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-width: 6ch;
}

.update-timer.timer-active {
  color: var(--accent);
}

.update-timer.timer-done {
  color: var(--positive);
}

.last-update {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.table-section h2,
.watchlist-section .watchlist-head h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.table-section .sub,
.watchlist-section .section-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-section {
  margin-bottom: 2rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.major-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.major-table th,
.major-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.major-table th {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.major-table th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 0.5rem;
}

.major-table th.sortable:hover {
  color: var(--text);
}

.major-table .sort-icon {
  font-size: 0.65em;
  opacity: 0.8;
  margin-left: 0.15em;
  display: inline-block;
  width: 0.9em;
  text-align: center;
}

.major-table th.num,
.major-table td.num {
  text-align: right;
}

.major-table th.pct-col,
.major-table td.pct-col {
  width: 3em;
  max-width: 3em;
  min-width: 2.5em;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.major-table tbody tr:last-child td {
  border-bottom: none;
}

.major-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.major-table .symbol {
  font-weight: 600;
}

.major-table .change-up { color: var(--positive); }
.major-table .change-down { color: var(--negative); }

/* Watchlist — like attachment */
.watchlist-section {
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 1.25rem;
}

.watchlist-head {
  margin-bottom: 0.75rem;
}

.watchlist-head .count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.watchlist-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.watchlist-actions input {
  flex: 1;
  max-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
}

.watchlist-actions input::placeholder {
  color: var(--text-muted);
}

.btn-add {
  padding: 0.5rem 1rem;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-add:hover {
  background: #4a4e52;
}


.watchlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.watchlist li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.watchlist li:last-child {
  border-bottom: none;
}

.watchlist .symbol-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.watchlist .symbol-info {
  flex: 1;
  min-width: 0;
}

.watchlist .symbol-primary {
  font-weight: 600;
  font-size: 0.9375rem;
}

.watchlist .symbol-secondary {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.watchlist .btn-deduct {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--deduct);
  border: none;
  color: white;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.watchlist .btn-deduct:hover {
  filter: brightness(1.1);
}

.watchlist .btn-deduct::after {
  content: "−";
  font-weight: 300;
}

.watchlist-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1rem 0;
}

/* View toggle (home vs symbol subpage) */
.hidden {
  display: none !important;
}

.symbol-page-header {
  margin-bottom: 1rem;
}

.link-back {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.link-back:hover {
  text-decoration: underline;
}

.symbol-page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.symbol-link {
  color: var(--accent);
  text-decoration: none;
}

.symbol-link:hover {
  text-decoration: underline;
}

.major-table td.symbol.updated-success,
.major-table td.symbol.updated-success .symbol-link {
  color: var(--positive);
}

.major-table td.symbol.updated-fail,
.major-table td.symbol.updated-fail .symbol-link {
  color: var(--negative);
}

.empty-records {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1.5rem;
  text-align: center;
}
