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

body {
  font-family: "Open Sans", sans-serif;
  background: #ffffff;
  color: #222;
  line-height: 1.4;
}

/* === Header === */
header {
  position: relative;
  padding: 20px 32px 0;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-bottom: 12px;
  border-bottom: 4px solid #3a7d3a;
  margin-right: 130px; /* stop green line before logo (90px logo + 32px right padding + gap) */
}

header h1 {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #222;
  text-align: center;
}

.header-logo {
  width: 90px;
  height: auto;
  flex-shrink: 0;
  position: absolute;
  right: 32px;
  bottom: 0;
  transform: translateY(50%);
  z-index: 2;
}

/* === Filters === */
.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f5f5f5;
  flex-wrap: wrap;
  font-size: 0.9rem;
  margin-left: 32px;
  margin-right: 162px; /* 32px header padding + 130px logo space */
}

.filters label {
  font-weight: 600;
}

.filters select {
  padding: 5px 10px;
  font-size: 0.9rem;
  font-family: "Open Sans", sans-serif;
  border: 1px solid #bbb;
  border-radius: 4px;
}

.filters input[type="date"] {
  padding: 5px 10px;
  font-size: 0.9rem;
  font-family: "Open Sans", sans-serif;
  border: 1px solid #bbb;
  border-radius: 4px;
}

/* === Main Content (two columns) === */
.main-content {
  display: flex;
  gap: 24px;
  padding: 20px 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.target-column {
  flex: 0 0 300px;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.target-wrapper {
  border: 2px solid #3a7d3a;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 324px;
}

#target-main {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Ring distribution table */
#ring-distribution {
  margin-top: 12px;
  width: 100%;
  max-width: 300px;
  overflow-x: auto;
}

#ring-distribution table {
  border-collapse: collapse;
  font-size: 0.75rem;
}

#ring-distribution th {
  padding: 3px 6px;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  background: transparent;
}

#ring-distribution td {
  padding: 2px 6px;
  text-align: center;
  border: none;
  font-size: 0.7rem;
  color: #555;
}

/* === Right Column (subtitle + KPIs + Top5) === */
.right-column {
  flex: 1 1 500px;
  min-width: 400px;
  display: flex;
  flex-direction: column;
}

.right-column h2 {
  font-size: 1.3rem;
  font-weight: 400;
  color: #333;
  padding-bottom: 8px;
  border-bottom: 3px solid #3a7d3a;
  margin-bottom: 20px;
}

/* === KPI Row === */
.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 24px;
  margin-right: auto;
}

.kpi-card {
  background: transparent;
  padding: 6px 18px;
  text-align: center;
  flex: 0 0 auto;
  min-width: 158px;
  border-right: 1px solid #ddd;
}

.kpi-card:last-child {
  border-right: none;
}

.kpi-value {
  display: block;
  font-size: 2.4rem;
  font-weight: 300;
  color: #222;
}

.kpi-label {
  display: block;
  font-size: 0.72rem;
  color: #666;
  margin-top: 2px;
  font-weight: 400;
}

/* Top 5 column */
.top5-column {
  flex: 1;
  margin-top: -30px;
}

#top5-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  justify-content: flex-start;
  align-items: flex-end;
}

.top5-item {
  text-align: center;
  font-size: 0.8rem;
  flex-shrink: 1;
  min-width: 0;
  margin-bottom: 10px;
}

.top5-item.teiler-target {
  margin-bottom: 0;
}

.top5-item canvas {
  display: block;
  margin-bottom: 4px;
  max-width: 100%;
  height: auto;
}

.top5-score {
  font-weight: 700;
  font-size: 1rem;
}

.top5-date {
  color: #666;
}

.teiler-target {
  border: 2px solid #3a7d3a;
  border-radius: 8px;
  padding: 8px;
}

.teiler-target canvas {
  display: block;
  margin-bottom: 4px;
}

.teiler-headline {
  font-weight: 700;
  font-size: 0.85rem;
  color: #3a7d3a;
  margin-bottom: 4px;
}

/* === Timeline === */
.timeline {
  padding: 20px 32px 40px;
  position: relative;
  min-height: 250px;
  margin-top: -40px;
}

.timeline canvas {
  width: 100% !important;
  height: 220px !important;
}

/* === Responsive === */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }

  .target-column {
    flex: 1 1 auto;
  }

  .right-column {
    min-width: auto;
  }

  .kpi-card {
    flex: 0 0 auto;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .header-logo {
    width: 60px;
    right: 16px;
  }

}

