:root {
      --bg: #0f172a;
      --text: #e5e7eb;
      --muted: #9ca3af;
      --accent: #22c55e;
      --accent2: #38bdf8;
      --border: rgba(255,255,255,0.12);
      --shadow: 0 20px 50px rgba(0,0,0,0.35);
      --panel: rgba(17,24,39,0.86);
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: Arial, Helvetica, sans-serif;
      background:
        radial-gradient(circle at top left, rgba(34,197,94,0.18), transparent 35%),
        radial-gradient(circle at top right, rgba(56,189,248,0.16), transparent 35%),
        var(--bg);
      color: var(--text);
    }

    .page {
      width: min(1250px, 94%);
      margin: 0 auto;
      padding: 34px 0 60px;
    }

    header {
      display: flex;
      justify-content: space-between;
      gap: 20px;
      align-items: center;
      margin-bottom: 28px;
    }

    .title h1 {
      margin: 0;
      font-size: clamp(28px, 4vw, 46px);
      letter-spacing: -1px;
    }

    .title p {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 16px;
    }

    .top-actions {
      display: flex;
      gap: 10px;
      align-items: center;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .badge,
    .help-btn,
    .link-btn {
      border-radius: 999px;
      padding: 10px 16px;
      font-weight: 700;
      white-space: nowrap;
    }

    .badge {
      border: 1px solid var(--border);
      color: var(--muted);
      background: rgba(255,255,255,0.04);
    }

    .link-btn {
      text-decoration: none;
      border: 1px solid rgba(34,197,94,0.35);
      background: rgba(34,197,94,0.12);
      color: var(--text);
      cursor: pointer;
      transition: 0.15s;
    }

    .help-btn {
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.08);
      color: var(--text);
      cursor: pointer;
      transition: 0.15s;
    }

    .link-btn:hover,
    .help-btn:hover,
    .btn:hover,
    .range-btn:hover {
      transform: translateY(-1px);
      filter: brightness(1.08);
    }

    .upload-card,
    .analysis-card,
    .table-card {
      background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
      border: 1px solid var(--border);
      border-radius: 24px;
      box-shadow: var(--shadow);
    }

    .upload-card {
      padding: 26px;
      margin-bottom: 24px;
    }

    .upload-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 14px;
      margin-bottom: 18px;
    }

    .upload-type {
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 20px;
      background: rgba(15,23,42,0.65);
      cursor: pointer;
      transition: 0.15s;
    }

    .upload-type:hover {
      transform: translateY(-2px);
      background: rgba(255,255,255,0.07);
      border-color: rgba(56,189,248,0.45);
    }

    .upload-type.active {
      border-color: var(--accent);
      background: rgba(34,197,94,0.12);
    }

    .upload-type h2 {
      margin: 0 0 8px;
      font-size: 20px;
    }

    .upload-type p {
      margin: 0;
      color: var(--muted);
      line-height: 1.45;
      font-size: 14px;
    }

    .dropzone {
      border: 2px dashed rgba(255,255,255,0.25);
      border-radius: 20px;
      padding: 34px 20px;
      text-align: center;
      background: rgba(15,23,42,0.55);
      transition: 0.2s;
      cursor: pointer;
    }

    .dropzone.dragover {
      border-color: var(--accent);
      background: rgba(34,197,94,0.09);
      transform: scale(1.01);
    }

    .dropzone h2 {
      margin: 0 0 8px;
      font-size: 24px;
    }

    .dropzone p {
      margin: 0 0 18px;
      color: var(--muted);
    }

    input[type="file"] {
      display: none;
    }

    .btn {
      border: none;
      border-radius: 12px;
      padding: 12px 18px;
      font-weight: 700;
      cursor: pointer;
      color: #041014;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
      transition: 0.15s;
    }

    .btn.secondary {
      background: rgba(255,255,255,0.08);
      color: var(--text);
      border: 1px solid var(--border);
    }

    .status {
      margin-top: 14px;
      color: var(--muted);
      font-size: 14px;
    }

    .error {
      color: #fecaca;
      background: rgba(239,68,68,0.12);
      border: 1px solid rgba(239,68,68,0.35);
      padding: 12px 14px;
      border-radius: 12px;
      margin-top: 14px;
      display: none;
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 14px;
      margin: 22px 0;
    }

    .stat {
      background: rgba(255,255,255,0.06);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 18px;
    }

    .stat span {
      display: block;
      color: var(--muted);
      font-size: 13px;
      margin-bottom: 8px;
    }

    .stat strong {
      font-size: 24px;
    }

    .analysis-section {
      display: none;
      margin: 24px 0;
    }

    .analysis-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 18px;
    }

    .analysis-card {
      padding: 22px;
      background: var(--panel);
    }

    .analysis-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      flex-wrap: wrap;
      margin-bottom: 16px;
    }

    .analysis-head h2 {
      margin: 0;
      font-size: 24px;
    }

    .analysis-head p {
      margin: 5px 0 0;
      color: var(--muted);
    }

    .chart-wrap {
      height: 380px;
      position: relative;
    }

    .station-select,
    .day-input {
      min-width: 220px;
      padding: 12px 14px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.07);
      color: var(--text);
      outline: none;
    }

    .station-select option {
      background: #111827;
      color: var(--text);
    }

    .range-buttons {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
      margin: 12px 0 18px;
    }

    .range-btn {
      border: 1px solid var(--border);
      border-radius: 999px;
      padding: 9px 13px;
      background: rgba(255,255,255,0.08);
      color: var(--text);
      cursor: pointer;
      font-weight: 700;
      transition: 0.15s;
    }

    .range-btn.active {
      background: rgba(34,197,94,0.20);
      border-color: var(--accent);
      color: #bbf7d0;
    }

    .selected-station-info {
      color: var(--muted);
      margin-top: -5px;
      margin-bottom: 10px;
    }

    .toolbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 14px;
      margin: 24px 0 14px;
      flex-wrap: wrap;
    }

    .toolbar-buttons {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .search {
      flex: 1;
      min-width: 240px;
      padding: 13px 15px;
      border-radius: 12px;
      border: 1px solid var(--border);
      outline: none;
      background: rgba(255,255,255,0.07);
      color: var(--text);
      font-size: 15px;
    }

    .search::placeholder {
      color: var(--muted);
    }

    .table-card {
      overflow: hidden;
      background: rgba(17,24,39,0.82);
    }

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

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 760px;
    }

    thead {
      background: rgba(255,255,255,0.08);
    }

    th, td {
      text-align: left;
      padding: 15px 16px;
      border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    th {
      color: var(--muted);
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    tbody tr:hover {
      background: rgba(255,255,255,0.05);
    }

    .sortable {
      cursor: pointer;
      user-select: none;
      transition: 0.15s;
    }

    .sortable:hover {
      color: var(--accent2);
      background: rgba(56,189,248,0.08);
    }

    .sortable span {
      color: var(--accent);
      margin-left: 6px;
      font-weight: 900;
    }

    .clickable-row {
      cursor: pointer;
    }

    .clickable-row:hover {
      background: rgba(34,197,94,0.12) !important;
    }

    .rank {
      font-weight: 800;
      color: var(--accent2);
      width: 90px;
      white-space: nowrap;
    }

    .station {
      font-weight: 700;
    }

    .number,
    .type {
      color: var(--muted);
      white-space: nowrap;
    }

    .amount {
      font-weight: 800;
      color: var(--accent);
      text-align: right;
      white-space: nowrap;
    }

    .empty {
      text-align: center;
      color: var(--muted);
      padding: 30px;
    }

    details.expand-box {
      border-radius: 24px;
      overflow: hidden;
    }

    details.expand-box summary {
      list-style: none;
      cursor: pointer;
      padding: 20px 22px;
      background: rgba(255,255,255,0.06);
      border-bottom: 1px solid var(--border);
    }

    details.expand-box summary::-webkit-details-marker {
      display: none;
    }

    .summary-row {
      display: flex;
      justify-content: space-between;
      gap: 14px;
      align-items: center;
      flex-wrap: wrap;
    }

    .summary-row h2 {
      margin: 0;
      font-size: 24px;
    }

    .summary-row p {
      margin: 5px 0 0;
      color: var(--muted);
    }

    .expand-icon {
      font-weight: 900;
      color: var(--accent2);
    }

    details[open] .expand-icon {
      color: var(--accent);
    }

    .top-days-content {
      padding: 18px 22px 22px;
    }

    .help-modal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: rgba(2,6,23,0.78);
      backdrop-filter: blur(8px);
      padding: 20px;
      overflow-y: auto;
    }

    .help-modal.show {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .help-box {
      width: min(900px, 96vw);
      max-height: 92vh;
      overflow-y: auto;
      background: linear-gradient(180deg, #111827, #0f172a);
      border: 1px solid var(--border);
      border-radius: 24px;
      padding: 28px;
      box-shadow: 0 30px 80px rgba(0,0,0,0.55);
      position: relative;
    }

    .help-box h2 {
      margin: 0 0 14px;
      font-size: 28px;
    }

    .help-box p,
    .help-box li {
      color: var(--muted);
      line-height: 1.6;
    }

    .help-close {
      position: absolute;
      top: 16px;
      right: 18px;
      width: 38px;
      height: 38px;
      border: 1px solid var(--border);
      border-radius: 50%;
      background: rgba(255,255,255,0.08);
      color: var(--text);
      font-size: 24px;
      cursor: pointer;
      line-height: 34px;
    }

    .meter-box {
      margin-top: 16px;
      padding: 16px;
      border: 1px solid rgba(255,255,255,0.10);
      border-radius: 18px;
      background: rgba(255,255,255,0.04);
    }

    .code-label {
      margin-top: 18px;
      margin-bottom: 8px;
      color: var(--muted);
      font-weight: 700;
    }

    .help-code {
      background: #020617;
      color: #86efac;
      border: 1px solid rgba(34,197,94,0.35);
      border-radius: 14px;
      padding: 16px;
      overflow-x: auto;
      font-size: 14px;
      line-height: 1.5;
      white-space: pre;
    }

    .copy-btn {
      margin-top: 10px;
      border: none;
      border-radius: 12px;
      padding: 12px 18px;
      font-weight: 800;
      cursor: pointer;
      color: #041014;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
    }

    .copy-status {
      margin-top: 10px;
      color: var(--accent);
      font-weight: 700;
      min-height: 20px;
    }

    .help-note {
      margin-top: 20px;
      padding: 14px;
      border-radius: 14px;
      background: rgba(56,189,248,0.10);
      border: 1px solid rgba(56,189,248,0.25);
      color: var(--text);
      line-height: 1.5;
    }

    @media (max-width: 850px) {
      header {
        flex-direction: column;
        align-items: flex-start;
      }

      .top-actions {
        justify-content: flex-start;
      }

      .upload-grid {
        grid-template-columns: 1fr;
      }

      .stats {
        grid-template-columns: repeat(2, 1fr);
      }

      .chart-wrap {
        height: 320px;
      }
    }

    @media (max-width: 560px) {
      .page {
        width: 94%;
        padding-top: 22px;
      }

      .upload-card,
      .analysis-card {
        padding: 18px;
      }

      .dropzone {
        padding: 26px 14px;
      }

      .stats {
        grid-template-columns: 1fr;
      }

      .stat strong {
        font-size: 22px;
      }

      .toolbar-buttons {
        width: 100%;
      }

      .toolbar-buttons .btn {
        flex: 1;
      }

      .chart-wrap {
        height: 280px;
      }

      .help-box {
        padding: 22px 18px;
      }

      .help-box h2 {
        font-size: 22px;
        padding-right: 38px;
      }

      .help-code {
        font-size: 12px;
      }
    }


.compare-card {
  margin-top: 24px;
}

.compare-title-head {
  margin-bottom: 16px;
}

.compare-upload-grid,
.compare-chart-grid,
.compare-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.compare-upload-box {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: rgba(15,23,42,0.55);
}

.compare-upload-box h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.compare-upload-box p,
.compare-help-text {
  color: var(--muted);
  line-height: 1.5;
}

.compare-selector-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.compare-selector-grid .station-select {
  width: 100%;
}

.compare-search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  outline: none;
  font-size: 15px;
}

.compare-search::placeholder {
  color: var(--muted);
}

.compare-search:focus {
  border-color: rgba(56,189,248,0.65);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.12);
}

.compare-search-info {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.compare-help-text {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(56,189,248,0.10);
  border: 1px solid rgba(56,189,248,0.22);
}

@media (max-width: 850px) {
  .compare-upload-grid,
  .compare-chart-grid,
  .compare-selector-grid {
    grid-template-columns: 1fr;
  }
}


.days-slider-box {
  margin: -4px 0 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.045);
}

.days-slider-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 14px;
}

