        .warning        { color:#b30000; font-weight:700; }
        .status-ok      { color:#006400; font-weight:600; }
        .status-warn    { color:#b30000; font-weight:600; }
.text-danger { color: var(--danger-600); }
.text-success { color: var(--success-600); }
.bg-overlay { background-color: var(--surface); }
.details { display: none; }
.details.open { display: block; }

html, body {
  overflow-x: hidden;
}

.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid currentColor;
  background: transparent;
}

.status-chip .material-symbols-rounded {
  font-size: 16px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}

.chip-ok {
  color: var(--success-600);
  border-style: solid;
}

.chip-hint {
  color: var(--brand-600);
  border-style: dotted;
}

.chip-warn {
  color: #b30000;
  border-style: dashed;
}

.chip-alarm {
  color: var(--danger-600);
  border-style: double;
  border-width: 2px;
}

/* Climate tile additions */
.timestamp {
  font-size: 0.75rem;
  margin-left: auto;
  color: var(--text-secondary);
}

.warn-strip {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-top: 4px;
  border-radius: var(--radius-1);
  font-size: 0.85rem;
}

.warn-strip.warn {
  display: flex;
  background: #fff3cd;
  color: #664d03;
}

.warn-strip.alarm {
  display: flex;
  background: #f8d7da;
  color: #842029;
}

.plant-response {
  display: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 4px;
}

.info-icon {
  background: none;
  border: none;
  padding: 0 0 0 4px;
  cursor: pointer;
  color: inherit;
}

.hidden { display: none !important; }
:root{
  /* Spacing & radius */
  --space-1:4px;
  --space-2:8px;
  --space-3:16px;
  --radius-1:6px;
  /* Surfaces & borders */
  --surface:#ffffffcc;
  --surface-border:#e6f7f0;
  /* Brand & semantic palette */
  --brand-600:#007a33; /* contrast 5.11 on body-bg */
  --success-600:#006400; /* contrast 6.93 on body-bg */
  --danger-600:#d50000; /* contrast 5.11 on body-bg */
  --text-secondary:#555;
  --body-bg:#f5f7fa;
  --text-primary:#222;
}

/* Dark theme palette tuned with WCAG contrast guidance */
body.dark-mode{
  --surface:#0f1d14cc;
  --surface-border:#173b2f;
  --brand-600:#00a95c; /* contrast 6.09 on body-bg */
  --success-600:#00e676; /* contrast 10.43 on surface */
  --danger-600:#ff8080; /* contrast 7.17 on surface */
  --text-secondary:#c7d1cc;
  --body-bg:#0b120d;
  --text-primary:#e0e0e0;
}
/* lighten monochrome icons for clarity on dark background without losing accent colours */
body.dark-mode img[src*="fonts.gstatic.com"] {
  filter: var(--icon-filter, brightness(1.8) saturate(1.2));
}
/* icons sitting on light surfaces keep their original colours */
body.dark-mode .booster-bubble,
body.dark-mode .nutri-item,
body.dark-mode .device-icon {
  --icon-filter: none;
}
body.dark-mode .button-image :is(img, lottie-player, .lottie) {
  /* brighten icons for contrast on dark background */
  filter: brightness(1.8) saturate(1.2);
}
/* -----------------  tiny traffic-light circles  ------------------ */
.status-indicator        { width:14px; height:14px; border-radius:50%;
                           display:inline-block; margin-right:6px;
                           box-shadow:0 0 4px rgba(0,0,0,.4); }
.status-green            { background:#00c853; }   /* material green A700 */
.status-red              { background:#d50000; }   /* material red A700   */

/* nicer warning list */
#growWarnings           { margin:6px 0 0 6px; padding-left:14px; }
#growWarnings li        { list-style:none; margin:2px 0;
                          position:relative; padding-left:20px; }
#growWarnings li::before{ content:"⚠"; position:absolute; left:0; }

/* optional: colour ages >3 h amber even when not stale (purely cosmetic) */
.age-amber              { color:#ff8f00; font-weight:600; }
  /* give the little inline icons a predictable size */
.device-icon.sm   { width:20px; height:20px; }

/* red version used for any “bad / stale” condition */
.device-icon.bad  { }

        /* Slider container styling */
        .slider-container {
          margin: 15px 0;
        }
  /* centre big numbers inside the metric circles */
.metric-value      { font-size:1.25rem; font-weight:700; line-height:1; }
/* soft themed backgrounds for metric icons */
  .device-icon {
    background:#d8f3dc;
    border-radius:50%;
  }
  body.dark-mode .device-icon {
    background:#1e4d3d;
  }
  .device-icon.good {
    border:2px solid #00c853;
  }
  .device-icon.bad {
    border:2px solid #d50000;
  }
/* red tint for stale‐FYTA icon */
.device-icon.stale { }   /* 🔴 */

        .slider-label {
          font-weight: bold;
          margin-bottom: 5px;
        }
  
        .slider-value {
          display: inline-block;
          margin-left: 10px;
          font-weight: bold;
          color: #333;
        }
  
        /* round-slider container */
        .round-slider-container {
          text-align: center;
          margin-top: 20px;
        }
        .tile-container > .tile:first-child {
          grid-column: 1 / -1; /* This makes the first tile span all columns */
          grid-row: 1; /* keep menu in the first grid row */
          width: 100%; /* stretch across the screen */
          justify-self: stretch;
          display: flex;
          flex-direction: row; /* lay out menu elements horizontally */
          justify-content: center;
          align-items: center;
          text-align: center;
        }
        .roundslider-label {
          margin-top: 10px;
          font-weight: bold;
        }
  
        /* Entries table */
        .entries-table {
          width: 100%;
          border-collapse: collapse;
          margin-top: 20px;
        }
  
        .entries-table th,
        .entries-table td {
          padding: 10px;
          border-bottom: 1px solid #ddd;
          white-space: normal; 
          word-wrap: break-word; 
          overflow-wrap: anywhere; 
          /* 
            Optionally:
            overflow-wrap: anywhere;
            word-break: break-all; 
          */
        }
        
  
        .entries-table th {
          background: #f0f0f0;
          font-weight: bold;
        }
  
        .entries-table tr:hover {
          background: #f9f9f9;
        }
  
        .entries-table caption {
          caption-side: top;
          font-weight: bold;
          table-layout: fixed; /* Force columns to share space proportionally */
          width: 100%;
          word-wrap: break-word;
          border-collapse: collapse;
        }  
      /* Copy entire style block from index */
      body {
        font-family: 'IBM Plex Serif', serif;
        margin: 0;
        padding: 0;
        border: none;
        background-color:var(--body-bg);
        color:var(--text-primary);
        background-image:none !important;
        max-width: none !important;
      }
      .device-timer {
        position: absolute;
        top: -5px;
        right: -5px;
        background: rgba(255, 0, 0, 0.7);
        color: #fff;
        padding: 2px 5px;
        border-radius: 50%;
        font-size: 0.8em;
      }
      .sensor-age-badge {
        position: absolute;
        top: -6px;
        right: -6px;
        min-width: 36px;
        text-align: center;
        background: rgba(0, 128, 64, 0.85);
        color: #fff;
        padding: 2px 6px;
        border-radius: 999px;
        font-size: 0.8em;
        line-height: 1.3;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
        transition: background-color 0.3s ease;
      }
      .sensor-age-badge.stale {
        background: rgba(200, 0, 0, 0.85);
      }
      .sensor-age-badge.fresh {
        background: rgba(0, 128, 64, 0.85);
      }
      .device-wrapper {
        position: relative;
        display: inline-block;
      }
      .tile-container {
        align-self: center;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
        font-family: 'IBM Plex Serif', serif;
      }
      
      @media (min-width: 600px) {
        .tile-container {
          grid-template-columns: repeat(2, 1fr); /* Two columns for medium screens */
        }
      }
      
      @media (min-width: 1024px) {
        .tile-container {
          grid-template-columns: repeat(3, 1fr); /* Three columns for larger screens */
        }
      }
      @media (min-width: 1300px) {
        .tile-container {
          grid-template-columns: repeat(4, 1fr);
        }
      }
      .tile {
        font-family: 'IBM Plex Serif', serif;
        background: var(--surface);
        border: 1px solid var(--surface-border);
        border-radius: var(--radius-1);
        padding: var(--space-3);
        overflow-x: auto;
        max-width: 100%;
        box-shadow: 0 4px 8px rgba(0,0,0,0.15); /* Enhance visibility */
        text-align: left;
      }
.tile:hover{ box-shadow:0 4px 12px rgba(0,0,0,.08); }
      .tile h1, .tile h2 {
        margin-top: 0;
        color:var(--text-primary);
      }

/* Modern heading typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Roboto Slab', serif;
  color: var(--text-primary);
  margin: 1.2em 0 0.6em;
  line-height: 1.2;
  font-weight: 600;
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
  letter-spacing: -0.015em;
  border-bottom: 2px solid #ddd;
  padding-bottom: 0.3em;
}

h3 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 1.5rem;
}

h5 {
  font-size: 1.25rem;
}

h6 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
      .day-block {
        display:inline-block;
        width:10px;
        height:10px;
        margin:1px;
        border-radius:2px;
        box-shadow:0 0 2px rgba(0,0,0,.45);
        transition:transform .2s ease;
        cursor:pointer;
      }
      .day-block:hover { transform:scale(1.4); }
      .seedling { background-color: lightgreen; }
      .vegetation { background-color: green; }
      .bloom { background-color: yellowgreen; }
      .flushing { background-color: blue; }
      .today {
        border: 2px solid red;
        background-color: aqua;
        width: 10px;
        height: 10px;
      }
      #growProgress #progress-bar { display:flex; flex-wrap:wrap; justify-content:center; margin-bottom:6px; }
      #growProgress .legend { margin-bottom:6px; }
      #growProgress .legend-item { display:inline-flex; align-items:center; margin-right:4px; color:#000; font-size:.8rem; }
      #growProgress .legend-color { width:12px; height:12px; border-radius:2px; margin-right:4px; }
      #growProgress .progress-summary { font-size:.85rem; text-align:center; }
      .average-display {
        margin-top: 10px;
        font-weight: bold;
        text-align: center;
        background:rgba(109, 102, 102, 0.8);
        padding: 10px;
        border-radius: 5px;
        width: 90%;
      }
      .camera-feeds {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 20px;
      }
      .camera-feeds img {
        max-width: 100%;
        height: auto;
        border: 2px solid #ccc;
        border-radius: 10px;
      }
      .button-image {
        margin: 5px;
      }
        .button-image :is(img, lottie-player, .lottie) {
          width: 50px;
          height: 50px;
          border-radius: 50%;
          transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .button-image :is(img, lottie-player, .lottie):hover {
          transform: scale(1.1);
          box-shadow: 0 0 10px var(--success-600);
        }
        .menu-links a.active {
          border: 2px solid var(--brand-600);
          box-shadow: 0 0 10px var(--brand-600);
          border-radius: 50%;
        }
        body.dark-mode .menu-links a.active {
          filter: none;
        }
        body.dark-mode .menu-links a.active :is(img, lottie-player, .lottie) {
          filter: none;
        }
        .markdown-style {
          white-space: pre-wrap;
          font-family: 'IBM Plex Serif', serif;
        }
      .device-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 10px;
        text-align: center;
        margin-bottom: 20px;
      }
      .device-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
      }
      .device-item img {
        margin-bottom: 5px;
      }
      
      .device-label {
        font-size: 0.9em;
      }
      .device-icon.on {
        border: 2px solid #00c853;
        border-radius: 50%;
      }
      .device-icon.off {
        border: 2px solid #ccc;
        border-radius: 50%;
      }
      .device-icon.error {
        border: 2px solid #ff5722;
        border-radius: 50%;
      }
      .device-item.problem {
        box-shadow: 0 0 10px 2px #ff5722;
        border-radius: 8px;
      }
      .radio-container {
        margin-bottom: 20px;
      }
      .trend,
      .trend-arrow {
        font-size: 1.2em;
        margin-left: 4px;
        transition: color .3s ease, transform .3s ease;
      }
      .trend-up   { color:#00c853; transform: translateY(-1px); }  /* green ↑ */
      .trend-down { color:#d50000; transform: translateY( 1px); }  /* red   ↓ */
      .trend-stable { color:#999; }
      .data-line {
        display: flex;
        align-items: center;
        margin: 5px 0;
      }
      .data-line strong {
        margin-right: 5px;
      }
      .data-line span {
        margin-right: 5px;
      }
      /* ───── Generic “informational” blue ───── */
  .device-icon.info {
    border: 2px solid #2196f3;
    border-radius: 50%;
  }

/* ───── Phase colours (match grow-tracker blocks) ───── */
.device-icon.seedling   { }
.device-icon.vegetation { }
.device-icon.bloom      { }
.device-icon.flushing   { }

/* Fert-Today line must not “explode” the layout                */
#metricFertToday.metric-value{
  font-size:0.9rem;               /* a tad smaller               */
  max-width:80px;                 /* never wider than DLI tile   */
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

      .trend-arrow,
      #vpdTrendArrow,
      #humidityTrendArrow,
      #temperatureTrendArrow { transition: color .3s ease; }

/* Modern form fields */
input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  padding: 0.6em 1em;
  border: none;
  border-radius: 0.5em;
  background: #f0f0f5;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 1rem;
  transition: box-shadow 0.3s ease, background 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
  outline: none;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 150, 255, 0.5);
}

/* Modern buttons */
button,
input[type="submit"],
input[type="button"] {
  padding: 0.6em 1.2em;
  background: linear-gradient(135deg, #00c853 0%, #007a33 100%);
  color: #ffffff;
  border: none;
  border-radius: 0.5em;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

button:active,
input[type="submit"]:active,
input[type="button"]:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
    /* ─── Refresh‑indicator ─────────────────────────────── */
    .device-item {                   /* allow overlay positioning */
      position: relative;
    }

    @keyframes flashRefresh {
      0%   { opacity: 0; transform: scale(0.4); }
      10%  { opacity: 1; transform: scale(1.2); }
      90%  { opacity: 1; transform: scale(1);   }
      100% { opacity: 0; transform: scale(0.4); }
    }
    .refresh-indicator {
      position: absolute;
      top: -6px;
      left: -6px;
      font-size: 1.1rem;
      line-height: 1;
      color: #007a33;          /* corporate green */
      pointer-events: none;
      animation: flashRefresh 0.8s ease-out forwards;
      text-shadow: 0 0 2px #0008;
    }

    @keyframes flashBg {
      from { background-color: rgba(255,255,255,0.8); }
      to   { background-color: var(--surface); }
    }

    .flash-refresh {
      animation: flashBg 0.8s ease-out;
    }
/* ─── Touch‑friendly overrides (2025) ─────────────────────────── */
:root{
  --nav-btn-size:72px;                       /* bigger hit area   */
}

/* make the whole nav row scrollable on narrow screens */
.navbar{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;          /* Firefox */
}
.navbar::-webkit-scrollbar{display:none;}    /* WebKit */

.navbar a{
  flex:0 0 auto;                 /* never shrink */
  width:var(--nav-btn-size);
  height:var(--nav-btn-size);
  margin:0 4px;
  touch-action:manipulation;     /* better mobile feedback */
  border-radius:20%;             /* softened circle */
}

/* Tap ripple */
@keyframes rip{from{transform:scale(0);opacity:.5}to{transform:scale(2);opacity:0}}
.navbar a:active::before{
  content:'';
  position:absolute;
  inset:0;
  border-radius:inherit;
  background:rgba(255,255,255,.35);
  animation:rip .6s ease-out;
  pointer-events:none;
}

/* Active/hover tweaks (keeps previous lift‑up) */
.navbar a:active{transform:scale(.94);}
.navbar a:hover::after,
.navbar a:focus-visible::after{opacity:1;}

/* Focus ring for keyboard users */
.navbar a:focus-visible{
  outline:2px solid #0af;
  outline-offset:4px;
}

/* Icon padding so fingers don’t cover the graphic completely */
.navbar img{
  padding:6px;
  object-fit:contain;
}

/* Bigger brand logos for visual balance */
.brand-header .brand-logo{
  width:72px;
  height:72px;
}

    /* ─── Modern Grow‑Tiles (DLI / Nutrient / Growth Tracker) ─── */
.dli-card,
.nutri-grid         { display:grid; gap:8px; padding:12px;
                      border-radius:8px; background:#f7f7f7; }

.dli-phase,
.dli-week           { font-weight:600; }

.dli-gauge          { position:relative; height:12px; border-radius:6px;
                      background:#e0e0e0; overflow:hidden; }
.dli-bar            { position:absolute; inset:0;
                      background:linear-gradient(90deg,#00c853,#aeea00); }
.dli-value          { font-size:.9rem; margin-top:4px; display:inline-block; }

.nutri-grid         { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); }
.nutri-item         { text-align:center; background:#ffffffaa; border-radius:6px; padding:8px; }
.nutri-label        { display:block; font-size:.8rem; color:#555; }
.nutri-value        { font-size:1.1rem; font-weight:700; }

.booster-bubble    { display:inline-block; padding:var(--space-1) var(--space-2);
                      border:1px solid var(--brand-600); border-radius:var(--radius-1);
                      margin:var(--space-1); font-size:.85rem; }

/* Dark theme colours for nutrient grid and booster bubbles */
body.dark-mode .nutri-grid {
  background:#1a3328;
  color:var(--text-primary);
}
body.dark-mode .nutri-item {
  background:#1e4d3d;
}
body.dark-mode .booster-bubble {
  background:#255d46;
  color:var(--text-primary);
}
body.dark-mode .nutri-grid .nutri-label,
body.dark-mode .nutri-grid .nutri-value {
  color:var(--text-primary);
}
/* Ensure good contrast on light cards when dark mode is enabled */
body.dark-mode .dli-card {
  color:#000;
}

.growth-tile .progress-bar-horizontal { display:flex; height:12px;
                                        border-radius:6px; overflow:hidden;
                                        margin-bottom:8px; }
.progress-segment.seedling   { background:lightgreen; }
.progress-segment.vegetation { background:green; }
.progress-segment.bloom      { background:yellowgreen; }
.progress-segment.flushing   { background:cornflowerblue; }
.progress-segment.today      { outline:2px solid red; outline-offset:-2px; }

.progress-info      { font-size:.9rem; text-align:center; }
/* ────────────────────────────────────────────────
   Typography & Spacing Patch (June 2025)
   – IBM Plex Serif everywhere
   – Balanced heading scale
   – Uniform metric text
   – Tidy, evenly‑spaced tiles
   ──────────────────────────────────────────────── */
body,
button,
input,
select,
textarea,
.metric-label,
.metric-value {
  font-family: 'IBM Plex Serif', serif !important;
}

/* Balanced “perfect‑fourth” heading cascade */
h1 { font-size: 2.488rem; line-height: 1.15; font-weight: 700; }
h2 { font-size: 1.990rem; line-height: 1.20; font-weight: 700; }
h3 { font-size: 1.592rem; line-height: 1.25; font-weight: 700; }
h4 { font-size: 1.274rem; line-height: 1.30; font-weight: 700; }
h5 { font-size: 1.019rem; line-height: 1.35; font-weight: 700; }
h6 { font-size: 0.815rem; line-height: 1.40; font-weight: 700; }
h1, h2, h3, h4, h5, h6 {
  margin: 0.8em 0 0.4em;
  font-family: 'IBM Plex Serif', serif !important;
}

/* Uniform metric read‑outs */
.metric-value {
  font-size: 1.05rem;
  font-weight: 700;
}
.metric-label,
.device-label {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Tidy tile rhythm */
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 1.3rem 1.3rem 1.6rem;
}
.tile > *:last-child { margin-bottom: 0; }

/* Harmonise internal grid gaps */
.device-grid,
.nutri-grid,
.vpd-grid {
  gap: 1rem !important;
}
/* ───────────────────────────────────────────────────────────── */
/* END NEW STYLES */
/* ============================================================ */
      .ref-photo { width:120px; border-radius:6px; }

/* ----------------- Diary Timeline Styles ------------------ */
.diary-timeline {
  max-height: 400px;
  overflow-y: auto;
  border-left: 3px solid var(--brand-600);
  padding-left: 1rem;
}
.diary-entry {
  position: relative;
  margin-bottom: 1rem;
}
.diary-entry::before {
  content: '';
  position: absolute;
  left: -0.65rem;
  top: 0.25rem;
  width: 0.8rem;
  height: 0.8rem;
  background: var(--brand-600);
  border-radius: 50%;
}
.diary-entry .entry-date {
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.diary-entry p {
  margin: 0.2rem 0;
}
/* ----------------------------------------------------------- */

/* Dark mode toggle switch */
.menu-controls{
  position:absolute;
  top:0.5rem;
  right:1rem;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  text-align:right;
  gap:0.5rem;
  z-index:1000;
}
.theme-switch-wrapper{
  display:flex;
  align-items:center;
  gap:0.35rem;
}
.theme-label{
  font-size:0.65rem;
  letter-spacing:0.02em;
  text-transform:uppercase;
  opacity:0.65;
  color:var(--text-muted, #5f6b63);
}
.theme-switch{
  position:relative;
  display:inline-block;
  width:50px;
  height:24px;
}
.theme-switch input{
  opacity:0;
  width:0;
  height:0;
}
.theme-switch .slider{
  position:absolute;
  cursor:pointer;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background-color:#ccc;
  transition:.4s;
  border-radius:34px;
}
.theme-switch .slider:before{
  position:absolute;
  content:"";
  height:18px;
  width:18px;
  left:3px;
  bottom:3px;
  background-color:white;
  transition:.4s;
  border-radius:50%;
}
.theme-switch input:checked + .slider{
  background-color:var(--brand-600);
}
.theme-switch input:checked + .slider:before{
  transform:translateX(26px);
}

.language-switch-wrapper select{
  appearance:none;
  background-color:var(--brand-600);
  color:#fff;
  border:none;
  padding:0.25rem 1.5rem 0.25rem 0.5rem;
  border-radius:4px;
  cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 0.5rem center;
  background-size:0.65rem;
}

.language-switch-wrapper select:focus{
  outline:2px solid var(--brand-600);
}

/* ---------- Menu bar layout ---------- */
#menu-bar{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:1rem;
  text-align:left;
  width:100%;
  padding:0.5rem 1rem;
  position:sticky;
  top:0;
  z-index:100;
  background:rgba(255,255,255,0.6);
  border:1px solid var(--surface-border);
  backdrop-filter:blur(10px);
  border-radius:var(--radius-1);
  box-shadow:0 4px 12px rgba(0,0,0,0.08);
  overflow:visible; /* ensure icon glows aren't clipped */
}
body.dark-mode #menu-bar{
  background:rgba(15,29,20,0.6);
  border-color:#173b2f;
  box-shadow:0 4px 12px rgba(0,0,0,0.4);
}
#menu-bar .logo{
  height:60px;
  width:auto;
}
#menu-bar.small .logo{
  height:50px;
}
#menu-bar .menu-content{
  display:flex;
  flex-direction:column;
  gap:0.5rem;
  flex:1;
  padding-right:4rem;
}
#menu-bar .menu-links{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:1rem;
  flex-wrap:nowrap;
  max-width:100%;
  /* Allow vertical overflow so tooltips or labels can extend
     outside the menu item grid without being clipped. Enable horizontal scrolling on narrow screens without showing scrollbars. */
  overflow:visible;
  overflow-x:auto;
  scrollbar-width:none; /* Firefox */
  -ms-overflow-style:none; /* IE 10+ */
}
#menu-bar .menu-links::-webkit-scrollbar{
  display:none;
}
#menu-bar .menu-links .button-image{
  display:flex;
  align-items:center;
  justify-content:center;
  width:104px;
  height:104px;
  border-radius:50%;
  overflow:visible; /* allow icon glow to extend beyond the circle */
  transition:transform 0.2s;
  position:relative;
  box-sizing:border-box;
  background:rgba(255,255,255,0.35);
  backdrop-filter:blur(6px);
  border:1px solid rgba(255,255,255,0.3);
  box-shadow:0 2px 6px rgba(0,0,0,0.1);
}
body.dark-mode #menu-bar .menu-links .button-image{
  background:rgba(15,29,20,0.45);
  border:1px solid rgba(255,255,255,0.1);
  box-shadow:0 2px 6px rgba(0,0,0,0.6);
}
#menu-bar .menu-links .button-image :is(img, lottie-player, .lottie){
  width:80px;
  height:80px;
  border-radius:50%;
  transition:transform 0.2s;
}
#menu-bar .menu-links .button-image:hover{
  transform:scale(1.05);
}
#menu-bar .menu-links .button-image:hover :is(img, lottie-player, .lottie){
  transform:scale(1.1);
}

#menu-bar .menu-links .button-image[data-tooltip]::after{
  content:attr(data-tooltip);
  position:absolute;
  bottom:110%;
  left:50%;
  transform:translateX(-50%);
  background:rgba(0,0,0,0.45);
  color:#fff;
  padding:4px 8px;
  border-radius:8px;
  white-space:nowrap;
  opacity:0;
  pointer-events:none;
  transition:opacity 0.2s;
  z-index:10;
  backdrop-filter:blur(4px);
}

