/* ══════════════════════════════════════════
   ระบบแจ้งซ่อมครุภัณฑ์ ICT — style.css
   ══════════════════════════════════════════ */

/* Google Fonts with Thai system font fallback */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  --primary:       #1a56db;
  --primary-dark:  #1e429f;
  --primary-light: #eff6ff;
  --nav-bg:        #1e3a5f;
  --border:        #e5e7eb;
  --bg:            #f0f2f5;
  --white:         #ffffff;
  --text:          #111827;
  --muted:         #6b7280;
  --shadow:        0 1px 4px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 20px rgba(0,0,0,.10);
  --radius:        12px;
  --radius-sm:     8px;

  /* Font scale — ใหญ่ขึ้นทุกระดับ */
  --fs-xs:   13px;
  --fs-sm:   15px;
  --fs-base: 16px;
  --fs-md:   17px;
  --fs-lg:   20px;
  --fs-xl:   24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Sarabun', 'TH Sarabun New', 'Leelawadee UI', 'Tahoma', system-ui, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: var(--fs-base); }
input, select, textarea { cursor: text; }
button { cursor: pointer; }

/* ══════════════════════════════════════════
   NAVIGATION
   ══════════════════════════════════════════ */
.nav {
  background: var(--nav-bg);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: .5rem;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: white;
  font-size: var(--fs-md);
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; }
.nav-icon {
  width: 36px; height: 36px;
  background: #2563eb;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.nav-tabs {
  display: flex;
  gap: .15rem;
  margin-left: .9rem;
  flex: 1;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: .45rem 1rem;
  color: rgba(255,255,255,.7);
  border-radius: 7px;
  font-size: var(--fs-sm);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  text-decoration: none;
}
.nav-tab:hover  { color: white; background: rgba(255,255,255,.12); text-decoration: none; }
.nav-tab.active { color: white; background: rgba(255,255,255,.2); font-weight: 600; }

/* ══════════════════════════════════════════
   LAYOUT — กึ่งกลาง
   ══════════════════════════════════════════ */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
  width: 100%;
}

.page-header { margin-bottom: 1.5rem; }
.page-title  { font-size: var(--fs-xl); font-weight: 700; }
.page-sub    { font-size: var(--fs-sm); color: var(--muted); margin-top: .25rem; }

/* ══════════════════════════════════════════
   CARD
   ══════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ══════════════════════════════════════════
   STAT GRID
   ══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  border-left: 5px solid transparent;
}
.stat-card.blue   { border-left-color: #3b82f6; }
.stat-card.amber  { border-left-color: #f59e0b; }
.stat-card.indigo { border-left-color: #6366f1; }
.stat-card.green  { border-left-color: #10b981; }
.stat-label { font-size: var(--fs-sm);  color: var(--muted); font-weight: 500; }
.stat-val   { font-size: 34px;          font-weight: 700; line-height: 1; margin: .35rem 0 .25rem; }
.stat-sub   { font-size: var(--fs-xs);  color: var(--muted); }

/* ══════════════════════════════════════════
   2-COL GRID
   ══════════════════════════════════════════ */
