/* IT Service Desk — ส่วนของแอป (ใช้ตัวแปรสี/มุม/เงาจาก vendor/theme.css เท่านั้น ห้าม hardcode สีใหม่โดยไม่จำเป็น — ดู docs/DESIGN_SYSTEM.md) */

/* ข้อความบนพื้นสีอ่อนต้องอ่านได้ (WCAG AA): โหมดสว่างใช้สีเข้มขึ้นหนึ่งระดับ, โหมดมืดใช้ค่าจาก theme */
:root {
  --chip-emerald: #047857;
  --chip-amber: #b45309;
  --chip-rose: #be123c;
  --chip-teal: #0e7490;
  --btn-gradient: linear-gradient(135deg, #047857 0%, #0369a1 55%, #4338ca 100%);
  --chart-1: #059669;
  --focus: #2563eb;
}
[data-theme="dark"] {
  --chip-emerald: var(--c-emerald);
  --chip-amber: var(--c-amber);
  --chip-rose: var(--c-rose);
  --chip-teal: var(--c-teal);
  --chart-1: #10a877;
  --focus: #38bdf8;
}

/* ---------- พื้นฐาน (แก้ค่าที่ theme.css ตั้งไว้สำหรับแอปเดิม) ---------- */
body { padding-bottom: 0; font-size: 16px; }
header { text-align: left; }
a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { color: var(--text-main); }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; justify-content: center; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-body); }
.icon { flex-shrink: 0; }
.boot { padding: 64px 16px; text-align: center; color: var(--text-muted); }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 18px; border-radius: var(--radius-pill);
  border: 1px solid transparent; font: inherit; font-size: 0.9rem; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; transition: var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled, .btn.is-busy { opacity: 0.6; cursor: progress; transform: none; }
.btn-primary { background: var(--btn-gradient); color: #fff; box-shadow: 0 4px 14px rgba(4, 120, 87, 0.28); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(4, 120, 87, 0.38); filter: brightness(1.06); }
.btn-success { background: #047857; color: #fff; box-shadow: 0 4px 14px rgba(4, 120, 87, 0.25); }
.btn-success:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--bg-surface); color: var(--text-main); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--border-focus); }
.btn-danger { background: var(--bg-surface); color: var(--chip-rose); border-color: var(--c-rose-border); }
.btn-danger:hover { background: var(--c-rose-bg); }
.btn-icon { width: 42px; padding: 0; background: transparent; color: var(--text-muted); }
.btn-icon:hover { background: var(--bg-subtle); color: var(--text-main); transform: none; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 0.82rem; }
.btn-lg { min-height: 50px; padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--c-blue); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; }