.days-slider-head strong {
  color: var(--accent);
  font-size: 18px;
}

.days-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.days-slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}


.compare-range-info {
  margin: 10px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(56,189,248,0.08);
  color: var(--muted);
  font-size: 14px;
}


.compare-range-panel {
  margin-top: 18px;
}


.exclude-last-day {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.exclude-last-day input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}


.station-picker-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: min(420px, 100%);
}

.station-picker-box .station-select {
  min-width: min(320px, 100%);
}


@media (min-width: 851px) {
  .upload-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}


.compare-chart-grid .chart-wrap,
#compareSection .chart-wrap {
  min-height: 360px;
}


.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.compare-chart-grid .chart-wrap,
#compareSection .chart-wrap {
  height: 380px;
  min-height: 380px;
}

/* Trendfärger:
   Vatten = blå
   Avlopp = röd
   Driftstid = orange
   Medelvärde = rosa
*/


.station-nav-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.station-nav-row .station-select {
  flex: 1 1 280px;
}

.station-nav-btn {
  white-space: nowrap;
}

.keyboard-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  display: block;
}


.extra-threshold-info {
  margin: 12px 0;
}

.warning-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  margin: 2px;
}

.extra-analysis-grid table th,
.extra-analysis-grid table td,
#suspiciousStationsBody td,
#abnormalDaysBody td,
#dayChangesBody td {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .warning-pill {
    font-size: 11px;
    padding: 3px 6px;
  }
}


.extra-analysis-section {
  display: none;
}

.extra-analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.extra-threshold-info {
  margin: 12px 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(56,189,248,0.08);
  border: 1px solid rgba(56,189,248,0.20);
}

.warning-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  margin: 2px;
}

.extra-analysis-grid table th,
.extra-analysis-grid table td,
#suspiciousStationsBody td,
#abnormalDaysBody td,
#dayChangesBody td,
#rainRelationBody td {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .warning-pill {
    font-size: 11px;
    padding: 3px 6px;
  }
}


.extra-analysis-section {
  display: none;
}

.extra-analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.suspicious-card {
  border-color: rgba(245, 158, 11, 0.35);
}

.extra-threshold-info {
  margin: 12px 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(56,189,248,0.08);
  border: 1px solid rgba(56,189,248,0.20);
}

.warning-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  margin: 2px;
}

.extra-analysis-grid table th,
.extra-analysis-grid table td,
#suspiciousStationsBody td,
#abnormalDaysBody td,
#dayChangesBody td,
#rainRelationBody td {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .warning-pill {
    font-size: 11px;
    padding: 3px 6px;
  }
}


/* Enklare layout för analys:
   - Trendrutorna lägger sig 2 bredvid varandra på PC
   - Extra analys lägger sig 2 bredvid varandra
   - Snabbnavigering ligger kvar uppe när man scrollar
*/
.analysis-quick-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0 18px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(15,23,42,0.92);
  backdrop-filter: blur(10px);
}

.chart-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

@media (min-width: 1050px) {
  #analysisSection .analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  #analysisSection .analysis-grid > .analysis-card {
    min-width: 0;
  }

  #stationAnalysisCard {
    grid-column: span 1;
  }

  #topDaysDetails {
    grid-column: span 2;
  }

  #extraAnalysisSection .extra-analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  #extraAnalysisSection .suspicious-card {
    grid-column: span 2;
  }

  #compareSection .compare-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.82);
  backdrop-filter: blur(8px);
  padding: 18px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1500px, 98vw);
  height: min(900px, 92vh);
  background: linear-gradient(180deg, #111827, #0f172a);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.65);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.chart-fullscreen-head h2 {
  margin: 0;
}

.chart-fullscreen-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

.chart-fullscreen-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 1049px) {
  .analysis-quick-nav {
    position: static;
  }
}


