/* ============================================================
   ระบบจองห้องประชุม & แจ้งซ่อม — โรงเรียน อบจ.กระบี่
   ดีไซน์: Sidebar layout โทนเขียวสด การ์ดมน soft shadow
   ============================================================ */
:root{
  --brand:#2f9e44; --brand-d:#248a3a; --brand-dd:#1e7a32;
  --brand-050:#eaf6ee; --brand-100:#d8efdf; --brand-200:#b7e2c4;
  --amber:#e8930c; --red:#e03131; --slate:#5c7080; --blue:#1c7ed6;
  --ink:#18271e; --muted:#6a8074; --line:#e7efe9; --line-2:#eef4f0;
  --bg:#eef6f0; --card:#ffffff;
  --sh:0 2px 12px rgba(24,50,32,.05); --sh-2:0 6px 22px rgba(24,50,32,.08);
  --r:18px; --r-sm:12px; --r-xs:10px;
  --sidebar-w:264px;
}
*{box-sizing:border-box; margin:0; padding:0;}
html,body{background:var(--bg);}
body{
  font-family:'Sarabun',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  color:var(--ink); line-height:1.55; min-height:100vh; -webkit-font-smoothing:antialiased;
}
a{color:var(--brand-d); text-decoration:none;}
a:hover{text-decoration:none;}
.ic{flex:none; vertical-align:middle;}

/* ============ โครงหน้า (Shell) ============ */
.shell{display:flex; min-height:100vh;}

/* ---- Sidebar ---- */
.sidebar{
  width:var(--sidebar-w); flex:none; background:var(--card);
  border-right:1px solid var(--line); display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh; overflow-y:auto;
}
.sb-brand{display:flex; align-items:center; gap:11px; padding:20px 20px 16px;}
.sb-brand img{width:42px; height:42px; object-fit:contain; flex:none;}
.sb-brand b{font-size:14.5px; font-weight:600; color:var(--ink); line-height:1.25; display:block;}
.sb-nav{padding:8px 12px; flex:1;}
.sb-group{font-size:11.5px; font-weight:600; letter-spacing:.03em; color:#9aab9f;
  text-transform:uppercase; padding:16px 12px 7px; display:flex; align-items:center; gap:7px;}
