html, body { height: 100%; }
body { background: #f1f5f9; margin: 0; min-height: 100%; display: flex; flex-direction: column; }
body.page-chat {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
body.page-chat .lite-nav { flex: 0 0 auto; }
body.page-chat .lite-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lite-nav { background: #0f172a; flex-shrink: 0; }
.lite-nav .navbar-brand { white-space: nowrap; }
.lite-nav .nav-link.active { color: #fff; font-weight: 600; }
.lite-nav-meta { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.lite-nav-email { max-width: min(240px, 42vw); }
.nav-count {
  display: inline-block;
  min-width: 1.15rem;
  padding: 0 .35rem;
  margin-left: .15rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.2rem;
  vertical-align: 1px;
  text-align: center;
}
.nav-count.is-zero {
  background: #334155;
  color: #94a3b8;
}
.lite-notify-btn {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.lite-notify-btn:hover { background: #1e293b; color: #fff; }
.lite-notify-btn.is-off { color: #64748b; }
.lite-badge { font-size: .7rem; background: #334155; color: #cbd5e1; border-radius: 999px; padding: .12rem .45rem; }
.lite-main { flex: 1; min-height: 0; overflow: auto; }
.lite-main:has(.chat-layout) { overflow: hidden; display: flex; flex-direction: column; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #1e3a8a, #0f172a); }
.login-card { width: min(400px, 92vw); }
.ticket-bubble { border-radius: 12px; padding: 10px 12px; max-width: 80%; }
.ticket-bubble.guest { background: #fff; border: 1px solid #e2e8f0; }
.ticket-bubble.staff { background: #eff6ff; margin-left: auto; border: 1px solid #bfdbfe; }
.chat-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.chat-list {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e2e8f0;
  overflow: hidden;
  background: #fff;
  min-height: 0;
}
.chat-search {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  z-index: 2;
}
.chat-create-btn {
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: .82rem;
}
.chat-create-btn:hover { background: #1d4ed8; color: #fff; }
.chat-search-actions {
  display: flex;
  gap: 8px;
}
.chat-search-actions .chat-create-btn,
.chat-search-actions .chat-markall-btn {
  flex: 1;
}
.chat-markall-btn {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 7px 10px;
  background: #fff;
  color: #334155;
  font-weight: 600;
  font-size: .82rem;
}
.chat-markall-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.chat-markall-btn[hidden] { display: none !important; }
.chat-search input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px 8px 34px;
  font-size: .875rem;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 10px 50%;
  outline: none;
}
.chat-search input:focus {
  background-color: #fff;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.chat-list-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.chat-sec-label {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 14px 6px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: #64748b;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.chat-empty-sec { padding: 10px 14px; font-size: .82rem; color: #94a3b8; }
.chat-old-toggle {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; border: 0; border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0;
  background: #f8fafc; color: #334155; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.chat-old-toggle:hover { background: #eef2f7; }
.chat-item { display: block; padding: 12px 14px; border-bottom: 1px solid #f1f5f9; color: inherit; text-decoration: none; }
.chat-item-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-item-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-email {
  font-size: .78rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 1px 0 2px;
}
.chat-online-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); flex-shrink: 0;
}
.chat-item:hover, .chat-item.is-on { background: #f8fafc; }
.chat-item.is-online { background: #f0fdf4; }
.chat-item.is-online.is-on, .chat-item.is-online:hover { background: #dcfce7; }
.chat-loading { padding: 6px 0 12px; }
.chat-loading-hint { padding: 8px 14px 4px; font-size: .82rem; color: #64748b; }
.chat-skel {
  height: 52px;
  margin: 8px 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 45%, #f1f5f9 90%);
  background-size: 200% 100%;
  animation: chat-skel 1.05s ease-in-out infinite;
}
.chat-skel.msg {
  max-width: 46%;
  height: 36px;
  margin: 0 0 10px;
  border: 0;
  padding: 0;
}
.chat-skel.msg.staff { margin-left: auto; }
.chat-thread-placeholder { color: #94a3b8; text-align: center; padding: 48px 16px; font-size: .95rem; }
@keyframes chat-skel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.chat-main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #f1f5f9;
  height: 100%;
}
.chat-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #e2e8f0; background: #fff; gap: 8px; }
.chat-back { display: none; }
.chat-more-bar { text-align: center; padding: 6px 8px 0; background: #f8fafc; }
.chat-thread { min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 16px 18px 20px; -webkit-overflow-scrolling: touch; }
.chat-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #e2e8f0;
  background: #fff;
  align-items: flex-end;
  z-index: 5;
}
.chat-compose textarea { flex: 1; min-width: 0; resize: none; border-radius: 16px; }
.chat-compose .btn { flex-shrink: 0; border-radius: 16px; padding-inline: 18px; }
.msg-day {
  display: flex;
  justify-content: center;
  margin: 14px 0 12px;
}
.msg-day span {
  font-size: .72rem;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 3px 10px;
  border-radius: 999px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: min(72%, 480px);
  margin-bottom: 10px;
}
.msg.staff { margin-left: auto; align-items: flex-end; }
.msg.guest { align-items: flex-start; }
.msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: .95rem;
}
.msg.staff .msg-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.guest .msg-bubble {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: .68rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}
.msg.msg-track { display: none; max-width: min(78%, 560px); padding: 0; border: 0; background: transparent; align-items: flex-start; }
body.show-url-track .msg.msg-track { display: flex; }
.url-tracking-message {
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 3px solid #94a3b8;
  font-size: .8rem;
  color: #475569;
  max-width: 100%;
}
.url-tracking-message > div:first-child {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}
.url-tracking-message > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.url-tracking-message a { color: #2563eb; text-decoration: none; }
.url-tracking-message a:hover { text-decoration: underline; }
.chat-error-detail {
  margin-top: 10px;
  font-size: .78rem;
  color: #b91c1c;
  white-space: pre-wrap;
  word-break: break-word;
}
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 991.98px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-back { display: inline-block; }
  .chat-layout:not(.is-open) .chat-main { display: none; }
  .chat-layout.is-open .chat-list { display: none; }
  .lite-nav-email { max-width: 100%; }
}
@media (max-width: 575.98px) {
  .chat-compose { flex-direction: column; align-items: stretch; }
  .msg { max-width: 88%; }
  .container { padding-left: 12px; padding-right: 12px; }
}
.lite-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1080;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.lite-toast {
  pointer-events: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 4px solid;
  animation: lite-toast-in 0.28s ease-out;
}
.lite-toast.success { border-left-color: #16a34a; }
.lite-toast.error { border-left-color: #dc2626; }
.lite-toast.warning { border-left-color: #d97706; }
.lite-toast.info { border-left-color: #2563eb; }
.lite-toast-icon { font-size: 1.15rem; line-height: 1.3; flex-shrink: 0; }
.lite-toast.success .lite-toast-icon { color: #16a34a; }
.lite-toast.error .lite-toast-icon { color: #dc2626; }
.lite-toast.warning .lite-toast-icon { color: #d97706; }
.lite-toast.info .lite-toast-icon { color: #2563eb; }
.lite-toast-text { flex: 1; font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.lite-toast-close {
  background: none; border: none; color: #64748b; cursor: pointer;
  font-size: 1.15rem; line-height: 1; padding: 0; width: 20px; height: 20px; flex-shrink: 0;
}
.lite-toast.hiding { animation: lite-toast-out 0.28s ease-in forwards; }
@keyframes lite-toast-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes lite-toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(24px); opacity: 0; }
}
body.page-ticket {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
body.page-ticket .lite-nav { flex: 0 0 auto; }
body.page-ticket .lite-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ticket-page {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.ticket-head {
  padding: 14px 20px 16px;
  background: #fff;
  border-bottom: 1px solid #e8eef5;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.ticket-head-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ticket-head-actions { display: flex; align-items: center; gap: 8px; }
.ticket-collapse-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s;
}
.ticket-collapse-btn:hover { background: #f8fafc; color: #0f172a; }
.ticket-head.is-compact .ticket-collapse-btn i { transform: rotate(180deg); }
.ticket-head.is-compact .ticket-meta,
.ticket-head.is-compact #ticketHeadIp { display: none; }
.ticket-head.is-compact .ticket-subject { margin-bottom: 0; }
.ticket-head.is-compact .ticket-meta-compact { display: flex; }
.ticket-meta-compact {
  display: none;
  gap: 6px;
  align-items: center;
  font-size: .85rem;
  margin-top: 4px;
}
.ticket-meta-compact .ticket-chip { font-size: .78rem; padding: 3px 8px; }
.ticket-back {
  color: #64748b;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
}
.ticket-back:hover { color: #0f172a; }
.ticket-status-wrap { position: relative; }
.ticket-status-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 6px 12px;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ticket-status-btn.ticket-status {
  padding: 6px 12px;
  font-size: .82rem;
}
.ticket-status-btn:disabled { cursor: default; opacity: .75; }
.ticket-status-btn:not(:disabled)::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .7;
}
.ticket-status-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 188px;
  padding: 6px;
  background: #334155;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .28);
}
.ticket-status-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: left;
  font-size: .9rem;
  font-weight: 500;
}
.ticket-status-menu button::before {
  content: "";
  width: 1em;
  flex: 0 0 1em;
  text-align: center;
}
.ticket-status-menu button.is-on::before { content: "✓"; }
.ticket-status-menu button:hover { background: rgba(255,255,255,.08); }
.ticket-subject { font-size: 1.28rem; font-weight: 750; margin: 0 0 10px; line-height: 1.3; word-break: break-word; color: #0f172a; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; }
.ticket-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
}
.ticket-chip.is-link { background: #eff6ff; color: #1d4ed8; }
.ticket-chip.is-link:hover { background: #dbeafe; color: #1e40af; }
.ticket-chip.is-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
.ticket-chip.is-wallet { background: #ecfdf5; color: #047857; }
.ticket-chip.is-src { background: #fff; border: 1px solid #e2e8f0; }
.ticket-chip.is-muted { font-weight: 500; color: #64748b; }
.ticket-ip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: .8rem;
}
.ticket-head .ticket-ip { margin-top: 10px; }
.ticket-ip code {
  font-size: .78rem;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}
.ticket-ip-loc { color: #15803d; font-weight: 600; }
.ticket-ip-isp {
  color: #1d4ed8;
  font-weight: 650;
  background: #eff6ff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .75rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-ip-check { padding: .12rem .45rem; line-height: 1.2; }
.ticket-thread {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 22px;
  background:
    radial-gradient(1200px 240px at 50% 0, rgba(37, 99, 235, .06), transparent 70%),
    #f1f5f9;
  -webkit-overflow-scrolling: touch;
}
.ticket-msg {
  display: flex;
  flex-direction: column;
  max-width: min(78%, 620px);
  margin-bottom: 14px;
}
.ticket-msg.guest { align-items: flex-start; }
.ticket-msg.staff { margin-left: auto; align-items: flex-end; }
.ticket-msg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.ticket-msg-meta { font-size: .75rem; color: #64748b; font-weight: 600; white-space: nowrap; }
.ticket-msg-row .ticket-ip { margin-top: 0; font-size: .73rem; gap: 5px; }
.ticket-msg-row .ticket-ip code { font-size: .72rem; padding: 1px 5px; }
.ticket-msg-row .ticket-ip-check { padding: .08rem .35rem; font-size: .7rem; }
.ticket-msg-row .ticket-ip-isp { font-size: .7rem; padding: 1px 6px; }
.ticket-msg-bubble {
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px 16px 16px 6px;
  padding: 11px 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .05);
  min-width: 0;
}
.ticket-msg.staff .ticket-msg-bubble {
  background: #eff6ff;
  border-color: #bfdbfe;
  border-radius: 16px 16px 6px 16px;
}
.ticket-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.ticket-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ticket-att {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #fff;
  line-height: 0;
}
.ticket-att img {
  display: block;
  width: 148px;
  height: 110px;
  object-fit: cover;
}
.ticket-att:hover img { opacity: .92; }
.ticket-att-file {
  display: inline-block;
  font-size: .82rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.ticket-compose {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #e8eef5;
  background: #fff;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .04);
}
.ticket-compose textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border-radius: 20px;
  padding: 8px 14px;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  font-size: .9rem;
}
.ticket-compose .btn {
  flex-shrink: 0;
  border-radius: 20px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 650;
}
.ticket-row { cursor: pointer; }
.ticket-row:hover { background: #f8fafc; }
.ticket-list-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 32px;
}
.ticket-list-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.ticket-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
}
button.ticket-pill {
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.ticket-pill:hover { background: #f8fafc; color: #0f172a; }
.ticket-pill.is-on { background: #0f172a; border-color: #0f172a; color: #fff; }
.ticket-pill.is-danger.is-on { background: #dc2626; border-color: #dc2626; }
.ticket-pill.is-open.is-on { background: #2563eb; border-color: #2563eb; }
.ticket-pill.is-answered.is-on { background: #0891b2; border-color: #0891b2; }
.ticket-pill.is-reply.is-on { background: #d97706; border-color: #d97706; }
.ticket-pill.is-closed.is-on { background: #64748b; border-color: #64748b; }
.ticket-pill.is-ok.is-on { background: #15803d; border-color: #15803d; }
.cust-svc-tabs { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 12px; }
.cust-svc-n {
  font-variant-numeric: tabular-nums;
  opacity: .72;
  font-weight: 700;
}
.ticket-pill.is-on .cust-svc-n { opacity: 1; }
.ticket-list-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 280px; justify-content: flex-end; }
.ticket-search { display: flex; gap: 8px; min-width: min(100%, 280px); flex: 1 1 240px; max-width: 420px; }
.ticket-search-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 12px;
  background: #fff;
  font-size: .9rem;
  outline: none;
}
.ticket-search-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ticket-search-btn,
.ticket-create-btn {
  border: 0;
  border-radius: 12px;
  padding: 8px 14px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  white-space: nowrap;
}
.ticket-create-btn { background: #2563eb; }
.ticket-create-btn:hover { background: #1d4ed8; color: #fff; }
.ticket-board {
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .05);
}
.ticket-board-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1.5fr) minmax(120px, .7fr) 140px 108px;
  gap: 12px;
  padding: 10px 18px;
  background: #f8fafc;
  color: #64748b;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid #eef2f7;
}
.ticket-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1.5fr) minmax(120px, .7fr) 140px 108px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
  transition: background .15s ease;
}
.ticket-card:last-child { border-bottom: 0; }
.ticket-card:hover { background: #f8fbff; }
.ticket-skel-card { display: block; }
.ticket-card-id span {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px 8px;
}
.ticket-card-title {
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 6px;
}
.ticket-card-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ticket-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #3730a3;
  font-size: .68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ticket-card-who-text { min-width: 0; display: flex; flex-direction: column; }
.ticket-card-who-text strong { font-size: .86rem; font-weight: 600; color: #334155; }
.ticket-card-email {
  font-size: .75rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-card-src {
  font-size: .78rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.ticket-status.is-open { background: #dbeafe; color: #1d4ed8; }
.ticket-status.is-answered { background: #cffafe; color: #0e7490; }
.ticket-status.is-customer-reply { background: #fef3c7; color: #b45309; }
.ticket-status.is-closed { background: #e2e8f0; color: #475569; }
.ticket-card-time { font-size: .78rem; color: #64748b; white-space: nowrap; }
.ticket-empty { padding: 48px 16px; text-align: center; color: #94a3b8; }
.ticket-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 16px; }
.ticket-page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
}
.ticket-page-btn.is-on { background: #0f172a; border-color: #0f172a; color: #fff; }
.ticket-page-gap { color: #94a3b8; padding: 0 4px; }
@media (max-width: 899.98px) {
  .ticket-board-head { display: none; }
  .ticket-card {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    grid-template-areas:
      "id main status"
      "id src time";
    align-items: start;
  }
  .ticket-card-id { grid-area: id; padding-top: 2px; }
  .ticket-card-main { grid-area: main; }
  .ticket-card-src { grid-area: src; }
  .ticket-card-status { grid-area: status; }
  .ticket-card-time { grid-area: time; }
}
.lite-preload {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2000;
  background: linear-gradient(90deg, #1d4ed8, #93c5fd, #1d4ed8);
  background-size: 200% 100%;
  animation: chat-skel 0.85s linear infinite;
}
.lite-preload[hidden] { display: none !important; }
.ticket-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(15, 23, 42, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ticket-lightbox[hidden] { display: none !important; }
.ticket-lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}
.ticket-lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
@media (max-width: 575.98px) {
  .ticket-msg { max-width: 94%; }
  .ticket-head { padding: 12px 14px 14px; }
  .ticket-thread { padding: 14px 12px 18px; }
  .ticket-compose textarea { min-width: 0; }
}
.ticket-status.is-active { background: #dcfce7; color: #15803d; }
.ticket-status.is-inactive { background: #fef3c7; color: #b45309; }
.ticket-status.is-pending { background: #fef3c7; color: #b45309; }
.ticket-status.is-suspended { background: #fee2e2; color: #b91c1c; }
.ticket-status.is-terminated { background: #e2e8f0; color: #475569; }
.ticket-status.is-muted { background: #f1f5f9; color: #64748b; }
.kind-chip, .count-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  background: #f1f5f9;
  color: #475569;
}
.kind-chip.is-vps, .count-pill.is-vps { background: #dbeafe; color: #1d4ed8; }
.kind-chip.is-hosting, .count-pill.is-hosting { background: #e0e7ff; color: #4338ca; }
.kind-chip.is-email, .count-pill.is-email { background: #dcfce7; color: #15803d; }
.kind-chip.is-license, .count-pill.is-license { background: #f1f5f9; color: #475569; }
.entity-filter-note { font-size: .82rem; color: #64748b; margin: -4px 0 12px; }
.cust-head, .cust-card {
  grid-template-columns: 72px minmax(0, 1.7fr) 128px 110px 56px 120px;
}
.svc-head, .svc-card {
  grid-template-columns: 64px minmax(0, 1.1fr) 80px minmax(0, 1fr) minmax(0, .9fr) 92px 78px 110px;
}
.svc-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.svc-sort:hover { color: #0f172a; }
.svc-sort.is-on { color: #0f172a; }
.svc-sort.is-on::after {
  content: "↓";
  font-size: .65rem;
  line-height: 1;
  opacity: .7;
}
.svc-sort.is-on.is-asc::after { content: "↑"; }
.svc-head-client, .svc-card-client {
  grid-template-columns: 64px 80px minmax(0, 1.15fr) minmax(0, .95fr) 92px 78px 110px;
}
.cust-phone, .cust-balance, .cust-svcs, .svc-due, .svc-pkg, .svc-days {
  font-size: .82rem;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.svc-days { font-weight: 650; }
.svc-days.is-ok { color: #15803d; }
.svc-days.is-soon { color: #b45309; }
.svc-days.is-over { color: #dc2626; font-weight: 750; }
.cust-balance { font-weight: 650; color: #0f172a; }
.cust-svcs { font-weight: 650; }
.svc-host { min-width: 0; display: flex; flex-direction: column; }
.svc-host strong { font-size: .86rem; font-weight: 650; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.detail-back {
  display: inline-flex;
  margin-bottom: 14px;
  color: #64748b;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
}
.detail-back:hover { color: #0f172a; }
.detail-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .05);
  margin-bottom: 16px;
}
.detail-avatar { width: 48px; height: 48px; font-size: 1rem; }
.detail-hero-main { flex: 1 1 240px; min-width: 0; }
.detail-title { font-size: 1.25rem; font-weight: 750; margin: 0 0 4px; color: #0f172a; }
.detail-sub { color: #64748b; font-size: .85rem; margin-bottom: 8px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.detail-hero-side { text-align: right; margin-left: auto; }
.detail-kicker { font-size: .75rem; color: #94a3b8; font-weight: 650; }
.detail-balance { font-size: 1.35rem; font-weight: 750; color: #0f172a; }
.detail-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.detail-metric {
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .04);
  min-width: 0;
}
.detail-metric-label {
  font-size: .72rem;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: .02em;
}
.detail-metric-value {
  margin-top: 6px;
  font-size: 1.18rem;
  font-weight: 750;
  color: #047857;
  line-height: 1.25;
  word-break: break-word;
}
.detail-metric-sub {
  margin-top: 4px;
  font-size: .75rem;
  color: #64748b;
  line-height: 1.35;
}
.detail-member-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-member-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
}
.detail-member-badge.is-muted { background: #94a3b8; }
.detail-member-pct { color: #d97706; font-size: 1.05rem; }
.detail-client-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  margin-left: auto;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, .8fr);
  gap: 16px;
}
.detail-card {
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .04);
}
.detail-card h2 {
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 14px;
}
.detail-kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.detail-kv div { min-width: 0; }
.detail-kv span { display: block; font-size: .72rem; color: #94a3b8; font-weight: 650; margin-bottom: 2px; }
.detail-kv .ticket-ip { margin-top: 4px; }
.login-ip-value {
  color: #a21caf;
  font-weight: 650;
  background: #faf5ff;
  word-break: break-all;
}
.detail-kv .span-2 { grid-column: 1 / -1; }
.detail-counts { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-notes {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  font-size: .88rem;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-hint { margin: 16px 0 0; font-size: .78rem; color: #94a3b8; }
.detail-error {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .78rem;
  color: #64748b;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 899.98px) {
  .cust-head, .svc-head, .svc-head-client { display: none; }
  .cust-card {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "id main status"
      "id phone balance";
  }
  .cust-card .ticket-card-id { grid-area: id; }
  .cust-card .ticket-card-main { grid-area: main; }
  .cust-card .ticket-card-status { grid-area: status; }
  .cust-phone { grid-area: phone; }
  .cust-balance { grid-area: balance; text-align: right; }
  .cust-svcs { display: none; }
  .svc-card {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "id main status"
      "id host due";
  }
  .svc-card .ticket-card-id { grid-area: id; }
  .svc-card .ticket-card-main { grid-area: main; }
  .svc-card .ticket-card-status { grid-area: status; }
  .svc-kind { display: none; }
  .svc-host { grid-area: host; }
  .svc-pkg { display: none; }
  .svc-due { display: none; }
  .svc-days { grid-area: due; text-align: right; }
  .svc-card-client {
    grid-template-areas:
      "id kind status"
      "id host due";
  }
  .svc-card-client .svc-kind { display: block; grid-area: kind; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-metrics { grid-template-columns: 1fr 1fr; }
  .detail-hero-side, .detail-actions { text-align: left; justify-content: flex-start; margin-left: 0; }
}
@media (max-width: 575.98px) {
  .detail-kv { grid-template-columns: 1fr; }
  .detail-metrics { grid-template-columns: 1fr; }
}
.home-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  padding: 28px 28px 22px;
  border-radius: 20px;
  color: #e2e8f0;
  background:
    radial-gradient(1200px 280px at 90% -40%, rgba(59, 130, 246, .35), transparent 55%),
    linear-gradient(145deg, #0f172a 0%, #1e3a8a 58%, #0f172a 120%);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .18);
  overflow: hidden;
  margin-bottom: 18px;
}
.home-hero-copy { min-width: 0; }
.home-kicker {
  margin: 0 0 6px;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #93c5fd;
}
.home-hero h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-weight: 750;
  color: #fff;
  letter-spacing: -.02em;
}
.home-lead { margin: 0; font-size: .92rem; color: #cbd5e1; }
.home-hero-side { align-self: start; }
.home-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #e2e8f0;
  font-size: .78rem;
  font-weight: 650;
  white-space: nowrap;
}
.home-live i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #94a3b8;
}
.home-live.is-on i {
  background: #4ade80;
  box-shadow: 0 0 0 4px rgba(74, 222, 128, .22);
}
.home-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.home-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  color: inherit;
  min-width: 0;
  transition: background .15s ease;
}
.home-stat:hover { background: rgba(255,255,255,.14); color: #fff; }
.home-stat strong {
  font-size: 1.35rem;
  font-weight: 750;
  color: #fff;
  line-height: 1.15;
}
.home-stat span {
  font-size: .75rem;
  color: #cbd5e1;
  line-height: 1.3;
}
.home-stat.is-alert {
  background: rgba(248, 113, 113, .18);
  border-color: rgba(252, 165, 165, .25);
}
.home-stat.is-live strong {
  font-variant-numeric: tabular-nums;
}
.home-stat strong.is-tick {
  animation: homeStatTick .35s ease;
}
@keyframes homeStatTick {
  from { transform: translateY(4px); opacity: .45; }
  to { transform: none; opacity: 1; }
}
.home-mods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.home-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 18px 18px 16px;
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.home-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, .1);
  border-color: #bfdbfe;
  color: inherit;
}
.home-ico {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.home-ico svg { width: 22px; height: 22px; }
.home-tile.is-ticket .home-ico { background: #dbeafe; color: #1d4ed8; }
.home-tile.is-chat .home-ico { background: #dcfce7; color: #15803d; }
.home-tile.is-cust .home-ico { background: #fef3c7; color: #b45309; }
.home-tile.is-svc .home-ico { background: #e0e7ff; color: #4338ca; }
.home-tile.is-set .home-ico { background: #f1f5f9; color: #475569; }
.home-tile-body { min-width: 0; flex: 1; }
.home-tile-top { display: flex; align-items: baseline; gap: 8px; }
.home-tile h2 { margin: 0; font-size: 1.05rem; font-weight: 750; color: #0f172a; }
.home-tile-top em {
  font-style: normal;
  font-size: .72rem;
  font-weight: 750;
  color: #dc2626;
  background: #fee2e2;
  border-radius: 999px;
  padding: 2px 8px;
}
.home-tile-count {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  min-width: 72px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #f8fafc;
  line-height: 1.15;
}
.home-tile-count strong {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}
.home-tile-count small {
  font-size: .68rem;
  font-weight: 650;
  color: #64748b;
  white-space: nowrap;
}
.home-tile-count.is-alert {
  background: #fef2f2;
}
.home-tile-count.is-alert strong { color: #dc2626; }
.home-tile-count.is-alert small { color: #b91c1c; }
.home-tile p { margin: 4px 0 0; font-size: .82rem; color: #64748b; line-height: 1.4; }
.home-go { color: #94a3b8; font-weight: 700; flex-shrink: 0; }
.home-tile:hover .home-go { color: #2563eb; }
.home-tile.is-set { grid-column: 1 / -1; }
@media (max-width: 899.98px) {
  .home-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 639.98px) {
  .home-hero { grid-template-columns: 1fr; padding: 22px 18px 16px; }
  .home-hero h1 { font-size: 1.4rem; }
  .home-stats { grid-template-columns: 1fr 1fr; }
  .home-mods { grid-template-columns: 1fr; }
  .home-tile.is-set { grid-column: auto; }
}
.settings-hero { margin-bottom: 16px; }
.settings-status {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.settings-hero .ticket-status { background: rgba(255,255,255,.12); color: #e2e8f0; }
.settings-hero .ticket-status.is-active { background: rgba(74, 222, 128, .2); color: #bbf7d0; }
.settings-hero .ticket-status.is-suspended { background: rgba(248, 113, 113, .22); color: #fecaca; }
.settings-hero .ticket-status.is-closed { background: rgba(255,255,255,.1); color: #cbd5e1; }
.settings-meta {
  grid-column: 1 / -1;
  font-size: .8rem;
  color: #94a3b8;
}
.settings-err {
  grid-column: 1 / -1;
  font-size: .82rem;
  color: #fecaca;
  background: rgba(248, 113, 113, .12);
  border-radius: 10px;
  padding: 8px 12px;
}
.settings-tabs { margin: 0 0 16px; }
.settings-card { margin-bottom: 14px; }
.settings-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.settings-toggle:last-of-type { border-bottom: 0; }
.settings-card .settings-toggle:last-of-type { margin-bottom: 8px; }
.settings-toggle strong { display: block; font-size: .92rem; color: #0f172a; }
.settings-toggle small {
  display: block;
  margin-top: 3px;
  font-size: .8rem;
  color: #64748b;
  line-height: 1.4;
}
.settings-toggle input {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 3px;
  accent-color: #2563eb;
}
.settings-label {
  display: block;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 6px;
}
.settings-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font-size: .9rem;
  outline: none;
  margin-bottom: 8px;
}
.settings-input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.settings-hint { margin: 0 0 16px; font-size: .8rem; color: #64748b; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-btn-ghost {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 14px;
  background: #fff;
  color: #334155;
  font-weight: 600;
  font-size: .85rem;
}
.settings-btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
