:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.header h1 {
  margin: 0 0 0.25rem 0;
}

.header p {
  margin: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.controls select {
  width: min(420px, 100%);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: inherit;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: inherit;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.tab-button.is-active {
  background: #2f80ed;
  border-color: #2f80ed;
  color: #ffffff;
}

.tab-panel {
  display: grid;
  gap: 0.75rem;
}

.tab-panel.is-hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.panel h2 {
  margin-top: 0;
}

#ageChart {
  width: 100%;
  height: clamp(180px, 30vh, 260px);
  max-height: 260px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  border-bottom: 2px solid var(--border);
  padding: 0.6rem;
}

tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.6rem;
}

tbody tr:hover {
  background: rgba(47, 128, 237, 0.08);
}

.placeholder-panel {
  min-height: 220px;
}

.placeholder-hint {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-left: 4px solid #2f80ed;
  background: rgba(47, 128, 237, 0.12);
  border-radius: 6px;
  font-weight: 600;
}

.chatbot-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #2f80ed;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}

.chatbot-overlay {
  position: fixed;
  right: 1rem;
  bottom: 4.8rem;
  width: min(340px, calc(100vw - 1.5rem));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.chatbot-overlay h3 {
  margin: 0 0 0.5rem 0;
}

.chatbot-overlay p {
  margin: 0;
  line-height: 1.45;
}

.chatbot-overlay.is-hidden {
  display: none;
}

@media (max-width: 720px) {
  .container {
    padding: 0.75rem;
  }

  .tabs {
    gap: 0.35rem;
  }

  .tab-button {
    width: 100%;
    text-align: left;
  }

  #ageChart {
    height: clamp(160px, 26vh, 210px);
    max-height: 210px;
  }

  .chatbot-toggle {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .chatbot-overlay {
    right: 0.75rem;
    bottom: 4.5rem;
  }
}