.chart-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.86);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1600px, 98vw);
  height: min(980px, 94vh);
  background: linear-gradient(180deg, #111827, #0f172a);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.chart-fullscreen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.chart-fullscreen-head h2 {
  margin: 0;
}

.chart-fullscreen-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chart-fullscreen-actions .help-close {
  position: static;
  flex: 0 0 auto;
}

.chart-fullscreen-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

.chart-fullscreen-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}


/* Visningslägen:
   Kompakt text = mer information syns utan scroll.
   Större rutor = grafer och tabellrutor blir högre.
*/
.layout-control-separator {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
}

body.compact-ui {
  font-size: 13px;
}

body.compact-ui .analysis-card,
body.compact-ui .upload-card,
body.compact-ui .stat {
  padding: 14px;
  border-radius: 16px;
}

body.compact-ui .analysis-head {
  margin-bottom: 10px;
  gap: 8px;
}

body.compact-ui .analysis-head h2,
body.compact-ui .summary-row h2 {
  font-size: 18px;
}

body.compact-ui .analysis-head p,
body.compact-ui .summary-row p,
body.compact-ui .status,
body.compact-ui .selected-station-info,
body.compact-ui .compare-help-text,
body.compact-ui .help-note {
  font-size: 12px;
}

body.compact-ui th,
body.compact-ui td {
  padding: 8px 9px;
  font-size: 12px;
}

body.compact-ui .btn,
body.compact-ui .range-btn,
body.compact-ui .station-select,
body.compact-ui .day-input,
body.compact-ui .compare-search,
body.compact-ui .search {
  padding: 8px 10px;
  font-size: 12px;
}

body.compact-ui .chart-wrap {
  height: 300px;
}

body.compact-ui .warning-pill {
  font-size: 10px;
  padding: 2px 5px;
}

body.large-ui .analysis-card,
body.large-ui .upload-card {
  padding: 28px;
}

body.large-ui .chart-wrap {
  height: 560px;
}

body.large-ui .analysis-head h2,
body.large-ui .summary-row h2 {
  font-size: 28px;
}

body.large-ui th,
body.large-ui td {
  padding: 18px 18px;
  font-size: 15px;
}

.analysis-card,
.upload-card,
details.expand-box {
  position: relative;
}

.card-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(15,23,42,0.88);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  opacity: 0.55;
  transition: 0.15s;
}

.card-expand-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
}

body.compact-ui .card-expand-btn {
  font-size: 10px;
  padding: 4px 7px;
}

.card-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(2,6,23,0.86);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.card-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-fullscreen-box {
  width: min(1500px, 98vw);
  height: min(950px, 94vh);
  background: linear-gradient(180deg, #111827, #0f172a);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.72);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.card-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.card-fullscreen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border);
}

.card-fullscreen-head h2 {
  margin: 0;
}

.card-fullscreen-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-top: 14px;
}

.card-fullscreen-content .analysis-card,
.card-fullscreen-content .upload-card,
.card-fullscreen-content details.expand-box {
  box-shadow: none;
  border-radius: 18px;
}

.card-fullscreen-content th,
.card-fullscreen-content td {
  font-size: 15px;
  padding: 14px 16px;
}

.card-fullscreen-content table {
  min-width: 900px;
}

.card-modal-note {
  padding: 30px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .layout-control-separator {
    display: none;
  }

  .card-expand-btn {
    opacity: 0.9;
  }

  .card-fullscreen-box {
    width: 98vw;
    height: 94vh;
    padding: 12px;
  }
}


/* Slutfix: stora trendfönster + regn i mm */
.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.86);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1650px, 98vw);
  height: min(1000px, 95vh);
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.chart-fullscreen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.chart-fullscreen-head h2 {
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}

.chart-fullscreen-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chart-fullscreen-actions .help-close {
  position: static;
  flex: 0 0 auto;
}

.chart-fullscreen-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #0f172a;
}

.chart-fullscreen-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}


/* Robust större trendfönster */
.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.86);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1650px, 98vw);
  height: min(1000px, 95vh);
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.chart-fullscreen-head {
  flex: 0 0 auto;
}

.chart-fullscreen-wrap {
  flex: 1 1 auto;
  min-height: 500px;
  height: 100%;
  position: relative;
  background: #0f172a;
}

.chart-fullscreen-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}


/* Slutlig större-graf-fix:
   Originalcanvasen flyttas till stort läge och tillbaka. Därför blir grafen inte tom.
*/
.chart-fullscreen-wrap {
  flex: 1 1 auto;
  min-height: 520px;
  height: 100%;
  position: relative;
  background: #0f172a;
}

.chart-fullscreen-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-placeholder {
  width: 100%;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(15,23,42,0.35);
}


/* SLUTLIG FIX: stabil stor trend som bild */
.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.88);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1700px, 98vw);
  height: min(1000px, 95vh);
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.chart-fullscreen-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.chart-fullscreen-head h2 {
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}

.chart-fullscreen-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chart-fullscreen-actions .help-close {
  position: static;
  flex: 0 0 auto;
}

.chart-fullscreen-wrap.image-mode {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 18px;
}

#chartFullscreenImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
}


/* FIX: stor trend visas som stor bild av befintlig graf */
.chart-fullscreen-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2,6,23,0.88);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.chart-fullscreen-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-fullscreen-box {
  width: min(1700px, 98vw);
  height: min(1000px, 95vh);
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 22px;
  background: #0f172a;
}

.chart-fullscreen-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
}

.chart-fullscreen-head h2 {
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}

.chart-fullscreen-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chart-fullscreen-actions .help-close {
  position: static;
  flex: 0 0 auto;
}

.chart-fullscreen-wrap.image-mode {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 18px;
}

#chartFullscreenImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
}


/* SLUTFIX STOR TREND:
   Bilden fyller hela modalytan. X-knappen ligger överst och går att klicka.
*/
body.modal-open {
  overflow: hidden;
}

.chart-fullscreen-modal {
  display: none !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  background: rgba(2,6,23,0.90) !important;
  backdrop-filter: blur(8px);
  padding: 14px !important;
}

.chart-fullscreen-modal.show {
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
}

.chart-fullscreen-box {
  width: min(1800px, 98vw) !important;
  height: min(1050px, 96vh) !important;
  background: #0f172a !important;
  border: 1px solid var(--border) !important;
  border-radius: 24px !important;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75) !important;
  padding: 18px !important;
  display: flex !important;
  flex-direction: column !important;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  padding: 22px !important;
  background: #0f172a !important;
}

.chart-fullscreen-head {
  flex: 0 0 auto !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 0 4px 12px !important;
  z-index: 2 !important;
}

.chart-fullscreen-head h2 {
  margin: 0 !important;
  line-height: 1.25 !important;
  word-break: break-word !important;
}

.chart-fullscreen-actions {
  display: flex !important;
  gap: 10px !important;
  align-items: center !important;
  position: relative !important;
  z-index: 3 !important;
}

.chart-fullscreen-actions .help-close {
  position: static !important;
  flex: 0 0 auto !important;
  width: 42px !important;
  height: 42px !important;
  line-height: 36px !important;
  z-index: 4 !important;
  pointer-events: auto !important;
}

.chart-fullscreen-wrap.image-mode {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: auto !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  background: #0f172a !important;
  border-radius: 18px !important;
}

#chartFullscreenImage {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  border-radius: 12px !important;
  display: block !important;
}


/* SLUTFIX: stor trend ritas som riktig Chart.js-graf i stor canvas */
body.modal-open {
  overflow: hidden;
}

.chart-fullscreen-modal {
  display: none !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  background: rgba(2,6,23,0.90) !important;
  backdrop-filter: blur(8px);
  padding: 14px !important;
}

.chart-fullscreen-modal.show {
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
}

.chart-fullscreen-box {
  width: min(1800px, 98vw) !important;
  height: min(1050px, 96vh) !important;
  background: #0f172a !important;
  border: 1px solid var(--border) !important;
  border-radius: 24px !important;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75) !important;
  padding: 18px !important;
  display: flex !important;
  flex-direction: column !important;
}

.chart-fullscreen-box:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  padding: 22px !important;
  background: #0f172a !important;
}

.chart-fullscreen-head {
  flex: 0 0 auto !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 0 4px 12px !important;
  z-index: 2 !important;
}

