/* ============================================================
   Garten — Dark Theme + Glassmorphism
   ============================================================ */

/* --- Google Fonts ------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Design Tokens (Custom Properties) --------------------- */
:root {
  /* backgrounds */
  --bg-body:        #0a0a0f;
  --bg-card:        #12131a;
  --bg-card-hover:  #181924;
  --bg-input:       #1a1b26;
  --bg-modal:       rgba(0, 0, 0, 0.7);

  /* borders */
  --border-card:    1px solid rgba(255, 255, 255, 0.05);
  --border-input:   1px solid rgba(255, 255, 255, 0.1);
  --border-radius:  12px;

  /* glassmorphism */
  --glass-blur:     blur(12px);
  --glass-gradient: linear-gradient(
                      135deg,
                      rgba(255, 255, 255, 0.03) 0%,
                      rgba(255, 255, 255, 0.01) 100%
                    );

  /* accent colours */
  --green:   #22c55e;
  --amber:   #f59e0b;
  --red:     #ef4444;
  --cyan:    #06b6d4;
  --timelapse: #e040fb;

  /* text */
  --text-primary:   rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.5);

  /* typography */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* spacing */
  --gap:     1.25rem;
  --padding: 1.5rem;
}


/* --- Reset ------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  padding: var(--padding);
  max-width: 1400px;
  margin: 0 auto;
}


/* --- Utility ----------------------------------------------- */
.hidden {
  display: none !important;
}

.value {
  font-family: var(--font-mono);
  font-weight: 600;
}


/* --- Keyframe Animations ----------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 1;   }
  50%  { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(1);   opacity: 1;   }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

@keyframes slideInDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes slideOutUp {
  from { transform: translateY(0);     opacity: 1; }
  to   { transform: translateY(-100%); opacity: 0; }
}


/* --- Card (base) ------------------------------------------- */
.card {
  background: var(--bg-card);
  background-image: var(--glass-gradient);
  border: var(--border-card);
  border-radius: var(--border-radius);
  padding: var(--padding);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.6s ease-out both;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

/* staggered entry */
.card:nth-child(1) { animation-delay: 0s;    }
.card:nth-child(2) { animation-delay: 0.1s;  }
.card:nth-child(3) { animation-delay: 0.2s;  }
.card:nth-child(4) { animation-delay: 0.3s;  }

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}


/* --- Header ------------------------------------------------ */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap);
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  background-image: var(--glass-gradient);
  border: var(--border-card);
  border-radius: var(--border-radius);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.tab-bar {
  display: flex;
  gap: 0.25rem;
}

.header-strain {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: auto;
  margin-right: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tab-btn {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

#admin-toggle {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  line-height: 1;
}

#admin-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}



/* --- Offline State ----------------------------------------- */
body.offline .value {
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

/* --- Offline Glow Banner ----------------------------------- */
.offline-glow-banner {
  background: linear-gradient(
    180deg,
    rgba(239, 68, 68, 0.12) 0%,
    rgba(239, 68, 68, 0.0) 100%
  );
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.5rem 1.25rem;
  margin-bottom: var(--gap);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  transition: opacity 0.6s ease;
}

.offline-glow-banner .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  animation: pulse-slow 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
  50%      { opacity: 0.5; box-shadow: 0 0 16px rgba(239, 68, 68, 0.4); }
}


/* --- Toast Notification ------------------------------------ */
.toast {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1100;
  min-width: 260px;
  max-width: 380px;
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: slideIn 0.35s ease-out;
}

.toast.error {
  background: var(--red);
}

.toast.dismissing {
  animation: slideOut 0.3s ease-in forwards;
}

/* Portrait / mobile: full-width toast from the top */
@media (max-width: 767px) {
  .toast {
    top: 0;
    left: 0;
    right: 0;
    min-width: unset;
    max-width: unset;
    border-radius: 0 0 10px 10px;
    text-align: center;
    animation: slideInDown 0.35s ease-out;
  }

  .toast.dismissing {
    animation: slideOutUp 0.3s ease-in forwards;
  }
}


/* --- Main Grid --------------------------------------------- */
main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

#dashboard-content {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.grid-top {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: var(--gap);
}