/* ---------- โครงหน้าเจ้าหน้าที่ ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: 252px;
  display: flex; flex-direction: column; padding: 0 12px 12px;
  background: var(--bg-surface); border-right: 1px solid var(--border);
}
.side-top { height: 68px; display: flex; align-items: center; margin: 0 -12px 8px; padding: 0 18px; border-bottom: 1px solid var(--border-subtle); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 10px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 0.98rem; }
.brand-text small { font-size: 0.72rem; color: var(--text-muted); }
.side-label { padding: 12px 12px 6px; font-size: 0.72rem; letter-spacing: 0.06em; color: var(--text-dim); }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-pill);
  border: 1px solid transparent; color: var(--text-muted); font-size: 0.92rem; font-weight: 500;
}
.side-nav a:hover { background: var(--bg-subtle); color: var(--text-main); text-decoration: none; }
.side-nav a.active { background: var(--c-blue-bg); color: var(--c-blue); border-color: var(--c-blue-border); }
.side-sub { margin-top: 14px; padding: 0 4px; }
.side-sub a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 0.82rem; color: var(--text-muted); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); }
.side-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.side-user:hover { text-decoration: none; }
.side-user > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.side-user strong { font-size: 0.88rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-user small { font-size: 0.72rem; color: var(--text-muted); }
.avatar {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%;
  background: var(--c-indigo-bg); color: var(--c-indigo); border: 1px solid var(--c-indigo-border); font-size: 0.8rem; font-weight: 600;
}
.shell-main { margin-left: 252px; min-height: 100vh; }
.topbar, .scrim { display: none; }

.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; display: flex; flex-direction: column; gap: 20px; }
.page.page-narrow { max-width: 660px; }

@media (max-width: 960px) {
  .side { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-floating); }
  body.side-open .side { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.45); }
  .shell-main { margin-left: 0; }
  .topbar {
    position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 6px; padding: 0 6px;
    background: var(--bg-surface); border-bottom: 1px solid var(--border);
  }
  .topbar-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; color: var(--text-main); }
  .page { padding: 16px 16px 48px; gap: 16px; }
}

/* ---------- โครงหน้าสาธารณะ ---------- */
.pub { min-height: 100vh; display: flex; flex-direction: column; }
.pub-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.pub-nav { margin-left: auto; display: flex; gap: 4px; }
.pub-nav a { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-pill); color: var(--text-muted); font-size: 0.88rem; font-weight: 500; }
.pub-nav a:hover { background: var(--bg-subtle); color: var(--text-main); text-decoration: none; }
.pub-nav a.active { background: var(--c-emerald-bg); color: var(--chip-emerald); }
.pub-foot { margin-top: auto; padding: 20px 16px 28px; text-align: center; font-size: 0.78rem; color: var(--text-dim); }
@media (max-width: 640px) {
  .pub-top { padding: 8px 10px; gap: 4px; }
  .brand-text small { display: none; }
  .pub-nav a { padding: 10px; }
  .pub-nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- หัวหน้า / กล่อง ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.page-head p { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; font-size: 0.9rem; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions select { width: auto; min-width: 220px; }
.panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 22px; }
.panel-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 1.02rem; font-weight: 600; }
.hero { text-align: center; padding: 8px 8px 0; }
.hero h1 { font-size: 1.7rem; font-weight: 700; }
.hero p { max-width: 520px; margin: 6px auto 0; color: var(--text-muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: 0.88rem; color: var(--text-muted); }
@media (max-width: 640px) {
  .panel { padding: 16px; border-radius: var(--radius-md); }
  .page-head h1, .hero h1 { font-size: 1.35rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .page-actions select { flex: 1; min-width: 0; }
}

/* ---------- การ์ดตัวเลข (ใช้ .stat-card ของ theme) ---------- */
.stats-grid { margin-bottom: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
button.stat-card, a.stat-card { width: 100%; font: inherit; text-align: left; color: inherit; }
a.stat-card:hover { text-decoration: none; }
.stat-card.static { cursor: default; }
.stat-card.static:hover { transform: none; box-shadow: var(--shadow-card); border-color: var(--border); }
.stat-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-subtle); font-size: 0.8rem; color: var(--text-muted); }
.stats-grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis .stat-value { font-size: 1.75rem; }
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; min-height: 0; }
  .stat-value { font-size: 1.6rem; }
  .stat-badge-icon { display: none; }
}

