/* =========================================================
   GLOBAL
========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --background: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;

  --text: #17201b;
  --text-secondary: #64736a;
  --text-muted: #8a968f;

  --primary: #166534;
  --primary-dark: #14532d;
  --primary-light: #dcfce7;

  --border: #dfe7e1;

  --danger: #b91c1c;
  --danger-bg: #fee2e2;

  --warning: #92400e;
  --warning-bg: #fef3c7;

  --success: #166534;
  --success-bg: #dcfce7;

  --blue: #2563eb;
  --blue-light: #dbeafe;

  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);

  --radius: 15px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  background: var(--background);

  color: var(--text);

  min-height: 100vh;

  line-height: 1.5;
}

/* =========================================================
   HEADER
========================================================= */

.site-header {
  background: white;

  border-bottom: 1px solid var(--border);

  position: sticky;

  top: 0;

  z-index: 100;
}

.header-container {
  max-width: 1180px;

  margin: auto;

  padding: 15px 24px;

  display: flex;

  justify-content: space-between;

  align-items: center;
}

.brand {
  display: flex;

  align-items: center;

  gap: 11px;
}

.brand-icon {
  width: 43px;

  height: 43px;

  border-radius: 12px;

  display: flex;

  align-items: center;

  justify-content: center;

  background: linear-gradient(135deg, #166534, #22c55e);

  font-size: 21px;
}

.brand-title {
  font-size: 17px;

  font-weight: 750;

  line-height: 1.1;
}

.brand-subtitle {
  color: var(--text-secondary);

  font-size: 11px;

  margin-top: 3px;
}

.header-badge {
  color: var(--primary-dark);

  background: var(--primary-light);

  border-radius: 999px;

  padding: 6px 11px;

  font-size: 10px;

  font-weight: 700;
}

/* =========================================================
   MAIN
========================================================= */

.container {
  max-width: 1180px;

  margin: auto;

  padding: 42px 24px 70px;
}

/* =========================================================
   HERO
========================================================= */

.hero {
  margin-bottom: 28px;
}

.hero-label {
  color: var(--primary);

  font-size: 10px;

  font-weight: 800;

  letter-spacing: 1.2px;

  margin-bottom: 8px;
}

.hero h1 {
  font-size: 38px;

  line-height: 1.15;

  letter-spacing: -1px;

  margin-bottom: 10px;
}

.hero p {
  max-width: 760px;

  color: var(--text-secondary);

  font-size: 14px;

  line-height: 1.7;
}

/* =========================================================
   GRID
========================================================= */

.main-grid {
  display: grid;

  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(320px, 0.65fr);

  gap: 22px;

  align-items: start;
}

/* =========================================================
   CARDS
========================================================= */

.card {
  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius);

  box-shadow: var(--shadow);

  padding: 25px;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 17px;

  line-height: 1.3;

  margin-bottom: 5px;
}

.card-header p {
  color: var(--text-secondary);

  font-size: 11px;
}

/* =========================================================
   DROP ZONE
========================================================= */

.drop-zone {
  position: relative;

  padding: 42px 20px;

  text-align: center;

  border: 2px dashed #cbd8cf;

  border-radius: 13px;

  background: var(--surface-soft);

  cursor: pointer;

  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.2s;
}

.drop-zone:hover {
  border-color: #4ade80;

  background: #f0fdf4;
}

.drop-zone.dragover {
  border-color: var(--primary);

  background: #ecfdf5;

  transform: scale(1.005);
}

.upload-icon {
  width: 58px;

  height: 58px;

  margin: 0 auto 14px;

  border-radius: 50%;

  background: var(--primary-light);

  color: var(--primary-dark);

  display: flex;

  align-items: center;

  justify-content: center;

  font-size: 25px;

  font-weight: 700;
}

.drop-zone h3 {
  font-size: 15px;

  margin-bottom: 4px;
}

.drop-zone p {
  color: var(--text-secondary);

  font-size: 12px;

  margin-bottom: 15px;
}