#menu-bar .menu-links .button-image:hover::after,
#menu-bar .menu-links .button-image:focus::after{
  opacity:1;
}

#menu-bar.menu-compact .menu-links{
  flex-wrap:wrap;
  justify-content:center;
}
#menu-bar.menu-compact .menu-links .button-image{
  width:84px;
  height:84px;
}
#menu-bar.menu-compact .menu-links .button-image :is(img, lottie-player, .lottie){
  width:60px;
  height:60px;
}

#menu-bar.menu-tiny .menu-links{
  flex-wrap:wrap;
  justify-content:center;
}
#menu-bar.menu-tiny .menu-links .button-image{
  width:72px;
  height:72px;
}
#menu-bar.menu-tiny .menu-links .button-image :is(img, lottie-player, .lottie){
  width:48px;
  height:48px;
}

@media (max-width: 1000px){
  #menu-bar .menu-links{
    flex-wrap:wrap;
    justify-content:center;
  }
  #menu-bar .menu-links .button-image{
    width:84px;
    height:84px;
  }
  #menu-bar .menu-links .button-image :is(img, lottie-player, .lottie){
    width:60px;
    height:60px;
  }
}

@media (max-width: 600px){
  #menu-bar{
    flex-direction:column;
    align-items:center;
    gap:0.5rem;
  }
  #menu-bar .menu-content{
    width:100%;
  }
  #menu-bar .menu-links{
    flex-wrap:wrap;
    justify-content:center;
  }
  #menu-bar .menu-links .button-image{
    width:72px;
    height:72px;
  }
  #menu-bar .menu-links .button-image :is(img, lottie-player, .lottie){
    width:48px;
    height:48px;
  }
}