@media (min-width: 768px) {
  .grid-top {
    grid-template-columns: 1fr 1fr;
  }
}

/* Cards in top grid stretch to equal height */
.grid-top > .card {
  display: flex;
  flex-direction: column;
}

/* Content areas fill remaining card space, rows packed at top */
.grid-top .live-values,
.grid-top .camera-grid {
  flex: 1;
  align-content: start;
}

/* Consistent heading separator in top grid cards */
#camera > h2 {
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-controls {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}


/* --- Grow Overview ----------------------------------------- */
.grow-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.grow-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0;
}

.grow-header-meta {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.grow-tag {
  color: var(--text-primary);
  font-weight: 600;
}

.grow-sep {
  color: rgba(255, 255, 255, 0.2);
}

.grow-phase {
  color: var(--text-primary);
  font-weight: 500;
}

.grow-health {
  color: var(--green);
  font-weight: 600;
}

.budbot-summary {
  margin: 0.25rem 0 1rem;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}
.budbot-text {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-secondary, #ccc);
  list-style: disc;
}
.budbot-text li {
  margin-bottom: 0.2rem;
}
.budbot-time {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted, #888);
}

.live-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1rem;
}

.value-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.value-item .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.label-hint {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.65rem;
  opacity: 0.7;
}

.value-item .value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.value-item .unit {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 0.15em;
}


/* --- Camera Section ---------------------------------------- */
.camera-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

@media (min-width: 768px) {
  .camera-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.camera-grid figure {
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}

.camera-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: 8px 8px 0 0;
  background: var(--bg-body);
}

.camera-grid figcaption {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.6rem;
}

.camera-grid .cam-timestamp {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}


/* --- Parameters Form --------------------------------------- */
#parameters h2 {
  margin-bottom: 1rem;
}

.param-group {
  margin-bottom: 1rem;
}

.param-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.param-group input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: var(--border-input);
  border-radius: 8px;
  outline: none;
  transition: all 0.3s ease;
}

.param-group input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.card > button,
#save-targets,
#save-fan,
#save-hum {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--green);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.card > button:hover,
#save-targets:hover,
#save-fan:hover,
#save-hum:hover {
  background: #1db851;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.35);
}


/* --- Device Cards Grid ------------------------------------- */
.device-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

@media (max-width: 767px) {
  .device-cards-grid {
    grid-template-columns: 1fr;
  }
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.device-card-header h2 {
  margin: 0;
}

.device-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* --- Targets Grid ------------------------------------------ */
.targets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 767px) {
  .targets-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Toggle Switch ----------------------------------------- */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.toggle.on {
  background: var(--green);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle.on::after {
  transform: translateX(20px);
}

/* --- Unreachable / Disabled States ------------------------- */
.device-card.unreachable {
  border-color: rgba(239, 68, 68, 0.25);
  box-shadow:
    0 0 15px rgba(239, 68, 68, 0.08),
    inset 0 0 15px rgba(239, 68, 68, 0.03);
  opacity: 0.45;
  filter: saturate(0.2);
  transition: all 0.6s ease;
}

.device-card.unreachable input,
.device-card.unreachable .toggle,
.device-card.unreachable button {
  pointer-events: none;
}

.device-hint {
  display: block;
  font-size: 0.75rem;
  min-height: 1.1em;
  color: rgba(239, 68, 68, 0.6);
  letter-spacing: 0.01em;
  transition: opacity 0.4s ease;
}

.device-hint.hidden {
  display: block !important;
  visibility: hidden;
}

#targets-card.disabled {
  opacity: 0.3;
  filter: saturate(0.15);
  border-color: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.05);
  transition: all 0.6s ease;
}

#targets-card.disabled input,
#targets-card.disabled button {
  pointer-events: none;
}

/* --- Charts Section ---------------------------------------- */
.charts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.charts-header h2 {
  margin-bottom: 0;
}

.range-buttons {
  display: flex;
  gap: 0.4rem;
}

.range-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: var(--border-input);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.range-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.range-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.chart-wrapper {
  margin-bottom: 1.5rem;
}

.chart-wrapper:last-child {
  margin-bottom: 0;
}

.chart-wrapper h3 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

/* Trend matrix is rendered via Chart.js plugin (trendOverlay) — no CSS needed */

