/* ── Base ─────────────────────────────────────────────────── */
body {
  margin: 0;
  font-family: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #191f28;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  padding-left: 18px;
  padding-right: 18px;
  padding-top: 40px;
  padding-top: calc(env(safe-area-inset-top) + 16px);
  padding-bottom: 20px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  min-height: 100vh;
  box-sizing: border-box;
}

/* ── Top bar ──────────────────────────────────────────────── */
.top-bar {
  margin-bottom: 22px;
}

.logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #191f28;
}

.logo-sub {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 400;
  color: #8b95a1;
}

/* ── Cards ────────────────────────────────────────────────── */
.summary-card,
.result-card,
.chart-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 20px 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.06);
}

/* ── Summary ──────────────────────────────────────────────── */
.summary-label {
  font-size: 13px;
  font-weight: 500;
  color: #8b95a1;
  margin-bottom: 10px;
}

.summary-value {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  color: #191f28;
  font-variant-numeric: tabular-nums;
}

.summary-sub {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7684;
  font-variant-numeric: tabular-nums;
}

/* ── Section title ────────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #191f28;
  margin-bottom: 14px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: #6b7684;
  margin-bottom: 6px;
}

/* ── Form elements ────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #8b95a1;
  margin: 12px 0 7px;
}

input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e5e8eb;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  background: #fff;
  color: #191f28;
}

button {
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  background: #191f28;
  color: white;
  cursor: pointer;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#sortOption {
  height: 36px;
  border: 1px solid #e5e8eb;
  border-radius: 10px;
  padding: 0 10px;
  background: white;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: #191f28;
}

.add-stock-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #191f28;
  color: white;
  font-size: 22px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  margin-top: 0;
}

/* ── Inline add form ──────────────────────────────────────── */
.inline-add-form {
  margin-top: 14px;
  margin-bottom: 16px;
  padding: 16px 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #eef2f6;
}

.inline-form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.inline-form-buttons button {
  width: 100%;
  margin-top: 0;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
}

.secondary-btn {
  background: #f2f4f6;
  color: #4e5968;
}

/* ── Search ───────────────────────────────────────────────── */
.search-results {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e8eb;
  display: none;
}

.search-item {
  padding: 12px 14px;
  border-top: 1px solid #f0f2f4;
  cursor: pointer;
}

.search-item:first-child {
  border-top: none;
}

.search-item:hover {
  background: #f8fafc;
}

.search-ticker {
  font-size: 14px;
  font-weight: 700;
  color: #191f28;
}

.search-name {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: #8b95a1;
}

.selected-stock-box {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f2f4f6;
  color: #6b7684;
  font-size: 13px;
  font-weight: 500;
}

/* ── Stock list ───────────────────────────────────────────── */
.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid #f0f2f4;
  cursor: pointer;
}

.stock-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.stock-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.stock-qty {
  margin-top: 4px;
  color: #8b95a1;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.approx-tag {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #b0b8c1;
}

.approx-notice {
  font-size: 12px;
  font-weight: 400;
  color: #b0b8c1;
  line-height: 1.55;
  padding: 4px 0 2px;
}

.stock-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 160px;
}

.stock-diff {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stock-today {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Detail info card ─────────────────────────────────────── */
.detail-info-card {
  position: relative;
  overflow: visible;
  border-radius: 20px;
  padding-top: 20px;
  padding-bottom: 16px;
}

.detail-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.detail-menu-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: #f2f4f6;
  color: #6b7684;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 0;
  padding: 0;
  font-family: inherit;
}

.detail-menu {
  position: absolute;
  top: 40px;
  right: 0;
  min-width: 120px;
  background: #ffffff;
  border: 1px solid #eef2f6;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  padding: 6px;
  z-index: 1000;
}

.menu-item {
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  color: #191f28;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1.2;
}

.menu-item:hover {
  background: #f8fafc;
}

/* ── Info rows ────────────────────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid #f0f2f4;
}

.info-row:first-of-type {
  margin-top: 16px;
}

.info-label {
  font-size: 14px;
  font-weight: 500;
  color: #6b7684;
}

.info-value {
  font-size: 17px;
  font-weight: 700;
  color: #191f28;
  text-align: right;
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}

.pretax-note {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 400;
  color: #b0b8c1;
}

/* ── Chart card ───────────────────────────────────────────── */
.chart-card {
  border-radius: 20px;
  padding: 18px 18px 16px;
  overflow: hidden;
}

.chart-diff-badge {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #191f28;
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}

.fixed-chart-card {
  min-height: 360px;
  overflow: hidden;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}

#detailChart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Section headers ─────────────────────────────────────── */
.section-header {
  font-size: 12px;
  font-weight: 600;
  color: #8b95a1;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 14px 0 6px;
  border-top: 1px solid #eef2f6;
  margin-top: 4px;
}

.section-header:first-child {
  border-top: none;
  padding-top: 4px;
}

.section-subtotal {
  font-size: 12px;
  font-weight: 500;
  color: #6b7684;
  padding: 6px 0 2px;
}

/* ── Compare base tag ─────────────────────────────────────── */
.compare-base-tag {
  color: #b0b8c1;
  font-weight: 400;
}

/* ── Compare selector (detail page) ─────────────────────── */
.compare-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  margin-top: 2px;
}

.compare-selector-label {
  font-size: 13px;
  font-weight: 500;
  color: #6b7684;
  white-space: nowrap;
}

.compare-selector {
  height: 34px;
  border: 1px solid #e5e8eb;
  border-radius: 10px;
  padding: 0 10px;
  background: white;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: #191f28;
  cursor: pointer;
  outline: none;
}

.compare-selector:focus {
  border-color: #c9d3e0;
  box-shadow: 0 0 0 3px rgba(43, 110, 242, 0.07);
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Focus ────────────────────────────────────────────────── */
#sortOption:focus,
input:focus {
  outline: none;
  border-color: #c9d3e0;
  box-shadow: 0 0 0 3px rgba(43, 110, 242, 0.07);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 430px) {
  .summary-value {
    font-size: 34px;
  }

  .stock-diff {
    font-size: 16px;
  }

  .stock-right {
    min-width: 148px;
  }
}