/* Ensure Google charts have transparent row backgrounds in all themes */
.google-visualization-timeline rect[fill="#ffffff"],
.google-visualization-timeline rect[fill="#fff"],
.google-visualization-timeline rect[fill="#e5e5e5"],
.google-visualization-timeline rect[fill="#e6e6e6"],
.google-visualization-timeline rect[fill="#f5f5f5"],
.google-visualization-timeline rect[fill="#f8f9fa"],
.google-visualization-timeline rect[fill="#fafafa"],
.google-visualization-timeline rect[fill="#f0f0f0"]{
  fill:transparent;
}
.google-visualization-timeline text{
  fill:var(--text-primary);
}

/* Settings page enhancements */
.collapsible {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toggle-icon {
  font-size: 0.9em;
}
.help-icon {
  cursor: pointer;
  margin-left: 0.25rem;
  color: var(--brand-600);
}

/* grouped settings sections */
.settings-group {
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-1);
  padding: var(--space-2);
  margin-bottom: var(--space-3);
}

.settings-group legend {
  font-weight: 600;
}

.save-btn {
  display: block;
  margin-left: auto;
  margin-top: var(--space-2);
}

.test-btn {
  margin-top: var(--space-1);
}

.chart-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-zoom-overlay > div {
  width: 90%;
  height: 90%;
}