/* === Buttons === */
.btn-print,
.btn-toggle-mobile {
  padding: 5px 14px;
  font-size: 0.9rem;
  font-family: "Open Sans", sans-serif;
  background: #3a7d3a;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.btn-print:hover,
.btn-toggle-mobile:hover {
  background: #2c5282;
}

.btn-toggle-mobile.active {
  background: #2c5282;
}

/* === Mobile View (toggled via JS class) === */
body.mobile-view {
  background: #f7f7f8;
}

body.mobile-view header {
  padding: 10px 12px 0;
  background: #fff;
}

body.mobile-view .header-inner {
  margin-right: 52px;
  padding-bottom: 6px;
  border-bottom-width: 3px;
}

body.mobile-view header h1 {
  font-size: 1.05rem;
  line-height: 1.3;
}

body.mobile-view .header-logo {
  width: 40px;
  right: 12px;
}

body.mobile-view .filters {
  margin: 0;
  padding: 10px 12px;
  gap: 6px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  flex-direction: column;
}

body.mobile-view .filters label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

body.mobile-view .filters select {
  width: 100%;
  flex: none;
  padding: 8px 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #f7f7f8;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

body.mobile-view .btn-toggle-mobile {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: 2px;
}

body.mobile-view .main-content {
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}

body.mobile-view .target-column {
  flex: 1 1 auto;
  width: 100%;
}

body.mobile-view .target-wrapper {
  max-width: 100%;
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 16px 12px;
}

body.mobile-view #target-main {
  max-width: 260px;
  margin: 0 auto;
}

body.mobile-view .right-column {
  min-width: auto;
  width: 100%;
}

body.mobile-view .right-column h2 {
  font-size: 0.95rem;
  background: #fff;
  margin: 0 -12px;
  padding: 10px 12px 8px;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-bottom: 2px solid #3a7d3a;
  margin-bottom: 0;
}

body.mobile-view .kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: calc(100% + 24px);
  margin-left: -12px;
  background: #fff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-bottom: 4px;
}

body.mobile-view .kpi-card {
  border-right: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 8px;
  min-width: 0;
}

body.mobile-view .kpi-card:nth-child(odd) {
  border-right: 1px solid #f0f0f0;
}

body.mobile-view .kpi-card:nth-child(n+3) {
  border-bottom: none;
}

body.mobile-view .kpi-value {
  font-size: 1.7rem;
  font-weight: 600;
}

body.mobile-view .kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #888;
}

body.mobile-view .top5-column {
  margin-top: 8px;
}

body.mobile-view #top5-container {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 10px;
  padding: 4px 2px 10px;
  scroll-snap-type: x mandatory;
}

body.mobile-view .top5-item {
  scroll-snap-align: start;
  flex-shrink: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 12px;
  width: calc(100vw - 48px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.mobile-view .top5-item canvas {
  width: calc(100vw - 80px) !important;
  height: calc(100vw - 80px) !important;
  max-width: 320px !important;
  max-height: 320px !important;
}

body.mobile-view .top5-date {
  font-size: 0.7rem;
}

body.mobile-view .teiler-target {
  border-color: #3a7d3a;
  background: #fff;
  border-radius: 10px;
}

body.mobile-view .timeline {
  padding: 0 12px 24px;
  margin-top: 0;
  min-height: auto;
}

body.mobile-view .timeline-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body.mobile-view .timeline-scroll-inner {
  min-width: 100%;
}

body.mobile-view .timeline canvas {
  height: 200px !important;
}

body.mobile-view .btn-print {
  display: none;
}

/* Ring distribution bar chart (mobile) */
.ring-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  margin-top: 12px;
  width: 100%;
  max-width: 300px;
}

.ring-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.ring-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
}

.ring-bar-label {
  font-size: 0.65rem;
  color: #666;
  margin-top: 2px;
}

.ring-bar-count {
  font-size: 0.6rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 1px;
}

/* === Personal Summary === */
.personal-summary {
  padding: 20px 32px 32px;
  margin-top: -20px;
}

.personal-summary p {
  background: linear-gradient(135deg, #f0f7f0 0%, #e8f5e9 100%);
  border-left: 4px solid #3a7d3a;
  border-radius: 8px;
  padding: 20px 24px;
  font-size: 1rem;
  line-height: 1.7;
  color: #2d3748;
}

body.mobile-view .personal-summary {
  padding: 0 12px 24px;
  margin-top: 0;
}

body.mobile-view .personal-summary p {
  border-radius: 12px;
  padding: 16px;
  font-size: 0.95rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* === Print Styles === */
@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
    font-size: 10pt;
  }

  header {
    padding: 6px 16px 0;
  }

  header h1 {
    font-size: 1.3rem;
  }

  .header-inner {
    margin-right: 100px; /* reduced for print (60px logo + smaller padding) */
  }

  .header-logo {
    width: 60px;
  }

  .filters {
    padding: 4px 8px;
    margin-left: 16px;
    margin-right: 116px; /* 16px header padding + 100px logo space */
  }

  .btn-print {
    display: none;
  }

  .btn-toggle-mobile {
    display: none;
  }

  .main-content {
    padding: 8px 16px;
  }

  .ring-bar-chart {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .timeline {
    padding: 8px 16px 12px;
    page-break-inside: avoid;
    min-height: auto;
    margin-top: 4px;
  }

  .timeline canvas {
    height: 160px !important;
  }

  .kpi-card {
    border-right-color: #ccc;
  }

  .target-wrapper {
    padding: 8px;
  }

  .personal-summary {
    page-break-before: always;
    page-break-inside: avoid;
    padding: 24px 32px;
    margin-top: 0;
  }

  .personal-summary p {
    font-size: 1rem;
    line-height: 1.7;
    padding: 20px 24px;
    border: 2px solid #3a7d3a;
    border-radius: 8px;
    background: #f0f7f0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .filters select,
  .filters input[type="date"] {
    border: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    font-weight: 600;
  }
}