.chart-fullscreen-head h2 {
  margin: 0 !important;
  line-height: 1.25 !important;
  word-break: break-word !important;
}

.chart-fullscreen-actions {
  display: flex !important;
  gap: 10px !important;
  align-items: center !important;
  position: relative !important;
  z-index: 3 !important;
}

.chart-fullscreen-actions .help-close {
  position: static !important;
  flex: 0 0 auto !important;
  width: 42px !important;
  height: 42px !important;
  line-height: 36px !important;
  z-index: 4 !important;
  pointer-events: auto !important;
}

.chart-fullscreen-wrap.canvas-mode {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  overflow: hidden !important;
  background: #0f172a !important;
  border-radius: 18px !important;
}

#chartFullscreenCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}


/* =========================================================
   ENKLARE NAVIGERING – endast layout, inga analysfunktioner ändras
   ========================================================= */
.workspace-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 8000;
  margin: 0 0 18px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 34px rgba(0,0,0,0.28);
}

.workspace-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.workspace-tab {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.055);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: 0.16s ease;
}

.workspace-tab:hover {
  background: rgba(56,189,248,0.11);
  border-color: rgba(56,189,248,0.42);
}

.workspace-tab.active {
  color: #dcfce7;
  border-color: rgba(34,197,94,0.8);
  background: linear-gradient(135deg, rgba(34,197,94,0.24), rgba(56,189,248,0.13));
  box-shadow: inset 0 0 0 1px rgba(34,197,94,0.12);
}

.workspace-tab .workspace-tab-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.workspace-tab.active .workspace-tab-sub {
  color: #bbf7d0;
}

.workspace-hidden {
  display: none !important;
}

/* Resultatöversikten hålls kompakt och synlig i analys/listvy. */
#resultSection.workspace-result-active > .stats {
  margin-top: 4px;
  margin-bottom: 12px;
}

#resultSection.workspace-result-active > .stats .stat {
  padding: 13px 15px;
}

#resultSection.workspace-result-active > .stats .stat strong {
  font-size: 20px;
}

/* Mindre luft mellan stora block minskar scroll utan att ändra innehåll. */
body.workspace-compact-flow .upload-card,
body.workspace-compact-flow .analysis-card {
  margin-bottom: 14px;
}

body.workspace-compact-flow .analysis-section {
  margin-top: 14px;
  margin-bottom: 14px;
}

body.workspace-compact-flow .analysis-grid,
body.workspace-compact-flow .extra-analysis-grid {
  gap: 14px;
}

/* Tabellvyn använder tillgänglig skärmhöjd och får egen scroll. */
body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) {
  max-height: calc(100vh - 275px);
  overflow: hidden;
}

body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) .table-scroll {
  max-height: calc(100vh - 275px);
  overflow: auto;
}

body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* Snabbknapp tillbaka till sidans topp. */
.workspace-top-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 8100;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(56,189,248,0.45);
  border-radius: 50%;
  background: rgba(15,23,42,0.92);
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.16s ease;
}

.workspace-top-button.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .workspace-nav-wrap {
    top: 0;
    padding: 8px;
    border-radius: 14px;
  }

  .workspace-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-tab {
    min-height: 42px;
    padding: 8px 9px;
    font-size: 13px;
  }

  .workspace-tab-sub {
    display: none !important;
  }

  body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden),
  body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) .table-scroll {
    max-height: calc(100vh - 235px);
  }
}

/* ============================================================
   COMSEL ANALYSCENTER – DASHBOARD REDESIGN
   Endast layout och utseende. Befintliga ID:n, funktioner,
   händelser, grafer och analyslogik påverkas inte.
   ============================================================ */

:root {
  --bg: #07111f;
  --bg-soft: #0b1728;
  --panel: #101e31;
  --panel-2: #13243a;
  --panel-3: #172b43;
  --text: #f4f7fb;
  --muted: #91a2b8;
  --accent: #35d07f;
  --accent2: #4bb9ff;
  --accent3: #a78bfa;
  --warning: #f6b84a;
  --danger: #ff6b78;
  --border: rgba(151, 173, 202, 0.16);
  --border-strong: rgba(151, 173, 202, 0.28);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
  --sidebar-width: 268px;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #38506b #0a1422;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0a1422;
}

*::-webkit-scrollbar-thumb {
  background: #38506b;
  border: 2px solid #0a1422;
  border-radius: 999px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(75, 185, 255, 0.12), transparent 34%),
    radial-gradient(circle at 20% 100%, rgba(53, 208, 127, 0.08), transparent 30%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 32px 32px;
}

.page {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 28px 32px 72px calc(var(--sidebar-width) + 36px);
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */

header {
  min-height: 94px;
  margin: 0 0 24px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(75,185,255,0.09), transparent 42%),
    rgba(12, 27, 45, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.title {
  position: relative;
  padding-left: 54px;
}

.title::before {
  content: "C";
  position: absolute;
  left: 0;
  top: 50%;
  width: 40px;
  height: 40px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #06111d;
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px rgba(53,208,127,0.23);
}

.title h1 {
  margin: 0;
  font-size: clamp(25px, 2.7vw, 38px);
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.title p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.badge,
.help-btn,
.link-btn {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 750;
  white-space: nowrap;
}

.badge {
  color: #b8f7d1;
  border: 1px solid rgba(53,208,127,0.26);
  background: rgba(53,208,127,0.09);
  font-size: 13px;
}

.help-btn,
.link-btn {
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
}

/* ---------- Permanent desktop sidebar ---------- */

.workspace-nav-wrap {
  position: fixed;
  z-index: 1200;
  left: 18px;
  top: 18px;
  bottom: 18px;
  width: calc(var(--sidebar-width) - 18px);
  margin: 0;
  padding: 18px 14px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(75,185,255,0.08), transparent 26%),
    rgba(8, 20, 35, 0.97);
  box-shadow: 0 22px 50px rgba(0,0,0,0.36);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.workspace-nav-wrap::before {
  content: "COMSEL";
  display: block;
  margin: 4px 8px 20px;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.workspace-nav-wrap::after {
  content: "Analyscenter";
  position: absolute;
  left: 23px;
  top: 51px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 22px;
}

.workspace-tab {
  width: 100%;
  min-height: 64px;
  padding: 13px 14px 13px 48px;
  position: relative;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #c9d5e4;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: 160ms ease;
}

.workspace-tab:nth-child(1)::before { content: "↥"; }
.workspace-tab:nth-child(2)::before { content: "⌁"; }
.workspace-tab:nth-child(3)::before { content: "⇄"; }
.workspace-tab:nth-child(4)::before { content: "≡"; }

.workspace-tab::before {
  position: absolute;
  left: 14px;
  top: 15px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,0.045);
  font-size: 17px;
}

.workspace-tab:hover {
  transform: none;
  border-color: var(--border);
  color: var(--text);
  background: rgba(255,255,255,0.045);
}

.workspace-tab.active {
  color: #fff;
  border-color: rgba(75,185,255,0.28);
  background:
    linear-gradient(90deg, rgba(75,185,255,0.16), rgba(53,208,127,0.07));
  box-shadow: inset 3px 0 0 var(--accent2);
}

.workspace-tab.active::before {
  color: #07111f;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
}

.workspace-tab-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ---------- General panels ---------- */

.upload-card,
.analysis-card,
.table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: rgba(15, 30, 49, 0.92);
  box-shadow: var(--shadow);
}

.upload-card {
  padding: 22px;
  margin: 0 0 20px;
}

.analysis-card {
  padding: 20px;
  background: rgba(15, 30, 49, 0.94);
}

.analysis-section {
  margin: 0;
}

.analysis-grid,
.extra-analysis-grid {
  gap: 16px;
}

/* ---------- Upload view ---------- */

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.upload-type {
  min-height: 126px;
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel-2);
  cursor: pointer;
  transition: 160ms ease;
}

.upload-type::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -30px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(75,185,255,0.07);
}

.upload-type:nth-child(2)::after { background: rgba(53,208,127,0.08); }
.upload-type:nth-child(3)::after { background: rgba(246,184,74,0.09); }

.upload-type:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--panel-3);
}

.upload-type.active {
  border-color: rgba(53,208,127,0.55);
  background:
    linear-gradient(130deg, rgba(53,208,127,0.13), transparent 65%),
    var(--panel-2);
  box-shadow: inset 0 0 0 1px rgba(53,208,127,0.08);
}

