* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

header {
  background: #1a1d2e;
  border-bottom: 1px solid #2d3748;
  padding: 1.5rem 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #63b3ed;
}

header .subtitle {
  color: #718096;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Input Section */
.input-section {
  background: #1a1d2e;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.input-row .search-wrap input {
  width: 100%;
  padding: 0.625rem 1rem;
  background: #0f1117;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 1rem;
}

.input-row input:focus {
  outline: none;
  border-color: #63b3ed;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  margin-top: 2px;
  padding: 0;
  list-style: none;
  background: #1a1d2e;
  border: 1px solid #4a5568;
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.autocomplete-list.hidden {
  display: none;
}

.autocomplete-list li {
  padding: 0.5rem 1rem;
  cursor: pointer;
  color: #e2e8f0;
  font-size: 0.9rem;
  border-bottom: 1px solid #2d3748;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.autocomplete-list li:last-child {
  border-bottom: none;
}

.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] {
  background: #2d3748;
}

.autocomplete-list .ticker {
  font-weight: 600;
  color: #63b3ed;
  flex-shrink: 0;
}

.autocomplete-list .name {
  color: #e2e8f0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  padding: 0.625rem 1.25rem;
  background: #3182ce;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) {
  background: #2b6cb0;
}

button:disabled {
  background: #2d3748;
  color: #718096;
  cursor: not-allowed;
}

.saved-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.saved-row label {
  color: #a0aec0;
  font-size: 0.875rem;
}

.saved-row select {
  padding: 0.5rem 0.75rem;
  background: #0f1117;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.875rem;
  min-width: 180px;
}

.saved-row button {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

#deleteBtn {
  background: #c53030;
}

#deleteBtn:hover:not(:disabled) {
  background: #9b2c2c;
}

/* Status */
.status-msg {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.status-msg.info { background: #1a365d; border: 1px solid #2b6cb0; color: #90cdf4; }
.status-msg.error { background: #2d1515; border: 1px solid #c53030; color: #fc8181; }
.status-msg.success { background: #1a2e1a; border: 1px solid #276749; color: #68d391; }

/* Company Bar */
.company-bar {
  background: #1a1d2e;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.company-name {
  font-weight: 700;
  font-size: 1rem;
  color: #63b3ed;
}

.sep { color: #4a5568; }

#manualPriceWrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#manualPrice {
  width: 120px;
  padding: 0.375rem 0.625rem;
  background: #0f1117;
  border: 1px solid #e53e3e;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.875rem;
}

#manualPriceBtn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

/* Sections */
section {
  background: #1a1d2e;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 1.5rem;
}

section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #a0aec0;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Financials Table */
.financials-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.financials-header h2 {
  margin-bottom: 0;
}

.currency-badge {
  background: #2d3748;
  color: #a0aec0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.convert-btn {
  background: #2b6cb0;
  color: #e2e8f0;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.convert-btn:hover:not(:disabled) {
  background: #3182ce;
}

.convert-btn:disabled {
  background: #1a365d;
  color: #718096;
  cursor: default;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.625rem 0.875rem;
  text-align: right;
  border-bottom: 1px solid #2d3748;
  white-space: nowrap;
  vertical-align: top;
}

th:first-child, td:first-child {
  text-align: left;
  color: #a0aec0;
  font-weight: 500;
}

#financialsTable th:not(:first-child),
#financialsTable td:not(:first-child) {
  text-align: center;
}

th {
  color: #718096;
  font-weight: 600;
  background: #0f1117;
}

.fin-year-header {
  text-align: center;
  white-space: normal;
}

.fin-year-label {
  font-weight: 600;
  color: #718096;
}

.fin-year-ended {
  font-size: 0.7rem;
  font-weight: 400;
  color: #4a5568;
  margin-top: 0.2rem;
  line-height: 1.2;
}

tr:hover td {
  background: #1e2235;
}

/* Financials cell: value + YoY growth */
.fin-cell .fin-value {
  display: block;
}

.fin-cell .yoy-growth {
  display: block;
  min-height: 1em;
  font-size: 0.7rem;
  color: #4a5568;
  font-weight: 400;
}

/* Sliders */
.sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.slider-group label {
  display: block;
  font-size: 0.875rem;
  color: #a0aec0;
  margin-bottom: 0.5rem;
}

.slider-group label span {
  color: #63b3ed;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: #3182ce;
  cursor: pointer;
}

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.result-card {
  background: #0f1117;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 1.25rem;
}

.result-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #63b3ed;
  margin-bottom: 1rem;
}

.model-description {
  font-size: 0.75rem;
  font-style: italic;
  color: #718096;
  margin: 0.25rem 0 0.75rem 0;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1a1d2e;
  font-size: 0.875rem;
  color: #a0aec0;
}

.result-row:last-child {
  border-bottom: none;
}

.result-row .value {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 1rem;
}

.verdict-row {
  justify-content: center;
  padding-top: 0.75rem;
}

.verdict {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.375rem 1rem;
  border-radius: 20px;
}

.verdict.undervalued {
  background: #1a2e1a;
  color: #68d391;
  border: 1px solid #276749;
}

.verdict.overvalued {
  background: #2d1515;
  color: #fc8181;
  border: 1px solid #c53030;
}

.result-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a5568;
  padding: 0.5rem 0 0.25rem;
  margin-top: 0.25rem;
  border-top: 1px solid #1a1d2e;
}

.result-section-label:first-of-type {
  border-top: none;
  margin-top: 0;
}

.verdict.error {
  background: #2d2a15;
  color: #f6e05e;
  border: 1px solid #b7791f;
}

/* Calculation breakdown */
.calc-breakdown {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #2d3748;
}

.calc-breakdown-title {
  font-size: 1rem;
  font-weight: 600;
  color: #a0aec0;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calc-tables {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.calc-block {
  background: #0f1117;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.calc-block.hidden {
  display: none !important;
}

.calc-block h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #63b3ed;
  margin-bottom: 0.75rem;
}

.calc-block .table-wrap {
  margin-bottom: 0.75rem;
}

.calc-block .table-wrap:last-child {
  margin-bottom: 0;
}

.hidden { display: none !important; }

/* Growth interval builder */
.intervals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.intervals-label {
  font-size: 0.875rem;
  color: #a0aec0;
  font-weight: 500;
}

.interval-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.interval-years-label {
  font-size: 0.875rem;
  color: #a0aec0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.interval-row .years-input {
  width: 70px;
  padding: 0.4rem 0.5rem;
  background: #0f1117;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.875rem;
}

.interval-row .remove-btn {
  background: #c53030;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.interval-row .remove-btn:hover:not(:disabled) {
  background: #9b2c2c;
}

.interval-row .rate-label {
  font-size: 0.875rem;
  color: #a0aec0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.interval-row .rate-input {
  width: 72px;
  padding: 0.4rem 0.5rem;
  background: #0f1117;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.875rem;
}

.interval-row .rate-pct-suffix {
  color: #63b3ed;
  font-weight: 600;
  font-size: 0.875rem;
}

.interval-row .rate-slider {
  width: 140px;
  min-height: 24px;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
}

.interval-end-values {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: #a0aec0;
}

.interval-end-values .interval-end-fcf,
.interval-end-values .interval-end-oe {
  white-space: nowrap;
}

.interval-row .rate-label input[type="range"] {
  flex: 1;
  min-width: 120px;
}

#intervalsContainer {
  margin-bottom: 1.25rem;
}