.chart-zoomable {
  cursor: zoom-in;
}

.ai-metrics-table {
  width: 100%;
  border-collapse: collapse;
}
.ai-metrics-table th,
.ai-metrics-table td {
  border: 1px solid var(--surface-border);
  padding: 4px 6px;
  text-align: left;
}

.skeleton {
  background: linear-gradient(90deg, #eee, #ddd, #eee);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  width: 100%;
  min-height: 1em;
  border-radius: 4px;
}

.updated-at.skeleton {
  display: none;
}

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

.why-link {
  font-size: 0.8em;
  margin-left: var(--space-1);
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}

.explain-popover {
  display: none;
  position: fixed;
  top: var(--space-3);
  right: var(--space-3);
  max-width: 240px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-1);
  padding: var(--space-2);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 1000;
}

.explain-popover.open {
  display: block;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: var(--space-3);
  right: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  z-index: 10000;
}

.toast {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-1);
  padding: var(--space-2);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

.toast-info {
  border-left: 4px solid var(--brand-600);
}

.toast-warning {
  border-left: 4px solid #b30000;
}

.toast-critical {
  border-left: 4px solid var(--danger-600);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.hide {
  opacity: 0;
  transform: translateY(10px);
}

.toast button {
  margin-left: var(--space-2);
}

body.loading .tile-container {
  display: none;
}

body.loading #menu-bar {
  display: none;
}