.upload-type.active::before {
  content: "VALD";
  position: absolute;
  top: 12px;
  right: 12px;
  color: #a9f3c5;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.upload-type h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.upload-type p {
  max-width: 90%;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.dropzone {
  min-height: 180px;
  padding: 34px 22px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px dashed rgba(75,185,255,0.42);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(75,185,255,0.07), rgba(53,208,127,0.045)),
    rgba(7,17,31,0.42);
}

.dropzone:hover,
.dropzone.dragover {
  transform: none;
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(75,185,255,0.11), rgba(53,208,127,0.08)),
    rgba(7,17,31,0.52);
}

.dropzone h2 {
  margin: 0 0 7px;
  font-size: 21px;
}

.dropzone p {
  margin: 0 0 16px;
  color: var(--muted);
}

/* ---------- Buttons and inputs ---------- */

.btn,
.copy-btn {
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  color: #04131f;
  background: linear-gradient(135deg, var(--accent), #58e39a);
  box-shadow: 0 7px 18px rgba(53,208,127,0.16);
  font-weight: 850;
  cursor: pointer;
  transition: 150ms ease;
}

.btn:hover,
.copy-btn:hover,
.range-btn:hover,
.help-btn:hover,
.link-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn.secondary {
  color: #dce7f4;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  box-shadow: none;
}

.search,
.compare-search,
.station-select,
.day-input {
  min-height: 43px;
  padding: 10px 13px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  background: #0c1a2c;
}

.search:focus,
.compare-search:focus,
.station-select:focus,
.day-input:focus {
  border-color: rgba(75,185,255,0.7);
  box-shadow: 0 0 0 3px rgba(75,185,255,0.12);
}

.station-select option {
  background: #0c1a2c;
}

.status,
.compare-search-info,
.keyboard-hint,
.selected-station-info {
  color: var(--muted);
}

.error {
  border-color: rgba(255,107,120,0.34);
  background: rgba(255,107,120,0.1);
}

/* ---------- KPI cards ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.stat {
  min-height: 104px;
  padding: 17px 18px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(140deg, rgba(75,185,255,0.07), transparent 62%),
    var(--panel);
}

.stat::after {
  content: "";
  position: absolute;
  width: 56px;
  height: 56px;
  right: -17px;
  top: -17px;
  border-radius: 50%;
  background: rgba(75,185,255,0.12);
}

.stat:nth-child(2)::after { background: rgba(53,208,127,0.12); }
.stat:nth-child(3)::after { background: rgba(167,139,250,0.13); }
.stat:nth-child(4)::after { background: rgba(246,184,74,0.13); }

.stat span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.stat strong {
  color: var(--text);
  font-size: clamp(18px, 2vw, 26px);
  letter-spacing: -0.025em;
}

/* ---------- Section heads / compact controls ---------- */

.analysis-head {
  margin-bottom: 15px;
  align-items: flex-start;
}

.analysis-head h2,
.summary-row h2 {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.analysis-head p,
.summary-row p {
  font-size: 13px;
  line-height: 1.5;
}

.analysis-quick-nav {
  position: sticky;
  top: 12px;
  z-index: 800;
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(8, 20, 35, 0.92);
  box-shadow: 0 12px 28px rgba(0,0,0,.24);
  backdrop-filter: blur(15px);
}

.range-buttons {
  gap: 7px;
  margin: 11px 0 14px;
}

.range-btn {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: #d8e3f0;
  background: #122238;
  font-size: 12px;
  font-weight: 800;
}

.range-btn.active {
  color: #07111f;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent2), #78d0ff);
}

.layout-control-separator {
  width: 1px;
  height: 25px;
  margin: 0 3px;
  background: var(--border-strong);
}

.chart-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* ---------- Charts ---------- */

.chart-wrap {
  height: 360px;
  padding: 10px;
  border: 1px solid rgba(151,173,202,0.10);
  border-radius: 14px;
  background: #0a1728;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.compare-chart-grid {
  gap: 16px;
}

.compare-chart-grid .chart-wrap,
#compareSection .chart-wrap {
  height: 350px;
  min-height: 350px;
}

.days-slider-box,
.date-range-slider-box,
.compare-range-info,
.compare-help-text,
.extra-threshold-info {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(10, 23, 40, 0.82);
}

.days-slider-box,
.date-range-slider-box {
  padding: 14px 15px;
}

.days-slider {
  accent-color: var(--accent2);
}

.exclude-last-day {
  color: var(--muted);
}

/* ---------- Compare page ---------- */

.compare-upload-grid,
.compare-chart-grid,
.compare-selector-grid {
  gap: 14px;
}

.compare-upload-box {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel-2);
}

.compare-upload-box h3 {
  font-size: 17px;
}

.compare-help-text {
  border-left: 3px solid var(--accent2);
}

/* ---------- Tables ---------- */

.toolbar {
  margin: 0 0 12px;
  padding: 12px;
  position: sticky;
  top: 12px;
  z-index: 700;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(8,20,35,.94);
  box-shadow: 0 10px 25px rgba(0,0,0,.22);
  backdrop-filter: blur(14px);
}

.table-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #0e1c2e;
}

.table-scroll {
  overflow: auto;
}

table {
  min-width: 760px;
  background: #0e1c2e;
}

thead {
  background: #17263a;
}

th {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 13px 15px;
  color: #9fb0c5;
  background: #17263a !important;
  border-bottom: 1px solid var(--border-strong);
  font-size: 11px;
  letter-spacing: .07em;
}

td {
  padding: 13px 15px;
  border-bottom: 1px solid rgba(151,173,202,0.10);
  font-size: 13px;
}

tbody tr {
  background: #0e1c2e;
  transition: 120ms ease;
}

tbody tr:nth-child(even) {
  background: #101f32;
}

tbody tr:hover,
.clickable-row:hover {
  background: #172b43 !important;
}

.rank {
  color: var(--accent2);
}

.amount {
  color: var(--accent);
}

.number,
.type {
  color: #a6b6ca;
}

body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden),
body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) .table-scroll {
  max-height: calc(100vh - 170px);
}

/* ---------- Expandable analysis ---------- */

details.expand-box {
  border-radius: var(--radius-lg);
}

