:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --text: #1d2530;
  --muted: #667085;
  --line: #d9e0e8;
  --blue: #2563eb;
  --blue-ink: #173f9a;
  --green: #12805c;
  --red: #c33b3b;
  --amber: #b7791f;
  --purple: #6d4aff;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.panel h2,
.rail-heading h3 {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
}

.brand p,
.hint,
.eyebrow {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.primary-action,
.secondary-action,
.ghost-action {
  width: 100%;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.primary-action {
  padding: 13px 16px;
  background: var(--blue);
  color: white;
  font-weight: 750;
  box-shadow: var(--shadow);
}

.secondary-action {
  padding: 10px 12px;
  background: var(--text);
  color: white;
}

.ghost-action {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover {
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.test-result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.test-result.ok {
  border-color: rgba(18, 128, 92, 0.28);
  background: rgba(18, 128, 92, 0.08);
  color: var(--green);
}

.test-result.fail {
  border-color: rgba(195, 59, 59, 0.28);
  background: rgba(195, 59, 59, 0.08);
  color: var(--red);
}

.panel,
.rail-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
}

label input,
.search {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
  outline: none;
}

label input:focus,
.search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mode-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-switch button.active {
  background: var(--text);
  color: white;
  font-weight: 750;
}

.source-list {
  display: grid;
  gap: 9px;
}

.source-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 13px;
}

.source-item strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.warn {
  background: var(--amber);
}

.status-dot.fail {
  background: var(--red);
}

.source-item span {
  color: var(--muted);
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 28px;
}

.run-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.run-meta span,
.badge,
.stock-chip,
.reminder-date {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.segmented button {
  min-width: 68px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--text);
  color: white;
}

.search {
  max-width: 340px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.analysis-list {
  display: grid;
  gap: 12px;
}

.analysis-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.analysis-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.analysis-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
}

.importance {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-weight: 800;
}

.card-meta,
.stocks,
.triggers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge.positive {
  color: var(--green);
  border-color: rgba(18, 128, 92, 0.28);
  background: rgba(18, 128, 92, 0.08);
}

.badge.negative {
  color: var(--red);
  border-color: rgba(195, 59, 59, 0.28);
  background: rgba(195, 59, 59, 0.08);
}

.badge.mixed {
  color: var(--amber);
  border-color: rgba(183, 121, 31, 0.28);
  background: rgba(183, 121, 31, 0.1);
}

.badge.uncertain {
  color: var(--muted);
}

.badge.evidence-strong {
  color: var(--green);
  border-color: rgba(18, 128, 92, 0.28);
  background: rgba(18, 128, 92, 0.08);
}

.badge.evidence-medium {
  color: var(--blue-ink);
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.07);
}

.badge.evidence-weak {
  color: var(--amber);
  border-color: rgba(183, 121, 31, 0.28);
  background: rgba(183, 121, 31, 0.1);
}

.stock-chip {
  color: var(--blue-ink);
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.07);
}

.analysis-card p {
  margin: 12px 0 0;
  color: #384252;
  font-size: 14px;
  line-height: 1.65;
}

.evidence-block,
.counter-block {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.evidence-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.evidence-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  background: #fbfcfd;
  text-decoration: none;
}

.evidence-row strong,
.evidence-row small,
.evidence-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.evidence-row span {
  color: var(--muted);
  font-size: 11px;
}

.evidence-row strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.evidence-row small {
  color: var(--muted);
  line-height: 1.45;
}

.evidence-row.strong {
  border-left-color: var(--green);
}

.evidence-row.medium {
  border-left-color: var(--blue);
}

.evidence-row.weak {
  border-left-color: var(--amber);
}

.evidence-row.watch {
  border-left-color: var(--muted);
}

.counter-list,
.verify-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.counter-list span {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(195, 59, 59, 0.08);
  color: #8f2b2b;
  font-size: 12px;
  line-height: 1.45;
}

.triggers span {
  padding: 5px 8px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a5b12;
  font-size: 12px;
}

.verify-links {
  margin-top: 12px;
}

.verify-links a {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--blue);
  font-size: 12px;
  text-decoration: none;
}

.card-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--blue);
  font-size: 13px;
  text-decoration: none;
}

.right-rail {
  display: grid;
  gap: 16px;
}

.rail-panel {
  margin-top: 0;
}

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

.rail-heading h3 {
  font-size: 15px;
}

.rail-heading span {
  color: var(--muted);
  font-size: 12px;
}

.reminder-list,
.news-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.reminder,
.news-item {
  display: grid;
  gap: 7px;
  padding: 11px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.reminder.done {
  opacity: 0.58;
}

.reminder strong,
.news-item strong {
  font-size: 13px;
  line-height: 1.45;
}

.reminder small,
.news-item small {
  color: var(--muted);
  line-height: 1.45;
}

.reminder button {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 5px 8px;
  color: var(--muted);
  cursor: pointer;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.hidden {
  display: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

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

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

  .search {
    max-width: none;
  }

  .segmented {
    overflow-x: auto;
  }
}
