:root {
  --bg-canvas: #030608;
  --bg-kiosk: #080f13;
  --bg-panel: #0f1c22;
  --bg-card: #121d24;
  --bg-card-hover: #172731;
  --border-subtle: #1c323e;
  --border-focus: #2a4c5d;
  --border-active: #2ef387;
  --accent-green: #2ef387;
  --accent-cyan: #22d3ee;
  --accent-amber: #f59e0b;
  --accent-red: #ef233c;
  --text-primary: #ffffff;
  --text-secondary: #d1e2eb;
  --text-muted: #9ab3c0;

  /* Checklist / Task Typography & Touch Target Tokens */
  --task-title-size: 20px;
  --task-desc-size: 16px;
  --task-tag-size: 14px;
  --task-btn-min-height: 56px;
  --task-card-gap: 16px;
  --task-card-padding: 16px;

  /* Aliases */
  --todo-title-size: var(--task-title-size);
  --todo-desc-size: var(--task-desc-size);
  --todo-tag-size: var(--task-tag-size);
  --todo-btn-min-height: var(--task-btn-min-height);
  --todo-card-gap: var(--task-card-gap);
  --todo-card-padding: var(--task-card-padding);
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-canvas);
  background: radial-gradient(circle at 50% 18%, #10242a 0%, #080f13 65%, #04080a 100%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-family: 'Prompt', 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  letter-spacing: 0.005em;
}

/* Accessible focus visible ring */
:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

/* Reduced motion preference support */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive Kiosk & Web Viewport Container */
.kiosk-viewport {
  width: 100%;
  max-width: 880px;
  min-height: 100vh;
  height: auto;
  position: relative;
  background: radial-gradient(circle at 50% 18%, #10242a 0%, #080f13 65%, #04080a 100%);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95), 0 0 0 1px #1c323e;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 12px !important;
  gap: 12px;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .kiosk-viewport {
    padding: 20px 22px !important;
    border-radius: 24px;
    margin: 16px auto;
    min-height: calc(100vh - 32px);
  }
}

@media (min-width: 768px) {
  .kiosk-viewport {
    padding: 24px 28px !important;
    gap: 12px;
    border-radius: 32px;
    margin: 20px auto;
  }
}

/* Dedicated Physical 800x1280 Kiosk Display Profile */
@media screen and (min-width: 799px) and (max-width: 801px) and (min-height: 1279px) and (max-height: 1281px) {
  .kiosk-viewport {
    width: 800px;
    height: 1280px;
    min-width: 800px;
    max-width: 800px;
    min-height: 1280px;
    max-height: 1280px;
    border-radius: 36px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.95), 0 0 0 12px #010406;
    margin: 0;
    overflow: hidden;
  }
}

/* Top System Header */
.kiosk-viewport > header[data-purpose="system-header"] {
  min-height: 52px;
  padding: 8px 16px !important;
  border-radius: 16px;
  background: #111b22;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 640px) {
  .kiosk-viewport > header[data-purpose="system-header"] {
    min-height: 56px;
    padding: 10px 24px !important;
  }
}

.kiosk-viewport > header h1 {
  font-family: 'Prompt', sans-serif;
  font-size: 20px !important;
  font-weight: 800 !important;
  letter-spacing: 0.03em !important;
  color: #ffffff !important;
  margin: 0;
}

@media (min-width: 640px) {
  .kiosk-viewport > header h1 {
    font-size: 22px !important;
  }
}

.header-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #172731;
  border: 1px solid #284452;
  padding: 5px 12px;
  border-radius: 9999px;
}

@media (min-width: 640px) {
  .header-status-pill {
    gap: 8px;
    padding: 6px 14px;
  }
}

.header-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 9999px;
  background-color: var(--accent-green);
}

.header-status-text {
  font-size: 12px;
  font-weight: 700;
  color: #f1f7f9;
  letter-spacing: 0.05em;
}

@media (min-width: 640px) {
  .header-status-text {
    font-size: 13px;
  }
}

.header-time {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-green);
  min-width: 60px;
  text-align: right;
}

@media (min-width: 640px) {
  .header-time {
    font-size: 22px;
    min-width: 70px;
  }
}

/* Lifecycle Stage Tracker Section */
.kiosk-viewport [data-purpose="lifecycle-tracker"] {
  margin-top: 0 !important;
  padding: 12px 14px !important;
  border-radius: 20px;
}

