:root {
  color-scheme: light;
  font-family: Arial, sans-serif;
  background: #f4f6f8;
  color: #18212f;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

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

.topbar-actions,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #526071;
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 7vw, 40px);
}

h2 {
  font-size: 20px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: #12715b;
  color: white;
  cursor: pointer;
}

.add-button {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: linear-gradient(135deg, #15906f, #10664f);
  box-shadow: 0 10px 22px rgb(18 113 91 / 26%);
  color: white;
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transform: translateY(0);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.add-button:hover {
  background: linear-gradient(135deg, #18a57f, #0d5c49);
  box-shadow: 0 12px 28px rgb(18 113 91 / 34%);
  transform: translateY(-1px);
}

.add-button:active {
  box-shadow: 0 6px 14px rgb(18 113 91 / 24%);
  transform: translateY(0);
}

.floating-add {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
}

.theme-toggle,
.nav-icon-button {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  z-index: 21;
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #dde3ea;
  border-radius: 999px;
  padding: 0;
  background: rgb(255 255 255 / 92%);
  color: #344255;
  box-shadow: 0 8px 18px rgb(24 33 47 / 10%);
}

.theme-toggle {
  right: max(14px, env(safe-area-inset-right));
}

.nav-icon-button {
  left: max(14px, env(safe-area-inset-left));
  text-decoration: none;
}

.theme-toggle:hover,
.nav-icon-button:hover {
  background: white;
}

.theme-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-link {
  border-radius: 8px;
  padding: 11px 14px;
  background: #12715b;
  color: white;
  text-decoration: none;
}

.button-link:hover {
  background: #0d5c49;
}

.secondary-link {
  color: #12715b;
  font-weight: 700;
  text-decoration: none;
}

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

button:hover {
  background: #0d5c49;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  background: #6b7480;
}

.danger-button {
  background: #a83232;
}

.danger-button:hover {
  background: #862525;
}

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

.metric {
  min-width: 0;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.metric-label {
  display: block;
  color: #637083;
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 23px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.hidden {
  display: none;
}

[hidden] {
  display: none !important;
}

.panel {
  background: white;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 16px;
}

.portfolio-panel {
  background: #eef2f6;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-title {
  margin-bottom: 14px;
  text-align: center;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.search-field {
  min-width: 0;
}

.company-list,
.portfolio-list {
  display: grid;
  gap: 10px;
}

.company,
.portfolio-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 12px;
}

.company {
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 6px;
  padding: 12px;
}

.company.saved {
  background: #f0faf6;
  border-color: #2d8a6f;
}

.company-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.company-title-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
}

.company-symbol {
  flex: 0 0 auto;
}

.company-title-separator {
  flex: 0 0 auto;
  color: #637083;
}

.company-meta {
  min-width: 0;
  color: #637083;
  font-size: 12px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-name {
  flex: 1 1 auto;
  min-width: 0;
  color: #344255;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-details {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-footer {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-top: 1px solid #eef1f5;
  padding-top: 3px;
}

.company-add-icon,
.company-market-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #dde3ea;
  border-radius: 999px;
  padding: 0;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 18px rgb(24 33 47 / 10%);
  color: #12715b;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.company-add-icon:hover,
.company-add-icon:focus-visible,
.company-market-icon:hover,
.company-market-icon:focus-visible {
  background: white;
  color: #0d5c49;
}

.list-loader,
.list-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
}

.loader-dot {
  width: 16px;
  height: 16px;
  border: 2px solid #c9d2de;
  border-top-color: #12715b;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.portfolio-item {
  background: #ffffff;
  cursor: pointer;
}

.watch-card-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.watch-title {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.watch-title strong {
  flex: 0 0 auto;
}

.watch-number {
  flex: 0 0 auto;
  color: #637083;
  font-size: 13px;
  font-weight: 700;
}

.watch-name {
  min-width: 0;
  color: #344255;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.fact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #dde3ea;
  border-radius: 999px;
  padding: 5px 9px;
  color: #344255;
  font-size: 13px;
}

.mini-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.watch-alert-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #eef1f5;
  padding-top: 7px;
}

.alert-side {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: calc(50% - 4px);
  gap: 5px;
}

.buyer-alert {
  justify-content: flex-end;
  text-align: right;
}

.alert-icon {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  padding: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.seller-alert .alert-icon {
  color: #b64632;
}

.buyer-alert .alert-icon {
  color: #12715b;
}

.alert-text {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.alert-text span {
  color: #637083;
  font-size: 11px;
}

.alert-text strong {
  color: #18212f;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.alert-text small {
  font-size: 10px;
  font-weight: 700;
}

.symbol {
  font-weight: 700;
}

.muted {
  color: #637083;
  font-size: 14px;
}

.empty-state {
  display: grid;
  gap: 6px;
  border: 1px dashed #c9d2de;
  border-radius: 8px;
  padding: 18px;
  color: #637083;
}

.empty-state strong {
  color: #18212f;
}

dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.market-dialog {
  width: min(720px, calc(100% - 24px));
}

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

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

form {
  display: grid;
  gap: 11px;
  padding: 16px;
}

.market-dialog-content {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.dialog-header h2 {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.dialog-symbol,
.dialog-company-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-symbol {
  color: #18212f;
  font-size: 18px;
  line-height: 1.15;
}

.dialog-company-name {
  color: #637083;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.25;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #dde3ea;
  border-radius: 999px;
  padding: 0;
  background: white;
  color: #344255;
}

.icon-button:hover {
  background: #f4f6f8;
}

.button-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.market-body {
  display: grid;
  gap: 9px;
}

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

.market-summary div {
  display: grid;
  gap: 3px;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  min-width: 0;
  padding: 9px;
  background: #f7fafc;
}

.market-summary span,
.market-updated,
.depth-heading span,
.depth-count {
  color: #637083;
  font-size: 12px;
}

.market-summary strong {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-updated {
  text-align: right;
}

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

.depth-side {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dde3ea;
  border-radius: 8px;
}

.depth-heading {
  display: grid;
  padding: 8px 10px;
  background: #f7fafc;
  border-bottom: 1px solid #dde3ea;
}

.depth-side.ask .depth-heading strong {
  color: #b64632;
}

.depth-side.bid .depth-heading strong {
  color: #12715b;
}

.depth-list {
  display: grid;
}

.depth-row {
  display: grid;
  grid-template-columns: 24px minmax(88px, 1.1fr) minmax(72px, 0.9fr) minmax(58px, 0.7fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-bottom: 1px solid #eef1f5;
  padding: 8px 9px;
  font-size: 12px;
}

.depth-row:last-child {
  border-bottom: 0;
}

.depth-position {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: #eef2f6;
  color: #637083;
  font-weight: 700;
}

.depth-price {
  font-weight: 700;
}

.depth-row.ask .depth-price {
  color: #b64632;
}

.depth-row.bid .depth-price {
  color: #12715b;
}

.depth-price small {
  color: #637083;
  font-size: 10px;
}

.depth-volume,
.depth-count {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-empty {
  padding: 16px 12px;
  color: #637083;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: #344255;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(112px, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 9px;
}

.form-row label {
  min-width: 0;
  overflow: hidden;
  color: #344255;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-help {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.help-button {
  position: relative;
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #c9d2de;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: #637083;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.help-button:hover,
.help-button:focus-visible {
  background: transparent;
  color: #12715b;
}

.help-button::after {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: min(260px, calc(100vw - 48px));
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 9px 10px;
  background: white;
  box-shadow: 0 12px 28px rgb(24 33 47 / 16%);
  color: #344255;
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.help-button:hover::after,
.help-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

input {
  min-width: 0;
  border: 1px solid #c9d2de;
  border-radius: 8px;
  padding: 9px 10px;
}

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

.actions.add-only {
  justify-content: flex-end;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 126px;
}

.confirm-content {
  display: grid;
  gap: 13px;
  padding: 17px;
}

.confirm-icon {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: #fff0f0;
  color: #a83232;
}

.confirm-text {
  display: grid;
  gap: 5px;
}

.confirm-text strong {
  color: #18212f;
  font-size: 18px;
}

.confirm-text span {
  color: #637083;
  font-size: 13px;
  line-height: 1.4;
}

.confirm-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.confirm-actions .action-button {
  min-width: 0;
  flex: 1 1 0;
  padding-inline: 10px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100% - 32px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #12715b;
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #a83232;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #111827;
  color: #f6f7f9;
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .company,
:root[data-theme="dark"] .portfolio-item,
:root[data-theme="dark"] dialog {
  background: #182232;
  border-color: #2b384a;
  color: #f6f7f9;
}

:root[data-theme="dark"] .portfolio-panel {
  background: #223047;
}

:root[data-theme="dark"] .company.saved {
  background: #12281f;
  border-color: #2d8a6f;
}

:root[data-theme="dark"] .company-add-icon,
:root[data-theme="dark"] .company-market-icon {
  background: #111827;
  border-color: #3b4a60;
  color: #6fe0bd;
}

:root[data-theme="dark"] .company-add-icon:hover,
:root[data-theme="dark"] .company-add-icon:focus-visible,
:root[data-theme="dark"] .company-market-icon:hover,
:root[data-theme="dark"] .company-market-icon:focus-visible {
  background: #172033;
  color: #8cf0cf;
}

:root[data-theme="dark"] .watch-name,
:root[data-theme="dark"] .company-name,
:root[data-theme="dark"] .dialog-symbol,
:root[data-theme="dark"] .confirm-text strong,
:root[data-theme="dark"] .alert-text strong,
:root[data-theme="dark"] .empty-state strong {
  color: #f6f7f9;
}

:root[data-theme="dark"] label,
:root[data-theme="dark"] .form-row label,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .metric-label,
:root[data-theme="dark"] .watch-number,
:root[data-theme="dark"] .company-meta,
:root[data-theme="dark"] .company-title-separator,
:root[data-theme="dark"] .dialog-company-name,
:root[data-theme="dark"] .confirm-text span,
:root[data-theme="dark"] .alert-text span,
:root[data-theme="dark"] .fact {
  color: #b8c1ce;
}

:root[data-theme="dark"] .confirm-icon {
  background: #351b22;
  color: #ff9b86;
}

:root[data-theme="dark"] .watch-alert-footer {
  border-color: #2b384a;
}

:root[data-theme="dark"] .company-footer {
  border-color: #2b384a;
}

:root[data-theme="dark"] .fact {
  border-color: #3b4a60;
}

:root[data-theme="dark"] .market-summary div,
:root[data-theme="dark"] .depth-heading,
:root[data-theme="dark"] .help-button::after {
  background: #111827;
  border-color: #3b4a60;
}

:root[data-theme="dark"] .depth-side {
  border-color: #3b4a60;
}

:root[data-theme="dark"] .depth-row {
  border-color: #2b384a;
}

:root[data-theme="dark"] .depth-position {
  background: #223047;
  color: #b8c1ce;
}

:root[data-theme="dark"] .market-summary span,
:root[data-theme="dark"] .market-updated,
:root[data-theme="dark"] .depth-heading span,
:root[data-theme="dark"] .depth-count,
:root[data-theme="dark"] .depth-price small,
:root[data-theme="dark"] .market-empty,
:root[data-theme="dark"] .help-button {
  color: #b8c1ce;
}

:root[data-theme="dark"] .help-button {
  background: transparent;
  border-color: #3b4a60;
}

:root[data-theme="dark"] .help-button:hover,
:root[data-theme="dark"] .help-button:focus-visible {
  background: transparent;
  color: #6fe0bd;
}

:root[data-theme="dark"] .help-button::after {
  color: #f6f7f9;
}

:root[data-theme="dark"] .seller-alert .alert-icon {
  color: #ff9b86;
}

:root[data-theme="dark"] .buyer-alert .alert-icon {
  color: #6fe0bd;
}

:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .nav-icon-button,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] input {
  background: #111827;
  border-color: #3b4a60;
  color: #f6f7f9;
}

:root[data-theme="dark"] .empty-state {
  border-color: #3b4a60;
  color: #b8c1ce;
}

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

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

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 19px;
  }

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

  .company button {
    justify-self: stretch;
  }

  .company button.company-add-icon,
  .company button.company-market-icon {
    justify-self: auto;
  }

  .market-depth-grid {
    grid-template-columns: 1fr;
  }

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

  .market-summary div {
    padding: 8px;
  }

  .market-summary strong {
    font-size: 13px;
  }

  .depth-row {
    grid-template-columns: 22px minmax(80px, 1fr) minmax(64px, 0.8fr);
  }

  .depth-count {
    display: none;
  }

  .form-row {
    grid-template-columns: minmax(96px, 0.9fr) minmax(0, 1.1fr);
    gap: 7px;
  }

  .form-row label {
    font-size: 12px;
  }
}
