/* ============================================================
   GETCO — ระบบยืม-คืนวัสดุ
   Design tokens
   ============================================================ */
:root{
  --bg: #F3F9F1;
  --surface: #FFFFFF;
  --surface-alt: #EBF5E8;
  --primary: #4C8C5B;
  --primary-dark: #33613E;
  --primary-light: #DCEEDD;
  --ink: #223126;
  --ink-muted: #66796A;
  --border: #D7E6D3;
  --amber: #E4A339;
  --amber-bg: #FBF0DA;
  --danger: #C1554A;
  --danger-bg: #F8E4E1;
  --success: #3F8F5C;
  --success-bg: #E1F1E4;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow: 0 2px 10px rgba(51,97,62,0.08);
  --shadow-lift: 0 10px 30px rgba(51,97,62,0.14);
  font-size: 16px;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Sarabun', 'Segoe UI', sans-serif;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{
  font-family:'Kanit','Sarabun',sans-serif;
  color:var(--primary-dark);
  margin:0 0 .4em 0;
  font-weight:600;
}
a{color:var(--primary-dark);}
button{font-family:inherit;}
::selection{background:var(--primary-light);}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.5em;
  padding:.62em 1.3em;
  border-radius:999px;
  border:1.5px solid transparent;
  font-size:.95rem;
  font-weight:600;
  cursor:pointer;
  transition:transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space:nowrap;
}
.btn:active{transform:scale(.97);}
.btn-primary{background:var(--primary);color:#fff;}
.btn-primary:hover{background:var(--primary-dark);}
.btn-outline{background:transparent;border-color:var(--primary);color:var(--primary-dark);}
.btn-outline:hover{background:var(--primary-light);}
.btn-danger{background:var(--danger-bg);color:var(--danger);}
.btn-danger:hover{background:var(--danger);color:#fff;}
.btn-ghost{background:transparent;color:var(--ink-muted);border-color:transparent;}
.btn-ghost:hover{background:var(--surface-alt);}
.btn-sm{padding:.4em .9em;font-size:.82rem;}
.btn:disabled{opacity:.45;cursor:not-allowed;}
.btn-block{width:100%;}

/* ---------- forms ---------- */
label{display:block;font-size:.88rem;font-weight:600;color:var(--ink-muted);margin:0 0 .35em 2px;}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],
select,textarea{
  width:100%;
  padding:.72em .9em;
  border-radius:var(--radius-s);
  border:1.5px solid var(--border);
  background:#fff;
  font-size:.95rem;
  color:var(--ink);
  font-family:inherit;
  transition:border-color .15s;
}
input:focus,select:focus,textarea:focus{
  outline:none;border-color:var(--primary);
  box-shadow:0 0 0 3px var(--primary-light);
}
.field{margin-bottom:1.05em;}
.field-hint{font-size:.78rem;color:var(--ink-muted);margin-top:.3em;}
.field-error{font-size:.78rem;color:var(--danger);margin-top:.3em;display:none;}
.input-error{border-color:var(--danger) !important;}

/* ---------- auth pages ---------- */
.auth-wrap{
  min-height:100vh;
  display:flex;
  align-items:stretch;
  justify-content:center;
}
.auth-side{
  flex:1.1;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 45%),
    linear-gradient(160deg, var(--primary-dark), var(--primary) 65%, #6DA978);
  color:#fff;
  display:none;
  flex-direction:column;
  justify-content:space-between;
  padding:3.2rem 3rem;
  position:relative;
  overflow:hidden;
}
.auth-side svg.leaf{position:absolute;opacity:.16;}
.auth-brand{display:flex;align-items:center;gap:.7em;font-family:'Kanit';font-weight:600;font-size:1.25rem;}
.auth-brand .logo-mark{width:38px;height:38px;flex:none;}
.auth-tagline h2{color:#fff;font-size:2rem;line-height:1.3;max-width:9.5em;}
.auth-tagline p{color:rgba(255,255,255,.85);font-size:.98rem;max-width:26em;}
.auth-steps{display:flex;flex-direction:column;gap:.9rem;font-size:.92rem;color:rgba(255,255,255,.92)}
.auth-steps div{display:flex;gap:.7em;align-items:flex-start;}
.auth-steps span.n{
  width:24px;height:24px;border-radius:50%;background:rgba(255,255,255,.22);
  display:flex;align-items:center;justify-content:center;font-size:.75rem;flex:none;font-weight:700;
}
.auth-form-col{
  flex:1;
  display:flex;align-items:center;justify-content:center;
  padding:2.5rem 1.5rem;
}
.auth-card{width:100%;max-width:400px;}
.auth-card .mobile-brand{display:flex;align-items:center;gap:.6em;margin-bottom:2rem;font-family:'Kanit';font-weight:600;color:var(--primary-dark);font-size:1.15rem;}
.auth-card .mobile-brand .logo-mark{width:32px;height:32px;}
.auth-card h1{font-size:1.55rem;margin-bottom:.15em;}
.auth-card .sub{color:var(--ink-muted);margin-bottom:1.7rem;font-size:.93rem;}
.auth-foot{margin-top:1.4rem;text-align:center;font-size:.9rem;color:var(--ink-muted);}
.auth-foot a{font-weight:700;text-decoration:none;}
.auth-alert{
  background:var(--danger-bg);color:var(--danger);border-radius:var(--radius-s);
  padding:.75em 1em;font-size:.87rem;margin-bottom:1.1em;display:none;
}
.auth-alert.success{background:var(--success-bg);color:var(--success);}
@media(min-width:920px){.auth-side{display:flex;}}

/* ---------- app shell ---------- */
.app-shell{display:flex;min-height:100vh;}
.sidebar{
  width:264px;flex:none;
  background:var(--primary-dark);
  color:#EAF3EA;
  display:flex;flex-direction:column;
  position:fixed;top:0;bottom:0;left:0;
  transition:transform .25s ease;
  z-index:40;
}
.sidebar-brand{
  display:flex;align-items:center;gap:.7em;
  padding:1.5rem 1.4rem 1.1rem;
  font-family:'Kanit';font-weight:600;font-size:1.05rem;color:#fff;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.sidebar-brand .logo-mark{width:34px;height:34px;flex:none;}
.sidebar-brand .brand-sub{display:block;font-size:.68rem;font-weight:400;color:rgba(255,255,255,.6);letter-spacing:.02em;}
.side-nav{flex:1;overflow-y:auto;padding:1rem .8rem;}
.side-section-label{
  font-size:.7rem;color:rgba(255,255,255,.45);padding:1.1em .7em .5em;font-weight:700;
}
.side-link{
  display:flex;align-items:center;gap:.8em;
  padding:.68em .9em;
  border-radius:var(--radius-s);
  color:rgba(255,255,255,.82);
  text-decoration:none;
  font-size:.92rem;
  margin-bottom:.15em;
  cursor:pointer;
  border:none;background:none;width:100%;text-align:left;font-family:inherit;
}
.side-link svg{width:19px;height:19px;flex:none;opacity:.9;}
.side-link:hover{background:rgba(255,255,255,.08);color:#fff;}
.side-link.active{background:#fff;color:var(--primary-dark);font-weight:700;}
.side-link.active svg{opacity:1;}
.side-link .badge-count{
  margin-left:auto;background:var(--amber);color:#4a3204;font-size:.7rem;font-weight:700;
  border-radius:999px;padding:.1em .55em;
}
.sidebar-foot{padding:1rem 1.2rem 1.3rem;border-top:1px solid rgba(255,255,255,.12);}
.side-user{display:flex;align-items:center;gap:.7em;margin-bottom:.8em;}
.side-user .avatar{width:36px;height:36px;border-radius:50%;background:var(--primary);display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;flex:none;font-size:.85rem;}
.side-user .who{overflow:hidden;}
.side-user .who .name{font-size:.87rem;font-weight:600;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.side-user .who .role{font-size:.72rem;color:rgba(255,255,255,.6);}

.main-col{margin-left:264px;flex:1;min-width:0;display:flex;flex-direction:column;min-height:100vh;}
.topbar{
  background:#fff;border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  padding:.9rem 1.6rem;position:sticky;top:0;z-index:20;
}
.topbar .page-title{font-family:'Kanit';font-weight:600;font-size:1.15rem;color:var(--primary-dark);}
.topbar-right{display:flex;align-items:center;gap:.8rem;}
.icon-btn{
  width:38px;height:38px;border-radius:50%;border:1px solid var(--border);background:#fff;
  display:flex;align-items:center;justify-content:center;cursor:pointer;position:relative;color:var(--ink-muted);
}
.icon-btn:hover{background:var(--surface-alt);}
.icon-btn .dot{position:absolute;top:6px;right:7px;width:8px;height:8px;border-radius:50%;background:var(--danger);display:none;}
.menu-toggle{display:none;}
.content{padding:1.6rem;flex:1;}
@media(max-width:960px){
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);box-shadow:var(--shadow-lift);}
  .main-col{margin-left:0;}
  .menu-toggle{display:flex;}
  .sidebar-backdrop{position:fixed;inset:0;background:rgba(20,30,20,.35);z-index:30;display:none;}
  .sidebar-backdrop.show{display:block;}
}

/* ---------- generic layout helpers ---------- */
.page{display:none;}
.page.active{display:block;animation:fadein .18s ease;}
@keyframes fadein{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:none;}}
.grid{display:grid;gap:1.1rem;}
.grid-4{grid-template-columns:repeat(4,1fr);}
.grid-3{grid-template-columns:repeat(3,1fr);}
.grid-2{grid-template-columns:repeat(2,1fr);}
@media(max-width:1200px){.grid-4{grid-template-columns:repeat(2,1fr);}.grid-3{grid-template-columns:repeat(2,1fr);}}
@media(max-width:640px){.grid-4,.grid-3,.grid-2{grid-template-columns:1fr;}}

.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-m);padding:1.3rem;box-shadow:var(--shadow);}
.card h3{font-size:1rem;}
.stat-card{display:flex;flex-direction:column;gap:.35rem;}
.stat-card .stat-top{display:flex;align-items:center;justify-content:space-between;}
.stat-card .icon-wrap{width:40px;height:40px;border-radius:var(--radius-s);background:var(--primary-light);display:flex;align-items:center;justify-content:center;color:var(--primary-dark);}
.stat-card .value{font-family:'Kanit';font-size:1.9rem;font-weight:600;color:var(--primary-dark);}
.stat-card .label{color:var(--ink-muted);font-size:.85rem;}
.stat-card .trend{font-size:.78rem;color:var(--success);}

.section-head{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.8rem;margin-bottom:1.1rem;}
.section-head p{color:var(--ink-muted);font-size:.9rem;margin:.15em 0 0;}
.toolbar{display:flex;gap:.7rem;flex-wrap:wrap;align-items:center;}
.search-box{position:relative;}
.search-box input{padding-left:2.4em;min-width:220px;}
.search-box svg{position:absolute;left:.8em;top:50%;transform:translateY(-50%);color:var(--ink-muted);width:16px;height:16px;}

table{width:100%;border-collapse:collapse;font-size:.9rem;}
thead th{
  text-align:left;color:var(--ink-muted);font-weight:600;font-size:.78rem;
  padding:.7em .9em;border-bottom:2px solid var(--border);white-space:nowrap;
}
tbody td{padding:.8em .9em;border-bottom:1px solid var(--border);vertical-align:middle;}
tbody tr:hover{background:var(--surface-alt);}
.table-wrap{overflow-x:auto;}
.empty-row td{text-align:center;color:var(--ink-muted);padding:2.2em;}

.badge{display:inline-flex;align-items:center;gap:.35em;padding:.28em .8em;border-radius:999px;font-size:.76rem;font-weight:700;}
.badge-pending{background:var(--amber-bg);color:#8a611c;}
.badge-approved{background:var(--success-bg);color:var(--success);}
.badge-rejected{background:var(--danger-bg);color:var(--danger);}
.badge-returned{background:var(--primary-light);color:var(--primary-dark);}
.badge-overdue{background:var(--danger-bg);color:var(--danger);}
.badge-admin{background:#EFE1F7;color:#6B3E93;}
.badge-user{background:var(--surface-alt);color:var(--ink-muted);}

.equipment-card{background:#fff;border:1px solid var(--border);border-radius:var(--radius-m);overflow:hidden;display:flex;flex-direction:column;box-shadow:var(--shadow);}
.equipment-thumb{height:130px;background:var(--surface-alt);display:flex;align-items:center;justify-content:center;overflow:hidden;color:var(--primary);}
.equipment-thumb img{width:100%;height:100%;object-fit:cover;}
.equipment-body{padding:.95rem 1rem 1.1rem;display:flex;flex-direction:column;gap:.4rem;flex:1;}
.equipment-body .code{font-size:.74rem;color:var(--ink-muted);font-family:monospace;}
.equipment-body .name{font-weight:600;font-family:'Kanit';font-size:.98rem;}
.equipment-body .avail{font-size:.83rem;color:var(--ink-muted);margin-top:auto;}
.equipment-body .avail b{color:var(--primary-dark);}

.modal-backdrop{
  position:fixed;inset:0;background:rgba(20,30,20,.4);display:none;
  align-items:center;justify-content:center;z-index:100;padding:1rem;
}
.modal-backdrop.show{display:flex;}
.modal{background:#fff;border-radius:var(--radius-l);max-width:460px;width:100%;padding:1.6rem;box-shadow:var(--shadow-lift);max-height:90vh;overflow-y:auto;}
.modal h3{margin-bottom:.2em;}
.modal .modal-sub{color:var(--ink-muted);font-size:.87rem;margin-bottom:1.2rem;}
.modal-actions{display:flex;gap:.7rem;justify-content:flex-end;margin-top:1.3rem;}

.toast-stack{position:fixed;top:1.2rem;right:1.2rem;z-index:200;display:flex;flex-direction:column;gap:.6rem;}
.toast{
  background:var(--primary-dark);color:#fff;padding:.85em 1.2em;border-radius:var(--radius-s);
  font-size:.87rem;box-shadow:var(--shadow-lift);display:flex;align-items:center;gap:.6em;
  animation:toastin .18s ease;max-width:320px;
}
.toast.danger{background:var(--danger);}
.toast.info{background:#3D6EA5;}
@keyframes toastin{from{opacity:0;transform:translateX(20px);}to{opacity:1;transform:none;}}

.empty-state{text-align:center;padding:3rem 1rem;color:var(--ink-muted);}
.empty-state svg{width:52px;height:52px;color:var(--primary-light);margin-bottom:.7rem;}
.empty-state h3{color:var(--ink);font-size:1rem;}

.chip{display:inline-flex;align-items:center;gap:.4em;padding:.35em .85em;border-radius:999px;border:1.5px solid var(--border);font-size:.82rem;cursor:pointer;background:#fff;}
.chip.active{background:var(--primary);border-color:var(--primary);color:#fff;font-weight:700;}

.bar-row{display:flex;align-items:center;gap:.8rem;margin-bottom:.75rem;}
.bar-row .lbl{width:130px;font-size:.83rem;color:var(--ink-muted);flex:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.bar-track{flex:1;height:10px;background:var(--surface-alt);border-radius:999px;overflow:hidden;}
.bar-fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--primary-dark));border-radius:999px;}
.bar-val{width:34px;text-align:right;font-size:.8rem;font-weight:700;color:var(--primary-dark);flex:none;}

.qr-tile{border:1.5px solid var(--border);border-radius:var(--radius-m);padding:1rem;text-align:center;background:#fff;}
.qr-tile img,.qr-tile canvas{width:100%;max-width:150px;height:auto;margin:0 auto .6rem;}
.qr-tile .code{font-family:monospace;font-size:.82rem;color:var(--ink-muted);}
.qr-tile .name{font-weight:600;font-size:.88rem;margin-top:.15em;}
.qr-tile input[type=checkbox]{width:16px;height:16px;margin-bottom:.5rem;}

.avatar-sm{width:32px;height:32px;border-radius:50%;background:var(--primary-light);color:var(--primary-dark);display:inline-flex;align-items:center;justify-content:center;font-size:.78rem;font-weight:700;}

.print-only{display:none;}
@media print{
  .sidebar,.topbar,.no-print{display:none !important;}
  .main-col{margin-left:0 !important;}
  .print-only{display:block;}
  body{background:#fff;}
}
.helper-note{background:var(--amber-bg);border:1px solid #EFD6A0;color:#7a5a17;border-radius:var(--radius-s);padding:.8em 1em;font-size:.83rem;display:flex;gap:.6em;}
.helper-note svg{flex:none;width:18px;height:18px;margin-top:1px;}

.scroll-x{overflow-x:auto;}
.tag-list{display:flex;gap:.4rem;flex-wrap:wrap;}

.switch{position:relative;display:inline-block;width:42px;height:24px;flex:none;}
.switch input{opacity:0;width:0;height:0;}
.switch .slider{position:absolute;inset:0;background:var(--border);border-radius:999px;transition:.15s;cursor:pointer;}
.switch .slider:before{content:"";position:absolute;width:18px;height:18px;left:3px;top:3px;background:#fff;border-radius:50%;transition:.15s;}
.switch input:checked + .slider{background:var(--primary);}
.switch input:checked + .slider:before{transform:translateX(18px);}

.divider{height:1px;background:var(--border);margin:1.2rem 0;border:none;}
