:root {
  color-scheme: dark;
  --bg: #121212;
  --panel: #1e1e1e;
  --panel-alt: #232323;
  --border: #2f2f2f;
  --accent: #4a90e2;
  --accent-muted: rgba(74, 144, 226, 0.2);
  --text: #f0f0f0;
  --text-muted: #b0b0b0;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.loader-content {
  background: rgba(24, 24, 24, 0.95);
  border-radius: 16px;
  padding: 1.75rem 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 1rem;
  align-items: center;
  justify-items: center;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #111 0%, #000 100%);
  color: var(--text);
  padding: 5rem 2rem 2rem;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(12, 12, 12, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  z-index: 500;
}

.nav-brand {
  font-weight: 600;
  letter-spacing: 0.04em;
}

.navbar nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  margin-left: 1.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

.navbar nav a:hover {
  color: var(--text);
}

.navbar nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  background: rgba(18, 18, 18, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 600;
  text-align: center;
}

.subhead {
  text-align: center;
  margin-top: 0.5rem;
  color: var(--text-muted);
}

form {
  margin-top: 2rem;
  display: grid;
  gap: 1.5rem;
}

.field-group {
  display: grid;
  gap: 0.75rem;
}

label {
  font-size: 0.95rem;
  font-weight: 500;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: var(--panel);
  color: var(--text);
  transition: border 0.2s ease, background 0.2s ease;
}

select:focus,
textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-alt);
}

.years-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.years-options label {
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  background: var(--panel);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.years-options input {
  margin-right: 0.4rem;
}

.years-options label:hover,
.years-options input:checked + span {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

button {
  padding: 0.85rem 1.8rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(74, 144, 226, 0.35);
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(74, 144, 226, 0.4);
  color: var(--accent);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--accent-muted);
  box-shadow: none;
}

.panels {
  margin-top: 2.5rem;
  display: grid;
  gap: 1.5rem;
}

.panel {
  background: rgba(28, 28, 28, 0.9);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1.5rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.download-btn:hover {
  background: #3a7ec8;
  box-shadow: 0 8px 20px rgba(74, 144, 226, 0.35);
}

.download-btn.small {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

.download-btn.disabled {
  pointer-events: none;
  opacity: 0.4;
  box-shadow: none;
}

.pdf-year {
  display: grid;
  gap: 0.6rem;
}

.pdf-year-heading {
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.pdf-list {
  display: grid;
  gap: 1rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.pdf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.pdf-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.35);
  background: rgba(74, 144, 226, 0.12);
}

.pdf-info {
  display: grid;
  gap: 0.25rem;
}

.pdf-info span:first-child {
  font-weight: 600;
}

.pdf-actions .btn-secondary,
.pdf-actions a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(74, 144, 226, 0.25);
  background: transparent;
}

.pdf-actions .btn-secondary:hover,
.pdf-actions a:hover {
  background: var(--accent-muted);
}

.messages {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.message {
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  font-size: 0.95rem;
}

.message.error {
  background: rgba(255, 77, 79, 0.12);
  border: 1px solid rgba(255, 77, 79, 0.25);
}

.message.warning {
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.25);
}

.message.success {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.helper-text {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

.helper-text.secondary-note {
  margin-top: 1rem;
  font-size: 0.85rem;
}

.error-text {
  color: #ff6b6b;
  margin: 0;
  font-size: 0.85rem;
}

.response-output {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-muted);
}

.history-panel {
  display: grid;
  gap: 1.2rem;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.history-item {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: grid;
  gap: 0.55rem;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-company {
  font-weight: 600;
  color: var(--text);
}

.history-prompt,
.history-response {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.history-prompt strong,
.history-response strong {
  color: var(--text);
}

.history-actions {
  margin-top: 0.4rem;
}

.history-actions .download-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(74, 144, 226, 0.4);
}

.history-actions .download-btn:hover {
  background: var(--accent-muted);
  box-shadow: none;
}

.history-grid {
  margin-top: 2rem;
  display: grid;
  gap: 1.5rem;
}

.history-card {
  background: rgba(18, 18, 18, 0.85);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.6rem;
  display: grid;
  gap: 1rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.history-card-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.history-card-header .history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history-card-actions {
  display: flex;
  gap: 0.75rem;
}

.history-card-body details {
  background: rgba(28, 28, 28, 0.9);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
}

.history-card-body summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.history-card-body summary::-webkit-details-marker {
  display: none;
}

.history-card-body summary:after {
  content: '▾';
  float: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.history-card-body details[open] summary:after {
  transform: rotate(180deg);
}

.history-card-body p {
  margin: 0.7rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.history-transcript-list {
  list-style: none;
  padding: 0;
  margin: 0.7rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.history-transcript-title {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.history-transcript-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

iframe.pdf-preview {
  width: 100%;
  min-height: 400px;
  border: none;
  border-radius: 12px;
  background: #fff;
}

@media (max-width: 768px) {
  body {
    padding: 1.5rem;
  }

  .shell {
    padding: 1.8rem;
  }

  button {
    width: 100%;
  }

  .actions {
    justify-content: stretch;
    flex-direction: column;
    gap: 0.5rem;
  }

  .history-meta {
    flex-direction: column;
    gap: 0.3rem;
  }

  .history-card-header {
    flex-direction: column;
    align-items: stretch;
  }
}
