:root{
  --bg:#06130f;
  --bg2:#071a14;
  --card:#0b2018;
  --card2:#0e2a20;
  --line:#163c2f;
  --text:#eafff6;
  --muted:#a7d5c1;
  --green:#22c55e;
  --red:#ef4444;
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --r18: 22px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font-family: "Prompt", system-ui, -apple-system, "Kanit", sans-serif;
  background: radial-gradient(900px 520px at 18% 10%, rgba(34,197,94,.18), transparent 55%),
              radial-gradient(900px 520px at 85% 0%, rgba(16,185,129,.12), transparent 52%),
              linear-gradient(180deg, var(--bg2), var(--bg));
}

.bg{
  position:fixed; inset:0;
  background:
    radial-gradient(800px 520px at 20% 0%, rgba(34,197,94,.16), rgba(34,197,94,0) 60%),
    radial-gradient(900px 600px at 80% 10%, rgba(34,197,94,.10), rgba(34,197,94,0) 62%);
  pointer-events:none;
}

.wrap{
  max-width:1100px;
  margin:0 auto;
  padding:18px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  gap:14px;
  align-items:center;
  padding:14px 16px;
  border-radius:var(--r18);
  border:1px solid rgba(34,197,94,.18);
  background: linear-gradient(90deg, rgba(34,197,94,.14), rgba(34,197,94,.04));
  box-shadow: 0 10px 34px rgba(0,0,0,.25);
}

.brandBlock{display:flex;flex-direction:column}
.brandLogo{
  font-weight:1000;
  letter-spacing:.18em;
  font-size:15px;
}
.brandSub{
  margin-top:5px;
  font-size:12.5px;
  color:rgba(234,255,246,.75);
}

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

.card{
  position:relative;
  padding:18px;
  border-radius:var(--r18);
  border:1px solid rgba(34,197,94,.16);
  background: linear-gradient(180deg, rgba(14,42,32,.85), rgba(11,32,24,.80));
  box-shadow: var(--shadow);
  overflow:hidden;
}

.shine{
  position:absolute; inset:-40%;
  background: radial-gradient(circle at 35% 20%, rgba(34,197,94,.22) 0%, rgba(34,197,94,0) 55%);
  animation: float 5.2s ease-in-out infinite;
  pointer-events:none;
}
@keyframes float{
  0%,100%{transform:translateY(-6px)}
  50%{transform:translateY(6px)}
}

