:root {
  --ink: #222222;
  --muted: #6b6b6b;
  --soft: #f7f7f7;
  --line: #ebebeb;
  --panel: #ffffff;
  --accent: #7cc7ff;
  --accent-dark: #1f7fb7;
  --teal: #008489;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar {
  display: grid;
  gap: 34px;
  padding: 4px 0 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 10px;
  font-size: clamp(38px, 7vw, 76px);
  letter-spacing: 0;
  line-height: 0.96;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
  letter-spacing: 0;
}

.intro {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.table-section {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.2fr);
  gap: 22px;
  align-items: start;
  padding: 26px;
  border-bottom: 1px solid var(--line);
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.meta-line {
  line-height: 1.5;
}

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

.list-filter {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.filter-card {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.filter-card:hover {
  border-color: #dddddd;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}

.filter-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.filter-copy strong {
  font-size: 15px;
}

.filter-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.segment-control {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  min-width: 300px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbff;
}

.segment-option {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segment-option:hover {
  color: var(--ink);
}

.segment-option.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 5px 18px rgba(31, 127, 183, 0.16);
}

.toggle {
  display: inline-flex;
  flex: 0 0 auto;
}

.toggle input {
  flex: 0 0 auto;
  appearance: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid #c9c9c9;
  border-radius: 999px;
  background: #f1f1f1;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.toggle input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle input:checked::after {
  transform: translateX(18px);
}

.table-wrap {
  overflow-x: hidden;
}

table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.col-stock {
  width: 34%;
}

.col-segment {
  width: 8%;
}

.col-day {
  width: 9%;
}

.col-close {
  width: 17%;
}

.col-open {
  width: 17%;
}

.col-volume {
  width: 15%;
}

th,
td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fcfcfc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  line-height: 1.25;
  white-space: normal;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  letter-spacing: 0;
  text-align: inherit;
  text-transform: inherit;
}

.sort-header:hover,
.sort-header.active {
  color: var(--teal);
}

.sort-header span {
  display: inline-block;
  width: 14px;
  color: var(--teal);
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
}

.sort-header.asc span::before {
  content: "▲";
}

.sort-header.desc span::before {
  content: "▼";
}

th:first-child,
td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #ffffff;
  box-shadow: 1px 0 0 var(--line);
}

th:first-child {
  background: #fcfcfc;
}

th:first-child .sort-header {
  justify-content: flex-start;
}

tbody tr:hover td {
  background: #f3fbff;
}

.stock-cell strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.stock-link {
  color: inherit;
  text-decoration: none;
}

.stock-link:hover strong {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.segment-pill {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #eef8ff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}

.day-indicator {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 900;
}

.day-indicator.up {
  background: #e7f8ef;
  color: #087a43;
}

.day-indicator.up::before {
  content: "↑";
}

.day-indicator.down {
  background: #fff0f0;
  color: #c1352b;
}

.day-indicator.down::before {
  content: "↓";
}

.day-indicator.flat {
  background: #f1f3f5;
  color: #6b6b6b;
}

.day-indicator.flat::before {
  content: "–";
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.database-note {
  margin: 0;
  padding: 16px 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.detail-shell {
  max-width: 1120px;
}

.detail-header {
  display: grid;
  gap: 18px;
  padding: 6px 0 20px;
}

.back-link {
  width: fit-content;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}

.back-link::before {
  content: "←";
  margin-right: 8px;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.detail-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.detail-panel h2 {
  margin-bottom: 8px;
  font-size: 16px;
}

.metric-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.metric-list div,
.person-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.metric-list div:first-child,
.person-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.metric-list dt,
.person-row span {
  color: var(--muted);
  font-size: 11px;
}

.metric-list dd {
  margin: 0;
  font-size: 12px;
  font-weight: 850;
  text-align: right;
}

.muted-text {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.overview-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  max-width: 900px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.overview-line span {
  white-space: nowrap;
}

.overview-line strong {
  color: var(--ink);
  font-weight: 850;
}

.chart-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.chart-head {
  display: block;
  margin-bottom: 12px;
}

.chart-head h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.chart-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.chart-controls {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbff;
}

.chart-period {
  min-height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
}

.chart-period.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 3px 10px rgba(31, 127, 183, 0.12);
}

.indicator-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.indicator-option {
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
}

.indicator-option.active {
  border-color: rgba(31, 127, 183, 0.35);
  background: #eef8ff;
  color: var(--accent-dark);
}

.candle-chart {
  width: 100%;
  min-height: 250px;
}

.candle-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: #edf2f5;
  stroke-width: 1;
}

.chart-label,
.chart-date {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.y-label {
  text-anchor: end;
}

.chart-date.end {
  text-anchor: end;
}

.chart-date {
  text-anchor: middle;
  dominant-baseline: hanging;
}

.chart-axis,
.chart-tick {
  stroke: #cfdce5;
  stroke-width: 1.2;
}

.candle line {
  stroke-width: 2;
}

.candle rect {
  stroke-width: 1.5;
}

.candle.up line,
.candle.up rect {
  stroke: #087a43;
}

.candle.up rect {
  fill: #dff6e9;
}

.candle.down line,
.candle.down rect {
  stroke: #c1352b;
}

.candle.down rect {
  fill: #ffe3e1;
}

.indicator-line {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.indicator-line.ema20 {
  stroke: #1f7fb7;
}

.indicator-line.ema50 {
  stroke: #7b61ff;
}

.indicator-line.ema200 {
  stroke: #555555;
}

.indicator-line.tenkan {
  stroke: #f28c28;
}

.indicator-line.kijun {
  stroke: #0f9b8e;
}

.indicator-line.senkou-a {
  stroke: rgba(31, 127, 183, 0.82);
}

.indicator-line.senkou-b {
  stroke: rgba(123, 97, 255, 0.82);
}

.ichimoku-cloud {
  fill: rgba(124, 199, 255, 0.18);
  stroke: none;
  pointer-events: none;
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 28px, 1180px);
    padding-top: 20px;
  }

  .section-head {
    grid-template-columns: 1fr;
  }

  .view-tools {
    grid-template-columns: 1fr;
  }

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

  .list-filter {
    grid-template-columns: 1fr;
  }

  .segment-control {
    width: 100%;
    min-width: 0;
  }

  .chart-controls {
    width: fit-content;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 42px;
  }

  .intro {
    font-size: 16px;
  }

  .section-head {
    padding: 20px;
  }

  .table-section {
    border-radius: 20px;
  }

  .segment-option {
    padding: 0 8px;
    font-size: 12px;
  }

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

  th {
    font-size: 10px;
  }

  .sort-header {
    gap: 3px;
  }

  .sort-header span {
    width: 8px;
    font-size: 9px;
  }

  .stock-cell strong {
    font-size: 13px;
    white-space: normal;
  }

  .day-indicator,
  .segment-pill {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .detail-panel {
    padding: 16px;
    border-radius: 16px;
  }

  .chart-panel {
    padding: 16px;
    border-radius: 16px;
  }

  .metric-list div,
  .person-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .metric-list dd {
    text-align: left;
  }

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

  .overview-line span {
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