.chart-wrapper canvas {
  width: 100% !important;
  max-height: 220px;
  cursor: grab;
  touch-action: pan-y;
}

.chart-wrapper canvas:active {
  cursor: grabbing;
}

.live-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--cyan);
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
  cursor: pointer;
  transition: all 0.3s ease;
}

.live-btn:hover {
  background: rgba(6, 182, 212, 0.25);
}


/* --- Admin Modal ------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-modal);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 380px;
  padding: 2rem;
  text-align: center;
}

.modal-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

#token-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: var(--border-input);
  border-radius: 8px;
  outline: none;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

#token-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.modal-buttons {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.modal-buttons button {
  padding: 0.55rem 1.4rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#token-save {
  background: var(--green);
  color: #fff;
}

#token-save:hover {
  background: #1db851;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}

#token-logout {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

#token-logout:hover {
  background: rgba(239, 68, 68, 0.25);
}

#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s ease;
}

#modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}


/* --- Responsive -------------------------------------------- */
@media (max-width: 767px) {
  body {
    padding: 1rem;
  }

  header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .header-strain {
    order: -1;
    width: 100%;
    text-align: center;
    margin: 0 0 0.25rem;
    font-size: clamp(1.4rem, 5.8vw, 2.4rem);
  }

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

  .value-item .value {
    font-size: 1.25rem;
  }

  .charts-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-wrapper canvas {
    max-height: 180px;
  }
}


/* --- Scrollbar --------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}


/* --- Auth Overlay ------------------------------------------ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 17, 23, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-overlay-box {
  text-align: center;
  max-width: 420px;
  padding: 2rem;
}

.auth-overlay-box h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-overlay-box p {
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

/* --- Device Management ------------------------------------- */
#device-management hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1rem 0;
}

.device-alert {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 0.5rem;
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.device-name {
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
}
.device-name:hover { border-bottom-color: var(--accent); }
.rename-input {
  font-size: 0.9rem;
  padding: 2px 6px;
  width: 160px;
  background: var(--card-bg);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  border-radius: 4px;
}

.device-meta {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.device-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.status-active { color: #22c55e; }
.status-locked { color: #ef4444; }

.link-create {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.link-create input[type="text"] {
  flex: 1 1 100%;
}

.link-create select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

#link-result {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

#link-url {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.8);
}

.link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  gap: 0.5rem;
}

.link-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.link-meta {
  color: rgba(255, 255, 255, 0.5);
}

.link-id {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
}

.muted {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

/* --- Selection --------------------------------------------- */
::selection {
  background: rgba(34, 197, 94, 0.3);
  color: #fff;
}

/* --- Timelapse Preview (video over image) ----------------- */
.timelapse-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #000;
  border-radius: 8px 8px 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

.timelapse-preview.playing {
  opacity: 1;
}

/* --- Timelapse Control Bar -------------------------------- */
.timelapse-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.4rem 0.6rem;
  border-radius: 0 0 8px 8px;
}

.timelapse-controls button {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.timelapse-controls button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Play icon (triangle) */
.tl-play-btn::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 11px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 2px;
}

/* Pause icon (two bars) */
.tl-play-btn.is-playing::after {
  content: '';
  width: 9px;
  height: 12px;
  border-style: double;
  border-width: 0 0 0 9px;
  border-color: currentColor;
  margin-left: 0;
}

/* Stop icon (square) */
.tl-stop-btn::after {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  background: currentColor;
  border-radius: 1px;
}

/* Fullscreen icon (expand arrows) */
.tl-fullscreen-btn::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.tl-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 5.5em;
  text-align: center;
}

/* Seekbar (range input) */
.tl-seekbar {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  min-width: 0;
}

.tl-seekbar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  border: none;
}

.tl-seekbar::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  border: none;
}

/* --- Image Lightbox Overlay ------------------------------- */
.timelapse-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.timelapse-overlay.hidden {
  display: none;
}

.timelapse-overlay-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timelapse-overlay-content img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--border-radius);
  object-fit: contain;
  background: #000;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
}

.timelapse-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.2s ease;
  line-height: 1;
}

.timelapse-close:hover {
  color: #fff;
}


