@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root, body[data-theme="light"]{
  --bg:#F3F6FA; --bg-line:rgba(27,58,107,0.035);
  --surface:#FFFFFF; --surface-2:#F6F8FB;
  --primary:#173B70; --primary-dark:#0D2852;
  --steel:#64748B; --steel-light:#C9D3DF;
  --amber:#C97D1E; --amber-bg:#FBF0DD;
  --green:#2E7D53; --green-bg:#E4F3EA;
  --red:#B23A2C; --red-bg:#FBE7E4;
  --grey-bg:#EEF1F4;
  --text:#172B4D; --text-muted:#62738B;
  --border:#D8E2EE; --shadow:0 1px 2px rgba(20,45,82,0.04),0 10px 28px rgba(20,45,82,0.07);
}
body[data-theme="dark"]{
  --bg:#0A121D; --bg-line:rgba(255,255,255,0.025);
  --surface:#111C2B; --surface-2:#16233522;
  --primary:#6C9CDE; --primary-dark:#3E6BAA;
  --steel:#8A9AB0; --steel-light:#2A394E;
  --amber:#EFAE5C; --amber-bg:#3A2C14;
  --green:#66C48C; --green-bg:#123521;
  --red:#E48178; --red-bg:#3A1815;
  --grey-bg:#182231;
  --text:#E7ECF4; --text-muted:#8FA0B6;
  --border:#22334A; --shadow:0 1px 2px rgba(0,0,0,0.3),0 8px 24px rgba(0,0,0,0.25);
}
*{box-sizing:border-box;}
body{
  margin:0; background:var(--bg);
  background-image:
    linear-gradient(var(--bg-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-line) 1px, transparent 1px);
  background-size:28px 28px;
  font-family:'Inter',sans-serif; color:var(--text);
  transition:background-color .2s ease, color .2s ease;
  min-height:100vh;
}
h1,h2,h3,.disp{font-family:'Space Grotesk',sans-serif;}
.mono{font-family:'IBM Plex Mono',monospace;}
a{color:var(--primary);}
.wrap{max-width:1120px; margin:0 auto; padding:30px 28px 72px;}

/* ---------- App shell (sidebar layout, MS To Do style) ---------- */
.app-shell{display:flex; min-height:100vh;}
.sidebar{
  width:268px; flex-shrink:0; background:linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); border-right:1px solid var(--border);
  display:flex; flex-direction:column; padding:18px 14px; gap:4px;
  position:sticky; top:0; height:100vh; overflow-y:auto; z-index:30;
}
.sb-brand{display:flex; align-items:center; justify-content:center; padding:4px 6px 18px; margin-bottom:8px; text-decoration:none; border-bottom:1px solid var(--border);}
.sb-logo-wrap{
  display:inline-flex; align-items:center; justify-content:center; padding:8px 6px;
}
.sb-logo-img{height:62px; width:auto; display:block;}