/* ---------- ป้ายสถานะ / ความเร่งด่วน (สี + ข้อความเสมอ) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-subtle); color: var(--text-body);
  font-size: 0.76rem; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.chip.st-new { background: var(--c-indigo-bg); color: var(--c-indigo); border-color: var(--c-indigo-border); }
.chip.st-in_progress { background: var(--c-blue-bg); color: var(--c-blue); border-color: var(--c-blue-border); }
.chip.st-external_repair { background: var(--c-purple-bg); color: var(--c-purple); border-color: var(--c-purple-border); }
.chip.st-unrepairable { background: var(--bg-subtle); color: var(--text-main); border-color: var(--border-focus); }
.chip.st-awaiting_replacement { background: var(--c-teal-bg); color: var(--chip-teal); border-color: var(--c-teal-border); }
.chip.st-done { background: var(--c-emerald-bg); color: var(--chip-emerald); border-color: var(--c-emerald-border); }
.chip.st-cancelled { background: transparent; color: var(--text-muted); border-color: var(--border); }
.chip.sev-1 { background: var(--bg-subtle); color: var(--text-muted); border-color: var(--border); }
.chip.sev-2 { background: var(--c-amber-bg); color: var(--chip-amber); border-color: var(--c-amber-border); }
.chip.sev-3 { background: var(--c-rose-bg); color: var(--chip-rose); border-color: var(--c-rose-border); }
.chip.as-1 { background: var(--c-emerald-bg); color: var(--chip-emerald); border-color: var(--c-emerald-border); }
.chip.as-2 { background: var(--bg-subtle); color: var(--text-main); border-color: var(--border-focus); }
.chip.as-3 { background: var(--c-purple-bg); color: var(--c-purple); border-color: var(--c-purple-border); }
.chip.as-4 { background: transparent; color: var(--text-muted); border-color: var(--border); }
.chip-flag { background: var(--c-yellow-bg); color: var(--text-main); border-color: var(--c-yellow-border); font-weight: 500; }

/* ---------- แถบเครื่องมือ / ตัวกรอง ---------- */
.toolbar { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; }
.tabs-row { flex-wrap: nowrap; overflow-x: auto; padding: 2px; }
.tab-btn { flex-shrink: 0; white-space: nowrap; font: inherit; font-size: 0.86rem; }
.tab-btn.active { background: var(--btn-gradient); box-shadow: 0 4px 14px rgba(4, 120, 87, 0.25); }
.filters { display: grid; grid-template-columns: minmax(240px, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 10px; }
.filters.filters-3 { grid-template-columns: 2fr 1fr 1fr; }
.filters select.form-control { text-overflow: ellipsis; }
@media (max-width: 1100px) {
  .filters, .filters.filters-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .search-wrap { grid-column: 1 / -1; }
}
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search-wrap .form-control { padding-left: 38px; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-muted); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 12px; border-radius: var(--radius-pill);
  background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid var(--c-blue-border); font: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer;
}

/* ---------- การ์ดใบงาน (3 บรรทัด, ปุ่มหลักปุ่มเดียว) ---------- */
.ticket-list { display: flex; flex-direction: column; gap: 12px; }
.ticket {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 16px 20px; overflow: hidden;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); transition: var(--transition);
}
.ticket::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.ticket.sev-edge-2::before { background: var(--c-amber); }
.ticket.sev-edge-3::before { background: var(--c-rose); }
.ticket:hover { border-color: var(--border-focus); box-shadow: var(--shadow-hover); }
.ticket-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ticket-line1 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.82rem; }
.ticket-id { font-size: 0.86rem; font-weight: 600; color: var(--text-main); }
.ticket-time, .ticket-src { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }
.ticket-title { font-size: 1rem; font-weight: 600; line-height: 1.45; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ticket-title a { color: var(--text-main); }
.ticket-title a:hover { text-decoration: none; }
.ticket-title .muted { font-weight: 400; }
.stretched::after { content: ''; position: absolute; inset: 0; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--text-muted); }
.ticket-meta > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.unassigned { color: var(--text-dim); font-style: italic; }
.ticket-action { position: relative; z-index: 1; flex-shrink: 0; }
@media (max-width: 640px) {
  .ticket { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 14px 14px 18px; }
  .ticket-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ticket-action .btn { width: 100%; }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.86rem; }
.pager:empty { display: none; }
.pager-btns { display: flex; align-items: center; gap: 6px; }
.pager-num { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-body); }

/* ---------- ฟอร์ม (ใช้ .form-group/.form-label/.form-control ของ theme) ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-label { font-size: 0.86rem; font-weight: 600; color: var(--text-body); }
.form-control { min-height: 44px; font-size: 0.95rem; }
textarea.form-control { min-height: 96px; resize: vertical; line-height: 1.6; }
select.form-control { cursor: pointer; }
.req { color: var(--chip-rose); }
.hint { font-size: 0.78rem; color: var(--text-muted); }
.field-error { font-size: 0.82rem; color: var(--chip-rose); }
.field-error:empty { display: none; }
.has-error .form-control { border-color: var(--c-rose); }
.has-error .seg { outline: 1px solid var(--c-rose); outline-offset: 4px; border-radius: var(--radius-md); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.form-message { min-height: 1.2em; font-size: 0.88rem; color: var(--chip-rose); }
.form-panel { max-width: 860px; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-control { font-size: 16px; } /* กัน iPhone ซูมตอนแตะช่องกรอก */
  .form-actions .btn { flex: 1; }
}