/* --- Score Chart ------------------------------------------- */
.score-chart-card {
  margin-bottom: var(--gap);
}

.score-chart-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}

.score-chart-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.score-chart-canvas-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

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

/* Image preview on hover */
.score-preview {
  width: 200px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-body);
  border: var(--border-card);
  transition: opacity 0.2s ease;
}

.score-preview.hidden {
  opacity: 0;
  pointer-events: none;
}

.score-preview img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.02);
}

.score-preview-label {
  display: block;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.25rem;
}

@media (max-width: 768px) {
  .score-chart-body {
    flex-direction: column;
  }
  .score-preview {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }
  .score-chart-canvas-wrap canvas {
    height: 160px !important;
  }
}

/* --------------- Phase Bar --------------------------------- */

.phase-bar {
    display: flex;
    gap: 2px;
    margin: 4px 0 0 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
}

.phase-bar.hidden { display: none; }

.phase-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background 0.15s;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    min-height: 22px;
}

.phase-segment:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
}

.phase-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

/* --------------- Protokoll Textbox -------------------------- */

.protokoll-textbox {
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 14px 16px;
}

.protokoll-textbox.hidden { display: none; }

.textbox-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.textbox-nav-btn {
    background: none;
    border: none;
    color: rgba(245, 158, 11, 0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
    flex-shrink: 0;
}

.textbox-nav-btn:hover:not(:disabled) {
    color: rgba(245, 158, 11, 0.9);
    background: rgba(255, 255, 255, 0.06);
}

.textbox-nav-btn:disabled {
    color: rgba(255, 255, 255, 0.12);
    cursor: not-allowed;
}

.textbox-title {
    color: #f59e0b;
    font-size: 0.9rem;
    font-weight: 600;
    flex: 1;
}

.textbox-inline-score {
    color: #22c55e;
    font-weight: 700;
}

/* Checkbox styling in protocol entries */
.textbox-body input[type="checkbox"] {
    accent-color: #22c55e;
    margin-right: 0.4em;
}
.textbox-body li:has(input[type="checkbox"]:checked) {
    color: rgba(34, 197, 94, 0.7);
}
.textbox-body li:has(input[type="checkbox"]:not(:checked)) {
    color: rgba(245, 158, 11, 0.8);
}

/* Warning/alert highlights */
.textbox-body strong:has(~ em), .textbox-body blockquote {
    border-left-color: rgba(245, 158, 11, 0.4);
}

.textbox-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.textbox-score {
    color: rgba(34, 197, 94, 0.8);
    font-weight: 600;
    font-size: 0.8rem;
}

.textbox-body {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.8rem;
    line-height: 1.7;
}

.textbox-body p { margin: 0 0 0.6rem 0; }
.textbox-body p:last-child { margin-bottom: 0; }
.textbox-body strong { color: rgba(255, 255, 255, 0.75); }
.textbox-body ul, .textbox-body ol { padding-left: 1.2rem; margin: 0.3rem 0; }
.textbox-body li { margin-bottom: 0.2rem; }
.textbox-body blockquote {
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    margin: 0.5rem 0;
}

.textbox-stats {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
}

.textbox-placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-style: italic;
}

/* No-bullet lists (Aufgaben, Log) */
.textbox-body .protokoll-no-bullets {
    list-style: none;
    padding-left: 0;
}
.textbox-body .protokoll-no-bullets li {
    padding: 0.15rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* Timestamp highlights in log entries */
.protokoll-timestamp {
    color: #f59e0b;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    margin-right: 0.4em;
}

.textbox-header .btn-edit {
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* --- Protokoll --------------------------------------------- */

/* Expanded detail */
.protokoll-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Bold-only paragraphs — BudBot writes "**PROGRESS...**" as standalone lines
   which become <p><strong>...</strong></p> and look like huge headers. Cap them. */
.protokoll-detail .protokoll-section-header {
  font-size: 0.82rem;
  margin: 0.6rem 0 0.2rem;
  line-height: 1.4;
  color: var(--amber);
}
.protokoll-detail .protokoll-section-header strong {
  font-weight: 600;
  color: inherit;
}

/* Headings — cap at parent font-size, never browser-default h1/h2 */
.protokoll-detail h1,
.protokoll-detail h2,
.protokoll-detail h3,
.protokoll-detail h4,
.protokoll-detail h5,
.protokoll-detail h6 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--amber);
  margin: 0.75rem 0 0.25rem;
  line-height: 1.4;
}