details.expand-box summary {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.top-days-content {
  padding: 14px;
}

.warning-pill {
  border: 1px solid rgba(246,184,74,.24);
  background: rgba(246,184,74,.10);
  color: #ffd88f;
}

/* ---------- Fullscreen / help dialogs ---------- */

.help-modal,
.chart-fullscreen-modal,
.card-fullscreen-modal {
  background: rgba(2, 8, 16, 0.84);
  backdrop-filter: blur(12px);
}

.help-box,
.chart-fullscreen-box,
.card-fullscreen-box {
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #0b1829;
  box-shadow: 0 30px 90px rgba(0,0,0,.52);
}

.chart-fullscreen-head,
.card-fullscreen-head {
  border-bottom-color: var(--border);
  background: #101f33;
}

.help-close {
  border: 1px solid var(--border-strong);
  background: #17283f;
}

.help-code {
  border-color: rgba(53,208,127,.26);
  background: #06111f;
}

.meter-box,
.help-note {
  border-color: var(--border);
  background: var(--panel-2);
}

/* Keep application visibility logic intact */
.workspace-hidden {
  display: none !important;
}

/* ---------- Floating top button ---------- */

.workspace-top-button {
  right: 22px;
  bottom: 22px;
  width: 45px;
  height: 45px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  color: var(--text);
  background: #18304b;
  box-shadow: var(--shadow);
}

/* ---------- Responsive ---------- */

@media (min-width: 1320px) {
  .page {
    padding-right: 44px;
  }

  .analysis-grid {
    gap: 18px;
  }

  .extra-analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .extra-analysis-grid > .analysis-card {
    min-width: 0;
  }
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 226px;
  }

  .page {
    padding-left: calc(var(--sidebar-width) + 28px);
    padding-right: 22px;
  }

  .workspace-nav-wrap {
    width: calc(var(--sidebar-width) - 18px);
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  .upload-type {
    min-height: 96px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 820px) {
  body {
    padding-bottom: 76px;
  }

  .page {
    width: 100%;
    padding: 16px 14px 92px;
  }

  header {
    min-height: auto;
    padding: 16px;
    border-radius: 17px;
  }

  .title {
    padding-left: 0;
  }

  .title::before {
    display: none;
  }

  .title h1 {
    font-size: 25px;
  }

  .workspace-nav-wrap {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    height: 66px;
    padding: 6px;
    border-radius: 17px;
    overflow: visible;
  }

  .workspace-nav-wrap::before,
  .workspace-nav-wrap::after {
    display: none;
  }

  .workspace-nav {
    height: 100%;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 5px;
  }

  .workspace-tab {
    min-height: 52px;
    padding: 31px 3px 4px;
    text-align: center;
    border-radius: 11px;
    font-size: 10px;
    line-height: 1;
  }

  .workspace-tab::before {
    left: 50%;
    top: 6px;
    width: 23px;
    height: 23px;
    transform: translateX(-50%);
  }

  .workspace-tab-sub {
    display: none;
  }

  .workspace-tab.active {
    box-shadow: none;
  }

  .analysis-quick-nav,
  .toolbar {
    top: 8px;
  }

  .compare-upload-grid,
  .compare-chart-grid,
  .compare-selector-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap,
  .compare-chart-grid .chart-wrap,
  #compareSection .chart-wrap {
    height: 300px;
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .upload-card,
  .analysis-card {
    padding: 15px;
    border-radius: 16px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat {
    min-height: 88px;
    padding: 13px;
  }

  .stat strong {
    font-size: 18px;
  }

  .analysis-quick-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .analysis-quick-nav .range-btn {
    flex: 0 0 auto;
  }

  .station-nav-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .station-nav-row .station-select {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .date-range-slider-row {
    grid-template-columns: 44px 1fr;
  }

  .date-range-slider-row strong {
    grid-column: 2;
    text-align: left;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .search,
  .toolbar-buttons {
    width: 100%;
  }

  .toolbar-buttons .btn {
    flex: 1;
  }

  .chart-wrap,
  .compare-chart-grid .chart-wrap,
  #compareSection .chart-wrap {
    height: 270px;
    min-height: 270px;
  }

  .workspace-top-button {
    display: none;
  }
}


/* ---------- Adjustable analysis thresholds ---------- */

.threshold-control-panel {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(75,185,255,0.07), rgba(53,208,127,0.04)),
    rgba(10, 23, 40, 0.86);
}

.threshold-control-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.threshold-control-head h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.015em;
}

.threshold-control-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.threshold-reset-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}

.threshold-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.threshold-slider-card {
  display: block;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(7, 17, 31, 0.54);
}

.threshold-slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.threshold-slider-label strong {
  color: var(--accent);
  font-size: 15px;
  white-space: nowrap;
}

.threshold-slider-card input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent2);
  cursor: pointer;
}

.threshold-slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

@media (max-width: 720px) {
  .threshold-control-head {
    flex-direction: column;
  }

  .threshold-control-grid {
    grid-template-columns: 1fr;
  }

  .threshold-reset-btn {
    width: 100%;
  }
}


/* Reglagen sitter nu direkt i rutan Misstänkta stationer */
#extraThresholdControls {
  margin: 0 0 14px;
  border-color: rgba(75, 185, 255, 0.26);
  box-shadow: inset 0 0 0 1px rgba(75, 185, 255, 0.035);
}

#suspiciousStationsBody tr:first-child td {
  border-top: 0;
}

#suspiciousStationsBody td:nth-child(3),
#suspiciousStationsBody td:nth-child(4) {
  white-space: nowrap;
}


/* ============================================================
   COMSEL-LIK LAYOUT 2026-08
   Ljus, tät arbetsvy med orange Comsel-profil och mindre scroll.
   ============================================================ */

:root {
  --bg: #f3f4f6;
  --bg-soft: #eef0f2;
  --panel: #ffffff;
  --panel-2: #f8f9fa;
  --panel-3: #fff4ea;
  --text: #20242a;
  --muted: #69717c;
  --accent: #ff7a1a;
  --accent2: #ff9b52;
  --accent3: #2f80ed;
  --warning: #d97706;
  --danger: #c93434;
  --border: #d9dde2;
  --border-strong: #c5cad1;
  --shadow: 0 1px 3px rgba(24, 30, 38, 0.10);
  --radius-xl: 5px;
  --radius-lg: 4px;
  --radius-md: 3px;
  --comsel-header-height: 62px;
  --comsel-nav-height: 49px;
}

html {
  background: var(--bg);
  scroll-padding-top: calc(var(--comsel-header-height) + var(--comsel-nav-height) + 16px);
}

* {
  scrollbar-color: #aeb4bc #eef0f2;
}

*::-webkit-scrollbar-track {
  background: #eef0f2;
}

*::-webkit-scrollbar-thumb {
  background: #aeb4bc;
  border-color: #eef0f2;
}

body,
body.compact-ui,
body.large-ui {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

body::before {
  display: none !important;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 18px 30px;
}

/* Orange huvudrad i samma riktning som Comsel Service Hub. */
header {
  position: sticky;
  top: 0;
  z-index: 3000;
  min-height: var(--comsel-header-height);
  height: var(--comsel-header-height);
  margin: 0 -18px;
  padding: 0 22px;
  border: 0;
  border-radius: 0;
  background: #ff7a1a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  backdrop-filter: none;
}

.title {
  padding-left: 42px;
}

.title::before {
  content: "C";
  left: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #ff7a1a;
  background: #ffffff;
  box-shadow: none;
  font-size: 16px;
}

.title h1 {
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title p {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

.top-actions {
  gap: 8px;
}

.badge,
.help-btn,
.link-btn {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 3px;
  font-size: 12px;
}

.badge {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.13);
}

.help-btn,
.link-btn {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.10);
}

.help-btn:hover,
.link-btn:hover {
  background: rgba(255, 255, 255, 0.20);
}

/* Horisontell arbetsnavigering i stället för stor mörk sidomeny. */
.workspace-nav-wrap {
  position: sticky;
  z-index: 2900;
  top: var(--comsel-header-height);
  left: auto;
  right: auto;
  bottom: auto;
  width: auto;
  height: var(--comsel-nav-height);
  margin: 0 -18px 12px;
  padding: 0 18px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(24, 30, 38, 0.06);
  backdrop-filter: none;
}

.workspace-nav-wrap::before,
.workspace-nav-wrap::after {
  display: none !important;
}

.workspace-nav {
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
}

.workspace-tab {
  width: auto;
  min-width: 145px;
  min-height: var(--comsel-nav-height);
  padding: 7px 18px 5px;
  position: relative;
  text-align: center;
  color: #525a64;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
}

.workspace-tab::before {
  display: none !important;
}

.workspace-tab:hover {
  color: #20242a;
  border-color: #ffd4b5;
  background: #fff8f2;
}

.workspace-tab.active {
  color: #d95f08;
  border-color: var(--accent);
  background: #fff8f2;
  box-shadow: none;
}

.workspace-tab-sub,
.workspace-tab.active .workspace-tab-sub {
  margin-top: 1px;
  color: #8a919a;
  font-size: 10px;
  font-weight: 400;
}

/* Paneler och kort: platta, vita och täta i stället för glaspaneler. */
.upload-card,
.analysis-card,
.table-card,
body.compact-ui .upload-card,
body.compact-ui .analysis-card,
body.compact-ui .stat,
body.large-ui .upload-card,
body.large-ui .analysis-card {
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.upload-card,
body.compact-ui .upload-card,
body.large-ui .upload-card {
  margin-bottom: 12px;
  padding: 16px;
}

.analysis-card,
body.compact-ui .analysis-card,
body.large-ui .analysis-card {
  padding: 14px;
}

.analysis-section {
  margin: 0;
}

.analysis-grid,
.extra-analysis-grid {
  gap: 10px;
}

/* Uppladdningen ryms på en skärmhöjd på vanlig kontorsskärm. */
main.page > .upload-card:not(.compare-card) {
  min-height: 0;
}

.upload-grid {
  gap: 8px;
  margin: 0;
}

.upload-type {
  min-height: 82px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafbfc;
  box-shadow: none;
}

.upload-type::after {
  display: none;
}

.upload-type:hover {
  transform: none;
  border-color: #ffb37c;
  background: #fff8f2;
}

.upload-type.active {
  border-color: var(--accent);
  background: #fff3e9;
  box-shadow: inset 3px 0 0 var(--accent);
}

.upload-type.active::before {
  color: #c85608;
}

.upload-type h2 {
  margin-bottom: 5px;
  color: #2b3036;
  font-size: 16px;
}

.upload-type p {
  max-width: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dropzone {
  min-height: 160px;
  padding: 24px 18px;
  border: 1px dashed #f2a066;
  border-radius: 4px;
  background: #fffaf6;
}

.dropzone:hover,
.dropzone.dragover {
  transform: none;
  border-color: var(--accent);
  background: #fff3e9;
}

.dropzone h2 {
  color: #2b3036;
  font-size: 19px;
}

.dropzone p,
.status,
.compare-search-info,
.keyboard-hint,
.selected-station-info {
  color: var(--muted);
}

/* Knappar och fält. */
.btn,
.copy-btn,
body.compact-ui .btn,
body.large-ui .btn {
  min-height: 35px;
  padding: 7px 12px;
  color: #ffffff;
  border: 1px solid #e8680d;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: none;
  font-size: 12px;
  font-weight: 650;
}

.btn:hover,
.copy-btn:hover,
.range-btn:hover,
.help-btn:hover,
.link-btn:hover {
  transform: none;
  filter: none;
}

.btn:hover,
.copy-btn:hover {
  background: #e9680f;
}

.btn.secondary {
  color: #39414b;
  border: 1px solid var(--border-strong);
  background: #f7f8f9;
}

.btn.secondary:hover {
  border-color: #f0a36c;
  background: #fff5ed;
}

.search,
.compare-search,
.station-select,
.day-input,
body.compact-ui .search,
body.compact-ui .compare-search,
body.compact-ui .station-select,
body.compact-ui .day-input {
  min-height: 36px;
  padding: 7px 10px;
  color: #20242a;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: #ffffff;
  font-size: 12px;
}

.search:focus,
.compare-search:focus,
.station-select:focus,
.day-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 122, 26, 0.14);
}

.station-select option {
  color: #20242a;
  background: #ffffff;
}

/* KPI-raden är låg och lätt att överblicka. */
.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 9px;
}