.upload-hint {
  color: var(--text-muted);

  font-size: 10px;

  margin-top: 13px;
}

#fileInput {
  position: absolute;

  width: 1px;

  height: 1px;

  opacity: 0;

  pointer-events: none;
}

/* =========================================================
   BUTTONS
========================================================= */

.browse-button {
  display: inline-block;

  padding: 9px 15px;

  border: 1px solid var(--border);

  border-radius: 8px;

  background: white;

  color: var(--text);

  font-size: 12px;

  font-weight: 700;

  cursor: pointer;

  transition:
    background 0.2s,
    border-color 0.2s;
}

.browse-button:hover {
  background: var(--primary-light);

  border-color: #86efac;
}

.primary-button {
  width: 100%;

  border: 0;

  border-radius: 10px;

  padding: 13px 18px;

  margin-top: 23px;

  background: var(--primary);

  color: white;

  font-size: 13px;

  font-weight: 750;

  cursor: pointer;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 9px;

  transition:
    background 0.2s,
    transform 0.1s;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.5;

  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid var(--border);

  background: white;

  color: var(--text);

  border-radius: 8px;

  padding: 8px 13px;

  font-size: 11px;

  font-weight: 700;

  cursor: pointer;

  transition:
    background 0.2s,
    border-color 0.2s;
}

.secondary-button:hover {
  background: var(--surface-soft);

  border-color: #aebdb3;
}