.btn{
  border:0;
  border-radius:14px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:900;
  color:#062014;
  background: linear-gradient(180deg, rgba(34,197,94,1), rgba(16,185,129,1));
  box-shadow: 0 10px 28px rgba(34,197,94,.20);
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.btn:active{transform:translateY(1px)}
.btn.ghost{
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(34,197,94,.25);
  box-shadow:none;
}
.btn:hover{filter:brightness(1.03)}
.btn.ghost:hover{background:rgba(34,197,94,.08)}

.pill{
  font-size:12px;
  font-weight:900;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(34,197,94,.20);
  background: rgba(34,197,94,.10);
  color: rgba(234,255,246,.95);
}
.pillOk{border-color:rgba(34,197,94,.32);background:rgba(34,197,94,.12)}
.pillWarn{border-color:rgba(239,68,68,.32);background:rgba(239,68,68,.12)}

.mainGrid{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:14px;
  margin-top:14px;
}
.settingsGrid{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:14px;
  margin-top:14px;
}

.heroTitleRow{display:flex;align-items:center;justify-content:space-between;gap:12px}
.heroTitle{margin:0;font-size:34px;letter-spacing:-.02em}
.heroDesc{margin:10px 0 0;color:rgba(234,255,246,.78);line-height:1.55}

.statusLine{display:flex;align-items:center;gap:10px;margin-top:14px}
.dot{
  width:10px;height:10px;border-radius:99px;
  background:rgba(34,197,94,.40);
  box-shadow:0 0 0 6px rgba(34,197,94,.08);
}
.statusText{font-weight:900}

.hint{
  margin-top:10px;
  font-size:12.5px;
  color:rgba(234,255,246,.65);
}
.divider{
  height:1px;
  background:rgba(34,197,94,.14);
  margin:16px 0;
}

.manualBox{
  padding:14px;
  border-radius:18px;
  border:1px solid rgba(34,197,94,.14);
  background:rgba(6,27,20,.45);
}
.manualTitle{font-weight:1000;margin-bottom:10px}
.manualRow{display:flex;gap:10px;align-items:flex-end}
.manualHint{margin-top:10px;color:rgba(234,255,246,.70);font-size:12.5px}

.field{display:flex;flex-direction:column;gap:8px;flex:1}
label{font-size:12.5px;color:rgba(234,255,246,.78)}
input{
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(34,197,94,.18);
  background:#061b14;
  color:var(--text);
  outline:none;
}
input:focus{
  border-color: rgba(34,197,94,.45);
  box-shadow: 0 0 0 4px rgba(34,197,94,.10);
}

.footerMini{
  margin-top:16px;
  font-size:12px;
  color:rgba(234,255,246,.58);
  display:flex;gap:10px;align-items:center;flex-wrap:wrap;
}
.sep{opacity:.5}

.sideCard .sideTitle{margin:0;font-size:18px}
.sideSub{margin-top:6px;color:rgba(234,255,246,.70);font-size:12.5px;line-height:1.45}
.cats{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.catChip{
  padding:9px 12px;
  border-radius:14px;
  border:1px solid rgba(34,197,94,.18);
  background:rgba(34,197,94,.10);
  font-weight:1000;
}
.sideNote{
  margin-top:14px;
  padding:12px;
  border-radius:18px;
  border:1px solid rgba(34,197,94,.12);
  background:rgba(6,27,20,.38);
}
.noteTitle{font-weight:1000;margin-bottom:8px}
.ul{margin:0;padding-left:18px;color:rgba(234,255,246,.78);font-size:13px;line-height:1.6}

.pageTitle{margin:0;font-size:28px}
.sectionTitleRow{display:flex;align-items:center;justify-content:space-between;gap:12px}
.formRow{margin-top:12px}

.listHead{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:10px 0 12px}
.listTitle{font-weight:1000}

.catList{display:flex;flex-direction:column;gap:10px}
.catRow{
  display:flex;align-items:center;gap:10px;
  padding:10px;
  border-radius:18px;
  border:1px solid rgba(34,197,94,.12);
  background:rgba(6,27,20,.45);
}
.uBox{
  width:38px;height:38px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  font-weight:1000;
  background:rgba(34,197,94,.12);
  border:1px solid rgba(34,197,94,.18);
}
.ageInput{flex:1}
.dangerBtn{
  border-radius:14px;
  padding:10px 12px;
  cursor:pointer;
  color:var(--text);
  background:rgba(239,68,68,.12);
  border:1px solid rgba(239,68,68,.22);
  font-weight:900;
}
.actions{display:flex;justify-content:flex-end;margin-top:14px}

.toast{
  position:fixed;
  left:50%;
  bottom:16px;
  transform:translateX(-50%);
  padding:10px 14px;
  border-radius:14px;
  border:1px solid rgba(34,197,94,.20);
  background:rgba(6,27,20,.90);
  color:var(--text);
  opacity:0;
  pointer-events:none;
  transition:.18s;
}
.toast.show{opacity:1}

.modal{
  position:fixed; inset:0;
  display:none;
  z-index:999;
}
.modal.show{display:block}
.modalBackdrop{
  position:absolute; inset:0;
  background:rgba(0,0,0,.62);
}
.modalCard{
  position:relative;
  width:min(720px, calc(100% - 26px));
  margin:80px auto 0;
  border-radius:22px;
  border:1px solid rgba(34,197,94,.20);
  background: linear-gradient(180deg, rgba(14,42,32,.98), rgba(11,32,24,.98));
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modalHead{
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid rgba(34,197,94,.14);
}
.modalTitle{font-weight:1000}
.iconBtn{
  border:0;
  background:transparent;
  color:var(--text);
  font-size:18px;
  cursor:pointer;
}
.modalBody{padding:16px}
.kv{
  display:grid;
  grid-template-columns: 180px 1fr;
  gap:10px 12px;
}
.k{color:rgba(234,255,246,.68);font-size:13px}
.v{font-weight:1000}
.resultBox{
  margin-top:14px;
  padding:14px;
  border-radius:18px;
  border:1px solid rgba(34,197,94,.14);
  background:rgba(6,27,20,.45);
}
.badge{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(34,197,94,.25);
  background:rgba(34,197,94,.12);
  font-weight:1000;
  font-size:12px;
}
.bigMsg{
  margin-top:10px;
  font-size:20px;
  font-weight:1000;
  line-height:1.25;
}
.modalFoot{
  padding:14px 16px;
  border-top:1px solid rgba(34,197,94,.14);
  display:flex;
  justify-content:flex-end;
}

@media (max-width: 920px){
  .mainGrid,.settingsGrid{grid-template-columns:1fr}
}
@media (max-width: 560px){
  .heroTitle{font-size:28px}
  .manualRow{flex-direction:column;align-items:stretch}
  .manualRow .btn{width:100%}
  .kv{grid-template-columns: 1fr}
}

/* Date input polish + calendar icon */
.dateInput{
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2399f6c6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Flatpickr theme */
.flatpickr-calendar{
  background: linear-gradient(180deg, rgba(14,42,32,.98), rgba(11,32,24,.98));
  border: 1px solid rgba(34,197,94,.22);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.50);
  color: var(--text);
}
.flatpickr-weekday{ color: rgba(234,255,246,.65); font-weight: 700; }
.flatpickr-day{
  border-radius: 12px;
  color: rgba(234,255,246,.88);
}
.flatpickr-day:hover{ background: rgba(34,197,94,.12); }
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange{
  background: rgba(34,197,94,.95);
  border-color: rgba(34,197,94,.95);
  color:#062014;
  font-weight: 900;
}
.flatpickr-day.today{ border-color: rgba(34,197,94,.40); }



/* ===== TOPBAR: compact + premium ===== */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;

  padding:14px 18px;              /* ✅ ลดความหนา */
  border-radius:20px;
  border:1px solid rgba(34,197,94,.18);
  background: linear-gradient(180deg, rgba(10,35,26,.92), rgba(7,22,16,.82));
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

/* Left brand group */
.brandBlock{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 0;                   /* กันดันปุ่ม */
}

.logo{
  width:42px;                     /* ✅ ขนาดกำลังดี */
  height:42px;
  object-fit:contain;
  flex:0 0 auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.35));
}

.brandText{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.brandName{
  font-family: "Kanit","Prompt",sans-serif;
  font-size:22px;                 /* ✅ ชัด แต่ไม่ยืด */
  font-weight:900;
  letter-spacing:.20em;
  line-height:1;
  white-space:nowrap;
}

.brandSub{
  margin-top:4px;
  font-size:12.5px;
  color: rgba(234,255,246,.72);
  line-height:1.25;

  /* ✅ กัน subtitle ยาวแล้วชนปุ่ม */
  max-width: 56vw;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Right button alignment */
.nav{
  display:flex;
  align-items:center;
  gap:10px;
  flex:0 0 auto;
}

/* Make ghost button look premium */
.btn.ghost{
  border-radius:14px;
  padding:10px 14px;
  border:1px solid rgba(34,197,94,.28);
  background: rgba(6,27,20,.25);
  backdrop-filter: blur(6px);
}

.btn.ghost:hover{
  background: rgba(34,197,94,.10);
  border-color: rgba(34,197,94,.40);
}

/* Mobile polish */
@media (max-width: 560px){
  .topbar{padding:12px 14px}
  .logo{width:36px;height:36px}
  .brandName{font-size:18px; letter-spacing:.16em}
  .brandSub{max-width: 52vw; font-size:11.5px}
  .btn.ghost{padding:9px 12px}
}


/* ===== TOPBAR : 3 COLUMNS ===== */
.topbar{
  display: grid;
  grid-template-columns: auto 1fr auto; /* ซ้าย | กลาง | ขวา */
  align-items: center;
  gap: 14px;

  padding: 14px 18px;
  border-radius: 20px;
  border: 1px solid rgba(34,197,94,.18);
  background: linear-gradient(180deg, rgba(10,35,26,.92), rgba(7,22,16,.82));
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

/* ซ้าย */
.top-left{
  display:flex;
  align-items:center;
}
.logo{
  width:42px;
  height:auto;
}

/* กลาง */
.top-center{
  text-align:center;               /* ✅ อยู่กลางจริง */
  display:flex;
  flex-direction:column;
  align-items:center;
}
.brandName{
  font-family:"Kanit","Prompt",sans-serif;
  font-size:22px;
  font-weight:900;
  letter-spacing:.22em;
  line-height:1;
}
.brandSub{
  margin-top:4px;
  font-size:12.5px;
  color:rgba(234,255,246,.72);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 60vw;
}

/* ขวา */
.top-right{
  display:flex;
  align-items:center;
}

/* ปุ่ม */
.btn.ghost{
  padding:10px 14px;
  border-radius:14px;
  border:1px solid rgba(34,197,94,.28);
  background: rgba(6,27,20,.25);
}

/* Mobile */
@media (max-width: 640px){
  .brandName{font-size:18px; letter-spacing:.18em}
  .brandSub{font-size:11.5px; max-width: 52vw}
  .logo{width:36px}
}
/* ===== DESKTOP / DEFAULT ===== */
.topbar{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;

  padding: 14px 18px;
  border-radius: 20px;
  border: 1px solid rgba(34,197,94,.18);
  background: linear-gradient(180deg, rgba(10,35,26,.92), rgba(7,22,16,.82));
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

/* ซ้าย */
.top-left{
  display:flex;
  align-items:center;
}
.logo{
  width:42px;
  height:auto;
}

/* กลาง */
.top-center{
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
}
.brandName{
  font-family:"Kanit","Prompt",sans-serif;
  font-size:22px;
  font-weight:900;
  letter-spacing:.22em;
  line-height:1;
}
.brandSub{
  margin-top:4px;
  font-size:12.5px;
  color:rgba(234,255,246,.72);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 60vw;
}

/* ขวา */
.top-right{
  display:flex;
  align-items:center;
}

/* ===== MOBILE ===== */
@media (max-width: 640px){
  .topbar{
    grid-template-columns: 1fr;      /* 1 คอลัมน์ */
    text-align: center;
    gap: 10px;
  }

  /* โลโก้ขึ้นบนสุด */
  .top-left{
    justify-content: center;
    order: 1;
  }
  .logo{
    width: 52px;                     /* ขยายให้เด่น */
  }

  /* ชื่อระบบ */
  .top-center{
    order: 2;
  }
  .brandName{
    font-size:18px;
    letter-spacing:.18em;
  }
  .brandSub{
    font-size:11.5px;
    max-width: 90vw;
  }

  /* ปุ่มลงล่าง */
  .top-right{
    order: 3;
    justify-content: center;
    margin-top: 6px;
  }
}
