:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #1f6feb;
  --red: #c0342b;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

body.locked .app-shell {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.auth-panel h1 {
  margin: 0 0 8px;
}

.auth-panel p {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tabs button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 9px;
}

.auth-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.auth-form button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.auth-message {
  min-height: 18px;
  font-size: 13px;
}

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

.sidebar {
  background: #111827;
  color: #fff;
  padding: 20px;
}

.sidebar h1 {
  font-size: 22px;
  margin: 0 0 10px;
}

.user-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
  color: #d0d5dd;
  font-size: 13px;
}

.user-line button {
  border: 1px solid #344054;
  border-radius: 6px;
  background: transparent;
  color: #d0d5dd;
  cursor: pointer;
  padding: 5px 8px;
}

.add-form {
  display: grid;
  gap: 8px;
}

.add-form input {
  width: 100%;
  border: 1px solid #344054;
  border-radius: 6px;
  padding: 10px;
}

.add-form button,
.topbar button,
.stock-card button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.watchlist {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 8px;
}

.watchlist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid #344054;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
}

.watchlist li.active {
  background: #24324a;
}

.watchlist small {
  color: #d0d5dd;
}

.delete-btn {
  background: transparent;
  color: #fda29b;
  border: 0;
  cursor: pointer;
}

.content {
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.topbar,
.panel,
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.topbar h2,
.panel h3 {
  margin: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(108px, 1fr));
  gap: 10px;
}

.summary-card {
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.summary-card strong {
  display: block;
  font-size: 24px;
}

.summary-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.panel {
  padding: 16px;
}

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

.alert-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.alerts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.clear-filter,
.expand-alerts {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.compact-alert-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.alert-row {
  display: grid;
  grid-template-columns: minmax(92px, 120px) 72px minmax(0, 1fr) 98px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 42px;
  padding: 8px 10px;
  text-align: left;
}

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

.alert-row:hover {
  background: #f8fafc;
}

.alert-stock {
  font-weight: 700;
}

.alert-kind {
  color: var(--accent);
  font-size: 13px;
}

.alert-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-time {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.alert-meta,
.source-line {
  color: var(--muted);
  font-size: 13px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.section-head h3 {
  margin: 0;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.report-list {
  display: grid;
  gap: 8px;
}

.report-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.report-main {
  min-width: 0;
}

.report-main h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.report-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

.report-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.report-action:hover {
  background: #eff6ff;
  text-decoration: none;
}

.report-action.disabled {
  border-color: var(--line);
  color: var(--muted);
}

.stock-card {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.stock-card.empty {
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

.chart-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.summary-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-head h3 {
  margin: 0;
}

.chart-head span,
.chart-label {
  color: var(--muted);
  font-size: 13px;
}

.kline-chart {
  display: block;
  width: 100%;
  height: 260px;
}

.intraday-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.intraday-chart {
  display: block;
  width: 100%;
  height: 150px;
  margin-bottom: 8px;
}

.axis {
  stroke: var(--line);
  stroke-width: 1;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fafbfc;
}

.insight-card span,
.insight-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.insight-card strong {
  display: block;
  margin: 4px 0;
  font-size: 19px;
}

.raw-details {
  margin-top: 10px;
}

.raw-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  user-select: none;
}

.raw-details table {
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 14px;
}

.compact-table th,
.compact-table td {
  padding: 6px 8px;
}

textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
}

.error {
  color: var(--red);
}

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

  .sidebar {
    padding: 14px;
  }

  .sidebar h1 {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .add-form {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .add-form input {
    min-width: 0;
    padding: 9px 10px;
  }

  .add-form button {
    padding: 9px 14px;
    white-space: nowrap;
  }

  .watchlist {
    margin-top: 10px;
  }

  .watchlist li {
    padding: 9px 10px;
  }

  .content {
    padding: 12px;
    gap: 10px;
  }

  .topbar {
    padding: 12px;
  }

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

  .topbar button {
    padding: 9px 12px;
  }

  .summary-grid,
  .metric-grid,
  .insight-grid {
    grid-template-columns: 1fr 1fr;
  }

  .summary-card,
  .metric,
  .insight-card {
    padding: 9px;
  }

  .alert-row {
    grid-template-columns: 78px 58px minmax(0, 1fr);
  }

  .alert-time {
    display: none;
  }

  .panel,
  .chart-block,
  .summary-block,
  .intraday-block {
    padding: 12px;
  }

  .section-head,
  .chart-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .kline-chart {
    height: 210px;
  }

  .intraday-chart {
    height: 126px;
  }

  .report-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .report-action {
    justify-self: start;
    min-width: 68px;
  }
}

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

  .summary-card strong {
    font-size: 22px;
  }

  .alert-row {
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    min-height: 52px;
  }

  .alert-stock {
    grid-column: 1;
  }

  .alert-kind {
    grid-column: 2;
    justify-self: end;
  }

  .alert-title {
    grid-column: 1 / -1;
  }

  .metric-grid,
  .insight-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stock-card {
    gap: 10px;
  }

  .metric strong,
  .insight-card strong {
    font-size: 18px;
  }

  th,
  td {
    font-size: 13px;
    padding: 6px;
  }
}