.stat,
body.compact-ui .stat {
  min-height: 66px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  background: #ffffff;
  box-shadow: none;
}

.stat::after {
  display: none;
}

.stat span {
  margin-bottom: 4px;
  color: #747b84;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.stat strong,
body.compact-ui .stat strong {
  color: #20242a;
  font-size: 19px;
  font-weight: 650;
}

/* Analysväxling: översikt, station och avvikelser utan lång sidscroll. */
.analysis-quick-nav {
  position: sticky;
  top: calc(var(--comsel-header-height) + var(--comsel-nav-height));
  z-index: 2800;
  min-height: 42px;
  margin: 0 0 9px;
  padding: 4px 0;
  gap: 3px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(24, 30, 38, 0.06);
  backdrop-filter: none;
}

.range-btn,
body.compact-ui .range-btn {
  min-height: 32px;
  padding: 6px 10px;
  color: #4e5660;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.range-btn:hover {
  color: #c85608;
  border-color: #ffd6ba;
  background: #fff7f1;
}

.range-btn.active,
.analysis-view-btn.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.analysis-view-btn:disabled {
  color: #a5abb2;
  cursor: not-allowed;
  background: #f3f4f5;
}

.layout-control-separator {
  background: var(--border);
}

.analysis-panel-hidden {
  display: none !important;
}

#analysisSection > .stats {
  margin-bottom: 9px;
}

#analysisSection .analysis-grid {
  display: block;
}

.analysis-head {
  margin-bottom: 10px;
  gap: 10px;
}

.analysis-head h2,
.summary-row h2,
body.compact-ui .analysis-head h2,
body.large-ui .analysis-head h2 {
  color: #252a30;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.analysis-head p,
.summary-row p,
body.compact-ui .analysis-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.chart-actions {
  gap: 5px;
}

.chart-wrap,
body.compact-ui .chart-wrap,
body.large-ui .chart-wrap {
  padding: 7px;
  border: 1px solid #e2e5e9;
  border-radius: 3px;
  background: #ffffff;
}

#yearOverviewCard .chart-wrap {
  height: min(650px, calc(100vh - 315px));
  min-height: 430px;
}

/* Stationstrend: reglage till vänster och graf till höger. */
#stationAnalysisCard {
  display: grid;
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
  grid-template-areas:
    "station-head station-chart"
    "station-info station-chart"
    "station-range station-chart"
    "station-days station-chart"
    "station-advanced station-chart";
  align-content: start;
  align-items: start;
  gap: 8px 14px;
  min-height: min(690px, calc(100vh - 230px));
}

#stationAnalysisCard > .analysis-head {
  grid-area: station-head;
  display: block;
  margin: 0;
}

#stationAnalysisCard .station-picker-box {
  width: 100%;
  margin-top: 9px;
}

#stationAnalysisCard .compare-search,
#stationAnalysisCard .station-select {
  width: 100%;
  min-width: 0;
}

#stationAnalysisCard .station-nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 5px;
}

#stationAnalysisCard .station-nav-row .station-select {
  grid-column: 1 / -1;
  grid-row: 1;
}

#stationAnalysisCard .station-nav-row .station-nav-btn {
  grid-row: 2;
}

#stationAnalysisCard .station-nav-row .btn:not(.station-nav-btn) {
  grid-row: 3;
}

#stationAnalysisCard .keyboard-hint {
  display: none;
}

#stationAnalysisCard > .selected-station-info {
  grid-area: station-info;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #f1c6a7;
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  background: #fff8f2;
  font-size: 11px;
}

#stationAnalysisCard > .range-buttons {
  grid-area: station-range;
  margin: 0;
}

#stationAnalysisCard > .days-slider-box {
  grid-area: station-days;
  margin: 0;
}

#stationAnalysisCard > .advanced-range-details {
  grid-area: station-advanced;
}

#stationAnalysisCard > .chart-wrap {
  grid-area: station-chart;
  width: 100%;
  height: 100%;
  min-height: 520px;
  align-self: stretch;
}

.days-slider-box,
.date-range-slider-box,
.compare-range-info,
.compare-help-text,
.extra-threshold-info {
  color: #4f5862;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f8f9fa;
}

.days-slider-box,
.date-range-slider-box {
  padding: 9px 10px;
}

.days-slider,
.date-range-slider-row input,
.threshold-slider-card input[type="range"] {
  accent-color: var(--accent);
}

.advanced-range-details {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f8f9fa;
}

.advanced-range-details > summary {
  padding: 8px 10px;
  color: #4e5660;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.advanced-range-details[open] > summary {
  color: #c85608;
  border-bottom: 1px solid var(--border);
  background: #fff7f1;
}

.advanced-range-details .date-range-slider-box {
  margin: 0 !important;
  border: 0;
  background: #ffffff;
}

#topDaysDetails {
  margin-top: 9px;
}

/* Avvikelsevyn får egna scrollbara tabeller i stället för en mycket lång sida. */
#extraAnalysisSection > .analysis-head,
#extraAnalysisSection > .extra-threshold-info {
  margin-bottom: 8px;
}

.extra-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.extra-analysis-grid > .analysis-card {
  min-width: 0;
  height: clamp(300px, calc((100vh - 255px) / 2), 390px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.extra-analysis-grid > .analysis-card > .analysis-head,
.extra-analysis-grid > .analysis-card > .status {
  flex: 0 0 auto;
}

.extra-analysis-grid > .analysis-card > .table-card {
  flex: 1 1 auto;
  min-height: 0;
}

.extra-analysis-grid > .analysis-card .table-scroll {
  height: 100%;
  max-height: none;
}

.threshold-control-panel {
  flex: 0 0 auto;
  margin: 0 0 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f8f9fa;
}

.threshold-control-head {
  margin-bottom: 8px;
}

.threshold-control-head h3 {
  color: #30363d;
  font-size: 13px;
}

.threshold-control-head p {
  font-size: 10px;
}

.threshold-control-grid {
  gap: 7px;
}

.threshold-slider-card {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #ffffff;
}

.threshold-slider-label {
  margin-bottom: 6px;
  color: #5f6771;
  font-size: 10px;
}

.threshold-slider-label strong {
  color: #c85608;
  font-size: 12px;
}

/* Jämförelsevyn: reglage i smal vänsterspalt, två trender bredvid. */
.compare-upload-box {
  border-color: var(--border);
  border-radius: 4px;
  background: #fafbfc;
}

.compare-help-text {
  border-left: 3px solid var(--accent);
}

#compareSection > .analysis-grid {
  display: grid;
  grid-template-columns: minmax(310px, 355px) minmax(0, 1fr);
  grid-template-areas:
    "compare-controls compare-pair"
    "compare-combined compare-combined"
    "compare-table compare-table";
  align-items: start;
  gap: 9px;
}

#compareSection > .analysis-grid > .analysis-card:first-child {
  grid-area: compare-controls;
}