.sb-link{
  display:flex; align-items:center; gap:12px; padding:10px 13px; border-radius:12px;
  color:#42564a; font-size:15px; font-weight:500; margin-bottom:2px; transition:.13s;
}
.sb-link .ic{color:#7d9285; transition:.13s;}
.sb-link:hover{background:var(--brand-050);}
.sb-link.active{background:var(--brand-050); color:var(--brand-dd); font-weight:600;}
.sb-link.active .ic{color:var(--brand);}
.sb-user{padding:14px; border-top:1px solid var(--line-2); margin-top:auto;}
.sb-user-card{display:flex; align-items:center; gap:11px; padding:6px 4px 12px;}
.avatar{width:40px; height:40px; border-radius:50%; background:var(--brand);
  color:#fff; display:flex; align-items:center; justify-content:center; font-size:18px; font-weight:600; flex:none;}
.sb-user-card b{font-size:14.5px; display:block; line-height:1.2;}
.sb-user-card small{font-size:12.5px; color:var(--muted);}

/* ---- Topbar (มือถือ) ---- */
.topbar{display:none; align-items:center; gap:12px; background:var(--card);
  padding:12px 16px; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:40;}
.topbar img{width:34px; height:34px;}
.topbar b{font-size:15px;}
.burger{background:none; border:0; cursor:pointer; color:var(--ink); display:flex; padding:4px;}
.scrim{display:none; position:fixed; inset:0; background:rgba(20,40,25,.4); z-index:60;}

/* ---- Main ---- */
.main{flex:1; min-width:0;}
.content{max-width:1080px; margin:0 auto; padding:30px 34px 48px;}

/* ============ หัวเรื่อง ============ */
.page-head{margin-bottom:24px;}
.page-head h1{font-size:26px; font-weight:700; color:var(--ink); line-height:1.2;}
.page-head p{color:var(--muted); font-size:15px; margin-top:5px;}
.section-head{display:flex; align-items:center; justify-content:space-between; margin:26px 0 14px;}
.section-head h2{font-size:18px; font-weight:700; color:var(--ink);}
.section-head .more{font-size:14px; color:var(--brand-d); display:inline-flex; align-items:center; gap:3px; font-weight:500;}
.section-head .more:hover{gap:6px;}
.subtle{color:#9aab9f; font-weight:400; font-size:14px;}

/* ============ การ์ด ============ */
.card{background:var(--card); border-radius:var(--r); box-shadow:var(--sh); padding:22px 24px;
  margin-bottom:18px; border:1px solid var(--line-2);}
.card h2{font-size:17px; color:var(--ink); margin-bottom:14px; font-weight:700;}
.card.pad-lg{padding:30px 32px;}

.grid{display:grid; gap:16px;}
.grid-2{grid-template-columns:repeat(2,1fr);}
.grid-3{grid-template-columns:repeat(3,1fr);}
.grid-4{grid-template-columns:repeat(4,1fr);}

/* ============ Stat tile ============ */
.stat{
  background:var(--card); border-radius:var(--r); box-shadow:var(--sh);
  border:1px solid var(--line-2); padding:20px 22px; display:flex; align-items:center; gap:16px;
}
.stat .chip{width:46px; height:46px; border-radius:13px; background:var(--brand-050);
  color:var(--brand); display:flex; align-items:center; justify-content:center; flex:none;}
.stat .lbl{font-size:13.5px; color:var(--muted);}
.stat .num{font-size:26px; font-weight:700; color:var(--ink); line-height:1.15;}
.stat .num small{font-size:14px; font-weight:400; color:var(--muted); margin-left:3px;}
.stat.amber .chip{background:#fdf1dd; color:var(--amber);}
.stat.red   .chip{background:#fde8e8; color:var(--red);}
.stat.slate .chip{background:#eef1f4; color:var(--slate);}
.stat.blue  .chip{background:#e5f0fb; color:var(--blue);}

/* ============ ปุ่ม ============ */
.btn{display:inline-flex; align-items:center; gap:8px; justify-content:center;
  padding:11px 20px; border-radius:12px; border:0; cursor:pointer; font-family:inherit;
  font-size:15px; font-weight:600; transition:.14s; white-space:nowrap;}
.btn:hover{text-decoration:none;}
.btn-primary{background:var(--brand); color:#fff; box-shadow:0 2px 8px rgba(47,158,68,.28);}
.btn-primary:hover{background:var(--brand-d); color:#fff;}
.btn-outline{background:#fff; color:#3d5245; border:1.5px solid var(--line);}
.btn-outline:hover{background:var(--brand-050); border-color:var(--brand-200); color:var(--brand-dd);}
.btn-danger{background:var(--red); color:#fff;} .btn-danger:hover{background:#c92a2a; color:#fff;}
.btn-ghost{background:var(--brand-050); color:var(--brand-dd);} .btn-ghost:hover{background:var(--brand-100);}
.btn-sm{padding:7px 13px; font-size:13.5px; border-radius:10px; gap:6px;}
.btn-block{width:100%;}
.btn-row{display:flex; gap:10px; flex-wrap:wrap;}

/* ============ ฟอร์ม ============ */
.form-group{margin-bottom:17px;}
.form-group label{display:block; font-size:14.5px; font-weight:600; margin-bottom:7px; color:#2b3a30;}
.req{color:var(--red);}
.form-control{width:100%; padding:11px 14px; border:1.5px solid var(--line); border-radius:12px;
  font-family:inherit; font-size:15px; color:var(--ink); background:#fbfdfb; transition:.14s;}
.form-control:focus{outline:0; border-color:var(--brand-200); background:#fff;
  box-shadow:0 0 0 3px rgba(47,158,68,.14);}
textarea.form-control{resize:vertical; min-height:96px;}
select.form-control{appearance:none; background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236a8074' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat:no-repeat; background-position:right 13px center; padding-right:38px;}
.form-hint{font-size:12.5px; color:var(--muted); margin-top:5px;}

/* ============ Alert ============ */
.alert{padding:13px 17px; border-radius:12px; margin-bottom:16px; font-size:14.5px;
  display:flex; align-items:center; gap:9px; border:1px solid transparent;}
.alert-success{background:#e6f6ec; color:#1b6e33; border-color:#c7ecd3;}
.alert-danger{background:#fdeaea; color:#b02525; border-color:#f6cccc;}
.alert-info{background:#e7f1fb; color:#1a5a94; border-color:#cde1f6;}

/* ============ Pill สถานะ ============ */
.pill{display:inline-flex; align-items:center; gap:7px; padding:4px 12px 4px 10px; border-radius:999px;
  font-size:13px; font-weight:600; color:var(--pc,#5c7080); background:color-mix(in srgb, var(--pc,#5c7080) 12%, #fff);}
.pill-dot{width:8px; height:8px; border-radius:50%; background:var(--pc,#5c7080); flex:none;}

/* ============ ตาราง ============ */
.table-wrap{overflow-x:auto; border-radius:var(--r); border:1px solid var(--line-2); background:#fff; box-shadow:var(--sh);}
table.data{width:100%; border-collapse:collapse; font-size:14.5px;}
table.data th, table.data td{padding:13px 16px; text-align:left; border-bottom:1px solid var(--line-2);}
table.data th{background:#f6faf7; color:#41564a; font-weight:600; white-space:nowrap; font-size:13.5px;}
table.data tr:last-child td{border-bottom:0;}
table.data tr:hover td{background:#fafdfb;}

/* ============ รายการ (list item) ============ */
.list-item{display:flex; align-items:center; gap:14px; padding:14px 4px; border-bottom:1px solid var(--line-2);}
.list-item:last-child{border-bottom:0;}
.list-item .chip-sm{width:42px; height:42px; border-radius:12px; background:var(--brand-050);
  color:var(--brand); display:flex; align-items:center; justify-content:center; flex:none;}
.list-item .li-body{flex:1; min-width:0;}
.list-item .li-body b{font-size:15px; display:block;}
.list-item .li-body small{color:var(--muted); font-size:13px;}

/* ============ Empty state ============ */
.empty{text-align:center; padding:44px 24px; color:var(--muted);}
.empty .chip{width:58px; height:58px; border-radius:16px; background:var(--brand-050); color:var(--brand);
  display:inline-flex; align-items:center; justify-content:center; margin-bottom:14px;}
.empty b{display:block; font-size:16px; color:var(--ink); margin-bottom:4px;}

/* ============ กล่อง auth (login/register) ============ */
.auth-wrap{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;}
.auth-box{background:#fff; border-radius:22px; box-shadow:var(--sh-2); width:100%; max-width:440px; overflow:hidden;}
.auth-head{background:linear-gradient(135deg,var(--brand-d),var(--brand)); color:#fff; padding:30px 30px 24px; text-align:center;}
.auth-head img{width:68px; height:68px; object-fit:contain; background:#fff; border-radius:50%; padding:5px; margin-bottom:12px;}
.auth-head h1{font-size:20px; font-weight:700;}
.auth-head p{font-size:13px; opacity:.92; margin-top:3px;}
.auth-body{padding:28px 30px;}
.auth-body .switch{text-align:center; margin-top:18px; font-size:14px; color:var(--muted);}
.auth-body .switch a{font-weight:600;}

/* ============ อื่น ๆ ============ */
.muted{color:var(--muted);} .text-center{text-align:center;} .mb-0{margin-bottom:0;}
.mt-1{margin-top:8px;} .mt-2{margin-top:14px;} .mt-3{margin-top:22px;}
.flex{display:flex;} .between{justify-content:space-between;} .items-center{align-items:center;} .gap{gap:12px;} .wrap{flex-wrap:wrap;}
.tag{display:inline-block; background:var(--brand-050); color:var(--brand-dd); padding:2px 10px; border-radius:8px; font-size:12.5px; margin:2px 3px 2px 0;}
.divider{height:1px; background:var(--line-2); margin:18px 0;}
.kv{display:flex; gap:10px; font-size:14.5px; padding:7px 0; border-bottom:1px solid var(--line-2);}
.kv:last-child{border-bottom:0;} .kv .k{color:var(--muted); min-width:130px; flex:none;}

/* ============ แถวลงนามรับทราบ ============ */
.ack-row{border:1px solid var(--line-2); border-radius:12px; padding:11px 14px; margin-bottom:8px; background:#fbfdfb;}
.ack-check{width:22px; height:22px; border-radius:7px; border:1.5px solid var(--line); background:#fff;
  display:inline-flex; align-items:center; justify-content:center; color:#fff; flex:none;}
.ack-check.on{background:var(--brand); border-color:var(--brand);}

/* ============ ปฏิทินรายเดือน ============ */
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:6px;}
.cal-wd{text-align:center; font-size:12px; font-weight:600; color:#9aab9f; padding-bottom:4px;}
.cal-day{display:flex; flex-direction:column; min-height:84px; border:1px solid var(--line-2);
  border-radius:12px; padding:7px 8px; background:#fbfdfb; color:var(--ink); transition:.12s;}
.cal-day:hover{border-color:var(--brand-200); background:var(--brand-050); text-decoration:none;}
.cal-day.today{border-color:var(--brand); background:var(--brand-050); box-shadow:inset 0 0 0 1px var(--brand);}
.cal-num{font-size:14px; font-weight:600;}
.cal-dots{margin-top:auto; display:flex; flex-wrap:wrap; gap:3px; align-items:center;}
.cal-dot{width:9px; height:9px; border-radius:50%; display:inline-block;}
@media (max-width:820px){ .cal-day{min-height:56px; padding:5px;} .cal-num{font-size:12px;} }

/* ============ ช่องลายเซ็น ============ */
.sigpad{margin-top:4px;}
.sigpad canvas{width:100%; height:140px; border:1.5px dashed var(--line); border-radius:12px;
  background:#fbfdfb; touch-action:none; display:block; cursor:crosshair;}
.sigpad.has-ink canvas{border-style:solid; border-color:var(--brand-200);}
.sigpad-bar{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap;
  margin-top:6px; font-size:12.5px; color:var(--muted);}
.sig-clear{background:none; border:0; color:var(--brand-d); font-weight:600; cursor:pointer; font-family:inherit; font-size:12.5px;}
.sig-clear:hover{text-decoration:underline;}
.sighint{margin-top:4px; font-size:12.5px; color:var(--muted);}
.sigsave{display:inline-flex; align-items:center; gap:6px; cursor:pointer; color:var(--ink); font-size:12.5px;}
.sigsave input{width:16px; height:16px; accent-color:var(--brand); cursor:pointer;}
.sigsave input:disabled{cursor:not-allowed;}
.sigsave:has(input:disabled){opacity:.45; cursor:not-allowed;}

/* แท็บเลือกวิธีลงนาม: เซ็นเอง / เลือกจากคลัง */
.sigtabs{display:flex; gap:0; margin-bottom:10px;}
.sigtab{flex:1; padding:10px 12px; font-family:inherit; font-size:14px; font-weight:600;
  color:var(--muted); background:#fff; border:1.5px solid var(--line); cursor:pointer;
  transition:background .15s, color .15s, border-color .15s;}
.sigtab:first-child{border-radius:var(--r-sm) 0 0 var(--r-sm);}
.sigtab:last-child{border-radius:0 var(--r-sm) var(--r-sm) 0; border-left-width:0;}
.sigtab:hover{color:var(--brand-d);}
.sigtab.is-active{color:var(--brand-dd); background:var(--brand-050); border-color:var(--brand);}
.sigtab.is-active + .sigtab{border-left-width:0;}
.sigtab.is-active:last-child{border-left-width:1.5px;}
.sigpane.is-hidden{display:none;}

/* คลังลายเซ็นที่บันทึกไว้ */
.siglist{display:flex; gap:12px; flex-wrap:wrap;}
.sigcard{padding:8px; background:#fff; border:1.5px solid var(--line); border-radius:var(--r-sm);
  cursor:pointer; font-family:inherit; display:flex; flex-direction:column; align-items:center; gap:4px;
  transition:border-color .15s, box-shadow .15s;}
.sigcard img{display:block; height:76px; width:auto; max-width:200px; object-fit:contain;}
.sigcard:hover{border-color:var(--brand-200);}
.sigcard.is-selected{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-050);}
.sigcard-label{font-size:12px; color:var(--muted);}

/* ============ Timeline (ประวัติงานซ่อม) ============ */
.timeline{position:relative; padding-left:26px;}
.timeline::before{content:''; position:absolute; left:7px; top:4px; bottom:4px; width:2px; background:var(--line);}
.tl-item{position:relative; padding-bottom:18px;}
.tl-item::before{content:''; position:absolute; left:-24px; top:4px; width:14px; height:14px; border-radius:50%;
  background:#fff; border:3px solid var(--brand);}
.tl-item small{color:var(--muted); font-size:12.5px;}

/* ============ Responsive ============ */
@media (max-width:900px){
  .sidebar{position:fixed; left:0; top:0; z-index:70; transform:translateX(-100%); transition:transform .22s; box-shadow:var(--sh-2);}
  .sidebar.open{transform:translateX(0);}
  .scrim.open{display:block;}
  .topbar{display:flex;}
  .content{padding:20px 18px 40px;}
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}
  .page-head h1{font-size:22px;}
}
@media print{
  .sidebar,.topbar,.no-print{display:none !important;}
  body,html{background:#fff;}
  .content{max-width:none; padding:0;}
}
