:root {
  color-scheme: dark;
  --bg: #111213;
  --panel: #171819;
  --panel-soft: #202124;
  --line: #34363a;
  --text: #f5f4f1;
  --muted: #9f9ea3;
  --good: #007c61;
  --bad: #aa3500;
  --sample: #b59b5a;
  --focus: #b678ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1160px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px clamp(14px, 3vw, 30px) 28px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(100%, 430px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1.05;
}

.login-form,
.add-bar {
  margin-top: 18px;
}

.watchlist-controls {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto minmax(260px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.watchlist-controls label {
  min-width: 0;
}

.watchlist-controls label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mobile-add-toggle {
  display: none;
}

.watchlist-controls select,
.watchlist-controls input {
  height: 36px;
}

.watchlist-controls .add-bar button,
.mobile-add-toggle {
  min-height: 36px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.secondary-button.is-active {
  border-color: var(--focus);
  color: #f2dcff;
}

.new-list-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  grid-column: 1 / -1;
}

.manage-panel {
  position: relative;
  justify-self: end;
  color: var(--muted);
}

.manage-panel[open] {
  justify-self: end;
}

.manage-panel summary {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0 12px;
}

.manage-grid {
  position: absolute;
  z-index: 6;
  right: 0;
  width: min(760px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(5, auto);
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151617;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 92px);
  overflow-y: auto;
}

.settings-import {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-column: 1 / -1;
  gap: 10px;
  align-items: end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.settings-import textarea {
  min-height: 72px;
  resize: vertical;
}

.settings-backup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-column: 1 / -1;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.settings-access {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-column: 1 / -1;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.settings-access > div:first-child span,
.settings-access > div:first-child small,
.access-code-row small {
  display: block;
}

.settings-access > div:first-child span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-access > div:first-child small,
.access-code-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.access-code-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.new-access-code {
  padding: 10px;
  border: 1px solid var(--focus);
  border-radius: 8px;
  background: color-mix(in srgb, var(--focus) 10%, var(--panel));
}

.new-access-code code {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.access-code-list {
  display: grid;
  gap: 7px;
}

.access-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.access-code-row .danger-action {
  color: var(--negative);
}

.settings-backup span,
.settings-backup small {
  display: block;
}

.settings-backup span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-backup small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.manage-grid label {
  min-width: 0;
}

.manage-grid label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.views-panel {
  position: relative;
  justify-self: start;
}

.views-panel summary {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0 12px;
}

.views-panel[open] {
  z-index: 7;
}

.filter-bar {
  position: absolute;
  z-index: 7;
  left: 0;
  width: max-content;
  max-width: min(720px, calc(100vw - 28px));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151617;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.filter-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 12px;
  font-size: 0.9rem;
}

.filter-button.active {
  background: var(--text);
  color: var(--bg);
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.field-row,
.add-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.add-bar {
  grid-template-columns: minmax(180px, 1fr) auto;
  margin-top: 0;
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 13px;
}

select {
  height: 42px;
  padding: 0 13px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  padding: 0 18px;
}

.form-error {
  min-height: 22px;
  margin-top: 10px;
  color: #ff9b7a;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: -16px calc(clamp(14px, 3vw, 30px) * -1) 0;
  padding: 16px clamp(14px, 3vw, 30px) 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  font-size: clamp(2rem, 4.5vw, 3.15rem);
}

.title-select {
  width: 240px;
  max-width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 750;
  line-height: 1.1;
  padding: 0 30px 0 9px;
}

.title-select:focus {
  border-radius: 8px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.topbar-actions .manage-panel summary {
  display: inline-grid;
  width: 42px;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 1.25rem;
  padding: 0;
}

.topbar-actions .manage-panel {
  justify-self: auto;
}

.topbar-actions .manage-panel summary {
  min-height: 42px;
  padding: 0;
  list-style: none;
}

.topbar-actions .manage-panel summary::-webkit-details-marker {
  display: none;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 48px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--panel-soft);
}

.search-result span {
  min-width: 0;
}

.search-result strong,
.search-result small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result strong {
  font-size: 0.98rem;
}

.search-result small,
.search-result em,
.search-message {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
}

.search-result em {
  flex: 0 0 auto;
}

.search-message {
  padding: 8px 10px;
}

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.stock-list {
  margin-top: 4px;
}

.stock-column-headings {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(105px, 0.85fr) minmax(82px, 0.65fr);
  gap: 12px;
  padding: 3px 12px 7px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stock-column-headings span:nth-child(n + 2) {
  text-align: right;
}

.stock-row {
  box-sizing: border-box;
  height: 76px;
  margin-bottom: 7px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  outline: none;
}

.stock-row.is-draggable {
  cursor: grab;
}

.stock-row:has(.reorder-buttons:not([hidden])) {
  height: auto;
}

.stock-row.is-dragging {
  cursor: grabbing;
  opacity: 0.45;
}

.stock-row.is-drop-target {
  border-top: 2px solid var(--focus);
}

.stock-row.has-alert .stock-copy h2::after {
  content: "Alert";
  display: inline-block;
  margin-left: 8px;
  border-radius: 999px;
  background: #7b2f00;
  color: #fff2e8;
  padding: 3px 8px;
  vertical-align: middle;
  font-size: 0.72rem;
}

.stock-row:hover,
.stock-row:focus-visible,
.stock-row.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.stock-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(105px, 0.85fr) minmax(82px, 0.65fr);
  align-items: start;
  gap: 12px;
  height: 100%;
}

.stock-copy {
  min-width: 0;
}

.stock-copy h2 {
  overflow: hidden;
  font-size: clamp(1.05rem, 1.4vw, 1.24rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-copy p {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: clamp(0.76rem, 1vw, 0.86rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-quote,
.stock-overall {
  display: grid;
  grid-template-rows: repeat(3, 16px);
  min-width: 0;
  justify-items: end;
  align-items: center;
  gap: 1px;
  text-align: right;
}

.daily-percent,
.daily-value,
.stock-performance {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.daily-percent.positive,
.daily-value.positive,
.overall-change.positive,
.stock-performance.positive {
  color: #7ed7c0;
}

.daily-percent.negative,
.daily-value.negative,
.overall-change.negative,
.stock-performance.negative {
  color: #ff9b7a;
}

.overall-change {
  font-size: 0.78rem;
  line-height: 1.05;
  white-space: nowrap;
}

.overall-period {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.menu-button {
  width: 28px;
  min-width: 28px;
  min-height: 26px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
}

.menu-button:hover,
.menu-button:focus-visible {
  background: var(--panel-soft);
  color: var(--text);
}

.stock-actions {
  position: relative;
  flex: 0 0 auto;
}

.detail-stock-actions {
  margin-top: -3px;
}

.stock-actions summary {
  display: grid;
  place-items: center;
  list-style: none;
  letter-spacing: 1px;
}

.stock-actions summary::-webkit-details-marker {
  display: none;
}

.stock-actions-menu {
  position: absolute;
  z-index: 8;
  top: 30px;
  right: 0;
  display: grid;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151617;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
}

.stock-actions-menu button {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.stock-actions-menu button:hover,
.stock-actions-menu button:focus-visible {
  background: var(--panel-soft);
}

.stock-actions-menu .danger-action {
  color: #ff9b7a;
}

.reorder-buttons {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

.reorder-buttons button {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 0;
}

.change-pill {
  display: inline-flex;
  align-items: center;
  min-width: 76px;
  min-height: 31px;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: clamp(0.9rem, 1.25vw, 1.05rem);
  font-weight: 800;
  padding: 3px 12px;
}

.metric-tip {
  cursor: help;
}

.change-pill.positive {
  background: var(--good);
}

.change-pill.negative {
  background: var(--bad);
}

.change-pill.compact {
  min-width: 82px;
  min-height: 42px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  padding: 3px 10px;
}

.price {
  min-width: 0;
  text-align: right;
  font-size: clamp(0.9rem, 1.15vw, 1.05rem);
  line-height: 16px;
}

.detail-panel {
  position: sticky;
  top: 102px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151617;
}

.mobile-back-button {
  display: none;
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-heading h2 {
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.1;
}

.detail-title-line {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}

.detail-title-line .eyebrow {
  flex: 0 0 auto;
}

.quote-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  margin-top: 14px;
}

.quote-strip div {
  display: grid;
  min-height: 54px;
  align-items: center;
  min-width: 0;
}

.quote-strip .quote-price {
  align-content: center;
  gap: 4px;
}

.price-time {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.2;
  white-space: nowrap;
}

.quote-strip strong {
  display: block;
  align-self: center;
  overflow-wrap: normal;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.05;
  white-space: nowrap;
}

#detailMove {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.quote-strip .change-pill {
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.range-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.range-tabs button {
  min-width: 0;
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.action-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(700px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151617;
  color: var(--text);
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.action-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.dialog-card {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 18px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-heading h2 {
  font-size: 1.35rem;
}

.confirm-dialog {
  width: min(430px, calc(100vw - 28px));
}

.confirm-message {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-button {
  background: #b83b0a;
  color: #fff;
}

.dialog-card label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dialog-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

#transferAction {
  display: grid;
  gap: 12px;
}

.listing-results {
  display: grid;
  gap: 6px;
  max-height: 390px;
  margin-top: 10px;
  overflow-y: auto;
  color: var(--muted);
}

.listing-result {
  display: grid;
  gap: 3px;
  min-height: 52px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.listing-result span {
  color: var(--muted);
  font-size: 0.82rem;
}

.range-tabs button.active {
  background: var(--text);
  color: var(--bg);
}

.chart-frame {
  position: relative;
  width: 100%;
  margin-top: 14px;
  border-radius: 8px;
  background: #101112;
  overflow: hidden;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202124;
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 800;
  pointer-events: none;
  white-space: nowrap;
}

.chart-frame canvas {
  display: block;
  width: 100%;
  height: 220px;
}

.chart-reference-legend {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 0 10px 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.chart-reference-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chart-reference-legend span::before {
  width: 18px;
  border-top: 1px dashed #6f7076;
  content: "";
}

.chart-reference-legend span:last-child::before {
  border-color: #a8a8ae;
  border-top-style: dashed;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.source-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.source-card span,
.source-card small {
  display: block;
  color: var(--muted);
}

.source-card strong {
  display: block;
  margin-top: 4px;
}

.source-card small {
  margin-top: 5px;
  font-size: 0.75rem;
  line-height: 1.35;
}

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

.stock-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.stock-details div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.detail-stats span,
.stock-details span,
.detail-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-stats strong,
.stock-details strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.detail-stats small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.stock-details strong {
  font-size: 0.92rem;
}

.tracking-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.tracking-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tracking-panel summary {
  min-height: 42px;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
  padding: 11px 13px;
}

.tracking-panel .tracking-form {
  margin-top: 0;
  padding: 0 12px 12px;
}

.tracking-form label {
  min-width: 0;
}

.tracking-form label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.tracking-form .wide,
.tracking-form button {
  grid-column: 1 / -1;
}

.tracking-form button {
  width: 100%;
}

.detail-note {
  margin-top: 12px;
  line-height: 1.4;
}

.empty-state {
  padding: 24px 0;
  color: var(--muted);
  font-weight: 700;
}

.is-loading {
  opacity: 0.62;
}

.detail-panel.is-loading {
  opacity: 1;
}

@media (max-width: 860px) {
  .market-layout {
    display: block;
  }

  .stock-list,
  .detail-panel {
    width: 100%;
  }

  .detail-panel {
    display: none;
    position: static;
    margin-top: 14px;
  }

  .market-layout.mobile-detail-open .stock-list {
    display: none;
  }

  .market-layout.mobile-detail-open .detail-panel {
    display: block;
  }

  .watch-view.mobile-detail-open .watchlist-controls,
  .watch-view.mobile-detail-open .status-row {
    display: none;
  }

  .mobile-back-button {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    padding: 0 11px;
    text-align: center;
  }

  .mobile-back-button span {
    position: absolute;
    left: 11px;
    font-size: 1.05rem;
  }

  .mobile-back-button strong {
    font-size: 0.82rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 14px 22px;
  }

  .topbar {
    gap: 8px;
    margin: -14px -14px 0;
    padding: 16px 14px 12px;
  }

  .topbar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-actions {
    flex: 0 0 auto;
  }

  .add-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .watchlist-controls {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
  }

  .mobile-add-toggle {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    white-space: nowrap;
  }

  .watchlist-controls .add-bar {
    display: none;
    grid-column: 1 / -1;
  }

  .watchlist-controls .add-bar.is-mobile-open {
    display: grid;
  }

  .views-panel,
  .views-panel[open] summary {
    justify-self: stretch;
  }

  .views-panel summary {
    width: auto;
    justify-content: center;
  }

  .manage-grid {
    position: fixed;
    top: 76px;
    right: 14px;
    left: 14px;
    width: auto;
    grid-template-columns: 1fr 1fr;
  }

  .settings-import {
    grid-template-columns: 1fr;
  }

  .settings-backup {
    grid-template-columns: 1fr;
  }

  .access-code-form,
  .access-code-row {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    position: absolute;
    width: auto;
    min-width: 100%;
    max-width: none;
  }

  .new-list-form {
    grid-column: 1 / -1;
  }

  .reorder-buttons {
    display: flex;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .status-row {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
  }

  #lastUpdated {
    text-align: right;
  }

  .stock-row {
    padding: 10px;
  }

  .stock-main {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 0.8fr) minmax(70px, 0.6fr);
    gap: 7px;
  }

  .stock-column-headings {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 0.8fr) minmax(70px, 0.6fr);
    gap: 7px;
    font-size: 0.58rem;
    padding-right: 10px;
    padding-left: 10px;
  }

  .price {
    font-size: 0.92rem;
  }

  .change-pill {
    min-width: 96px;
  }

  .detail-panel {
    padding: 14px;
  }

  .detail-stats {
    grid-template-columns: 1fr;
  }

  .quote-strip {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    align-items: center;
  }

  .quote-strip div {
    min-height: 0;
  }

  .quote-strip .quote-price {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .quote-strip .quote-move {
    grid-column: 2;
    grid-row: 1;
    justify-items: end;
    align-self: end;
  }

  .quote-strip .quote-change {
    grid-column: 2;
    grid-row: 2;
    justify-items: end;
    align-self: start;
  }

  #detailMove {
    font-size: 1.05rem;
    text-align: right;
  }

  .quote-strip .change-pill.compact {
    width: auto;
    min-width: 78px;
    min-height: 30px;
    justify-self: end;
    font-size: 0.98rem;
    padding: 4px 9px;
  }

  .stock-details {
    grid-template-columns: 1fr;
  }
}