@media (min-width: 640px) {
  .kiosk-viewport [data-purpose="lifecycle-tracker"] {
    padding: 14px 24px !important;
  }
}

/* Refined Card Surfaces */
.glass-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@media (min-width: 640px) {
  .glass-card {
    padding: 18px 22px;
  }
}

.w-13 {
  width: 3.25rem;
}

.h-13 {
  height: 3.25rem;
}

/* Specimen Container Zone */
.kiosk-viewport [data-purpose="specimen-monitoring-zone"] {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  height: auto !important;
  min-height: auto;
}

@media (min-width: 768px) {
  .kiosk-viewport [data-purpose="specimen-monitoring-zone"] {
    min-height: 440px;
    height: auto !important;
  }
}

/* Glass jar vector container styling */
.specimen-jar {
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(20,40,45,0.4) 60%, rgba(15,35,40,0.85) 100%);
  border: 1.5px solid rgba(130, 200, 220, 0.35);
  border-radius: 20px 20px 24px 24px;
  position: relative;
}

.specimen-jar::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 15%;
  right: 15%;
  height: 9px;
  background: rgba(140, 210, 230, 0.25);
  border: 1.5px solid rgba(130, 200, 220, 0.45);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

/* Specimen Plant Morphing by Stage */
.plant-leaf,
.tomato-fruit,
#plant-stem {
  transition: all 0.5s ease;
}

/* Slender cherry tomato shape: height > width, tapered natural silhouette */
.tomato-fruit {
  position: absolute;
  border-radius: 48% 48% 50% 50% / 44% 44% 56% 56% !important;
  transform-origin: center top;
  transition: transform 0.6s cubic-bezier(0.34, 1.3, 0.64, 1),
              opacity 0.5s ease,
              background 0.6s ease,
              border-color 0.6s ease,
              box-shadow 0.6s ease;
}

/* Realistic 5-point star green calyx / sepal at the crown of each tomato */
.tomato-fruit::before {
  content: '';
  position: absolute;
  top: -3.5px;
  left: 50%;
  transform: translateX(-50%);
  width: 9px;
  height: 4.5px;
  background: #22c55e;
  clip-path: polygon(50% 100%, 15% 0%, 35% 35%, 50% 10%, 65% 35%, 85% 0%);
  z-index: 3;
  transition: all 0.5s ease;
}

/* Base proportions of fruit clusters (scaled naturally to stem width) */
#plant-fruit-1 {
  width: 20px !important;
  height: 25px !important;
}

#plant-fruit-2 {
  width: 24px !important;
  height: 30px !important;
}

#plant-fruit-3 {
  width: 27px !important;
  height: 34px !important;
}

#plant-fruit-4 {
  width: 16px !important;
  height: 20px !important;
}

/* --- STAGE 1: ระยะเพาะกล้า (Seedling Sprout - วันที่ 1–25) ---
   ต้นกล้าเพิ่งงอก ลำต้นเรียวสั้น มีเฉพาะใบเลี้ยง/ใบอ่อนคู่บน ยังไม่มีผลเด็ดขาด */
#specimen-plant-container[data-stage="1"] #plant-stem {
  width: 9px;
  height: 8.5rem;
}
#specimen-plant-container[data-stage="1"] #plant-leaf-1,
#specimen-plant-container[data-stage="1"] #plant-leaf-2 {
  opacity: 0.9;
  transform: scale(0.6);
  filter: saturate(0.9);
}
#specimen-plant-container[data-stage="1"] #plant-leaf-4 {
  opacity: 0;
  transform: scale(0.2);
  pointer-events: none;
}
#specimen-plant-container[data-stage="1"] .tomato-fruit {
  opacity: 0 !important;
  transform: scale(0) !important;
  pointer-events: none;
}

/* --- STAGE 2: ระยะต้นกล้า / ย้ายปลูก-เจริญทางลำต้น (Vegetative & Budding - วันที่ 26–50) ---
   ต้นกล้าเจริญทางกิ่งก้านใบ ทรงพุ่มแตกแขนงแข็งแรง ลำต้นยืดสูง
   เริ่มพัฒนาตุ่มดอกตูม/ตุ่มผลอ่อนขนาดเล็กมาก สีเขียวสดอมเหลืองมะนาว */
