:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d6dde8;
  --line-strong: #b9c3d2;
  --text: #111827;
  --muted: #64748b;
  --muted-strong: #475569;
  --focus: #2563eb;
  --active: #0f7a3d;
  --active-bg: #e8f6ee;
  --watch: #475569;
  --watch-bg: #eef2f7;
  --paused: #b45309;
  --paused-bg: #fff4df;
  --banned: #b42318;
  --banned-bg: #fff0ee;
  --archived: #6b7280;
  --archived-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

button {
  min-height: 38px;
  padding: 0 13px;
  border-color: var(--line-strong);
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  border-color: var(--focus);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -16px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.masthead-title {
  min-width: 0;
}

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

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

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.subtle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-action {
  border-color: #14532d;
  background: #14532d;
  color: #ffffff;
}

.primary-action:hover {
  border-color: #0f7a3d;
  background: #0f7a3d;
}

.ghost-action {
  background: transparent;
}

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

.metric {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 10px 12px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.metric.is-selected {
  border-color: var(--focus);
}

.metric-value {
  font: 800 24px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric.status-active .metric-value {
  color: var(--active);
}

.metric.status-watch .metric-value {
  color: var(--watch);
}

.metric.status-paused .metric-value {
  color: var(--paused);
}

.metric.status-banned .metric-value {
  color: var(--banned);
}

.metric.status-archived .metric-value {
  color: var(--archived);
}

.next-run,
.control-bar,
.ticker-workspace {
  margin-bottom: 14px;
}

.next-run {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.count-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.ticker-strip {
  display: flex;
  gap: 8px;
  min-height: 34px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.ticker-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #9fd7b3;
  border-radius: 999px;
  background: var(--active-bg);
  color: var(--active);
  font: 800 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-decoration: none;
  white-space: nowrap;
}

.ticker-strip-empty {
  display: flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.6fr);
  gap: 10px;
  align-items: end;
}

.search-field span,
.stack-form span,
.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
}

.filter-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
}

.filter-tabs button {
  min-width: max-content;
  background: var(--surface);
}

.filter-tabs button.is-selected {
  border-color: #1d4ed8;
  background: #eff6ff;
  color: #1d4ed8;
}

.statusbar {
  min-height: 24px;
  color: var(--active);
}

.statusbar .error {
  color: var(--banned);
}

.ticker-list {
  display: grid;
  gap: 14px;
}

.ticker-group {
  display: grid;
  gap: 8px;
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-strong);
}

.group-heading h2 {
  font-size: 14px;
  font-weight: 850;
  text-transform: uppercase;
}

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

.ticker-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ticker-card.is-pending {
  opacity: 0.72;
}

.ticker-card-main {
  display: grid;
  grid-template-columns: minmax(80px, 0.7fr) minmax(150px, 1fr);
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.ticker-identity {
  min-width: 0;
}

.ticker-symbol {
  display: block;
  font: 900 22px/1.05 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.company-name {
  display: block;
  margin-top: 5px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.updated {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.status-control {
  min-width: 0;
}

.status-select {
  min-height: 40px;
  border-width: 1px;
  font-weight: 850;
}

.status-select.status-active,
.status-pill.status-active {
  border-color: #9fd7b3;
  background: var(--active-bg);
  color: var(--active);
}

.status-select.status-watch,
.status-pill.status-watch {
  border-color: #cbd5e1;
  background: var(--watch-bg);
  color: var(--watch);
}

.status-select.status-paused,
.status-pill.status-paused {
  border-color: #f5c66f;
  background: var(--paused-bg);
  color: var(--paused);
}

.status-select.status-banned,
.status-pill.status-banned {
  border-color: #ffb4aa;
  background: var(--banned-bg);
  color: var(--banned);
}

.status-select.status-archived,
.status-pill.status-archived {
  border-color: #d1d5db;
  background: var(--archived-bg);
  color: var(--archived);
}

.status-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ticker-card-fields {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.tags-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.save-state {
  min-width: 72px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.save-state.is-saving {
  color: #1d4ed8;
}

.save-state.is-error {
  color: var(--banned);
}

.save-state.is-saved {
  color: var(--active);
}

.notes-toggle {
  display: inline-flex;
  width: max-content;
  min-height: 32px;
  align-items: center;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 13px;
}

.notes-panel {
  display: grid;
  gap: 8px;
}

.notes-panel[hidden] {
  display: none;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 12px;
}

.archive-action {
  min-height: 32px;
  color: var(--banned);
  background: transparent;
}

.empty-state {
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  text-align: center;
}

.add-dialog {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

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

.dialog-shell {
  margin: 0;
  padding: 16px;
}

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

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

.stack-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  color: var(--text);
}

.toast.is-error {
  border-color: #ffb4aa;
  color: var(--banned);
}

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

  .control-bar {
    grid-template-columns: 1fr;
  }

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

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

  .masthead {
    align-items: flex-start;
    margin: 0 -12px 12px;
    padding: 10px 12px;
  }

  .masthead-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 118px;
  }

  .masthead-actions button {
    min-height: 34px;
    padding: 0 8px;
  }

  h1 {
    font-size: 22px;
  }

  .summary-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .metric {
    min-width: 124px;
  }

  .next-run {
    padding: 12px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .ticker-card-main {
    grid-template-columns: 1fr;
  }

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

  .save-state {
    min-width: 0;
    text-align: left;
  }

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

  .add-dialog {
    width: calc(100vw - 18px);
  }

  .toast-region {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
  }
}