#compareSection > .analysis-grid > .compare-chart-grid {
  grid-area: compare-pair;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

#compareSection > .analysis-grid > .analysis-card:nth-child(3) {
  grid-area: compare-combined;
}

#compareSection > .analysis-grid > details {
  grid-area: compare-table;
}

#compareSection .compare-selector-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

#compareSection .compare-chart-grid .chart-wrap {
  height: 330px;
  min-height: 330px;
}

#compareSection > .analysis-grid > .analysis-card:nth-child(3) .chart-wrap {
  height: 360px;
  min-height: 360px;
}

/* Tabeller. */
.toolbar {
  top: calc(var(--comsel-header-height) + var(--comsel-nav-height) + 5px);
  margin: 0 0 7px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 3px rgba(24, 30, 38, 0.10);
  backdrop-filter: none;
}

.table-card {
  overflow: hidden;
  border-radius: 3px;
  background: #ffffff;
}

table {
  color: #30363d;
  background: #ffffff;
}

thead,
th {
  color: #555e68;
  background: #f1f3f5 !important;
}

th {
  padding: 9px 10px;
  border-bottom: 1px solid #cfd4da;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
}

td,
body.compact-ui td,
body.compact-ui th {
  padding: 8px 10px;
  border-bottom: 1px solid #eceef1;
  font-size: 12px;
}

tbody tr,
tbody tr:nth-child(even) {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

tbody tr:hover,
.clickable-row:hover {
  background: #fff3e9 !important;
}

.rank,
.amount {
  color: #d95f08;
}

.number,
.type {
  color: #6b737d;
}

body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden),
body.workspace-table-view #resultSection > .table-card:not(.workspace-hidden) .table-scroll {
  max-height: calc(100vh - 215px);
}

/* Expanderbara rutor och dialoger. */
details.expand-box {
  border-radius: 3px;
}

details.expand-box summary {
  padding: 10px 12px;
  border-bottom-color: var(--border);
  background: #f8f9fa;
}

.warning-pill {
  color: #9a5a00;
  border-color: #f1c176;
  background: #fff7e6;
}

.card-expand-btn {
  color: #4c5560;
  border-color: var(--border-strong);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.94);
}

.help-modal,
.chart-fullscreen-modal,
.card-fullscreen-modal {
  background: rgba(28, 32, 37, 0.74) !important;
  backdrop-filter: blur(4px);
}

.help-box,
.chart-fullscreen-box,
.card-fullscreen-box,
.chart-fullscreen-box:fullscreen {
  color: var(--text);
  border-color: var(--border-strong) !important;
  border-radius: 5px !important;
  background: #ffffff !important;
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.30) !important;
}

.chart-fullscreen-head,
.card-fullscreen-head {
  border-bottom-color: var(--border);
  background: #f5f6f7;
}

.chart-fullscreen-wrap.canvas-mode,
#chartFullscreenCanvas {
  background: #ffffff !important;
}

.help-close {
  color: #38414b;
  border-color: var(--border-strong);
  background: #ffffff;
}

.help-code {
  color: #30363d;
  border-color: #f0b68c;
  background: #fff8f2;
}

.meter-box,
.help-note {
  border-color: var(--border);
  background: #f8f9fa;
}

.workspace-top-button {
  right: 18px;
  bottom: 18px;
  width: 40px;
  height: 40px;
  color: #ffffff;
  border: 1px solid #df630c;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

/* Tät uppladdningsvy på bred skärm. */
@media (min-width: 1180px) {
  main.page > .upload-card:not(.compare-card) {
    display: grid;
    grid-template-columns: minmax(390px, 0.85fr) minmax(500px, 1.15fr);
    grid-template-areas:
      "upload-types upload-drop"
      "upload-status upload-status"
      "upload-error upload-error";
    gap: 10px 12px;
  }

  main.page > .upload-card:not(.compare-card) > .upload-grid {
    grid-area: upload-types;
    grid-template-columns: 1fr;
  }

  main.page > .upload-card:not(.compare-card) > .dropzone {
    grid-area: upload-drop;
    min-height: 100%;
  }

  main.page > .upload-card:not(.compare-card) > #status {
    grid-area: upload-status;
    margin-top: 0;
  }

  main.page > .upload-card:not(.compare-card) > #errorBox {
    grid-area: upload-error;
    margin-top: 0;
  }
}

@media (max-width: 1179px) {
  #stationAnalysisCard {
    grid-template-columns: minmax(285px, 330px) minmax(0, 1fr);
  }

  #compareSection > .analysis-grid {
    grid-template-columns: 310px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  :root {
    --comsel-header-height: 68px;
  }

  header {
    height: var(--comsel-header-height);
  }

  .workspace-tab {
    min-width: 0;
    flex: 1;
    padding-left: 7px;
    padding-right: 7px;
  }

  .workspace-tab-sub {
    display: none;
  }

  #stationAnalysisCard,
  #compareSection > .analysis-grid {
    display: block;
    min-height: 0;
  }

  #stationAnalysisCard > * + *,
  #compareSection > .analysis-grid > * + * {
    margin-top: 9px;
  }

  #stationAnalysisCard > .chart-wrap {
    height: 440px;
    min-height: 440px;
  }

  #compareSection > .analysis-grid > .compare-chart-grid {
    grid-template-columns: 1fr;
  }

  .extra-analysis-grid {
    grid-template-columns: 1fr;
  }

  .extra-analysis-grid > .analysis-card {
    height: 360px;
  }
}

@media (max-width: 700px) {
  :root {
    --comsel-header-height: 78px;
    --comsel-nav-height: 50px;
  }

  body {
    padding-bottom: 0;
  }

  .page {
    padding: 0 8px 22px;
  }

  header {
    margin: 0 -8px;
    padding: 9px 12px;
    align-items: center;
    flex-direction: row;
  }

  .title {
    padding-left: 0;
  }

  .title::before,
  .title p {
    display: none;
  }

  .title h1 {
    font-size: 18px;
  }

  .workspace-nav-wrap {
    position: sticky;
    left: auto;
    right: auto;
    top: var(--comsel-header-height);
    bottom: auto;
    width: auto;
    height: var(--comsel-nav-height);
    margin: 0 -8px 8px;
    padding: 0;
    border-radius: 0;
  }

  .workspace-nav {
    grid-template-columns: none;
    display: flex;
  }

  .workspace-tab {
    min-height: var(--comsel-nav-height);
    padding: 15px 3px 4px;
    font-size: 10px;
  }

  .workspace-tab::before {
    display: none !important;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-quick-nav {
    top: calc(var(--comsel-header-height) + var(--comsel-nav-height));
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .analysis-quick-nav .range-btn {
    flex: 0 0 auto;
  }

  #yearOverviewCard .chart-wrap,
  #stationAnalysisCard > .chart-wrap,
  #compareSection .compare-chart-grid .chart-wrap,
  #compareSection > .analysis-grid > .analysis-card:nth-child(3) .chart-wrap {
    height: 310px;
    min-height: 310px;
  }

  .workspace-top-button {
    display: none;
  }
}

/* Tydlig länk i hjälpfönstret. Den generella .link-btn-stilen är gjord för orange toppfält och blev annars vit mot vit bakgrund här. */
.help-box .help-comsel-link {
  color: #ffffff !important;
  background: #f47d27 !important;
  border: 1px solid #d96516 !important;
  border-radius: 4px !important;
  padding: 10px 14px !important;
  min-height: 38px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.help-box .help-comsel-link:hover,
.help-box .help-comsel-link:focus-visible {
  color: #ffffff !important;
  background: #dc6819 !important;
  border-color: #bd5510 !important;
  outline: 3px solid rgba(244, 125, 39, 0.24);
  outline-offset: 2px;
}