lottie-player,
.lottie {
  display: block;
  margin: 0 auto;
}

/* ---------------- Settings page styles ---------------- */
.settings-form label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
  font-weight: 600;
  word-break: break-word;
}

.settings-form input,
.settings-form select {
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
  width: 100%;
  box-sizing: border-box;
}

.settings-form button {
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
}

.pid-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.pid-form h3 {
  margin-bottom: var(--space-2);
}

.pid-form button,
.pid-form input {
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
}

.user-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.user-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.user-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.user-item form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
}

.tile h2,
.tile h3 {
  margin-top: 0;
  margin-bottom: var(--space-2);
}

/* ----- update overlay ----- */
body.no-scroll {
  overflow: hidden;
}
.update-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 1000;
}
.update-overlay.hidden {
  display: none;
}
.update-card {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  width: min(90%, 600px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  position: relative;
}
#updateSteps {
  max-height: 60vh;
  overflow-y: auto;
  text-align: left;
}
.update-step pre {
  max-height: 200px;
  overflow-y: auto;
}
.update-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 1001;
}
.update-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.update-step pre {
  flex-basis: 100%;
}
.update-card .anim {
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.update-step .anim {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.update-step.ok span {
  color: #2e7d32;
}

.update-step.fail span {
  color: #c62828;
}

.update-step.fail .anim {
  color: #c62828;
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
}

#loading-overlay img {
  width: 120px;
  height: auto;
}

#loading-overlay.hidden {
  display: none;
}