.g2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.s-title {
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ══════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════ */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
thead th {
  text-align: left;
  padding: .65rem .85rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  background: #f9fafb;
  white-space: nowrap;
}
tbody td { padding: .75rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable:hover { background: #f9fafb; cursor: pointer; }

/* ══════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.b-pending     { background: #fef3c7; color: #92400e; }
.b-in-progress { background: #dbeafe; color: #1e40af; }
.b-resolved    { background: #d1fae5; color: #065f46; }
.b-closed      { background: #f3f4f6; color: #6b7280; }
.b-low    { background: #f0fdf4; color: #166534; }
.b-medium { background: #fef9c3; color: #713f12; }
.b-high   { background: #ffedd5; color: #9a3412; }
.b-urgent { background: #fee2e2; color: #991b1b; }
.b-dltv      { background: #ede9fe; color: #5b21b6; }
.b-network   { background: #e0f2fe; color: #0369a1; }
.b-computer  { background: #ecfeff; color: #0e7490; }
.b-printer   { background: #fdf4ff; color: #7e22ce; }
.b-projector { background: #fff7ed; color: #9a3412; }
.b-software  { background: #f0fdf4; color: #166534; }
.b-other     { background: #f9fafb; color: #374151; }

/* ══════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════ */
.fg { margin-bottom: 1.1rem; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.flabel {
  display: block;
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: .45rem;
  color: var(--text);
}
.flabel.req::after { content: ' *'; color: #ef4444; }

.finput {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.finput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}
.fselect {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath fill='%236b7280' d='M7 9L0 0h14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 2.5rem;
}
textarea.finput { resize: vertical; min-height: 100px; }
.fsect-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1.5px solid var(--border);
}

/* ══════════════════════════════════════════
   SOURCE TOGGLE
   ══════════════════════════════════════════ */
.src-toggle { display: flex; gap: 1rem; margin-bottom: 1.25rem; }
.src-opt {
  flex: 1;
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  cursor: pointer;
  text-align: center;
  transition: all .18s;
  background: var(--white);
  user-select: none;
}
.src-opt:hover    { border-color: var(--primary); background: #f8faff; }
.src-opt.sel      { border-color: var(--primary); background: var(--primary-light); }
.src-icon         { font-size: 34px; margin-bottom: .4rem; }
.src-lbl          { font-size: var(--fs-md); font-weight: 700; }
.src-desc         { font-size: var(--fs-xs); color: var(--muted); margin-top: .2rem; }

/* ══════════════════════════════════════════
   CATEGORY GRID
   ══════════════════════════════════════════ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: .85rem;
}
.cat-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem .75rem;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--white);
  user-select: none;
}
.cat-card:hover    { border-color: var(--primary); background: #f8faff; }
.cat-card.sel      { border-color: var(--primary); background: var(--primary-light); }
.cat-card-icon     { font-size: 26px; }
.cat-card-lbl      { font-size: var(--fs-sm); font-weight: 700; margin-top: .3rem; }
.cat-card-desc     { font-size: var(--fs-xs); color: var(--muted); margin-top: .2rem; line-height: 1.4; }

/* ══════════════════════════════════════════
   PRIORITY CHIPS
   ══════════════════════════════════════════ */
.pri-group { display: flex; gap: .75rem; flex-wrap: wrap; }
.pri-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.pri-chip:hover      { border-color: #9ca3af; }
.pri-chip.sel-low    { border-color: #16a34a; background: #f0fdf4; color: #16a34a; }
.pri-chip.sel-medium { border-color: #d97706; background: #fef9c3; color: #d97706; }
.pri-chip.sel-high   { border-color: #ea580c; background: #ffedd5; color: #ea580c; }
.pri-chip.sel-urgent { border-color: #dc2626; background: #fee2e2; color: #dc2626; }

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary);  color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sec     { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-sec:hover { background: #f9fafb; }
.btn-success { background: #059669; color: white; border-color: #059669; }
.btn-success:hover { background: #047857; }
.btn-danger  { background: #ef4444; color: white; border-color: #ef4444; }
.btn-lg  { padding: .8rem 1.75rem; font-size: var(--fs-lg); }
.btn-sm  { padding: .35rem .85rem;  font-size: var(--fs-xs); font-weight: 500; }

/* ══════════════════════════════════════════
   CONFIRM / SUCCESS BOX
   ══════════════════════════════════════════ */
.confirm-box {
  background: linear-gradient(135deg, #1e3a5f 0%, #1a56db 100%);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  color: white;
}
.ticket-id-box {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: .1em;
  background: rgba(255,255,255,.15);
  border: 2px dashed rgba(255,255,255,.45);
  border-radius: 8px;
  padding: .7rem 2rem;
  display: inline-block;
  margin: .85rem 0;
  font-family: monospace;
}

/* ══════════════════════════════════════════
   TIMELINE
   ══════════════════════════════════════════ */
.tl { list-style: none; }
.tl-item { display: flex; gap: 1rem; padding-bottom: 1.25rem; position: relative; }
.tl-item:not(:last-child)::after {
  content: ''; position: absolute;
  left: 15px; top: 32px; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0; z-index: 1;
  background: var(--border); color: var(--muted);
}
.tl-dot.active { background: #3b82f6; color: white; }
.tl-body  { flex: 1; padding-top: .3rem; }
.tl-title { font-size: var(--fs-md); font-weight: 500; }
.tl-date  { font-size: var(--fs-sm);  color: var(--muted); margin-top: .1rem; }

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-title  { font-size: var(--fs-lg); font-weight: 600; }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--white);
}
.btn-close {
  width: 32px; height: 32px;
  border-radius: 7px; border: 1px solid var(--border);
  background: #f3f4f6; cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}

/* ══════════════════════════════════════════
   DETAIL GRID
   ══════════════════════════════════════════ */
.det-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem 1.5rem; margin-bottom: 1.25rem; }
.det-item label { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .04em; }
.det-item span  { font-size: var(--fs-md); }

/* ══════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════ */
.fbar { display: flex; gap: .65rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.fsel {
  padding: .5rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  background: var(--white); color: var(--text); cursor: pointer;
}
.fsearch-wrap { position: relative; flex: 1; min-width: 200px; max-width: 300px; }
.fsearch-wrap::before { content: '🔍'; position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }
.fsearch {
  width: 100%;
  padding: .5rem .85rem .5rem 2.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-family: inherit;
}
.fsearch:focus { outline: none; border-color: var(--primary); }

/* ══════════════════════════════════════════
   INFO BOXES
   ══════════════════════════════════════════ */
.info-box {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  font-size: var(--fs-md); color: #1e40af;
  margin-bottom: 1.1rem;
  line-height: 1.55;
}
.warn-box {
  background: #fef9c3; border: 1px solid #fde047;
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  font-size: var(--fs-md); color: #713f12;
}

/* ══════════════════════════════════════════
   MINI BAR CHART
   ══════════════════════════════════════════ */
.mbar-row  { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.mbar-lbl  { font-size: var(--fs-sm); color: var(--muted); width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbar-track{ flex: 1; height: 9px; border-radius: 5px; background: #f3f4f6; overflow: hidden; }
.mbar-fill { height: 100%; border-radius: 5px; }
.mbar-cnt  { font-size: var(--fs-sm); font-weight: 700; width: 26px; text-align: right; }

/* ══════════════════════════════════════════
   QUICK ACTIONS
   ══════════════════════════════════════════ */
.qa-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.qa-btn {
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer; text-align: left;
  transition: all .15s;
  display: flex; align-items: center; gap: 1rem;
  text-decoration: none; color: var(--text);
}
.qa-btn:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(26,86,219,.1); text-decoration: none; }
.qa-ic   { width: 48px; height: 48px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.qa-lbl  { font-size: var(--fs-md); font-weight: 700; }
.qa-desc { font-size: var(--fs-xs); color: var(--muted); margin-top: .2rem; }

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty       { text-align: center; padding: 3rem 1rem; }
.empty-icon  { font-size: 44px; margin-bottom: .9rem; }
.empty-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: .35rem; }
.empty-sub   { font-size: var(--fs-sm); color: var(--muted); }

/* ══════════════════════════════════════════
   NOTES
   ══════════════════════════════════════════ */
.note-item { background: #f9fafb; border-radius: 8px; padding: .75rem 1rem; margin-bottom: .5rem; }
.note-item > div:first-child { font-size: var(--fs-md); }
.note-meta { font-size: var(--fs-xs); color: var(--muted); margin-top: .25rem; }

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.toast {
  position: fixed; top: 70px; right: 1.5rem;
  background: var(--white); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 1rem 1.25rem;
  border-left: 4px solid #10b981;
  max-width: 320px; z-index: 300;
  font-size: var(--fs-sm);
  transition: opacity .3s, transform .3s;
  opacity: 0; transform: translateX(12px); pointer-events: none;
}
.toast.show  { opacity: 1; transform: translateX(0); }
.toast.error { border-left-color: #ef4444; }
.toast-title { font-weight: 700; font-size: var(--fs-md); }
.toast-msg   { color: var(--muted); margin-top: .2rem; }

/* ══════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════ */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--white); border-radius: var(--radius);
  padding: 2.5rem; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-md);
}

/* ══════════════════════════════════════════
   ADMIN-SPECIFIC
   ══════════════════════════════════════════ */
.stats-mini { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sm-chip {
  background: white; border: 1.5px solid var(--border);
  border-radius: 9px; padding: .5rem 1rem;
  font-size: var(--fs-sm);
  display: flex; align-items: center; gap: .5rem;
  box-shadow: var(--shadow);
}
.sm-chip b { font-size: var(--fs-md); }
.priority-row-urgent { border-left: 4px solid #ef4444; }
.priority-row-high   { border-left: 4px solid #f97316; }
.act-btn {
  padding: .4rem .9rem; font-size: var(--fs-sm);
  border-radius: 6px; border: 1.5px solid var(--border);
  background: white; cursor: pointer;
  transition: all .15s; font-family: inherit; font-weight: 500;
}
.act-btn:hover { background: #f3f4f6; }
.act-btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.act-btn.primary:hover { background: var(--primary-dark); }
.mgmt-section { border-top: 1px solid var(--border); padding-top: 1.1rem; margin-top: .9rem; }
.mgmt-title   { font-size: var(--fs-sm); font-weight: 700; color: #374151; margin-bottom: .85rem; }
.status-btn {
  padding: .5rem 1rem; font-size: var(--fs-sm);
  border-radius: 7px; border: 1.5px solid var(--border);
  background: white; cursor: pointer;
  transition: all .15s; font-family: inherit; font-weight: 600;
}
.status-btn:hover { border-color: var(--primary); background: #f8faff; }
.status-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ══════════════════════════════════════════
   RESPONSIVE — Tablet (≤900px)
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  .main { padding: 1.25rem 1rem 3rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .g2         { grid-template-columns: 1fr; }
  .qa-grid    { grid-template-columns: 1fr 1fr; }
  .det-grid   { grid-template-columns: 1fr 1fr; }
  .f2         { grid-template-columns: 1fr 1fr; }
  .cat-grid   { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile (≤600px)
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
  :root {
    --fs-xs:   13px;
    --fs-sm:   15px;
    --fs-base: 16px;
    --fs-md:   17px;
    --fs-lg:   20px;
    --fs-xl:   22px;
  }

  .nav { height: 56px; padding: 0 1rem; }
  .nav-brand span { display: none; }   /* แสดงเฉพาะ icon บน mobile */
  .nav-tab { padding: .4rem .7rem; font-size: 13px; }

  .main { padding: 1rem .85rem 2.5rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .stat-val   { font-size: 28px; }

  .g2 { grid-template-columns: 1fr; }

  .src-toggle { flex-direction: column; gap: .75rem; }
  .src-opt    { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem; text-align: left; }
  .src-icon   { font-size: 28px; margin-bottom: 0; flex-shrink: 0; }

  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
  .cat-card-desc { display: none; } /* ซ่อน desc ใน mobile ให้กระชับ */

  .f2 { grid-template-columns: 1fr; }

  .det-grid { grid-template-columns: 1fr; }

  .qa-grid  { grid-template-columns: 1fr; }
  .qa-btn   { padding: 1rem; }

  .fbar { gap: .5rem; }
  .fsearch-wrap { max-width: 100%; flex-basis: 100%; }
  .fsel { flex: 1; min-width: 120px; }

  .pri-group { gap: .5rem; }
  .pri-chip  { padding: .5rem .9rem; font-size: 14px; }

  .btn-lg { padding: .75rem 1.5rem; font-size: var(--fs-md); }

  .page-title { font-size: var(--fs-xl); }

  .confirm-box { padding: 1.75rem 1.25rem; }
  .ticket-id-box { font-size: 22px; padding: .6rem 1.25rem; }

  .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 95vh; }
  .overlay { align-items: flex-end; padding: 0; }

  table { font-size: 13px; }
  thead th, tbody td { padding: .55rem .65rem; }

  .stats-mini { gap: .5rem; }
  .sm-chip    { padding: .4rem .75rem; font-size: 13px; }

  .login-card { padding: 1.75rem 1.25rem; }

  .toast { right: .75rem; left: .75rem; max-width: 100%; }
}

/* ══════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f3f4f6; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ══════════════════════════════════════════
   RESPONSIVE TABLE — ซ่อนคอลัมน์รองบน mobile
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
  .hide-mobile { display: none !important; }
}
@media (max-width: 900px) {
  .hide-tablet { display: none !important; }
}

/* ══════════════════════════════════════════
   SAFE AREA — iPhone notch / iPad
   ══════════════════════════════════════════ */
.nav {
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}
.main {
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}
@media (max-width: 600px) {
  .main {
    padding-left: max(.85rem, env(safe-area-inset-left));
    padding-right: max(.85rem, env(safe-area-inset-right));
  }
}

/* ══════════════════════════════════════════
   IMAGE UPLOAD COMPONENTS
   ══════════════════════════════════════════ */
.img-upload-area {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafafa;
  position: relative;
}
.img-upload-area:hover,
.img-upload-area.drag { border-color: var(--primary); background: var(--primary-light); }
.img-upload-area input[type=file] { position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%; }
.img-upload-icon  { font-size: 36px; margin-bottom: .5rem; }
.img-upload-text  { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.img-upload-sub   { font-size: var(--fs-xs); color: var(--muted); margin-top: .25rem; }
.img-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); gap: .65rem; margin-top: .85rem; }
.img-preview-item { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: #f3f4f6; }
.img-preview-item img { width:100%;height:100%;object-fit:cover;display:block; }
.img-preview-item .del {
  position:absolute;top:4px;right:4px;width:22px;height:22px;
  background:rgba(0,0,0,.6);color:white;border:none;border-radius:50%;
  cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;
}
.img-count-badge {
  display:inline-flex;align-items:center;gap:.35rem;
  background:#d1fae5;color:#065f46;border-radius:20px;
  padding:4px 12px;font-size:13px;font-weight:600;margin-top:.5rem;
}
.img-count-badge.warn { background:#fee2e2;color:#9b1c1c; }

/* ══════════════════════════════════════════
   SEARCHABLE AUTOCOMPLETE
   ══════════════════════════════════════════ */
.ac-wrap     { position: relative; }
.ac-clear    {
  position:absolute;right:.75rem;top:50%;transform:translateY(-50%);
  background:none;border:none;cursor:pointer;font-size:16px;
  color:var(--muted);padding:0;line-height:1;display:none;
}
.ac-dropdown {
  position:absolute;top:calc(100% + 4px);left:0;right:0;
  background:white;border:1.5px solid var(--primary);
  border-radius:var(--radius-sm);z-index:50;
  max-height:240px;overflow-y:auto;
  box-shadow:0 8px 24px rgba(0,0,0,.12);
  display:none;
}
.ac-dropdown.open { display:block; }
.ac-item {
  padding:.65rem 1rem;font-size:var(--fs-md);cursor:pointer;
  border-bottom:1px solid var(--border);transition:background .1s;
}
.ac-item:last-child { border-bottom:none; }
.ac-item:hover, .ac-item.focused { background:var(--primary-light);color:var(--primary); }
.ac-item mark { background:transparent;color:var(--primary);font-weight:700; }
.ac-empty { padding:.75rem 1rem;font-size:var(--fs-sm);color:var(--muted); }