#specimen-plant-container[data-stage="2"] #plant-stem {
  width: 11px;
  height: 13rem;
}
#specimen-plant-container[data-stage="2"] #plant-leaf-1,
#specimen-plant-container[data-stage="2"] #plant-leaf-2 {
  opacity: 1;
  transform: scale(0.85);
}
#specimen-plant-container[data-stage="2"] #plant-leaf-4 {
  opacity: 1;
  transform: scale(0.8);
}
#specimen-plant-container[data-stage="2"] .tomato-fruit {
  opacity: 0.8 !important;
  transform: scale(0.36) !important;
  background: linear-gradient(135deg, #a3e635 0%, #facc15 50%, #4ade80 100%) !important;
  border: 1px solid #a3e635 !important;
  box-shadow: 0 2px 6px rgba(163, 230, 53, 0.4) !important;
}
#specimen-plant-container[data-stage="2"] .tomato-fruit .fruit-gloss {
  opacity: 0.4;
}
#specimen-plant-container[data-stage="2"] .tomato-fruit::before {
  width: 6px;
  height: 3px;
  top: -2px;
  background: #4ade80;
}

/* --- STAGE 3: ระยะเติบโต / ออกดอก ติดผล และขยายผล (Fruit Enlargement - วันที่ 51–75) ---
   ผลมะเขือเทศกำลังขยายขนาดอย่างรวดเร็ว ผลขนาดกลาง สัดส่วนกำลังดี
   สีผลอยู่ในระยะ Breaker/Turning (สีเขียวอมส้ม กำลังเปลี่ยนเป็นสีส้มพีช) */
#specimen-plant-container[data-stage="3"] #plant-stem {
  width: 13px;
  height: 15.5rem;
}
#specimen-plant-container[data-stage="3"] .plant-leaf {
  opacity: 1;
  transform: scale(1);
  filter: saturate(1.05);
}
#specimen-plant-container[data-stage="3"] .tomato-fruit {
  opacity: 1 !important;
  transform: scale(0.72) !important;
  background: linear-gradient(145deg, #fdba74 0%, #f97316 45%, #65a30d 100%) !important;
  border: 1.5px solid #fb923c !important;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.4), inset 0 -2px 4px rgba(0, 0, 0, 0.3) !important;
}
#specimen-plant-container[data-stage="3"] .tomato-fruit .fruit-gloss {
  opacity: 0.75;
}
#specimen-plant-container[data-stage="3"] .tomato-fruit::before {
  width: 8px;
  height: 4px;
  top: -3px;
  background: #16a34a;
}

/* --- STAGE 4: ระยะเก็บเกี่ยว / ผลสุกเต็มที่ (Full Ripe Cherry Tomato - วันที่ 76–110) ---
   ผลมะเขือเทศเชอร์รี่สุกสมบูรณ์ สีแดงทับทิมฉ่ำเงา (Ruby Red) ผิวเต่งตึง พร้อมเก็บเกี่ยว
   สัดส่วนผลใหญ่เต็มที่ สวยงามสง่า ไม่เบียดบังลำต้นและใบ */
#specimen-plant-container[data-stage="4"] #plant-stem {
  width: 15px;
  height: 16.5rem;
}
#specimen-plant-container[data-stage="4"] .plant-leaf {
  opacity: 1;
  transform: scale(1.06);
  filter: saturate(1.15);
}
#specimen-plant-container[data-stage="4"] .tomato-fruit {
  opacity: 1 !important;
  transform: scale(0.96) !important;
  background: linear-gradient(145deg, #fda4af 0%, #ef4444 30%, #be123c 85%, #881337 100%) !important;
  border: 1.5px solid #f43f5e !important;
  box-shadow: 0 5px 14px rgba(225, 29, 72, 0.45), inset 0 -3px 6px rgba(0, 0, 0, 0.45) !important;
}
#specimen-plant-container[data-stage="4"] .tomato-fruit .fruit-gloss {
  opacity: 0.9;
}
#specimen-plant-container[data-stage="4"] .tomato-fruit::before {
  width: 10px;
  height: 5px;
  top: -4px;
  background: #15803d;
}

/* Daily Tasks Section */
.kiosk-viewport [data-purpose="tasks-card"] {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding: 18px 22px !important;
  border-radius: 20px;
}

.kiosk-viewport [data-purpose="tasks-card"] h2 {
  font-size: 21px !important;
  font-weight: 700 !important;
  color: #ffffff;
}

