/* เฟส 2: หนังสือราชการ — ลงทะเบียนรับ ทะเบียน รายละเอียด และกระดิ่งแจ้งเตือน */
.urg-1 { background: var(--orange-100); color: var(--orange-700); }
.urg-2 { background: #ffe4d1; color: #b03a07; }
.urg-3 { background: #fde2e2; color: #c0262d; animation: pulse-red 1.8s ease-in-out infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 0 4px rgba(192, 38, 45, .12); } }
.sec { background: #2a1f4d; color: #e1d6ff; }
.st-pending_deputy { background: var(--blue-50); color: var(--blue-700); }
.st-pending_director { background: var(--orange-100); color: var(--orange-700); }
.st-pending_deputy::before, .st-pending_director::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.link-like { color: var(--orange-600); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.link-btn { border: 0; background: none; color: var(--orange-600); font-size: 13px; cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

.next-no { display: flex; align-items: baseline; gap: 6px; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.next-no span { color: var(--text-3); font-size: 13px; }
.next-no b { font-family: var(--font-head); font-size: 26px; background: var(--grad-orange); -webkit-background-clip: text; background-clip: text; color: transparent; }
.next-no small { color: var(--text-3); }

.receive-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.drop {
  display: block; position: relative; border: 2px dashed var(--border-strong); border-radius: 16px; cursor: pointer; overflow: hidden;
  background: repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--orange-500) 3%, transparent) 12px 24px);
  transition: border-color .25s, background-color .25s, transform .25s var(--ease);
}
.drop:hover, .drop.over { border-color: var(--orange-500); background-color: var(--orange-50); }
.drop.over { transform: scale(1.02); }
.drop.has-file { border-style: solid; border-color: color-mix(in srgb, var(--orange-500) 45%, var(--border)); }
.drop-empty { display: grid; justify-items: center; gap: 4px; padding: 38px 18px; text-align: center; }
.drop-empty span { font-size: 13px; color: var(--text-3); }
.drop-ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; color: #fff; background: var(--grad-orange); margin-bottom: 8px; box-shadow: 0 12px 24px -10px rgba(234, 88, 12, .8); animation: float 3s ease-in-out infinite; }
.drop-file { display: grid; gap: 12px; padding: 14px; }
.drop-file canvas { width: 100%; border-radius: 8px; box-shadow: 0 6px 22px -10px rgba(15, 39, 102, .5); background: #fff; animation: rise .5s var(--ease); }
.drop-file .meta { display: grid; gap: 2px; }
.drop-file .meta b { font-weight: 500; word-break: break-all; }
.drop-file .meta span { font-size: 13px; color: var(--text-3); }
.route-card { display: grid; gap: 14px; }
.route-to { display: flex; gap: 12px; align-items: center; }
.route-to b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 17px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check-row input { margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); transition: all .25s var(--ease);
}
.chip span:hover { border-color: var(--orange-400); transform: translateY(-1px); }
.chip input:checked + span { background: var(--grad-orange); border-color: transparent; color: #fff; box-shadow: 0 8px 16px -10px rgba(234, 88, 12, .9); }
.chip input:focus-visible + span { box-shadow: var(--ring); }

.steps { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--text-3); font-size: 14px; transition: color .3s; }
.steps li i { font-size: 18px; }
.steps li.done { color: var(--success); }
.steps li.now { color: var(--blue-600); font-weight: 500; }
.steps li.now i { animation: spin 1s linear infinite; }
.steps li.fail { color: var(--danger); }

.success-card { position: relative; overflow: hidden; text-align: center; padding: 40px 24px; max-width: 620px; margin: 20px auto; width: 100%; }
.big-no { margin: 14px 0 4px; display: flex; justify-content: center; align-items: baseline; gap: 8px; }
.big-no span { color: var(--text-3); font-size: 14px; }
.big-no b { font-family: var(--font-head); font-size: 56px; line-height: 1; background: var(--grad-orange); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop .7s var(--spring) both .1s; }
.big-no small { color: var(--text-3); font-size: 20px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -12px; left: calc(var(--i) * 5.6%); width: 8px; height: 14px; border-radius: 2px;
  background: var(--orange-500); opacity: 0; animation: confetti 2.2s var(--ease) forwards; animation-delay: calc(var(--i) * 45ms);
}
.confetti i:nth-child(3n) { background: var(--blue-500); }
.confetti i:nth-child(4n) { background: var(--amber-300); width: 6px; height: 6px; border-radius: 50%; }
@keyframes confetti { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(420px) rotate(540deg); } }

.no-pill { display: inline-grid; place-items: center; min-width: 52px; height: 30px; padding: 0 10px; border-radius: 9px; font-family: var(--font-head); font-weight: 600; background: var(--blue-50); color: var(--blue-700); }
.doc-title { display: grid; gap: 2px; min-width: 260px; }
.doc-title b { font-weight: 500; }
.doc-title span { font-size: 13px; color: var(--text-3); }
.doc-title .badges { margin-top: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:focus-visible td { background: var(--blue-50); outline: none; }

.doc-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.no-block { display: grid; justify-items: center; padding: 10px 18px; border-radius: 16px; color: #fff; background: var(--grad-brand); box-shadow: 0 12px 26px -14px rgba(29, 78, 216, .9); }
.no-block span { font-size: 12px; opacity: .8; }
.no-block b { font-family: var(--font-head); font-size: 34px; line-height: 1.05; }
.no-block small { opacity: .75; }
.doc-subject { font-size: 21px; }

.flow { list-style: none; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.flow li { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.flow li::before { content: ""; position: absolute; top: 20px; left: -50%; width: 100%; height: 3px; background: var(--border); z-index: 0; }
.flow li:first-child::before { display: none; }
.flow li.done::before, .flow li.now::before { background: var(--grad-orange); }
.flow .dot { position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--surface-2); border: 2px solid var(--border); transition: all .4s var(--ease); }
.flow li.done .dot { background: var(--success-bg); color: var(--success); border-color: transparent; }
.flow li.now .dot { background: var(--grad-orange); color: #fff; border-color: transparent; box-shadow: 0 0 0 6px rgba(249, 115, 22, .18); animation: ping 2s infinite; }
.flow li.now b, .flow li.done b { color: var(--text); }
.flow b { font-weight: 500; }
.flow small { color: var(--orange-600); }

.doc-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.pdf-view { padding: 16px; display: grid; gap: 14px; background: color-mix(in srgb, var(--navy-800) 6%, var(--surface-2)); border-radius: 0 0 var(--radius-lg) var(--radius-lg); min-height: 300px; }
.pdf-page { width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 8px 26px -12px rgba(6, 15, 43, .55); }
.pdf-loading { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--text-3); padding: 60px 0; }
.pdf-loading i { animation: spin 1s linear infinite; font-size: 20px; }
.summary { border-left: 4px solid var(--orange-500); border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.summary b { display: flex; gap: 6px; align-items: center; color: var(--orange-600); margin-bottom: 6px; }
.summary p { white-space: pre-line; }
.timeline { list-style: none; margin: 0; display: grid; }
.timeline li { position: relative; padding: 0 0 16px 24px; display: grid; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li.pending::before { background: var(--orange-500); animation: ping 2s infinite; }
.timeline b { font-weight: 500; }
.timeline span { font-size: 13px; color: var(--text-3); }

/* กระดิ่งแจ้งเตือน */
.bell-wrap { position: relative; }
.bell-btn { position: relative; overflow: visible; }
.bell-btn i { font-size: 21px; }
.bell-btn.ring i { animation: ring 1s var(--ease); }
@keyframes ring { 10%, 30%, 50% { transform: rotate(14deg); } 20%, 40%, 60% { transform: rotate(-14deg); } 70% { transform: rotate(0); } }
.bell-count {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--grad-orange); box-shadow: 0 0 0 2px var(--bg); animation: pop .4s var(--spring);
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 24px)); z-index: 60; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); animation: modal-in .3s var(--spring);
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.bell-list { max-height: 420px; overflow-y: auto; }
.bell-item { width: 100%; display: flex; gap: 12px; text-align: left; padding: 12px 16px; border: 0; background: none; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .2s; }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: color-mix(in srgb, var(--orange-500) 6%, var(--surface)); }
.bi-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--orange-100); color: var(--orange-600); font-size: 18px; }
.bi-txt { display: grid; gap: 1px; min-width: 0; }
.bi-txt b { font-weight: 500; font-size: 14px; }
.bi-txt span { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bi-txt small { font-size: 12px; color: var(--text-3); }
.bell-item.unread .bi-txt b::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange-500); margin-left: 6px; vertical-align: middle; }

@media (max-width: 1100px) {
  .receive-grid, .doc-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 12px; }
  .flow .dot { width: 36px; height: 36px; font-size: 17px; }
  .flow li::before { top: 17px; }
  .big-no b { font-size: 44px; }
  .doc-head { gap: 14px; }
}