.text-button {
  border: 0;

  background: transparent;

  color: var(--primary);

  font-size: 10px;

  font-weight: 700;

  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

/* =========================================================
   FILE INFO
========================================================= */

.file-info {
  display: none;

  align-items: center;

  gap: 11px;

  margin-top: 13px;

  padding: 11px 12px;

  background: #f0fdf4;

  border: 1px solid #bbf7d0;

  border-radius: 9px;
}

.file-info.visible {
  display: flex;
}

.file-icon {
  flex-shrink: 0;

  width: 37px;

  height: 37px;

  border-radius: 8px;

  background: var(--primary);

  color: white;

  display: flex;

  align-items: center;

  justify-content: center;

  font-size: 9px;

  font-weight: 800;
}

.file-details {
  min-width: 0;

  flex: 1;
}

.file-name {
  font-size: 12px;

  font-weight: 700;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.file-size {
  color: var(--text-secondary);

  font-size: 10px;

  margin-top: 2px;
}

.remove-button {
  border: 0;

  background: transparent;

  color: var(--danger);

  font-size: 10px;

  font-weight: 700;

  cursor: pointer;
}

/* =========================================================
   FORM SECTION
========================================================= */

.form-section {
  margin-top: 25px;
}

.section-heading {
  display: flex;

  justify-content: space-between;

  align-items: flex-start;

  gap: 15px;

  margin-bottom: 11px;
}

.section-heading h3 {
  font-size: 13px;

  margin-bottom: 3px;
}

.section-heading p {
  color: var(--text-secondary);

  font-size: 10px;
}

/* =========================================================
   SPI SCALE CARDS
========================================================= */

.scale-grid {
  display: grid;

  grid-template-columns: repeat(4, 1fr);

  gap: 9px;
}

.scale-card {
  position: relative;

  cursor: pointer;
}

.scale-card input {
  position: absolute;

  opacity: 0;

  pointer-events: none;
}

.scale-content {
  min-height: 58px;

  border: 1px solid var(--border);

  border-radius: 9px;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  background: white;

  transition:
    background 0.2s,
    border-color 0.2s;
}

.scale-content strong {
  font-size: 12px;
}

.scale-content small {
  color: var(--text-muted);

  font-size: 9px;

  margin-top: 2px;
}

.scale-card:hover .scale-content {
  border-color: #86efac;
}

.scale-card input:checked + .scale-content {
  background: var(--primary-light);

  border-color: #4ade80;

  color: var(--primary-dark);
}

/* =========================================================
   STATUS
========================================================= */

.status {
  margin-top: 14px;

  padding: 11px 13px;

  border-radius: 9px;

  font-size: 11px;

  line-height: 1.5;
}

.status.success {
  color: var(--success);

  background: var(--success-bg);

  border: 1px solid #bbf7d0;
}

.status.warning {
  color: var(--warning);

  background: var(--warning-bg);

  border: 1px solid #fde68a;
}

.status.error {
  color: var(--danger);

  background: var(--danger-bg);

  border: 1px solid #fecaca;
}

.hidden {
  display: none !important;
}

/* =========================================================
   SPINNER
========================================================= */

.spinner {
  width: 14px;

  height: 14px;

  border: 2px solid rgba(255, 255, 255, 0.35);

  border-top-color: white;

  border-radius: 50%;

  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   METHOD
========================================================= */

.method-list {
  display: flex;

  flex-direction: column;

  gap: 17px;
}

.method-item {
  display: flex;

  align-items: flex-start;

  gap: 11px;
}

.method-number {
  flex-shrink: 0;

  width: 30px;

  height: 30px;

  border-radius: 8px;

  background: var(--primary-light);

  color: var(--primary-dark);

  display: flex;

  align-items: center;

  justify-content: center;

  font-size: 9px;

  font-weight: 800;
}

.method-item strong {
  display: block;

  font-size: 12px;

  margin-bottom: 3px;
}

.method-item p {
  color: var(--text-secondary);

  font-size: 10px;

  line-height: 1.55;
}

/* =========================================================
   PRIVACY
========================================================= */

.privacy-box {
  display: flex;

  gap: 10px;

  margin-top: 22px;

  padding: 12px;

  border-radius: 10px;

  background: #eff6ff;

  border: 1px solid #dbeafe;
}

.privacy-icon {
  font-size: 16px;
}

.privacy-box strong {
  display: block;

  color: #1e40af;

  font-size: 11px;

  margin-bottom: 3px;
}

.privacy-box p {
  color: #475569;

  font-size: 10px;

  line-height: 1.5;
}

/* =========================================================
   DATASET SUMMARY
========================================================= */

.dataset-card {
  margin-top: 22px;
}

.summary-grid {
  display: grid;

  grid-template-columns: repeat(5, 1fr);

  gap: 10px;
}

.summary-item {
  padding: 14px;

  border: 1px solid var(--border);

  border-radius: 10px;

  background: var(--surface-soft);
}

.summary-item span {
  display: block;

  color: var(--text-secondary);

  font-size: 10px;

  margin-bottom: 5px;
}

.summary-item strong {
  font-size: 15px;
}

/* =========================================================
   RESULTS
========================================================= */

.results-card {
  margin-top: 22px;
}

.results-header {
  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 20px;

  margin-bottom: 20px;
}

.results-header h2 {
  font-size: 17px;

  margin-bottom: 4px;
}

.results-header p {
  color: var(--text-secondary);

  font-size: 11px;
}

.results-actions {
  display: flex;

  gap: 8px;
}

/* =========================================================
   RESULT CLASSIFICATION
========================================================= */

.classification-grid {
  display: grid;

  grid-template-columns: repeat(7, 1fr);

  gap: 7px;

  margin-bottom: 24px;
}

.classification-card {
  padding: 11px 6px;

  text-align: center;

  border: 1px solid var(--border);

  border-radius: 9px;

  background: var(--surface-soft);
}

.classification-card .scale {
  display: block;

  font-size: 11px;

  font-weight: 800;

  margin-bottom: 3px;
}

.classification-card .value {
  display: block;

  font-size: 15px;

  font-weight: 800;

  margin-bottom: 2px;
}

.classification-card .label {
  display: block;

  color: var(--text-secondary);

  font-size: 8px;

  line-height: 1.3;
}

.classification-card.dry {
  background: #fff7ed;

  border-color: #fed7aa;
}

.classification-card.wet {
  background: #eff6ff;

  border-color: #bfdbfe;
}

.classification-card.normal {
  background: #f0fdf4;

  border-color: #bbf7d0;
}

/* =========================================================
   CHART
========================================================= */

.chart-container {
  padding: 17px;

  background: var(--surface-soft);

  border: 1px solid var(--border);

  border-radius: 12px;

  margin-bottom: 25px;
}

.chart-header {
  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 15px;

  margin-bottom: 13px;
}

.chart-header h3 {
  font-size: 13px;
}

.chart-select {
  padding: 6px 9px;

  border: 1px solid var(--border);

  border-radius: 7px;

  background: white;

  font-size: 11px;
}

.canvas-wrapper {
  width: 100%;

  overflow-x: auto;
}

#spiChart {
  display: block;

  width: 100%;

  min-width: 700px;

  height: 400px;
}

/* =========================================================
   TABLE
========================================================= */

.table-header {
  margin-bottom: 11px;
}

.table-header h3 {
  font-size: 13px;

  margin-bottom: 3px;
}

.table-header p {
  color: var(--text-secondary);

  font-size: 10px;
}

.table-wrapper {
  width: 100%;

  max-height: 500px;

  overflow: auto;

  border: 1px solid var(--border);

  border-radius: 10px;
}

table {
  width: 100%;

  border-collapse: collapse;

  font-size: 10px;
}

thead {
  position: sticky;

  top: 0;

  z-index: 2;
}

th {
  padding: 10px;

  text-align: left;

  white-space: nowrap;

  background: #f1f5f3;

  color: #475569;

  font-weight: 750;

  border-bottom: 1px solid var(--border);
}

td {
  padding: 9px 10px;

  white-space: nowrap;

  border-bottom: 1px solid #eef2ef;
}

tbody tr:hover {
  background: #f8fafc;
}

.spi-negative {
  color: #b91c1c;

  font-weight: 700;
}

.spi-positive {
  color: #166534;

  font-weight: 700;
}

/* =========================================================
   INTERPRETATION
========================================================= */

.interpretation-card {
  margin-top: 22px;
}

.classification-table {
  display: grid;

  grid-template-columns: repeat(7, 1fr);

  gap: 8px;
}

.classification-row {
  padding: 12px 7px;

  text-align: center;

  border: 1px solid var(--border);

  border-radius: 9px;

  background: var(--surface-soft);
}

.classification-row span {
  display: block;

  font-size: 10px;

  font-weight: 800;

  margin-bottom: 5px;
}

.classification-row strong {
  font-size: 9px;
}

.extreme-dry {
  color: #991b1b;
}

.severe-dry {
  color: #c2410c;
}

.moderate-dry {
  color: #b45309;
}

.normal {
  color: #166534;
}

.moderate-wet {
  color: #0369a1;
}

.very-wet {
  color: #1d4ed8;
}

.extreme-wet {
  color: #3730a3;
}

/* =========================================================
   FOOTER
========================================================= */

footer {
  background: white;

  border-top: 1px solid var(--border);
}

.footer-container {
  max-width: 1180px;

  margin: auto;

  padding: 20px 24px;

  display: flex;

  justify-content: space-between;

  gap: 20px;

  color: var(--text-secondary);

  font-size: 10px;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 950px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .classification-grid,
  .classification-table {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 650px) {
  .container {
    padding: 30px 15px 55px;
  }

  .header-container {
    padding: 13px 15px;
  }

  .header-badge {
    display: none;
  }

  .hero h1 {
    font-size: 29px;
  }

  .card {
    padding: 18px;
  }

  .scale-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .classification-grid,
  .classification-table {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-header {
    flex-direction: column;

    align-items: flex-start;
  }

  .results-actions {
    width: 100%;
  }

  .results-actions button {
    flex: 1;
  }

  .footer-container {
    flex-direction: column;

    text-align: center;
  }
}

@media (max-width: 420px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