.protokoll-detail p { margin-bottom: 0.35rem; }
.protokoll-detail strong { color: var(--text-primary); font-size: inherit; }

/* Horizontal rules — subtle separator */
.protokoll-detail hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 0.5rem 0;
}

/* Lists — visibly indented from surrounding text */
.protokoll-detail ul,
.protokoll-detail ol {
  margin: 0.3rem 0 0.4rem 1rem !important;
  padding-left: 1.2em !important;
  list-style-position: outside !important;
}
.protokoll-detail ul { list-style-type: disc !important; }
.protokoll-detail ol { list-style-type: decimal !important; }
.protokoll-detail li {
  margin-bottom: 0.2rem;
  padding-left: 0.25em;
}
.protokoll-detail li ul,
.protokoll-detail li ol {
  margin: 0.15rem 0 0.15rem 0.5rem !important;
}

/* Tables — compact */
.protokoll-detail table,
.textbox-body table { border-collapse: collapse; width: 100%; margin: 0.35rem 0; }
.protokoll-detail th, .protokoll-detail td,
.textbox-body th, .textbox-body td { padding: 0.2rem 0.4rem; border: 1px solid rgba(255,255,255,0.08); text-align: left; font-size: 0.78rem; }
.protokoll-detail th,
.textbox-body th { color: rgba(255, 255, 255, 0.5); font-weight: 500; }
/* First column (parameter name) */
.textbox-body td:first-child { color: rgba(255, 255, 255, 0.7); font-weight: 500; }
/* Value columns — monospace, default white */
.textbox-body td:nth-child(n+2) { font-family: 'JetBrains Mono', monospace; }
/* Status-colored table cells (set by JS based on ✓/⚠️ markers) */
.textbox-body td.status-ok { color: rgba(34, 197, 94, 0.85); }
.textbox-body td.status-warn { color: rgba(245, 158, 11, 0.9); }
.textbox-body td.status-critical { color: rgba(239, 68, 68, 0.9); }
/* Parenthesized targets within value cells — subdued */

/* Blockquotes */
.protokoll-detail blockquote {
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  margin: 0.25rem 0;
  padding: 0.15rem 0.5rem;
  color: var(--text-secondary);
}