/* Grow calendar grid */
.calendar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start;
}
.calendar-day {
  position: relative;
  width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
}
.calendar-day video,
.calendar-day .no-video,
.calendar-day img {
  width: 90%;
  height: 90%;
  margin: 5%;
  object-fit: cover;
  display: block;
}
.calendar-day video { opacity: 0.85; }
.calendar-day .no-video {
  background: #ccc;
  border-radius: 4px;
}
.thumb-date {
  position: absolute;
  top: 2px;
  left: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 1px 3px;
  font-size: 12px;
  border-radius: 2px;
}
.calendar-day img { opacity: 0.85; }
.calendar-day.S1, .day-block.S1, .legend-color.S1 { background: #e8f5e9; }
.calendar-day.S2, .day-block.S2, .legend-color.S2 { background: #c8e6c9; }
.calendar-day.S3, .day-block.S3, .legend-color.S3 { background: #a5d6a7; }
.calendar-day.S4, .day-block.S4, .legend-color.S4 { background: #81c784; }
.calendar-day.S5, .day-block.S5, .legend-color.S5 { background: #66bb6a; }
.calendar-day.S6, .day-block.S6, .legend-color.S6 { background: #dce775; }
.calendar-day.S7, .day-block.S7, .legend-color.S7 { background: #fff176; }
.calendar-day.S8, .day-block.S8, .legend-color.S8 { background: #ffd54f; }
.calendar-day.S9, .day-block.S9, .legend-color.S9 { background: #ffb74d; }
.calendar-day.S10, .day-block.S10, .legend-color.S10 { background: #ff8a65; }
.calendar-day.S11, .day-block.S11, .legend-color.S11 { background: #f4511e; }
.legend { margin-top: 6px; }
.legend-item { display:inline-flex; align-items:center; margin-right:4px; color:#000; font-size:.8rem; }
.legend-color { width:12px; height:12px; border-radius:2px; margin-right:4px; }
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content video {
  max-width: 90vw;
  max-height: 90vh;
}
.modal-content img {
  max-width: 90vw;
  max-height: 90vh;
}