.quick-add-sb-btn{
  display:flex; align-items:center; gap:8px; border:none; background:var(--primary); color:#fff;
  border-radius:10px; padding:11px 14px; font-size:13px; font-weight:700; cursor:pointer;
  font-family:'Inter',sans-serif; margin-bottom:16px; box-shadow:0 5px 12px rgba(23,59,112,.18); transition:transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.quick-add-sb-btn:hover{background:var(--primary-dark); box-shadow:0 8px 18px rgba(23,59,112,.23);}
.quick-add-sb-btn:active{transform:scale(.96);}

.smart-lists{display:flex; flex-direction:column; gap:2px; flex:1;}
.sb-section-label{
  font-size:10.5px; font-weight:700; color:var(--text-muted); text-transform:uppercase;
  letter-spacing:.6px; padding:14px 10px 4px;
}
.smart-item{
  display:flex; align-items:center; gap:11px; text-decoration:none; color:var(--text);
  padding:10px 11px; border-radius:9px; font-size:13px; font-weight:600; position:relative;
  transition:background-color .15s ease, color .15s ease, transform .15s ease;
}
.smart-item svg{flex-shrink:0; color:var(--text-muted); transition:color .15s ease;}
.smart-item:hover{background:var(--surface); color:var(--primary); transform:translateX(2px);}
.smart-item.active{background:rgba(23,59,112,.11); color:var(--primary); font-weight:700; box-shadow:inset 3px 0 0 var(--primary);}
.smart-item.active svg{color:var(--primary);}
.count-badge{
  margin-left:auto; background:var(--grey-bg); color:var(--text-muted); font-size:11px; font-weight:700;
  padding:1px 8px; border-radius:20px; font-family:'IBM Plex Mono',monospace;
}
.smart-item.active .count-badge{background:var(--primary); color:#fff;}

.sidebar-footer{
  border-top:1px solid var(--border); padding-top:12px; margin-top:8px;
  display:flex; flex-direction:column; gap:8px;
}
.sb-user{
  display:flex; align-items:center; gap:9px; min-width:0; text-decoration:none;
  padding:7px 8px; border-radius:9px; transition:background-color .15s ease;
}
.sb-user:hover{background:var(--surface-2);}
.sb-user.active{background:var(--grey-bg);}
.sb-user-chevron{flex-shrink:0; color:var(--text-muted); margin-left:auto;}
.avatar-circle{
  width:30px; height:30px; border-radius:50%; color:#fff; font-size:11.5px; font-weight:700;
  display:flex; align-items:center; justify-content:center; flex-shrink:0; font-family:'Space Grotesk',sans-serif;
}
.sb-user-text{flex:1; min-width:0; font-size:11px; color:var(--text-muted); line-height:1.3; overflow:hidden;}
.sb-user-text b{display:block; color:var(--text); font-size:12.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sb-icons{display:flex; align-items:center; gap:8px;}
.sb-icons .icon-link{margin-left:auto;}
.theme-toggle, .icon-link{
  border:1px solid var(--border); background:var(--surface); color:var(--text);
  width:34px; height:34px; border-radius:9px; cursor:pointer; display:flex;
  align-items:center; justify-content:center; flex-shrink:0; text-decoration:none;
}
.theme-toggle:hover, .icon-link:hover{border-color:var(--primary);}

.app-main{flex:1; min-width:0;}
.mobile-menu-btn{
  display:none; border:1px solid var(--border); background:var(--surface); color:var(--text);
  width:38px; height:38px; border-radius:9px; cursor:pointer; align-items:center; justify-content:center;
  margin:16px 0 0 16px;
}
.sidebar-overlay{display:none;}

@media (max-width:860px){
  .sidebar{
    position:fixed; left:0; top:0; transform:translateX(-100%); transition:transform .22s ease;
    width:260px; background:var(--surface) !important; opacity:1;
    box-shadow:12px 0 32px rgba(0,0,0,.35);
  }
  .sidebar.open{transform:translateX(0);}
  .mobile-menu-btn{display:flex;}
  .sidebar-overlay.open{
    display:block; position:fixed; inset:0; background:rgba(0,0,0,.58); z-index:29;
  }
}

/* ---------- Panels / cards ---------- */
section{margin-bottom:24px;}
.panel{
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  box-shadow:var(--shadow); padding:22px;
}
.section-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; flex-wrap:wrap; gap:10px;}
.section-head h2{font-size:15px; margin:0; font-weight:700; letter-spacing:-.1px;}
.page-title{font-size:24px; font-weight:700; letter-spacing:-.45px; margin:4px 0 20px;}

/* ---------- Work order (today) ---------- */
.worklog{
  position:relative; border:1.5px solid var(--primary); border-radius:10px;
  padding:20px 20px 18px; background:var(--surface);
}
.worklog::before,.worklog::after,.worklog .c2,.worklog .c3{
  content:''; position:absolute; width:14px; height:14px; border:2px solid var(--primary);
}
.worklog::before{top:-2px; left:-2px; border-right:none; border-bottom:none;}
.worklog::after{top:-2px; right:-2px; border-left:none; border-bottom:none;}
.worklog .c2{bottom:-2px; left:-2px; border-right:none; border-top:none;}
.worklog .c3{bottom:-2px; right:-2px; border-left:none; border-top:none;}
.worklog-head{display:flex; align-items:baseline; justify-content:space-between; margin-bottom:4px; flex-wrap:wrap; gap:6px;}
.worklog-head h2{margin:0; font-size:17px; font-weight:700; color:var(--primary);}
.worklog-date{font-size:12px; color:var(--text-muted);}
.worklog-sub{font-size:12.5px; color:var(--text-muted); margin:0 0 14px;}
.worklog-empty{padding:22px 6px; text-align:center; color:var(--text-muted); font-size:13.5px;}
.today-item{display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--border);}
.today-item:last-child{border-bottom:none;}
.rank{width:24px; height:24px; border-radius:6px; background:var(--grey-bg); color:var(--text-muted);
  font-family:'IBM Plex Mono',monospace; font-size:11.5px; font-weight:600;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.today-item.tag-overdue .rank{background:var(--red-bg); color:var(--red);}
.today-item.tag-today .rank{background:var(--amber-bg); color:var(--amber);}
.ti-name{font-size:13.5px; font-weight:500; margin:0 0 2px;}
.ti-meta{font-size:11.5px; color:var(--text-muted); display:flex; gap:8px; flex-wrap:wrap;}
.ti-main{flex:1; min-width:0;}
.tag{font-size:10.5px; font-weight:600; padding:3px 8px; border-radius:20px; white-space:nowrap;}
.tag-overdue .tag{background:var(--red-bg); color:var(--red);}
.tag-today .tag{background:var(--amber-bg); color:var(--amber);}
.tag-soon .tag{background:var(--grey-bg); color:var(--steel);}
.tag-hi .tag{background:var(--red-bg); color:var(--red);}

/* ---------- Forms ---------- */
form.add-form{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.stacked-form{display:flex; flex-direction:column; gap:12px;}
.field{display:flex; flex-direction:column; gap:5px;}
.field.full{grid-column:1 / -1;}
label{font-size:11.5px; color:var(--text-muted); font-weight:600; letter-spacing:.2px;}
input,select,textarea{
  border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:8px; padding:10px 11px; font-size:13.5px; font-family:'Inter',sans-serif;
  outline:none; width:100%; transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
/* Placeholder ต้องกำหนดสีเองเสมอ ไม่งั้นบาง browser จะใช้สีเทาเข้ม/ดำเป็นค่าเริ่มต้น
   ซึ่งกลืนกับพื้นหลังในโหมดมืด */
input::placeholder, textarea::placeholder{
  color:var(--text-muted); opacity:1;
}
/* Autofill ของ browser (เช่นช่อง login ที่จำรหัสผ่านไว้) จะบังคับพื้นหลังเป็นสีอ่อนเสมอ
   โดยไม่สนใจธีมของเว็บ ถ้าไม่ดักไว้ ตัวหนังสือสีอ่อน (โหมดมืด) จะกลืนกับพื้นอ่อนนั้น */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus{
  -webkit-text-fill-color:var(--text);
  -webkit-box-shadow:0 0 0 1000px var(--surface-2) inset;
  box-shadow:0 0 0 1000px var(--surface-2) inset;
  transition:background-color 9999s ease-in-out 0s;
}
/* บาง browser เรนเดอร์ popup ของ <select> แบบ native และไม่รับสไตล์จากปุ่ม select โดยตรง
   ต้องกำหนดสีให้ <option> เองอีกชั้น ไม่งั้นตัวหนังสือจะกลืนพื้นหลังในโหมดมืด */
select option{
  background-color:var(--surface); color:var(--text);
}
select option:disabled{
  color:var(--text-muted);
}
select option:checked{
  background-color:var(--primary); color:#fff;
}
textarea{resize:vertical; min-height:70px;}
input:focus,select:focus,textarea:focus{border-color:var(--primary); background:var(--surface); box-shadow:0 0 0 3px rgba(23,59,112,.12);}
input[type="file"]{padding:7px;}
input[type="checkbox"], input[type="radio"]{accent-color:var(--primary); cursor:pointer;}
input[type="time"]{cursor:pointer;}
/* ไอคอนปฏิทินของ input date/month เป็น icon สีดำตายตัวของ browser ถ้าไม่บอกว่าเป็นธีมมืด
   ไอคอนจะกลืนกับพื้นหลังมืดเช่นกัน (color-scheme บอก browser ให้เรนเดอร์ icon/ปฏิทินให้เข้ากับธีม) */
body[data-theme="dark"] input[type="date"],
body[data-theme="dark"] input[type="month"],
body[data-theme="dark"] input[type="time"]{
  color-scheme:dark;
}
.btn{
  border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:8px; padding:9px 15px; font-size:13px; font-weight:700; cursor:pointer;
  font-family:'Inter',sans-serif; text-decoration:none; display:inline-flex; align-items:center; gap:6px;
  transition:transform .14s ease, border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.btn-primary{background:var(--primary); border-color:var(--primary); color:#fff; box-shadow:0 3px 8px rgba(23,59,112,.18);}
.btn-primary:hover{background:var(--primary-dark); box-shadow:0 6px 14px rgba(23,59,112,.23);}
.btn-danger{color:var(--red); border-color:var(--red-bg);}
.btn-danger:hover{background:var(--red-bg);}
.btn:hover{border-color:var(--steel); transform:translateY(-1px);}
.btn:active{transform:translateY(0); box-shadow:none;}
.form-actions{grid-column:1/-1; display:flex; justify-content:flex-end; gap:8px; margin-top:2px;}
.form-error{background:var(--red-bg); color:var(--red); padding:10px 14px; border-radius:8px; font-size:13px; margin:0 0 12px;}
.form-success{background:var(--green-bg); color:var(--green); padding:10px 14px; border-radius:8px; font-size:13px; margin:0 0 12px;}

/* ---------- Filters ---------- */
.filters{display:flex; gap:6px; flex-wrap:wrap;}
.chip{border:1px solid var(--border); background:var(--surface); color:var(--text-muted);
  padding:5px 12px; border-radius:20px; font-size:12px; cursor:pointer; font-weight:600; text-decoration:none;}
.chip.active{background:var(--primary); border-color:var(--primary); color:#fff;}

/* ---------- Task list ---------- */
.task-list{display:flex; flex-direction:column; gap:10px;}
.task-card{background:var(--surface); border:1px solid var(--border); border-radius:12px;
  padding:14px 16px; display:flex; align-items:center; gap:14px; flex-wrap:wrap;}
.task-card.is-done{opacity:.6;}
.gear-ring{flex-shrink:0; width:48px; height:48px;}
.task-body{flex:1; min-width:180px;}
.task-top{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:3px;}
.task-name{font-size:14px; font-weight:600; margin:0; text-decoration:none; color:var(--text);}
.task-name.done{text-decoration:line-through; color:var(--text-muted);}
.prio-dot{width:8px; height:8px; border-radius:50%; flex-shrink:0;}
.prio-hi{background:var(--red);} .prio-mid{background:var(--amber);} .prio-lo{background:var(--steel);}
.task-meta{font-size:11.5px; color:var(--text-muted); display:flex; gap:10px; flex-wrap:wrap;}
.task-actions{display:flex; align-items:center; gap:6px; flex-shrink:0;}
.icon-btn{border:1px solid var(--border); background:var(--surface-2); color:var(--text-muted);
  width:30px; height:30px; border-radius:7px; cursor:pointer; display:flex; align-items:center; justify-content:center; text-decoration:none;}
.icon-btn:hover{border-color:var(--red); color:var(--red);}
.status-select{border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:7px; padding:6px 8px; font-size:11.5px; font-weight:600;}
.attach-count{font-size:11px; color:var(--steel); display:inline-flex; align-items:center; gap:4px;}

/* ---------- Attachment list (task form) ---------- */
.attach-list{list-style:none; margin:8px 0 0; padding:0; display:flex; flex-direction:column; gap:6px;}
.attach-list li{display:flex; align-items:center; justify-content:space-between; gap:8px;
  background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:8px 10px; font-size:12.5px;}
.attach-list a{text-decoration:none; font-weight:600;}

/* ---------- Task form: section grouping ---------- */
.form-section-title{
  grid-column:1/-1; font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.4px;
  color:var(--primary); margin:6px 0 -2px; padding-top:16px; border-top:1px solid var(--border);
}
.form-section-title:first-child{border-top:none; padding-top:0; margin-top:0;}
.req{color:var(--red); margin-left:2px;}
.assign-mode-row{display:flex; flex-direction:column; gap:10px; margin-bottom:10px;}
.radio-pill{
  display:grid; grid-template-columns:16px 1fr; align-items:start; gap:8px;
  font-weight:400; cursor:pointer; font-size:13px; color:var(--text); line-height:1.45; width:100%;
}
.radio-pill input[type="radio"]{margin-top:3px; width:16px; height:16px;}

/* ---------- Task form: file upload queue ---------- */
.upload-zone{
  grid-column:1/-1; border:1.5px dashed var(--border); border-radius:10px; background:var(--surface-2);
  padding:16px; display:flex; align-items:center; gap:14px; flex-wrap:wrap;
  transition:border-color .15s ease, background-color .15s ease;
}
.upload-zone.dragover{border-color:var(--primary); background:var(--grey-bg);}
.upload-zone-icon{
  width:38px; height:38px; border-radius:9px; background:var(--grey-bg); color:var(--primary);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.upload-zone-text{flex:1; min-width:200px; font-size:12.5px; color:var(--text);}
.upload-zone-hint{font-size:11px; color:var(--text-muted); margin-top:3px;}

.pending-file-list{list-style:none; margin:10px 0 0; padding:0; display:flex; flex-direction:column; gap:6px;}
.pending-file-list li{
  display:flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--border);
  border-radius:8px; padding:7px 8px 7px 10px; font-size:12.5px;
}
.pending-file-list li.pf-invalid{border-color:var(--red); background:var(--red-bg);}
.pf-icon{color:var(--steel); flex-shrink:0; display:flex;}
.pf-name{flex:1; min-width:0; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.pf-size{color:var(--text-muted); font-size:11.5px; flex-shrink:0; white-space:nowrap;}
.pf-error{color:var(--red); font-weight:600; font-size:11px; flex-shrink:0; white-space:nowrap;}
.pf-remove{
  border:none; background:transparent; color:var(--text-muted); cursor:pointer; width:24px; height:24px;
  border-radius:6px; display:flex; align-items:center; justify-content:center; flex-shrink:0; padding:0;
}
.pf-remove:hover{background:var(--red-bg); color:var(--red);}

/* ---------- Users table ---------- */
.table-scroll{
  overflow-x:auto; -webkit-overflow-scrolling:touch;
  max-width:100%;
}
.users-table{width:100%; border-collapse:collapse; font-size:13.5px;}
.users-table th, .users-table td{padding:12px 13px; border-bottom:1px solid var(--border); text-align:left; white-space:nowrap;}
.users-table th{color:var(--text-muted); font-size:10.5px; text-transform:uppercase; letter-spacing:.45px; background:var(--surface-2); font-weight:700;}
.users-table thead th:first-child{border-radius:8px 0 0 0;}
.users-table thead th:last-child{border-radius:0 8px 0 0;}
.users-table tbody tr{transition:background-color .14s ease;}
.users-table tbody tr:hover{background:rgba(23,59,112,.045);}
.users-table tbody tr:last-child td{border-bottom:none;}

/* SO table: use the page's available width and give each field an intentional, readable column. */
.accounting-layout .wrap{max-width:none; margin:0; padding-left:32px; padding-right:32px;}
.so-table{table-layout:fixed; font-size:13px;}
.so-table th, .so-table td{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; vertical-align:middle;}
.so-table th:nth-child(1){width:150px;}
.so-table td:nth-child(1){white-space:normal; overflow-wrap:anywhere; overflow:visible; text-overflow:clip;}
.so-table th:nth-child(2){width:128px;}
.so-table th:nth-child(3){width:112px;}
.so-table th:nth-child(4){width:154px;}
.so-table th:nth-child(5){width:112px;}
.so-table th:nth-child(6){width:126px;}
.so-table th:nth-child(7){width:106px;}
.so-table th:nth-child(8){width:68px;}
.so-table th:nth-child(9){width:130px;}
.so-actions{display:flex; gap:6px; align-items:center; white-space:nowrap; overflow:visible;}
@media (max-width:1200px){
  .accounting-layout .wrap{padding-left:20px; padding-right:20px;}
  .so-table{min-width:1080px; table-layout:auto;}
  .so-table th, .so-table td{white-space:nowrap; overflow-wrap:normal;}
  .so-actions{flex-wrap:nowrap;}
}
.badge{font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:20px;}
.badge-admin{background:var(--amber-bg); color:var(--amber);}
.badge-user{background:var(--grey-bg); color:var(--steel);}
.badge-inactive{background:var(--red-bg); color:var(--red);}
.badge-success{background:var(--green-bg); color:var(--green);}

/* ---------- Settings page (profile.php): toggle rows, switches, day pills ---------- */
.settings-panel + .settings-panel{margin-top:16px;}
.settings-row{
  display:flex; align-items:flex-start; justify-content:space-between; gap:14px; padding:13px 0;
}
.settings-row:first-child{padding-top:2px;}
.settings-row + .settings-row{border-top:1px solid var(--border);}
.settings-row-text{flex:1; min-width:0; padding-top:1px;}
.settings-row-text b{display:block; font-size:13.5px; font-weight:600; margin-bottom:2px; letter-spacing:0;}
.settings-row-text p{font-size:12px; color:var(--text-muted); margin:0; line-height:1.4;}
.settings-detail{
  margin:2px 0 14px 0; padding:14px 16px; background:var(--surface-2);
  border:1px solid var(--border); border-radius:10px; display:flex; flex-direction:column; gap:14px;
}
.settings-detail[hidden]{display:none;}
.settings-detail .field{max-width:220px;}
.settings-detail .field-row{display:flex; gap:12px; flex-wrap:wrap;}

.switch{position:relative; display:inline-flex; width:42px; height:24px; flex-shrink:0; cursor:pointer;}
.switch input{position:absolute; inset:0; opacity:0; margin:0; cursor:pointer;}
.switch .track{
  position:absolute; inset:0; background:var(--grey-bg); border:1px solid var(--border);
  border-radius:20px; transition:background-color .15s ease, border-color .15s ease;
}
.switch .thumb{
  position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%;
  background:var(--surface); box-shadow:0 1px 2px rgba(0,0,0,.3); transition:transform .15s ease;
}
.switch input:checked + .track{background:var(--primary); border-color:var(--primary);}
.switch input:checked + .track .thumb{transform:translateX(18px); background:#fff;}

.day-pills{display:flex; gap:6px; flex-wrap:wrap;}
.day-pill{
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:32px; border-radius:8px; border:1px solid var(--border);
  background:var(--surface); color:var(--text-muted); font-size:12.5px; font-weight:600;
  cursor:pointer; user-select:none; transition:background-color .15s ease, border-color .15s ease, color .15s ease;
}
.day-pill input{position:absolute; inset:0; opacity:0; margin:0; cursor:pointer;}
.day-pill:has(input:checked){background:var(--primary); border-color:var(--primary); color:#fff;}

.settings-columns{display:grid; grid-template-columns:1fr 320px; gap:16px; align-items:start;}
.settings-col-side .panel{position:sticky; top:20px;}
@media (max-width:900px){
  .settings-columns{grid-template-columns:1fr;}
  .settings-col-side .panel{position:static;}
}

.check-list{display:flex; flex-direction:column; gap:9px;}
.check-list label{
  display:flex; align-items:center; gap:9px; font-size:13px; font-weight:400; color:var(--text); cursor:pointer;
}
.check-list input[type="checkbox"]{width:16px; height:16px; flex-shrink:0;}

.toggle-list{display:flex; flex-direction:column;}
.toggle-list-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px; padding:8px 0;
  font-size:13px; font-weight:400; color:var(--text);
}
.toggle-list-row + .toggle-list-row{border-top:1px solid var(--border);}

.empty-state{text-align:center; padding:40px 16px; color:var(--text-muted); font-size:13.5px;}

/* ---------- Auth pages ---------- */
.auth-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
  position:relative; overflow:hidden;
}
.auth-wrap::before{
  content:''; position:absolute; width:640px; height:640px; border-radius:50%;
  background:radial-gradient(circle, var(--primary) 0%, transparent 70%); opacity:.08;
  top:50%; left:50%; transform:translate(-50%,-50%); pointer-events:none;
}
.auth-theme-toggle{position:absolute; top:18px; right:18px; z-index:2;}
.auth-card{
  position:relative; z-index:1; background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow:var(--shadow); padding:36px 32px; width:100%; max-width:380px;
}
.auth-card::before,.auth-card::after,.auth-card .c2,.auth-card .c3{
  content:''; position:absolute; width:16px; height:16px; border:2px solid var(--primary); pointer-events:none;
}
.auth-card::before{top:-1px; left:-1px; border-right:none; border-bottom:none;}
.auth-card::after{top:-1px; right:-1px; border-left:none; border-bottom:none;}
.auth-card .c2{bottom:-1px; left:-1px; border-right:none; border-top:none;}
.auth-card .c3{bottom:-1px; right:-1px; border-left:none; border-top:none;}
.auth-card h1{font-size:20px; color:var(--primary); margin:0 0 4px; text-align:center;}
.auth-card .muted{font-size:12.5px; color:var(--text-muted); margin:0 0 22px; text-align:center;}
.auth-logo{display:flex; justify-content:center; margin-bottom:16px;}
.field-icon{position:relative;}
.field-icon > svg{
  position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--text-muted); pointer-events:none;
}
.field-icon input{padding-left:34px;}
.field-icon .pw-toggle{
  position:absolute; right:6px; top:50%; transform:translateY(-50%); background:none; border:none;
  color:var(--text-muted); cursor:pointer; padding:5px; display:flex; align-items:center; border-radius:6px;
}
.field-icon .pw-toggle:hover{color:var(--primary);}
.auth-footer-text{text-align:center; font-size:11px; color:var(--text-muted); margin-top:20px;}

@media (max-width:640px){
  form.add-form{grid-template-columns:1fr;}
}

/* ---------- List header + animated progress bar ---------- */
.list-header{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:6px; flex-wrap:wrap;}
.list-header h1{font-size:21px; font-weight:700; margin:0; display:flex; align-items:center; gap:9px;}
.list-count-pill{font-size:12px; color:var(--text-muted); font-weight:600;}
.progress-track{
  height:6px; border-radius:20px; background:var(--grey-bg); overflow:hidden; margin:10px 0 22px;
}
.progress-fill{
  height:100%; width:0%; border-radius:20px; background:linear-gradient(90deg, var(--primary), var(--green));
  transition:width 1s cubic-bezier(.22,.9,.3,1);
}
.sort-toggle{display:flex; gap:6px; align-items:center; font-size:12px; color:var(--text-muted);}
.sort-toggle button{
  border:1px solid var(--border); background:var(--surface); color:var(--text-muted);
  padding:5px 11px; border-radius:20px; font-size:11.5px; font-weight:600; cursor:pointer;
}
.sort-toggle button.active{background:var(--primary); border-color:var(--primary); color:#fff;}

/* ---------- Quick add bar (MS To Do "+ Add a task") ---------- */
.quick-add-bar{
  display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border);
  border-radius:12px; padding:6px 6px 6px 16px; margin-bottom:16px; box-shadow:var(--shadow);
  transition:border-color .15s ease;
}
.quick-add-bar:focus-within{border-color:var(--primary);}
.quick-add-bar svg{color:var(--primary); flex-shrink:0;}
.quick-add-bar input{
  border:none; background:none; padding:10px 0; font-size:14px; flex:1; color:var(--text);
}
.quick-add-bar input:focus{outline:none;}
.quick-add-bar button{
  border:none; background:var(--primary); color:#fff; border-radius:8px; padding:9px 16px;
  font-size:12.5px; font-weight:700; cursor:pointer; flex-shrink:0; opacity:0; transform:translateX(6px);
  transition:opacity .15s ease, transform .15s ease; pointer-events:none;
}
.quick-add-bar input:not(:placeholder-shown) ~ button{opacity:1; transform:translateX(0); pointer-events:auto;}
.search-bar .search-clear{
  display:flex; align-items:center; justify-content:center; flex-shrink:0; width:26px; height:26px;
  border-radius:50%; color:var(--text-muted); transition:background-color .15s ease, color .15s ease;
}
.search-bar .search-clear:hover{background:var(--grey-bg); color:var(--text);}

/* ---------- To-do rows (MS To Do style task list) ---------- */
.todo-list{display:flex; flex-direction:column; gap:2px;}
.todo-row{
  display:flex; align-items:center; gap:12px; padding:12px 10px 12px 13px; border-radius:10px;
  background:var(--surface); border:1px solid var(--border); border-left:3px solid transparent; cursor:grab;
  transition:background-color .15s ease, box-shadow .15s ease, opacity .3s ease, transform .3s ease, max-height .35s ease, padding .35s ease, margin .35s ease, border-color .15s ease;
}
.todo-row:hover{background:var(--surface-2); box-shadow:0 2px 10px rgba(16,35,64,0.06);}
.todo-row[data-priority="high"]{border-left-color:var(--red);}
.todo-row[data-priority="medium"]{border-left-color:var(--amber);}
.todo-row[data-priority="low"]{border-left-color:var(--steel-light);}
.todo-row.dragging{opacity:.4;}
.todo-row.drag-over{border-color:var(--primary); box-shadow:0 0 0 2px var(--primary) inset;}
.todo-row.removing{
  opacity:0; transform:translateX(24px) scale(.97); max-height:0; padding-top:0; padding-bottom:0;
  margin:0; overflow:hidden;
}
.drag-handle{
  cursor:grab; color:var(--steel-light); flex-shrink:0; opacity:0; transition:opacity .15s ease; width:14px;
}
.todo-row:hover .drag-handle{opacity:1;}
.drag-handle:active{cursor:grabbing;}

.todo-check{
  width:22px; height:22px; border-radius:50%; border:2px solid var(--steel-light); flex-shrink:0;
  cursor:pointer; display:flex; align-items:center; justify-content:center; background:none;
  padding:0; position:relative; transition:border-color .2s ease, background-color .2s ease, transform .15s ease;
}
.todo-check:active{transform:scale(.85);}
.todo-check svg{width:12px; height:12px; opacity:0; transform:scale(.5); transition:opacity .2s ease, transform .2s ease; color:#fff;}
.todo-check.checked{background:var(--green); border-color:var(--green);}
.todo-check.checked svg{opacity:1; transform:scale(1);}
.todo-check.prio-high-ring{border-color:var(--red);}

.todo-body{flex:1; min-width:0;}
.todo-title{font-size:14px; font-weight:500; margin:0 0 2px; color:var(--text); transition:color .3s ease;}
.todo-title.done{color:var(--text-muted); text-decoration:line-through;}
.todo-meta{font-size:11.5px; color:var(--text-muted); display:flex; gap:9px; flex-wrap:wrap; align-items:center;}
.todo-meta a{color:var(--text-muted); text-decoration:none;}
.todo-meta a:hover{color:var(--primary);}
.meta-pill{padding:1px 8px; border-radius:20px; font-weight:600;}
.pill-overdue{background:var(--red-bg); color:var(--red);}
.pill-today{background:var(--amber-bg); color:var(--amber);}
.pill-soon{background:var(--grey-bg); color:var(--steel);}
.pill-hi{background:var(--red-bg); color:var(--red);}

.meta-icon{display:inline-flex; align-items:center; gap:4px;}
.empty-icon{display:block; margin:0 auto 10px; color:var(--steel-light); width:28px; height:28px;}

.todo-status-select{
  border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:7px; padding:6px 8px; font-size:11.5px; font-weight:600; flex-shrink:0;
}

/* ---------- Confetti burst ---------- */
.confetti-piece{
  position:fixed; top:0; left:0; width:5px; height:5px; pointer-events:none; z-index:999;
  border-radius:50%; animation:confetti-fall 650ms ease-out forwards;
}
@keyframes confetti-fall{
  0%{transform:translate(0,0) rotate(0deg); opacity:1;}
  100%{transform:var(--confetti-end) rotate(var(--confetti-spin)); opacity:0;}
}

@media (max-width:640px){
  .sidebar-footer{flex-wrap:wrap;}
  .list-header{align-items:flex-start; flex-direction:column;}
  .panel{padding:14px;}
  .users-table{font-size:12.5px;}
  .users-table th, .users-table td{padding:8px 9px;}
}
.table-scroll::-webkit-scrollbar{height:6px;}
.table-scroll::-webkit-scrollbar-thumb{background:var(--steel-light); border-radius:20px;}
.table-scroll::-webkit-scrollbar-track{background:transparent;}

/* ---------- Floating task detail card ---------- */
.detail-overlay{
  position:fixed; inset:0; background:rgba(10,18,29,0.45); z-index:100;
  display:none; align-items:center; justify-content:center; padding:20px; backdrop-filter:blur(1px);
}
.detail-overlay.open{display:flex;}
.detail-card{
  background:var(--surface); border-radius:16px; max-width:540px; width:100%; max-height:85vh;
  overflow-y:auto; box-shadow:0 24px 64px rgba(0,0,0,0.28); padding:26px; position:relative;
  animation:detail-pop 0.2s cubic-bezier(.22,.9,.3,1);
}
@keyframes detail-pop{
  from{opacity:0; transform:translateY(14px) scale(.97);}
  to{opacity:1; transform:translateY(0) scale(1);}
}
.detail-close{
  position:absolute; top:18px; right:18px; border:1px solid var(--border); background:var(--surface-2);
  color:var(--text-muted); width:30px; height:30px; border-radius:8px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.detail-close:hover{color:var(--red); border-color:var(--red-bg);}
.detail-card.wide{max-width:760px;}
.detail-card h2{font-size:16px; margin:0 0 14px; padding-right:34px;}

.multi-row{
  display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end;
  padding:10px; border:1px solid var(--border); border-radius:8px; margin-bottom:8px; background:var(--panel-bg,transparent);
}
.multi-row .remove-row-btn{flex-shrink:0; align-self:center;}
.cat-add-form{display:flex; flex-direction:column;}
@media (max-width:560px){
  .multi-row{flex-direction:column; align-items:stretch;}
  .multi-row .remove-row-btn{align-self:flex-end;}
}

.print-report-header{display:none;}
.chart-scroll-wrap{max-height:640px; overflow-y:auto; border:1px solid var(--border); border-radius:8px;}
@media print{
  .sidebar, .sidebar-overlay, .mobile-menu-btn, .no-print{display:none !important;}
  .app-main{margin:0 !important; padding:0 !important;}
  body{background:#fff !important; color:#000 !important;}
  .panel{border:1px solid #ccc !important; box-shadow:none !important; break-inside:avoid;}
  form, .form-actions, .icon-btn{display:none !important;}
  a{color:#000 !important; text-decoration:none !important;}
  /* กราฟที่กด "แสดงทั้งหมด" (โหมด scroll บนจอ) ต้องคลี่เต็มความสูงตอนพิมพ์ ไม่งั้นส่วนที่อยู่นอกกรอบ scroll จะหายไปตอนพิมพ์/PDF */
  .chart-scroll-wrap{max-height:none !important; overflow:visible !important; border:none !important;}
  .print-report-header{
    display:flex !important; align-items:center; gap:14px; padding:0 0 12px;
    margin:0 0 18px; border-bottom:2px solid #1B3A6B;
  }
  .print-report-header img{display:block; width:auto; height:46px; max-width:210px; object-fit:contain;}
  .print-report-header div{display:flex; flex-direction:column; gap:2px;}
  .print-report-header span{font-size:11px; color:#555;}

  /* บังคับให้ <details> รายละเอียด (หมวดค่าใช้จ่าย) กางออกเสมอเวลาพิมพ์ แม้จะยังไม่ได้กดเปิดบนหน้าจอ */
  details{break-inside:avoid;}
  details:not([open]) > *:not(summary){display:block !important;}
  summary{list-style:none !important;}
  summary::-webkit-details-marker{display:none !important;}
  summary::marker{content:"" !important;}

  /* หน้าเบิกค่าใช้จ่ายแบบฟอร์มพิมพ์ (letterhead) — ซ่อนตอนดูบนจอ โชว์เฉพาะตอนพิมพ์ */
  .screen-only{display:none !important;}
}

.print-only{display:none;}
@media print{
.print-only{display:block !important;}
.print-lh{color:#000;}
.print-lh-top{display:flex; align-items:flex-start; gap:16px; border-bottom:2px solid #1B3A6B; padding-bottom:10px; margin-bottom:10px;}
.print-lh-top img{height:50px; width:auto; max-width:190px; object-fit:contain; flex-shrink:0;}
.print-lh-company .name{font-size:18px; font-weight:700; font-style:italic; color:#1B3A6B; margin-bottom:2px;}
.print-lh-company .addr, .print-lh-company .contact{font-size:11px; color:#333; font-style:italic; line-height:1.5;}
.print-lh-title{text-align:center; font-size:15px; font-weight:700; margin:8px 0 12px;}
.print-lh-meta{display:flex; justify-content:flex-end; gap:26px; font-size:12px; margin-bottom:10px;}
.print-lh-meta div{display:flex; gap:6px;}
.print-lh-meta span{color:#555;}
.print-lh-table{width:100%; border-collapse:collapse; font-size:11.5px; margin-bottom:10px;}
.print-lh-table th, .print-lh-table td{border:1px solid #999; padding:5px 7px; vertical-align:top;}
.print-lh-table th{background:#eef1f6; font-weight:700; text-align:center;}
.print-lh-table td.num{text-align:right; white-space:nowrap; font-family:'IBM Plex Mono', monospace;}
.print-lh-table td.center{text-align:center; white-space:nowrap;}
.print-lh-cats{margin:5px 0 0; padding-left:16px; font-size:10.5px; color:#333;}
.print-lh-cats li{margin-bottom:1px;}
.print-lh-total-row td{font-weight:700; background:#f7f7f7;}
.print-lh-summary{display:flex; justify-content:flex-end; margin-bottom:30px;}
.print-lh-summary table{border-collapse:collapse; font-size:12px;}
.print-lh-summary td{border:1px solid #999; padding:5px 10px;}
.print-lh-summary td:first-child{color:#555;}
.print-lh-summary td.num{text-align:right; font-weight:700; min-width:90px; font-family:'IBM Plex Mono', monospace;}
.print-lh-sign{display:flex; justify-content:space-around; margin-top:24px; font-size:12px; text-align:center;}
.print-lh-sign .sign-box{width:220px;}
.print-lh-sign .sign-line{border-bottom:1px solid #333; height:36px; margin:4px 0;}
.print-page-break{page-break-before:always; break-before:page;}
}
.detail-title{font-size:17px; font-weight:700; margin:0 6px 4px 0; padding-right:34px; line-height:1.35;}
.detail-title.done{text-decoration:line-through; color:var(--text-muted);}
.detail-badges{display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 18px;}
.detail-badge{font-size:11px; font-weight:600; padding:3px 10px; border-radius:20px; background:var(--grey-bg); color:var(--steel);}
.detail-badge.prio-high{background:var(--red-bg); color:var(--red);}
.detail-badge.prio-medium{background:var(--amber-bg); color:var(--amber);}
.detail-desc{font-size:13.5px; color:var(--text); line-height:1.6; white-space:pre-wrap; margin:0 0 18px;}
.detail-status-row{display:flex; align-items:center; gap:10px; margin-bottom:18px; flex-wrap:wrap;}
.detail-status-row select{width:auto; flex:1; min-width:160px;}
.detail-info-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px 16px; font-size:12.5px; margin-bottom:18px;}
.detail-info-grid dt{color:var(--text-muted); margin-bottom:2px;}
.detail-info-grid dd{margin:0; font-weight:500;}
.detail-section{margin-bottom:18px;}
.detail-section h4{font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-muted); margin:0 0 9px; font-weight:700;}
.detail-attach-item{display:flex; align-items:center; justify-content:space-between; gap:8px; padding:7px 10px; background:var(--surface-2); border-radius:8px; font-size:12.5px; margin-bottom:6px;}
.detail-attach-item a{font-weight:600; text-decoration:none;}
.detail-activity-item{display:flex; gap:10px; padding:7px 0; border-bottom:1px solid var(--border); font-size:12.5px;}
.detail-activity-item:last-child{border-bottom:none;}
.detail-activity-dot{width:7px; height:7px; border-radius:50%; background:var(--primary); margin-top:5px; flex-shrink:0;}
.detail-activity-text b{font-weight:600;}
.detail-activity-time{color:var(--text-muted); font-size:11px;}
.detail-history-scroll{max-height:52vh; overflow-y:auto; text-align:left; padding-right:4px;}

/* ---------- ช่องค้นหาไลฟ์ (พิมพ์แล้วอัปเดตรายการทันที) ---------- */
#taskListRegion{position:relative; transition:opacity .12s ease;}
#taskListRegion.loading{opacity:.5; pointer-events:none;}
.detail-actions{display:flex; gap:8px; margin-top:20px; padding-top:16px; border-top:1px solid var(--border);}
.detail-empty{color:var(--text-muted); font-size:12.5px;}
.detail-loading{text-align:center; padding:40px 0; color:var(--text-muted); font-size:13px;}

/* ---------- Hover preview tooltip for task title ---------- */
.task-hover-tip{
  position:fixed; z-index:200; width:340px; max-width:calc(100vw - 24px);
  max-height:min(520px, calc(100vh - 24px)); overflow-y:auto;
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  box-shadow:0 12px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  padding:14px 16px; font-size:12.5px; line-height:1.5; color:var(--text);
  opacity:0; transform:translateY(4px); pointer-events:none;
  transition:opacity .12s ease, transform .12s ease;
}
.task-hover-tip.show{opacity:1; transform:translateY(0); pointer-events:auto;}
.task-hover-tip .tip-title{font-size:13.5px; font-weight:700; margin:0 0 8px; line-height:1.35;}
.task-hover-tip .tip-title.done{text-decoration:line-through; color:var(--text-muted);}
.task-hover-tip .tip-badges{display:flex; flex-wrap:wrap; gap:5px; margin-bottom:8px;}
.task-hover-tip .tip-badge{font-size:10.5px; font-weight:600; padding:2px 8px; border-radius:20px; background:var(--grey-bg); color:var(--steel);}
.task-hover-tip .tip-badge.prio-high{background:var(--red-bg); color:var(--red);}
.task-hover-tip .tip-badge.prio-medium{background:var(--amber-bg); color:var(--amber);}
.task-hover-tip .tip-desc{color:var(--text); margin:0 0 10px; white-space:pre-wrap; word-break:break-word; padding:8px 10px; background:var(--surface-2); border-radius:8px;}
.task-hover-tip .tip-section{margin-bottom:8px;}
.task-hover-tip .tip-section-label{font-size:10px; text-transform:uppercase; letter-spacing:.4px; color:var(--text-muted); font-weight:700; margin-bottom:4px;}
.task-hover-tip .tip-row{display:flex; justify-content:space-between; gap:10px; color:var(--text-muted); padding:2px 0;}
.task-hover-tip .tip-row b{color:var(--text); font-weight:500; text-align:right;}
.task-hover-tip .tip-attach-item{font-size:11.5px; padding:2px 0; color:var(--text);}
.task-hover-tip .tip-loading{color:var(--text-muted); text-align:center; padding:6px 0;}
@media (hover:none){ .task-hover-tip{display:none !important;} }
/* ---------- บัญชี: SO / ใบเสนอราคา / ต้นทุน ---------- */
.badge-position{background:var(--grey-bg); color:var(--primary);}
details > summary{outline:none;}
details > summary::-webkit-details-marker{display:none;}
details > summary::before{
  content:'▸'; display:inline-block; margin-right:8px; color:var(--text-muted);
  transition:transform .12s ease; font-size:11px;
}
details[open] > summary::before{transform:rotate(90deg);}

/* ---------- Corporate usability refresh ---------- */
a{transition:color .14s ease;}
a:hover{color:var(--primary-dark);}
:focus-visible{outline:3px solid rgba(23,59,112,.32); outline-offset:2px;}
.panel > :first-child{margin-top:0;}
.panel > :last-child{margin-bottom:0;}
.empty-state{border:1px dashed var(--border); border-radius:10px; background:var(--surface-2);}
.badge,.tag,.meta-pill{letter-spacing:.1px;}
.icon-btn{transition:border-color .14s ease, color .14s ease, background-color .14s ease, transform .14s ease;}
.icon-btn:hover{transform:translateY(-1px);}
.table-scroll{border-radius:9px;}
.search-bar,.quick-add-bar{box-shadow:0 3px 12px rgba(20,45,82,.045);}
.form-error,.form-success{border:1px solid currentColor; border-left-width:4px; border-radius:8px;}
.section-head > .btn{white-space:nowrap;}

@media (max-width:860px){
  .wrap{padding:20px 16px 56px;}
  .page-title{font-size:21px;}
  .sidebar{padding:16px 12px;}
  .panel{padding:16px; border-radius:11px;}
}

/* ---------- ปฏิทิน (ปฏิทินงาน / ปฏิทินบริษัท) ---------- */
.cal-toolbar{display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:16px;}
.cal-nav{display:flex; align-items:center; gap:10px;}
.cal-nav-btn{padding:8px 10px; display:inline-flex; align-items:center;}
.cal-title{font-family:'Space Grotesk',sans-serif; font-weight:700; font-size:16px; min-width:150px; text-align:center;}
.cal-grid{border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--surface); box-shadow:var(--shadow);}
.cal-grid-head{display:grid; grid-template-columns:repeat(7,1fr); background:var(--surface-2); border-bottom:1px solid var(--border);}
.cal-grid-head > div{padding:9px 8px; font-size:12px; font-weight:700; color:var(--text-muted); text-align:center;}
.cal-week{display:grid; grid-template-columns:repeat(7,1fr); min-width:0;}
.cal-week + .cal-week{border-top:1px solid var(--border);}
.cal-day{min-height:104px; min-width:0; padding:6px; border-right:1px solid var(--border); display:flex; flex-direction:column; gap:4px;
  transition:background-color .12s ease;}
.cal-day[data-modal-open]{cursor:pointer;}
.cal-day[data-modal-open]:hover{background:var(--surface-2);}
.cal-day[data-modal-open].is-today:hover{background:var(--amber-bg);}
.cal-day:last-child{border-right:none;}
.cal-day.is-out{background:var(--surface-2); opacity:.55;}
.cal-day.is-today{background:var(--amber-bg);}
.cal-day-num{font-size:12px; font-weight:700; color:var(--text-muted); padding:2px 4px;}
.cal-day.is-today .cal-day-num{color:var(--amber);}
.cal-day-events{display:flex; flex-direction:column; gap:3px; overflow:hidden; min-width:0;}
.cal-chip{display:block; width:100%; min-width:0; text-align:left; font-size:11px; font-weight:600; padding:3px 6px; border-radius:5px;
  border:none; cursor:pointer; text-decoration:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:'Inter',sans-serif;}
.cal-chip-prio-high{background:var(--red-bg); color:var(--red);}
.cal-chip-prio-medium{background:var(--amber-bg); color:var(--amber);}
.cal-chip-prio-low{background:var(--grey-bg); color:var(--text-muted);}
.cal-chip.is-done{opacity:.5; text-decoration:line-through;}
.cal-chip-color{background:color-mix(in srgb, var(--chip-color) 18%, transparent); color:var(--chip-color); border-left:3px solid var(--chip-color);}
.cal-more{font-size:10.5px; color:var(--text-muted); padding:1px 6px;}
.cal-color-picker{display:flex; align-items:center; gap:8px; flex-wrap:wrap;}
.cal-color-input{width:40px; height:32px; padding:2px; border:1px solid var(--border); border-radius:7px; background:var(--surface); cursor:pointer;}
.cal-swatch{width:22px; height:22px; border-radius:50%; border:2px solid var(--surface); box-shadow:0 0 0 1px var(--border); background:var(--sw); cursor:pointer; padding:0;}
.cal-swatch:hover{box-shadow:0 0 0 2px var(--sw);}

/* รายการงานภายใน modal ของแต่ละวัน (ปฏิทินงาน) */
.cal-day-tasklist{display:flex; flex-direction:column; gap:8px; max-height:340px; overflow-y:auto; margin-bottom:16px;}
.cal-day-task-row{display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:10px;
  background:var(--surface-2); text-decoration:none; color:var(--text); transition:border-color .12s ease, transform .12s ease;
  font-family:'Inter',sans-serif; text-align:left;}
button.cal-day-task-row{width:100%; appearance:none;}
.cal-day-task-row:hover{border-color:var(--primary); transform:translateY(-1px);}
.cal-day-task-row svg{flex-shrink:0; color:var(--text-muted);}
.cal-day-task-dot{width:9px; height:9px; border-radius:50%; flex-shrink:0;}
.cal-day-task-dot.cal-chip-prio-high{background:var(--red);}
.cal-day-task-dot.cal-chip-prio-medium{background:var(--amber);}
.cal-day-task-dot.cal-chip-prio-low{background:var(--steel-light);}
.cal-day-task-info{display:flex; flex-direction:column; gap:2px; min-width:0; flex:1;}
.cal-day-task-name{font-size:13.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.cal-day-task-name.is-done{color:var(--text-muted); text-decoration:line-through; font-weight:500;}
.cal-day-task-meta{font-size:11.5px; color:var(--text-muted);}

@media (max-width:860px){
  .cal-day{min-height:76px;}
  .cal-title{min-width:120px; font-size:14px;}
}