:root {
  --bg-color: #0b132b;
  --bg-dots: rgba(255, 255, 255, 0.05);
  --card-bg: rgba(255, 255, 255, 0.98);
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --text-main: #1c2536;
  --text-muted: #475467;
  --accent: #00bfa5;
  --accent-hover: #009688;
  --border-color: #eaecf0;
  --table-stripe: #f9fafb;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

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

::selection {
  background: var(--accent);
  color: white;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-color);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%2300bfa5' fill-opacity='0.04'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 50%, #0f1a3a 0%, var(--bg-color) 70%);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 2rem;
  text-align: center;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.header-motif {
  width: 48px;
  height: 36px;
  flex-shrink: 0;
  opacity: 0.8;
}

.header h2 {
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0;
  font-size: 2.5rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 0 20px rgba(0,191,165,0.15);
  position: relative;
  padding-bottom: 0.75rem;
}

.header h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
}

@media (max-width: 600px) {
  .header-motif { display: none; }
  .header h2 { font-size: 1.5rem; }
}

.app-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
  width: 100%;
}

@media (min-width: 1024px) {
  .app-container {
    grid-template-columns: 350px 1fr;
    align-items: start;
  }
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

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

label.control-label {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}

select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: white;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-main);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475467' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.1);
}

.results-panel {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-header {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  padding-left: 1rem;
  border-left: 4px solid var(--accent);
  margin-bottom: 1.5rem;
}

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

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--table-stripe);
}

tbody tr:nth-child(even) {
  background-color: var(--table-stripe);
}

/* Data values styling */
td:not(:first-child) {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-hover);
}

td:first-child {
  font-weight: 500;
  color: var(--text-main);
  width: 40%;
}

.upload-section {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.2s ease;
  background: var(--table-stripe);
  margin-bottom: 1rem;
}

.upload-section:hover {
  border-color: var(--accent);
  background: rgba(0, 191, 165, 0.04);
}

.upload-section.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(0, 191, 165, 0.08);
  box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.15);
  transform: scale(1.01);
}

.custom-file-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}

.custom-file-upload i {
  color: var(--accent);
  font-size: 1.25rem;
}

button[type="submit"], .download-btn {
  background-color: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button[type="submit"]:hover, .download-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.submit-container {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#response-message, #response-message-sfc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#file-name, #file-name-sfc {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.5rem;
}

.help-block {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: block;
}

.param-headings {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-main);
}

.param-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.footer-meta {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-meta strong {
  color: var(--text-main);
}

.footer-meta a {
  color: var(--accent-hover);
  text-decoration: none;
}

.footer-meta a:hover {
  text-decoration: underline;
}

.disclaimer {
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 2rem;
  padding: 1rem;
  background: var(--table-stripe);
  border-radius: 6px;
}

/* Calculate button */
#calc-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  margin-top: 0.5rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 191, 165, 0.35);
}

#calc-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 191, 165, 0.45);
}

#calc-btn:active:not(:disabled) {
  transform: translateY(0);
}

#calc-btn:disabled {
  background-color: #c8d0dc;
  box-shadow: none;
  cursor: not-allowed;
  color: #8a95a3;
}

#calc-btn.loading {
  background-color: var(--accent-hover);
  cursor: wait;
}

/* Results animation */
.shiny-html-output {
  transition: opacity 0.3s ease;
}

td:empty::after {
  content: "—";
  color: #a0aec0;
}