/* Kiosk Task Item Interactivity & Touch Targets */
.task-item-card {
  transition: all 0.2s ease;
  min-height: 62px;
  padding: 13px 18px;
  background-color: rgba(22, 35, 43, 0.75);
  border: 1px solid var(--border-subtle);
}

.home-tasks-progress-panel {
  padding: 16px 18px;
  background: linear-gradient(145deg, rgba(9, 19, 24, 0.95) 0%, rgba(6, 14, 18, 0.98) 100%);
  border: 1px solid rgba(26, 50, 60, 0.85);
  transition: all 0.25s ease;
}

.task-item-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.task-item-card.is-completed {
  background-color: rgba(18, 38, 30, 0.65);
  border-color: rgba(46, 243, 135, 0.35);
}

.task-item-card.is-overdue {
  background-color: rgba(35, 23, 11, 0.8) !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.08);
}

.task-item-card.is-overdue:hover {
  background-color: rgba(45, 29, 14, 0.9) !important;
  border-color: rgba(245, 158, 11, 0.75) !important;
}

.task-item-card .task-text {
  font-size: 16.5px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  line-height: 1.55 !important;
  letter-spacing: 0.005em !important;
}

.task-item-card.is-completed .task-text {
  color: #ffffff !important;
  text-decoration: none;
}

.task-item-card.is-due {
  background-color: rgba(32, 28, 10, 0.85);
  border-color: rgba(234, 179, 8, 0.45);
}

.task-item-card.is-due:hover {
  border-color: rgba(234, 179, 8, 0.75);
  background-color: rgba(38, 33, 12, 0.95);
}

/* Touch-friendly compact checkbox button (38x38px) */
.task-check-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  border: 2px solid rgba(148, 175, 190, 0.5);
  background: rgba(18, 33, 40, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.task-check-btn:hover {
  border-color: #2ef387;
  transform: scale(1.05);
}

.task-check-btn:active {
  transform: scale(0.95);
}

/* งานเลยเวลา: ขอบปุ่มสีส้มชัดเจน */
.task-check-btn.is-overdue,
.task-item-card.is-overdue .task-check-btn:not(.is-checked) {
  border: 2px solid #f59e0b !important;
  background: rgba(245, 158, 11, 0.12) !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.task-check-btn.is-overdue:hover,
.task-item-card.is-overdue .task-check-btn:not(.is-checked):hover {
  border-color: #fbbf24 !important;
  background: rgba(245, 158, 11, 0.2) !important;
}

/* เสร็จแล้ว: พื้นเขียวกะทัดรัด มีเครื่องหมายถูก */
.task-check-btn.is-checked {
  border: 2px solid #2ef387 !important;
  background: #2ef387 !important;
  color: #062218 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 8px rgba(46, 243, 135, 0.3);
}

.task-check-btn.is-checked:hover {
  border-color: #38f890 !important;
  background: #38f890 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 10px rgba(46, 243, 135, 0.45);
}

.task-check-btn svg {
  width: 20px !important;
  height: 20px !important;
  stroke: #062218;
  stroke-width: 3.2;
  display: block;
}

.task-text-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  min-height: 44px;
}

.task-text-link:hover .task-text {
  color: var(--accent-cyan);
}

/* Equipment Link Touch Target */
#equipment-link {
  min-height: 44px;
  padding: 10px 18px !important;
  font-size: 14px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bottom Hardware Navigation Bar */
.kiosk-viewport [data-purpose="bottom-navigation-bar"] {
  margin: 0 !important;
  padding: 8px !important;
  gap: 14px !important;
  border-radius: 18px;
  background-color: #111b22;
  border: 1px solid var(--border-subtle);
}

.kiosk-viewport [data-purpose="bottom-navigation-bar"] a {
  min-height: 60px;
  padding: 14px 20px;
  border-radius: 14px;
}

/* De-emphasized Admin Access Button in Header (Discreet icon-only for technicians) */
.admin-badge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #64748b;
  text-decoration: none;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.admin-badge-btn:hover {
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
}

/* Mobile device specific responsive refinements */
@media (max-width: 639px) {
  .kiosk-viewport [data-purpose="tasks-card"] {
    padding: 14px 14px !important;
  }

  .task-item-card {
    padding: 10px 12px;
    min-height: 52px;
  }

  .task-item-card .task-text {
    font-size: 14.5px !important;
  }

  .kiosk-viewport [data-purpose="bottom-navigation-bar"] a {
    min-height: 50px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .home-tasks-progress-panel {
    padding: 12px 14px;
  }
}

