:root {
  color-scheme: light;
  --bg: #eef3ef;
  --panel: #ffffff;
  --panel-soft: #f3f7f4;
  --text: #111a16;
  --muted: #63706a;
  --line: #d9e4dd;
  --green: #11834f;
  --green-dark: #074a31;
  --amber: #b36b00;
  --red: #bf3d3d;
  --blue: #245f9f;
  --ink: #102019;
  --shadow: 0 18px 44px rgba(20, 35, 27, 0.08);
  --shadow-soft: 0 10px 28px rgba(20, 35, 27, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  background:
    linear-gradient(180deg, #f8faf8 0, var(--bg) 340px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.workspace {
  display: grid;
  gap: 24px;
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 28px 22px 36px;
}

.topbar,
.search-panel,
.ai-panel,
.ticker-panel,
.chart-panel,
.score-panel,
.statement-panel,
.valuation-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.topbar {
  padding: 34px 38px;
}

.search-panel {
  padding: 24px 30px;
}

.ai-panel {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.25fr);
  gap: 30px;
  align-items: start;
  padding: 30px 34px;
  border-color: #cddfd5;
}

.ai-panel h2 {
  max-width: 520px;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.25;
}

.ai-panel p {
  max-width: 560px;
  margin: 14px 0 0;
  font-size: 1.02rem;
}

.ai-panel ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-panel li {
  position: relative;
  min-height: 58px;
  padding: 16px 18px 16px 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  color: var(--text);
  line-height: 1.65;
  box-shadow: var(--shadow-soft);
}

.ai-panel li::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 18px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 0;
  font-size: clamp(2.2rem, 4.1vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

p {
  line-height: 1.7;
  color: var(--muted);
}

.stock-search {
  position: relative;
  width: min(100%, 820px);
  margin: 0 auto;
}

.search-panel .stock-search {
  min-width: 0;
}

.search-panel .stock-search label {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 1.05rem;
}

.search-panel .search-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.search-panel .search-row input {
  min-height: 64px;
  padding: 0 24px;
  font-size: 1.25rem;
}

.search-panel .search-row button {
  min-width: 120px;
  min-height: 64px;
  padding: 0 28px;
  font-size: 1.25rem;
}

.stock-search label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.search-row input,
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
}

.search-row input {
  width: 100%;
  padding: 0 14px;
  text-transform: uppercase;
}

.search-row button,
.segmented button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.search-row button {
  padding: 0 18px;
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(17, 131, 79, 0.22);
}

.search-results {
  display: none;
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  right: 0;
  width: min(520px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.search-panel .search-results {
  left: 0;
  right: 0;
  width: 100%;
}

.search-results.visible {
  display: grid;
}

.search-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus {
  background: var(--panel-soft);
  outline: none;
}

.search-result strong,
.search-result span {
  display: block;
}

.search-result span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.search-result code {
  color: var(--green-dark);
  font-family: inherit;
  font-weight: 800;
}

.search-result-empty {
  padding: 12px 14px;
  color: var(--muted);
}

.ticker-panel {
  display: grid;
  gap: 26px;
  padding: 28px 32px;
}

.api-status {
  padding: 14px 16px;
  border: 1px solid #b7d8c4;
  border-radius: 8px;
  background: #e7f6ed;
  color: var(--green-dark);
  font-weight: 700;
}

.api-status.warn {
  border-color: #f2c879;
  background: #fff5dd;
  color: var(--amber);
}

.api-status.error {
  border-color: #f3b6b6;
  background: #fff0f0;
  color: var(--red);
}

.company-summary {
  display: flex;
  justify-content: space-between;
  gap: 28px;
}

.market-badge {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.price-block {
  min-width: 160px;
  text-align: right;
}

.price-block span,
.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.price-block strong {
  display: block;
  font-size: 2.15rem;
  line-height: 1;
}

.price-block em {
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

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

.metric-card {
  min-height: 136px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f9fcfa);
  box-shadow: var(--shadow-soft);
}

.metric-card strong {
  display: block;
  margin: 16px 0 9px;
  font-size: 2rem;
  line-height: 1;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
}

.chart-panel,
.score-panel,
.statement-panel,
.valuation-panel {
  padding: 26px;
}

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

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #ffffff;
  color: var(--green-dark);
  box-shadow: 0 2px 8px rgba(23, 33, 27, 0.08);
}

canvas {
  display: block;
  width: 100%;
  height: 390px;
  max-height: 390px;
  border-radius: 14px;
  background: #fbfdfb;
}

.score-panel {
  display: grid;
  align-content: start;
  justify-items: center;
  text-align: center;
}

.score-ring {
  display: grid;
  width: 190px;
  height: 190px;
  place-items: center;
  margin: 10px 0 18px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--score) * 1%), #e7eee9 0);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  background: #ffffff;
}

.score-ring strong,
.score-ring span {
  position: relative;
  z-index: 1;
}

.score-ring strong {
  font-size: 2.5rem;
}

.score-ring span {
  align-self: end;
  margin-bottom: 42px;
  color: var(--muted);
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

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

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.86rem;
}

td {
  font-weight: 700;
}

select {
  padding: 0 36px 0 12px;
}

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

.check-item {
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  box-shadow: var(--shadow-soft);
}

.check-item strong {
  display: block;
  margin-bottom: 8px;
}

.status {
  display: inline-flex;
  margin-top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.good {
  background: #ddf4e7;
  color: var(--green-dark);
}

.status.warn {
  background: #fff1d6;
  color: var(--amber);
}

.status.risk {
  background: #ffe4e4;
  color: var(--red);
}

@media (max-width: 1040px) {
  .analysis-grid,
  .ai-panel,
  .metric-grid,
  .checklist {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    padding: 30px;
  }

  h1 {
    font-size: clamp(2rem, 6vw, 3.4rem);
  }
}

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

  .topbar,
  .company-summary,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .ticker-panel,
  .chart-panel,
  .score-panel,
  .statement-panel,
  .valuation-panel,
  .ai-panel {
    padding: 20px;
  }

  h1 {
    font-size: clamp(1.9rem, 10vw, 2.8rem);
  }

  h2,
  .ai-panel h2 {
    font-size: 1.25rem;
  }

  .search-panel {
    padding: 20px;
  }

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

  .search-panel .search-row input,
  .search-panel .search-row button {
    min-height: 58px;
    font-size: 1.1rem;
  }

  .price-block {
    text-align: left;
  }

  .metric-grid,
  .ai-panel,
  .analysis-grid,
  .checklist {
    grid-template-columns: 1fr;
  }

  canvas {
    height: 320px;
    max-height: 320px;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
