.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #065a82;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 8px 0;
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}
* {
  box-sizing: border-box;
}

:root {
  --navy: #21295c;
  --deep: #065a82;
  --teal: #1c7293;
  --ice: #eaf2f8;
  --slate: #3a4a5c;
  --gray: #6b7280;
  --good: #16a34a;
  --good-bg: #dcf5e3;
  --average: #b7791f;
  --average-bg: #fef3d9;
  --concerning: #dc2626;
  --concerning-bg: #fdeaea;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 2rem;
  background: #f3f4f6;
  color: #111827;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

header {
  margin-bottom: 1.5rem;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-mark {
  font-size: 1.6rem;
  line-height: 1;
}

h1 {
  color: var(--navy);
  margin: 0;
  font-size: 1.8rem;
}

.tagline {
  color: var(--slate);
  margin: 0.35rem 0 0 0;
  font-size: 0.95rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  max-width: 600px;
}

#search-input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
  min-width: 0;
}

#search-input:focus {
  outline: none;
  border-color: var(--deep);
  box-shadow: 0 0 0 3px rgba(6, 90, 130, 0.15);
}

#search-button {
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  background: var(--deep);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

#search-button:hover {
  background: #054864;
}

#search-button:active {
  transform: scale(0.97);
}

#search-button:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.quick-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  max-width: 700px;
}

.quick-chips-label {
  font-size: 0.82rem;
  color: var(--gray);
  margin-right: 0.15rem;
}

.chip {
  font-size: 0.82rem;
  background: white;
  border: 1px solid #dde3e8;
  color: var(--deep);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-height: 32px;
}

.chip:hover {
  background: var(--ice);
  border-color: var(--deep);
}

.chip:focus-visible {
  outline: 2px solid var(--deep);
  outline-offset: 2px;
}

#results {
  max-width: 700px;
}

.idle-state {
  padding: 1.25rem 0;
}

.idle-message {
  color: var(--slate);
  font-size: 0.95rem;
  margin: 0;
}

.error-message {
  background: var(--concerning-bg);
  border-left: 4px solid var(--concerning);
  padding: 1rem 1.1rem;
  border-radius: 6px;
  color: #7a1f1f;
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

/* --- Fade-in micro-interaction --- */

.fade-in {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .chip, #search-button, #search-input { transition: none; }
}

/* --- Loading Skeleton --- */

.skeleton-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.25rem;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef0f2 25%, #f7f8f9 37%, #eef0f2 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  margin-bottom: 0.7rem;
}

.skeleton-title { width: 45%; height: 20px; }
.skeleton-short { width: 30%; }
.skeleton-medium { width: 75%; margin-bottom: 0; }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
}

/* --- Snapshot Card --- */

.snapshot-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.25rem;
  overflow-wrap: break-word;
}

.snapshot-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.snapshot-company-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.snapshot-ticker {
  font-size: 0.9rem;
  color: var(--gray);
  font-weight: 600;
  background: var(--ice);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.snapshot-price-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.snapshot-stat-label {
  font-size: 0.78rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}

.snapshot-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  overflow-wrap: break-word;
}

.snapshot-sector {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--teal);
  background: var(--ice);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.snapshot-description {
  font-size: 0.95rem;
  color: var(--slate);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.snapshot-updated {
  font-size: 0.78rem;
  color: #9aa5b1;
  font-style: italic;
}

/* --- Ratios Card --- */

.ratios-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.05rem;
  color: var(--navy);
  margin: 0 0 1rem 0;
}

.ratios-empty {
  color: var(--gray);
  font-size: 0.95rem;
}

.ratio-row {
  border-top: 1px solid #eef0f2;
  padding: 0.85rem 0;
}

.ratio-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.ratio-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.ratio-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #111827;
}

.ratio-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.ratio-badge-good { background: var(--good-bg); color: var(--good); }
.ratio-badge-average { background: var(--average-bg); color: var(--average); }
.ratio-badge-concerning { background: var(--concerning-bg); color: var(--concerning); }
.ratio-badge-unknown { background: #eceff1; color: var(--gray); }

.ratio-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.15rem;
}

.ratio-explanation {
  font-size: 0.85rem;
  color: var(--gray);
  line-height: 1.45;
}

.ratios-disclaimer {
  font-size: 0.78rem;
  color: #9aa5b1;
  font-style: italic;
  margin-top: 1rem;
  margin-bottom: 0;
}

/* --- Red Flags Card --- */

.flags-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.25rem;
}

.flags-card-clear { border-left: 4px solid var(--good); }
.flags-card-warning { border-left: 4px solid #e8a33d; }

.flags-clear-message {
  color: var(--good);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.flags-list {
  margin: 0;
  padding-left: 1.2rem;
}

.flag-item {
  font-size: 0.9rem;
  color: var(--slate);
  line-height: 1.5;
  margin-bottom: 0.6rem;
  overflow-wrap: break-word;
}

.flag-item:last-child {
  margin-bottom: 0;
}

/* --- Footer --- */

.site-footer {
  max-width: 700px;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #dde3e8;
  font-size: 0.8rem;
  color: #9aa5b1;
  text-align: center;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  body { padding: 1.25rem; }
  h1 { font-size: 1.5rem; }
  .snapshot-price-row { gap: 1rem; }
  .search-bar { max-width: 100%; }
  .quick-chips { max-width: 100%; }
}

@media (max-width: 340px) {
  .search-bar { flex-direction: column; }
  #search-button { width: 100%; }
}