/* Code inline */
.protokoll-detail code {
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.protokoll-collapse-btn {
  display: block;
  margin: 0.75rem auto 0;
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  padding: 0.25rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.protokoll-collapse-btn:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

/* Timelapse highlight */
.timelapse-highlight {
  background: rgba(224, 64, 251, 0.1);
  color: var(--timelapse);
  border-left: 2px solid var(--timelapse);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Edit mode */
.protokoll-edit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.protokoll-edit-toolbar .btn-timelapse {
  background: none;
  border: 1px solid rgba(224, 64, 251, 0.3);
  color: var(--timelapse);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  min-height: 44px;
}

.protokoll-edit-toolbar .btn-timelapse:hover,
.protokoll-edit-toolbar .btn-timelapse:focus {
  background: rgba(224, 64, 251, 0.1);
  outline: none;
}

.protokoll-textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.75rem;
}

.protokoll-textarea:focus {
  outline: none;
  border-color: rgba(6, 182, 212, 0.4);
}

.protokoll-char-count {
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.protokoll-char-count.warn { color: var(--amber); }
.protokoll-char-count.over { color: var(--red); }

.protokoll-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.protokoll-edit-footer .btn-save {
  background: var(--cyan);
  color: var(--bg-body);
  border: none;
  padding: 0.4rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
}

.protokoll-edit-footer .btn-cancel {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-secondary);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-edit {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-edit:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

/* Skeleton loader */
.protokoll-loading {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.skeleton-card {
  height: 100px;
  border-radius: var(--border-radius);
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Kosten Tab -------------------------------------------- */
.kosten-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.kosten-card h2 {
  font-size: 0.9rem;
}

.kosten-summary-card {
  grid-column: 1 / -1;
}

.kosten-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.kosten-table th {
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
}

.kosten-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.kosten-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.kosten-amount {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.kosten-num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.kosten-total {
  font-weight: 600;
  color: var(--green);
}

.kosten-table tfoot td {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  padding-top: 0.5rem;
  font-weight: 500;
}

.kosten-elec-summary {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.kosten-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}

.kosten-stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kosten-stat-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.kosten-stat-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.kosten-projected {
  color: var(--amber);
}

/* Summary */
.kosten-summary-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kosten-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
}

.kosten-summary-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.kosten-summary-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.kosten-summary-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0.15rem 0;
}

.kosten-summary-total .kosten-summary-label {
  font-weight: 600;
  color: var(--text-primary);
}

.kosten-summary-total .kosten-summary-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--green);
}

.kosten-summary-projected .kosten-summary-value {
  color: var(--amber);
  font-weight: 600;
}

.kosten-footnote {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Yield estimation */
.kosten-yield-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kosten-yield-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Scale-based yield bar */
.kosten-yield-scale-row {
  position: relative;
  height: 1.1rem;
}

.kosten-yield-scale-label {
  position: absolute;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.kosten-yield-price-tick {
  font-size: 0.6rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

.kosten-yield-bar-container {
  position: relative;
  height: 14px;
}

.kosten-yield-bar {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  /* gradient set dynamically via JS */
}

/* Tick marks every 10g */
.kosten-yield-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-0.5px);
}

/* Confidence interval bracket */
.kosten-yield-bracket {
  position: absolute;
  top: -3px;
  height: calc(100% + 6px);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  pointer-events: none;
}

/* Arrows at bracket edges */
.kosten-yield-arrow {
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
}

.kosten-yield-arrow-l {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid rgba(255, 255, 255, 0.85);
  transform: translate(2px, -50%);
}

.kosten-yield-arrow-r {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid rgba(255, 255, 255, 0.85);
  transform: translate(-8px, -50%);
}

/* Most likely marker (diamond) */
.kosten-yield-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

.kosten-yield-confidence {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.kosten-yield-note {
  font-style: italic;
  opacity: 0.7;
}

.kosten-cpg-wrap {
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.kosten-cpg-good {
  color: var(--green) !important;
}

.kosten-cpg-bad {
  color: var(--red) !important;
}

/* Reusable items */
.kosten-reusable-header .kosten-summary-label {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-style: italic;
}

.kosten-reusable-item .kosten-summary-label {
  padding-left: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.kosten-reusable-item .kosten-summary-value {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.kosten-reusable-total .kosten-summary-value {
  color: var(--green);
}

.kosten-nextgrow .kosten-summary-label {
  font-size: 0.82rem;
}

.kosten-nextgrow .kosten-summary-value {
  color: var(--cyan);
}

.kosten-cpg-adjusted .kosten-summary-label {
  font-size: 0.82rem;
  font-style: italic;
}

.kosten-cpg-adjusted .kosten-summary-value {
  color: var(--green);
}

/* Hero card (Ernteprognose eye-catcher) */
.kosten-hero {
  border: 1px solid rgba(34, 197, 94, 0.2);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.03) 0%, rgba(6, 182, 212, 0.03) 100%);
}

.kosten-hero h2 {
  font-size: 1.05rem;
  color: var(--green);
}

/* Amortized cost per gram row */
.kosten-amort-cpg-row {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.kosten-cpg-amort {
  color: var(--cyan) !important;
}

/* Amortized summary value */
.kosten-summary-amort .kosten-summary-value {
  color: var(--cyan);
  font-weight: 600;
}

.kosten-summary-amort .kosten-summary-label {
  font-weight: 600;
  color: var(--text-primary);
}

/* Progress bar */
.kosten-progress-wrap {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
}

.kosten-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.kosten-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.kosten-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Langzeit section layout */
.kosten-langzeit-wrap {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.kosten-langzeit-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kosten-section-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Amortization & history table column widths */
.kosten-amort-table {
  table-layout: fixed;
}

.kosten-amort-table th:nth-child(1),
.kosten-amort-table td:nth-child(1) { width: auto; }
.kosten-amort-table th:nth-child(2),
.kosten-amort-table td:nth-child(2) { width: 80px; }
.kosten-amort-table th:nth-child(3),
.kosten-amort-table td:nth-child(3) { width: 85px; }
.kosten-amort-table th:nth-child(4),
.kosten-amort-table td:nth-child(4) { width: 70px; }

.kosten-hist-table {
  table-layout: fixed;
}

.kosten-hist-table th:nth-child(1),
.kosten-hist-table td:nth-child(1) { width: 25px; }
.kosten-hist-table th:nth-child(2),
.kosten-hist-table td:nth-child(2) { width: auto; }
.kosten-hist-table th:nth-child(3),
.kosten-hist-table td:nth-child(3) { width: 35px; }
.kosten-hist-table th:nth-child(4),
.kosten-hist-table td:nth-child(4) { width: 55px; }
.kosten-hist-table th:nth-child(5),
.kosten-hist-table td:nth-child(5) { width: 90px; }
.kosten-hist-table th:nth-child(6),
.kosten-hist-table td:nth-child(6) { width: 60px; }

/* Grouped amortization table */
.kosten-cat-header {
  cursor: pointer;
  user-select: none;
}

.kosten-cat-header td {
  font-weight: 500;
  color: var(--text-primary);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kosten-cat-header:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.kosten-cat-total {
  font-weight: 500;
  color: var(--text-primary);
}

.kosten-cat-hidden {
  display: none;
}

.kosten-cat-item td:first-child {
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* --- Mobile -------------------------------------------------- */
@media (max-width: 768px) {
  .tab-bar { margin-left: 0.75rem; }
  .tab-btn { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
  .protokoll-textarea { min-height: 200px; }
  .kosten-grid { grid-template-columns: 1fr; }

  /* Stat boxes: stack vertically */
  .kosten-elec-summary {
    flex-direction: column;
    gap: 0.5rem;
  }

  .kosten-stat {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
  }

  .kosten-stat-label {
    font-size: 0.7rem;
    text-align: left;
  }

  .kosten-stat-value {
    font-size: 1rem;
    text-align: right;
  }

  .kosten-stat-sub {
    font-size: 0.68rem;
    text-align: right;
  }

  /* Tables: smaller text, tighter padding */
  .kosten-table {
    font-size: 0.75rem;
  }

  .kosten-table th,
  .kosten-table td {
    padding: 0.25rem 0.35rem;
  }

  .kosten-amount,
  .kosten-num {
    font-size: 0.73rem;
  }

  /* Summary items: stack label above value on narrow screens */
  .kosten-summary-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }

  .kosten-summary-value {
    font-size: 0.88rem;
  }

  /* Yield bar: hide price ticks (too cramped), enlarge gram labels */
  .kosten-yield-price-tick {
    display: none;
  }

  .kosten-yield-scale-label {
    font-size: 0.6rem;
  }

  /* Yield confidence: stack */
  .kosten-yield-confidence {
    flex-direction: column;
    gap: 0.2rem;
  }

  /* Reusable items: tighter */
  .kosten-reusable-item .kosten-summary-label {
    padding-left: 0.4rem;
    font-size: 0.75rem;
  }

  .kosten-reusable-item .kosten-summary-value {
    font-size: 0.75rem;
  }

  .kosten-footnote {
    font-size: 0.65rem;
  }

  /* Hero: slightly smaller on mobile */
  .kosten-hero h2 {
    font-size: 0.95rem;
  }

  /* Amort cpg row: stack */
  .kosten-amort-cpg-row {
    margin-top: 0.3rem;
    padding-top: 0.3rem;
  }

  /* Section titles */
  .kosten-section-title {
    font-size: 0.75rem;
  }
}

/* Yield bar on Dashboard tab */
.yield-dashboard-card {
  margin-bottom: 1rem;
}

.yield-bar-section {
  width: 100%;
}

.yield-bar-section h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

/* Reasoning click-to-expand */
.yield-reasoning-trigger {
  cursor: pointer;
  margin-left: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.6;
  transition: opacity 0.2s;
  user-select: none;
}

.yield-reasoning-trigger:hover,
.yield-reasoning-trigger.active {
  opacity: 1;
}

.yield-reasoning-text {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 0.5rem 0 0;
  line-height: 1.4;
}

.yield-reasoning-text.hidden {
  display: none;
}