/* ความเร่งด่วนแบบปุ่มเลือก (ไม่มีค่าเริ่มต้นที่เลือกไว้ให้) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg-item {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); transition: var(--transition);
}
.seg-item:hover { border-color: var(--border-focus); }
.seg-item:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg-item input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.seg-label { font-weight: 600; color: var(--text-main); }
.seg-item small { font-size: 0.76rem; line-height: 1.35; color: var(--text-muted); }
.seg-item.is-checked.seg-sev-1 { border-color: var(--text-muted); background: var(--bg-subtle); }
.seg-item.is-checked.seg-sev-2 { border-color: var(--c-amber); background: var(--c-amber-bg); }
.seg-item.is-checked.seg-sev-3 { border-color: var(--c-rose); background: var(--c-rose-bg); }
.seg-item.is-checked .seg-label::before { content: '✓ '; }
@media (max-width: 420px) {
  .seg { grid-template-columns: 1fr; }
  .seg-item { flex-direction: row; align-items: baseline; gap: 10px; }
}

/* ช่องเลือกเครื่อง */
.picker { position: relative; }
.pick-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; max-height: 280px; overflow-y: auto; padding: 6px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-floating);
}
.pick-item {
  width: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-body); font: inherit; cursor: pointer;
}
.pick-item:hover, .pick-item:focus-visible { background: var(--bg-subtle); }
.pick-empty { padding: 10px 12px; font-size: 0.86rem; color: var(--text-muted); }
.picked { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--c-emerald-border); border-radius: var(--radius-md); background: var(--c-emerald-bg); color: var(--text-main); }
.picked-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picked-text small { color: var(--text-muted); }

/* ---------- แจ้งสำเร็จ / ติดตามสถานะ ---------- */
.success-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 22px; text-align: center; }
.success-icon {
  width: 72px; height: 72px; margin-bottom: 6px; display: grid; place-items: center; border-radius: 50%;
  background: var(--c-emerald-bg); color: var(--chip-emerald); border: 1px solid var(--c-emerald-border);
}
.success-box h1 { font-size: 1.4rem; }
.ticket-big { font-size: 1.6rem; font-weight: 600; letter-spacing: 0.01em; color: var(--text-main); }
.success-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.track-search { display: flex; gap: 10px; }
.track-search .form-control { flex: 1; }
.track-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.steps { list-style: none; display: flex; flex-direction: column; margin: 18px 0 6px; }
.step { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ''; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; background: var(--border); }
.step:last-child::before { display: none; }
.step.done::before { background: var(--chart-1); }
.step-dot { width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--border); background: var(--bg-surface); color: #fff; }
.step.done .step-dot { background: #047857; border-color: #047857; }
.step.current .step-dot { box-shadow: 0 0 0 4px var(--c-emerald-bg); }
.step strong { display: block; color: var(--text-main); }
.step small { color: var(--text-muted); }
.kv { display: grid; grid-template-columns: minmax(104px, max-content) 1fr; gap: 8px 16px; margin-top: 12px; font-size: 0.92rem; }
.kv dt { color: var(--text-muted); }
.kv dd { min-width: 0; color: var(--text-main); overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.link-list { display: flex; flex-direction: column; }
.link-list a { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-subtle); color: var(--text-main); }
.link-list a:last-child { border-bottom: 0; }
.link-list a span:nth-child(2) { flex: 1; }
.notice { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; padding: 12px 14px; border-radius: var(--radius-md); font-size: 0.9rem; }
.notice .icon { margin-top: 2px; }
.notice-info { background: var(--c-blue-bg); border: 1px solid var(--c-blue-border); color: var(--text-main); }
.notice-muted { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-body); }

/* ---------- เข้าสู่ระบบ ---------- */
.login-panel { display: flex; flex-direction: column; gap: 6px; padding: 32px 26px; text-align: center; }
.login-panel h1 { font-size: 1.4rem; }
.login-panel form { margin-top: 14px; text-align: left; }
.login-icon { width: 56px; height: 56px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 18px; background: var(--btn-gradient); color: #fff; }

/* ---------- ใบงาน ---------- */
.job-head h1 { font-size: 1.45rem; }
.job-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.job-badges .ticket-big { font-size: 1.15rem; }
.job-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.job-col { display: flex; flex-direction: column; gap: 20px; }
.flag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
@media (max-width: 1024px) { .job-grid { grid-template-columns: 1fr; } }

.timeline { list-style: none; display: flex; flex-direction: column; }
.tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: 6px; top: 20px; bottom: 0; width: 2px; background: var(--border-subtle); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 14px; height: 14px; flex-shrink: 0; margin-top: 5px; border-radius: 50%; background: var(--text-dim); box-shadow: 0 0 0 3px var(--bg-surface); }
.tl-new .tl-dot { background: var(--c-indigo); }
.tl-in_progress .tl-dot { background: var(--c-blue); }
.tl-external_repair .tl-dot { background: var(--c-purple); }
.tl-unrepairable .tl-dot { background: var(--text-muted); }
.tl-awaiting_replacement .tl-dot { background: var(--c-teal); }
.tl-done .tl-dot { background: var(--chart-1); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-size: 0.9rem; }
.tl-head .muted { font-size: 0.8rem; }
.tl-user { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; }
.tl-note { margin-top: 4px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-body); font-size: 0.88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-add { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.note-add textarea { min-height: 64px; }

/* กล่องเลือกสถานะ */
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; }
.choice:hover { background: var(--bg-subtle); }
.choice input { width: 16px; height: 16px; accent-color: #047857; }
.choice small { flex-basis: 100%; padding-left: 26px; color: var(--text-muted); }
/* เลือกผู้ปฏิบัติงานหลายคน */
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); cursor: pointer; background: var(--bg-card); }
.pick:hover { background: var(--bg-subtle); }
.pick input { width: 16px; height: 16px; margin: 0; accent-color: #047857; }
.pick:has(input:checked) { background: var(--c-emerald-bg); border-color: var(--c-emerald-border); color: var(--chip-emerald); font-weight: 600; }
.pick:has(input:focus-visible) { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* modal (ต่อจาก theme) */
.modal-window.modal-wide { max-width: 780px; }
.modal-body { max-height: 70vh; }
.modal-footer .btn { min-width: 110px; }
@media (max-width: 640px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-window { max-height: 94vh; display: flex; flex-direction: column; border-radius: 22px 22px 0 0; }
  .modal-body { flex: 1; max-height: none; padding: 18px 16px; }
  .modal-footer .btn { flex: 1; }
}

/* toast / ว่าง / กำลังโหลด */
.toast-pill .icon { color: var(--chip-emerald); }
.toast-error { border-color: var(--c-rose); }
.toast-error .icon { color: var(--chip-rose); }
@media (max-width: 640px) { .toast-pill { left: 16px; right: 16px; bottom: 16px; justify-content: center; } }
.empty-title { font-weight: 600; color: var(--text-main); }
.empty-box .icon { color: var(--text-dim); }
.error-box .icon { color: var(--chip-rose); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--text-muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--chart-1); animation: sd-spin 0.8s linear infinite; }
@keyframes sd-spin { to { transform: rotate(360deg); } }

/* ---------- ตาราง ---------- */
.table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); scrollbar-width: thin; }
.table-wrap::-webkit-scrollbar { display: block; height: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { padding: 12px 16px; text-align: left; white-space: nowrap; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 16px; vertical-align: top; color: var(--text-body); border-bottom: 1px solid var(--border-subtle); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table.compact th, .data-table.compact td { padding: 6px 10px; }

/* ---------- ครุภัณฑ์ ---------- */
.device-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.device-card h1 { font-size: 1.35rem; }
.device-card .asset { font-size: 1rem; color: var(--text-body); }
.device-card .kv { width: 100%; margin: 14px 0 10px; text-align: left; }
.device-card .notice { text-align: left; width: 100%; }
.device-icon { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 18px; background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid var(--c-blue-border); }
.mini-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.mini-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--text-body); }
a.mini-item:hover { border-color: var(--border-focus); background: var(--bg-card-hover); text-decoration: none; }
.mini-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.82rem; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- ภาพรวมผลงาน (กราฟ: ชุดข้อมูลเดียว สีเดียว แท่งบาง ปลายมน 4px, tooltip ตอนชี้/โฟกัส, มีตาราง) ---------- */
.dash-body { display: flex; flex-direction: column; gap: 20px; transition: opacity 0.2s; }
.dash-body.is-refreshing { opacity: 0.55; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.col-chart { position: relative; height: 250px; margin-top: 24px; padding-left: 40px; }
.col-grid { position: absolute; top: 0; right: 0; bottom: 28px; left: 40px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.col-gridline { position: relative; height: 0; border-top: 1px solid var(--border-subtle); }
.col-gridline span { position: absolute; right: calc(100% + 8px); top: -9px; font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.col-plot { position: relative; height: 100%; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; border-radius: var(--radius-sm); color: inherit; }
.col:hover { background: var(--bg-subtle); text-decoration: none; }
.col-track { position: relative; flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { position: relative; width: min(24px, 62%); background: var(--chart-1); border-radius: 4px 4px 0 0; transition: filter 0.15s; }
.col:hover .col-bar, .col:focus-visible .col-bar { filter: brightness(1.15); }
.col-cap { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 0.75rem; font-weight: 600; color: var(--text-main); white-space: nowrap; }
.col-label { height: 28px; display: flex; align-items: center; font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.col-tip {
  position: absolute; top: 0; left: 50%; z-index: 5; display: none; flex-direction: column; gap: 1px;
  transform: translate(-50%, calc(-100% - 6px)); padding: 8px 10px; white-space: nowrap; pointer-events: none;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-floating);
  font-size: 0.78rem; color: var(--text-muted);
}
.col-tip strong { font-size: 0.92rem; color: var(--text-main); }
.col:hover .col-tip, .col:focus-visible .col-tip { display: flex; }
.col:first-child .col-tip, .col:nth-child(2) .col-tip { left: 0; transform: translate(0, calc(-100% - 6px)); }
.col:last-child .col-tip, .col:nth-last-child(2) .col-tip { left: auto; right: 0; transform: translate(0, calc(-100% - 6px)); }
@media (max-width: 640px) {
  .col-chart { height: 210px; padding-left: 30px; }
  .col-grid { left: 30px; }
  .col-label { font-size: 0.6rem; }
  .col-cap { font-size: 0.68rem; }
}
.bar-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(64px, 1fr) auto; align-items: center; gap: 12px;
  padding: 7px 8px; border-radius: var(--radius-sm); font-size: 0.88rem; color: var(--text-body);
}
a.bar-row:hover, a.bar-row:focus-visible { background: var(--bg-subtle); text-decoration: none; }
.bar-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-main); }
.bar-track { height: 10px; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--chart-1); border-radius: 0 4px 4px 0; }
.bar-value { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; white-space: nowrap; font-weight: 600; color: var(--text-main); font-variant-numeric: tabular-nums; }
.bar-value small { font-size: 0.72rem; font-weight: 400; color: var(--text-muted); }
@media (max-width: 640px) {
  .bar-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .bar-track { grid-column: 1 / -1; order: 3; }
}
.table-view { margin-top: 14px; font-size: 0.86rem; }
.table-view summary { width: fit-content; color: var(--c-blue); cursor: pointer; }
.table-view table { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .side, .topbar, .pub-top, .pub-foot, .page-actions, .btn, .toolbar, .pager { display: none !important; }
  .shell-main { margin-left: 0; }
  .panel, .ticket { box-shadow: none; }
}
