/* --- Reset & base --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: #1a1d24; background: #f6f7f9; line-height: 1.5; }
a { color: #2260d8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 1.5em; }
h3 { font-size: 1rem; }
code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.92em; background: #f0f1f4; padding: 1px 5px; border-radius: 4px; }
.muted { color: #6a7380; }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.big { font-size: 1.8rem; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
textarea { resize: vertical; min-height: 4em; }
section { margin-bottom: 2em; }

/* --- Top bar --- */
.topbar { display: flex; align-items: center; background: #1a1d24; color: #fff; padding: 0.6em 1.2em; gap: 1.5em; }
.topbar .brand { display: inline-flex; align-items: center; gap: 0.6em; color: #fff; font-weight: 600; text-decoration: none; }
.topbar .brand:hover { text-decoration: none; opacity: 0.85; }
.topbar-logo { height: 28px; width: auto; display: block; }
.topbar-support { font-size: 1rem; font-weight: 500; color: #dfe3ea; letter-spacing: 0.01em; padding-left: 0.4em; border-left: 1px solid #3a3f4a; }
.topbar nav { display: flex; gap: 1em; flex: 1; }
.topbar nav a { color: #dfe3ea; }
.topbar nav a:hover { color: #fff; }
.topbar .link, .topbar button.link { background: none; border: none; color: #dfe3ea; cursor: pointer; padding: 0; }
.topbar .link:hover { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 1em; }
.inline { display: inline; }

/* --- Notification bell --- */
.bell-wrap { position: relative; }
.bell-btn { background: transparent; border: none; color: #dfe3ea; cursor: pointer; padding: 0.35em; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; position: relative; transition: color 0.12s, background 0.12s; }
.bell-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.bell-btn.has-unread { color: #fff; }
.bell-badge { position: absolute; top: -2px; right: -2px; background: #e74c3c; color: #fff; font-size: 0.65rem; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; border: 1.5px solid #1a1d24; }
.bell-badge[hidden] { display: none; }
.bell-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 360px; max-width: calc(100vw - 2em); background: #fff; color: #1a1d24; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); border: 1px solid #e5e8ee; z-index: 100; overflow: hidden; }
.bell-dropdown[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 0.7em 1em; border-bottom: 1px solid #eef0f4; background: #fafbfc; }
.bell-head .link { background: transparent; border: none; color: #2260d8; font-size: 0.85rem; cursor: pointer; padding: 0; }
.bell-head .link:hover { text-decoration: underline; }
.bell-body { max-height: 60vh; overflow-y: auto; }

.notif-item { display: block; position: relative; padding: 0.7em 2.2em 0.7em 1em; border-bottom: 1px solid #eef0f4; color: #1a1d24; text-decoration: none; cursor: pointer; transition: background 0.1s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f6f7f9; text-decoration: none; }
.notif-item.unread { background: #f0f6ff; }
.notif-item.unread:hover { background: #e2edff; }
.notif-item.unread::before { content: ""; position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: #2260d8; }
.notif-body { font-size: 0.9rem; line-height: 1.35; margin-bottom: 0.2em; }
.notif-meta { display: flex; gap: 0.6em; align-items: center; font-size: 0.75rem; color: #6a7380; }
.notif-kind { background: #eaecf1; color: #555; padding: 1px 7px; border-radius: 8px; font-weight: 500; }
.notif-time { font-style: italic; }
.notif-delete { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); background: transparent; border: none; color: #999; cursor: pointer; font-size: 1.1rem; padding: 4px 8px; border-radius: 4px; line-height: 1; opacity: 0; transition: opacity 0.12s, background 0.12s; }
.notif-item:hover .notif-delete { opacity: 1; }
.notif-delete:hover { background: #fee; color: #c33; }

/* --- Auth-card brand (logo above heading) --- */
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 0.6em; margin-bottom: 1.5em; padding-bottom: 1em; border-bottom: 1px solid #eef0f4; }
.auth-logo { height: 36px; width: auto; display: block; }
.auth-support { font-size: 1.1rem; font-weight: 500; color: #6a7380; padding-left: 0.5em; border-left: 1px solid #e5e8ee; }

/* --- Auth cards --- */
body.auth { background: #1a1d24; color: #1a1d24; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2em 1em; }
.auth-card { background: #fff; padding: 2em; border-radius: 10px; width: 100%; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.auth-card.wide { max-width: 600px; }
.auth-card h1 { margin-bottom: 1em; }
.auth-card label { display: block; margin-bottom: 1em; font-weight: 500; font-size: 0.9rem; color: #333; }
.auth-card input, .auth-card textarea { width: 100%; padding: 0.6em 0.75em; border: 1px solid #d0d4dc; border-radius: 6px; margin-top: 0.25em; font-size: 1rem; }
.auth-card button.primary { background: #2260d8; color: #fff; border: none; padding: 0.7em 1.2em; border-radius: 6px; font-weight: 600; cursor: pointer; width: 100%; font-size: 1rem; }
.auth-card button.primary:hover { background: #1a4eb6; }
.auth-card .error { background: #fee; color: #c33; padding: 0.6em 1em; border-radius: 6px; margin-bottom: 1em; }
.auth-card .success { background: #eaf8ef; color: #1a7a3a; padding: 0.75em 1em; border-radius: 6px; margin-bottom: 1em; }
.auth-card .muted { color: #7a8090; }

/* --- Layout --- */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.sidebar { background: #fff; border-right: 1px solid #e5e8ee; padding: 1em; }
.sidebar .btn { margin-bottom: 1em; }
.sidebar .views { display: flex; flex-direction: column; margin-bottom: 1em; }
.sidebar .views a { padding: 0.5em 0.75em; border-radius: 6px; color: #333; display: flex; justify-content: space-between; align-items: center; font-size: 0.92rem; }
.sidebar .views a:hover { background: #f0f1f4; text-decoration: none; }
.sidebar .views a.active { background: #e8efff; color: #2260d8; font-weight: 600; }
.sidebar .badge { background: #eaecf1; color: #555; font-size: 0.75rem; padding: 1px 7px; border-radius: 10px; }
.sidebar .views a.active .badge { background: #2260d8; color: #fff; }
.sidebar .search input { width: 100%; padding: 0.5em 0.75em; border: 1px solid #d0d4dc; border-radius: 6px; }
.content { padding: 1.5em 2em; }
.container { padding: 1.5em 2em; max-width: 1100px; margin: 0 auto; }
.container.narrow { max-width: 800px; }

/* --- Buttons --- */
.btn { display: inline-block; padding: 0.5em 1em; border: 1px solid #d0d4dc; background: #fff; color: #1a1d24; border-radius: 6px; cursor: pointer; font-size: 0.95rem; text-decoration: none; }
.btn:hover { background: #f0f1f4; text-decoration: none; }
.btn-primary { background: #2260d8; color: #fff; border-color: #2260d8; }
.btn-primary:hover { background: #1a4eb6; }
.btn-sm { font-size: 0.82rem; padding: 0.25em 0.6em; border: 1px solid #d0d4dc; background: #fff; border-radius: 4px; cursor: pointer; }
.btn-sm.btn-primary { background: #2260d8; color: #fff; border-color: #2260d8; }
.btn-sm.btn-primary:hover { background: #1a4eb6; }
.btn-sm.danger, .btn.danger, button.danger { background: #fff; color: #c33; border-color: #f2b3b3; }
.btn-sm.danger:hover, .btn.danger:hover, button.danger:hover { background: #fee; }
.block { display: block; text-align: center; }
button.x { background: none; border: none; color: #999; cursor: pointer; padding: 0 0.25em; font-size: 1em; }
button.x:hover { color: #c33; }

/* --- Tables --- */
table.tickets { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e8ee; border-radius: 6px; overflow: hidden; font-size: 0.92rem; }
table.tickets th { background: #f6f7f9; font-weight: 600; text-align: left; padding: 0.6em 0.8em; border-bottom: 1px solid #e5e8ee; font-size: 0.82rem; color: #555; text-transform: uppercase; letter-spacing: 0.02em; position: relative; white-space: nowrap; user-select: none; overflow: hidden; text-overflow: ellipsis; }
table.tickets td { padding: 0.6em 0.8em; border-bottom: 1px solid #eef0f4; }
table.tickets tr:last-child td { border-bottom: none; }
table.tickets tr:hover { background: #fafbfc; cursor: pointer; }
table.tickets a { color: #1a1d24; font-weight: 500; }

/* --- Pills / badges --- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; text-transform: lowercase; }
.status-new { background: #e8efff; color: #2260d8; }
.status-open { background: #fff5e0; color: #a66900; }
.status-pending { background: #f0eaff; color: #6b3fb5; }
.status-on_hold { background: #fff0f0; color: #b04040; }
.status-solved { background: #eafbef; color: #1a7a3a; }
.status-closed { background: #eaecf1; color: #555; }
.prio-low { background: #eaecf1; color: #555; }
.prio-normal { background: #e8efff; color: #2260d8; }
.prio-high { background: #fff5e0; color: #a66900; }
.prio-urgent { background: #ffe4e4; color: #c33; }
.internal-tag { background: #fff5c2; color: #7a5a00; }

/* --- SLA --- */
.sla { font-size: 0.82rem; font-weight: 500; padding: 2px 7px; border-radius: 4px; }
.sla-ok { background: #eafbef; color: #1a7a3a; }
.sla-warn { background: #fff5e0; color: #a66900; }
.sla-breach { background: #ffe4e4; color: #c33; }

/* --- Forms --- */
form.stack { display: flex; flex-direction: column; gap: 0.75em; }
form.stack label { display: flex; flex-direction: column; font-weight: 500; font-size: 0.92rem; gap: 0.2em; }
form.stack input, form.stack select, form.stack textarea { padding: 0.5em 0.7em; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 0.95rem; }
form.stack .row { display: flex; gap: 1em; }
form.stack .row label { flex: 1; }
form.stack .actions { display: flex; gap: 0.75em; justify-content: flex-end; margin-top: 0.5em; }
form.stack-sm { margin-bottom: 0.5em; }
form.stack-sm label { display: block; font-size: 0.85rem; color: #555; }
form.stack-sm select { width: 100%; padding: 0.35em 0.5em; border: 1px solid #d0d4dc; border-radius: 4px; margin-top: 2px; }
form.inline-form { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; margin-top: 0.5em; }
form.inline-form input, form.inline-form select { padding: 0.4em 0.6em; border: 1px solid #d0d4dc; border-radius: 4px; font-size: 0.9rem; }
.tag-add input { border: 1px dashed #c0c4cc; background: transparent; padding: 2px 6px; border-radius: 10px; font-size: 0.82rem; }

/* --- Ticket detail --- */
.ticket-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5em; padding: 1.5em 2em; max-width: 1400px; margin: 0 auto; }
.ticket-main { min-width: 0; }
.ticket-side { display: flex; flex-direction: column; gap: 1em; }
.panel { background: #fff; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1em; }
.panel h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6a7380; margin-bottom: 0.5em; }
.panel h4 { font-size: 0.85rem; color: #555; margin-top: 0.75em; }
.panel ul { margin: 0; padding-left: 1.1em; }

.ticket-head { padding: 1em 0; border-bottom: 1px solid #e5e8ee; margin-bottom: 1em; }
.ticket-head h1 { font-size: 1.4rem; margin: 0.25em 0 0.5em; }
.tags-row { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; margin-top: 0.5em; }
.tag { display: inline-flex; align-items: center; gap: 0.25em; background: #e8efff; color: #2260d8; padding: 2px 8px; border-radius: 10px; font-size: 0.82rem; }

.messages { display: flex; flex-direction: column; gap: 0.75em; margin-bottom: 1.5em; }
.msg { background: #fff; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1em; }
.msg header { display: flex; gap: 0.5em; align-items: center; margin-bottom: 0.5em; flex-wrap: wrap; }
.msg.msg-customer { background: #f6f7f9; border-left: 3px solid #2260d8; }
.msg.internal { background: #fffbea; border-left: 3px solid #d4a017; }
.msg.msg-system { background: #f9f9fb; font-style: italic; color: #6a7380; font-size: 0.88rem; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.attachments { margin-top: 0.75em; display: flex; gap: 0.5em; flex-wrap: wrap; align-items: flex-start; }
.thumb-btn { background: none; border: none; padding: 0; margin: 0; cursor: pointer; border-radius: 6px; transition: transform 0.1s, box-shadow 0.1s; }
.thumb-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.thumb-btn:focus-visible { outline: 2px solid #2260d8; outline-offset: 2px; }
.attachments .thumb { max-width: 200px; max-height: 150px; border-radius: 6px; border: 1px solid #e5e8ee; display: block; }
.attachments .attach { display: inline-block; padding: 0.4em 0.75em; background: #f0f1f4; border-radius: 6px; color: #333; font-size: 0.9rem; }
.attachments .attach:hover { background: #e5e8ee; text-decoration: none; }

/* --- Internal-note delete button --- */
.msg-delete-form { margin-left: auto; }
.msg-delete-btn { background: transparent; border: none; cursor: pointer; opacity: 0.5; padding: 2px 6px; border-radius: 4px; font-size: 0.95rem; line-height: 1; transition: opacity 0.12s, background 0.12s; }
.msg-delete-btn:hover { opacity: 1; background: #fee; }
.msg.internal header { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }

/* --- Deleted message --- */
.msg.deleted { opacity: 0.6; background: #f9f9fb; border-left-color: #c0c4cc; }
.msg.deleted .body { font-style: italic; color: #6a7380; }
.msg.deleted .deleted-body { font-size: 0.92rem; }

/* --- Image lightbox --- */
.image-viewer { position: fixed; inset: 0; background: rgba(15, 18, 25, 0.92); z-index: 200; display: flex; flex-direction: column; }
.image-viewer[hidden] { display: none; }
.image-viewer-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 0.7em 1.2em; color: #fff; gap: 1em; flex-shrink: 0; }
.image-viewer-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.image-viewer-actions { display: flex; gap: 0.5em; flex-shrink: 0; }
.image-viewer-actions .btn { background: #fff; color: #1a1d24; border: none; }
.image-viewer-actions .btn:hover { background: #f0f1f4; }
.image-viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1em; overflow: hidden; cursor: zoom-out; }
.image-viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); cursor: default; }

.reply-box { background: #fff; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1em; margin-bottom: 1em; }
.reply-tabs { display: flex; gap: 0.5em; margin-bottom: 0.75em; }
.reply-tabs .tab { background: transparent; border: none; padding: 0.4em 0.8em; cursor: pointer; color: #6a7380; font-weight: 500; border-bottom: 2px solid transparent; }
.reply-tabs .tab.active { color: #1a1d24; border-bottom-color: #2260d8; }
.reply-box textarea { width: 100%; padding: 0.75em; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 0.95rem; min-height: 140px; }
.reply-box.internal textarea { background: #fffbea; border-color: #e0c060; }
.reply-actions { display: flex; gap: 0.5em; align-items: center; margin-top: 0.5em; }
.reply-actions .spacer { flex: 1; }
.file-btn { cursor: pointer; padding: 0.4em 0.8em; background: #f0f1f4; border-radius: 6px; font-size: 0.9rem; }
.macros-menu summary { cursor: pointer; padding: 0.4em 0.8em; background: #f0f1f4; border-radius: 6px; font-size: 0.9rem; list-style: none; }
.macros-menu summary::-webkit-details-marker { display: none; }
.macros-list { position: absolute; background: #fff; border: 1px solid #e5e8ee; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); margin-top: 0.5em; padding: 0.5em; min-width: 280px; z-index: 10; }
.macros-list .macro-btn { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 0.5em 0.6em; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.macros-list .macro-btn:hover { background: #f0f1f4; }

.csat-result { font-size: 1.4rem; font-weight: 600; }
.csat-3 { color: #1a7a3a; }
.csat-2 { color: #a66900; }
.csat-1 { color: #c33; }

/* --- Dashboard cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1em; margin-bottom: 1.5em; }
.card { background: #fff; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1.25em; text-align: center; }
.card .n { font-size: 2rem; font-weight: 600; color: #2260d8; }
.card .label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6a7380; margin-top: 0.25em; }

/* --- Error and success --- */
.error { background: #fee; color: #c33; padding: 0.6em 1em; border-radius: 6px; margin-bottom: 1em; }
.success { background: #eaf8ef; color: #1a7a3a; padding: 0.75em 1em; border-radius: 6px; margin-bottom: 1em; }

/* --- Presence --- */
#presence { margin-top: 0.25em; }
#presence .viewer { display: inline-block; background: #e8efff; color: #2260d8; padding: 1px 7px; border-radius: 10px; font-size: 0.78rem; margin-right: 0.25em; }

/* --- Back link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: #2260d8;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75em;
  text-decoration: none;
  padding: 0.4em 0.7em 0.4em 0.5em;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.back-link:hover { background: #e8efff; text-decoration: none; color: #1a4eb6; }
.back-arrow { font-size: 1.4rem; line-height: 1; font-weight: 700; display: inline-block; transform: translateY(-1px); }
.back-link:hover .back-arrow { transform: translate(-2px, -1px); }
.back-arrow { transition: transform 0.12s; }

/* --- Ticket head with action buttons --- */
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1em; }
.ticket-head-actions { display: flex; gap: 0.5em; flex-shrink: 0; padding-top: 0.5em; }

/* --- Banners --- */
.banner { padding: 0.75em 1em; border-radius: 6px; margin-bottom: 1em; font-size: 0.92rem; }
.banner-info { background: #e8efff; color: #2260d8; border-left: 3px solid #2260d8; }
.banner-warn { background: #fff5e0; color: #a66900; border-left: 3px solid #d4a017; padding: 0.75em 1em; border-radius: 6px; margin-bottom: 0.75em; }

/* --- Split mode --- */
.msg-select { display: none; }
body.split-mode .msg-select { display: block; position: absolute; top: 1em; right: 1em; }
body.split-mode .msg { padding-right: 3em; cursor: pointer; transition: background 0.1s, border-color 0.1s; position: relative; }
body.split-mode .msg:hover { border-color: #2260d8; }
body.split-mode .msg.selected { background: #e8efff; border-color: #2260d8; box-shadow: 0 0 0 2px rgba(34, 96, 216, 0.15); }
body.split-mode .msg-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: #2260d8; }
body.split-mode .reply-box { opacity: 0.5; pointer-events: none; }

/* --- Floating split bar --- */
.split-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #1a1d24; color: #fff; padding: 0.75em 1em; box-shadow: 0 -4px 12px rgba(0,0,0,0.15); z-index: 50; }
.split-bar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 1em; }
.split-bar #split-count { flex: 1; font-weight: 500; }
.split-bar .btn { background: #fff; color: #1a1d24; border: none; }
.split-bar .btn-primary { background: #2260d8; color: #fff; }
.split-bar .btn-primary:disabled { background: #4a5568; cursor: not-allowed; opacity: 0.6; }

/* --- Modals --- */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; background: rgba(15, 18, 25, 0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1em; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 10px; padding: 1.5em; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.modal-card.wide { max-width: 640px; }
.modal-card h2 { margin-top: 0; }
.modal-card label { display: block; margin: 1em 0 0.5em; font-weight: 500; font-size: 0.92rem; }
.modal-card input[type="text"], .modal-card input[type="search"], .modal-card select { width: 100%; padding: 0.6em 0.75em; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 0.95rem; }
.modal-card .confirm-check { display: flex; align-items: center; gap: 0.5em; cursor: pointer; }
.modal-card .confirm-check input { width: auto; margin: 0; }
.modal-actions { display: flex; gap: 0.5em; justify-content: flex-end; margin-top: 1.5em; }

/* --- Merge picker --- */
#merge-search { width: 100%; padding: 0.65em 0.85em; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 0.95rem; margin-top: 0.75em; }
.merge-results { max-height: 280px; overflow-y: auto; margin-top: 0.75em; border: 1px solid #e5e8ee; border-radius: 6px; }
.merge-results:empty { display: none; }
.merge-result { display: block; width: 100%; text-align: left; background: #fff; border: none; border-bottom: 1px solid #eef0f4; padding: 0.7em 0.9em; cursor: pointer; }
.merge-result:last-child { border-bottom: none; }
.merge-result:hover { background: #f6f7f9; }
.merge-result.selected { background: #e8efff; border-left: 3px solid #2260d8; padding-left: calc(0.9em - 3px); }
.merge-result-head { display: flex; gap: 0.5em; align-items: center; margin-bottom: 0.2em; }
.merge-result-subject { font-weight: 500; color: #1a1d24; margin-bottom: 0.15em; }
.same-cust { background: #eafbef; color: #1a7a3a; }

/* --- Linked list compact --- */
.linked-list { list-style: none; padding-left: 0; }
.linked-list li { display: flex; gap: 0.4em; align-items: center; flex-wrap: wrap; padding: 0.25em 0; }
.linked-list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Settings tabs --- */
.settings-tabs { display: flex; gap: 0.25em; border-bottom: 1px solid #e5e8ee; margin-bottom: 1.5em; flex-wrap: wrap; align-items: center; }
.settings-tabs a { padding: 0.65em 1em; color: #6a7380; text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; font-size: 0.95rem; margin-bottom: -1px; }
.settings-tabs a:hover { color: #1a1d24; text-decoration: none; }
.settings-tabs a.active { color: #2260d8; border-bottom-color: #2260d8; }
.settings-tabs-divider { width: 1px; height: 1.4em; background: #e5e8ee; margin: 0 0.5em; }
.actions-cell { display: flex; gap: 0.3em; flex-wrap: wrap; }
.actions-cell form { margin: 0; }
.edit-row td { background: #fafbfc; padding: 0.75em 0.8em; }
.edit-row .inline-form { margin: 0; }
.checkbox-label { display: flex; align-items: center; gap: 0.4em; }
.audit-table { font-size: 0.88rem; }
.audit-table .audit-details { font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem; max-width: 30em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-table .audit-details:hover { white-space: normal; word-break: break-all; }
.truncate { max-width: 24em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================
   INVENTORY
   ============================================ */
.container-wide { max-width: none; padding-left: 1.5em; padding-right: 1.5em; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-bottom: 1em; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: 0.5em; flex-wrap: wrap; }

.inventory-filters { display: flex; gap: 0.5em; margin-bottom: 1em; flex-wrap: wrap; align-items: center; background: #fff; padding: 0.75em; border-radius: 6px; border: 1px solid #e5e8ee; }
.inventory-filters input, .inventory-filters select { padding: 0.5em 0.7em; border: 1px solid #d0d4dc; border-radius: 6px; font-size: 0.92rem; }
.inventory-filters input[type="search"] { flex: 1; min-width: 240px; }

/* Multi-select popover (used by inventory filters) */
.multiselect { position: relative; }
.multiselect-toggle { display: inline-flex; align-items: center; gap: 0.5em; min-width: 180px; padding: 0.5em 0.75em; border: 1px solid #d0d4dc; border-radius: 6px; background: #fff; cursor: pointer; font-size: 0.92rem; color: #1a1d24; text-align: left; }
.multiselect-toggle:hover { border-color: #2260d8; }
.multiselect-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect-caret { color: #888; font-size: 0.8rem; }
.multiselect-popover { position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 320px; max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid #d0d4dc; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); z-index: 50; padding: 0.4em 0; }
.multiselect-popover[hidden] { display: none; }
.multiselect-option { display: flex; align-items: center; gap: 0.6em; padding: 0.45em 0.85em; cursor: pointer; font-size: 0.92rem; user-select: none; }
.multiselect-option:hover { background: #f0f6ff; }
.multiselect-option input[type="checkbox"] { margin: 0; cursor: pointer; }
.multiselect-option span { flex: 1; }

.bulk-form-mount { display: contents; }
.bulk-bar { display: none; background: #1a1d24; color: #fff; padding: 0.6em 1em; border-radius: 6px; margin-bottom: 0.75em; align-items: center; gap: 1em; }
.bulk-bar.is-visible { display: flex; }
.bulk-bar .btn { background: #fff; color: #1a1d24; border: none; }
.bulk-bar .btn.danger { background: #c33; color: #fff; }

.inventory-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.inventory-table { table-layout: fixed; font-size: 0.9rem; min-width: 100%; }
.inventory-table th { position: relative; white-space: nowrap; user-select: none; overflow: hidden; text-overflow: ellipsis; }
.inventory-table th.sorted { background: #e8efff; }
.inventory-table th a { color: #1a1d24; text-decoration: none; display: inline-block; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.inventory-table th a:hover { color: #2260d8; }
.inventory-table td { vertical-align: middle; overflow: hidden; }
.inventory-table td .cell-truncate, .inventory-table td.cell-truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.inventory-table tr:hover { background: #fafbfc; }
.inventory-table tr:hover .row-actions { visibility: visible; }
.inventory-table .check-col { text-align: center; }
.inventory-table .row-actions { display: flex; gap: 0.3em; visibility: hidden; }
.inventory-table .row-actions form { margin: 0; }
.inventory-table .serial { font-size: 0.85rem; color: #555; }
.inventory-table .status-select { padding: 0.25em 0.5em; border: 1px solid #d0d4dc; border-radius: 4px; font-size: 0.85rem; cursor: pointer; max-width: 100%; }

/* Column resize handle: thin invisible strip on the right edge of each <th> */
.col-resizer {
  position: absolute; top: 0; right: 0; width: 7px; height: 100%;
  cursor: col-resize; user-select: none;
  background: transparent; transition: background 0.12s;
  z-index: 2;
}
.col-resizer:hover, .col-resizer:active { background: #2260d8; }
body.col-resizing { cursor: col-resize !important; user-select: none; }
body.col-resizing * { cursor: col-resize !important; }

/* Status pills (re-used on edit page + linked-units list) */
.status-pill-operational { background: #eafbef; color: #1a7a3a; }
.status-pill-lost { background: #ffe4e4; color: #c33; }
.status-pill-in-repair { background: #fff5e0; color: #a66900; }
.status-pill-spare { background: #e8efff; color: #2260d8; }
.status-pill-replacement { background: #f0eaff; color: #6b3fb5; }
.status-pill-disposed { background: #eaecf1; color: #555; }

.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Inventory edit page */
.inventory-edit-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.5em; align-items: start; }
.inventory-form { background: #fff; padding: 1.5em; border: 1px solid #e5e8ee; border-radius: 8px; }
.inventory-form .form-actions { display: flex; gap: 0.5em; justify-content: flex-end; margin-top: 1em; padding-top: 1em; border-top: 1px solid #eef0f4; flex-wrap: wrap; }
.inventory-side { display: flex; flex-direction: column; gap: 1em; }
.inventory-side .panel { padding: 1em; }
.audit-list { list-style: none; padding-left: 0; margin: 0; }
.audit-list li { padding: 0.5em 0; border-bottom: 1px solid #eef0f4; }
.audit-list li:last-child { border-bottom: none; }
.audit-pre { background: #f6f7f9; padding: 0.5em; border-radius: 4px; font-size: 0.78rem; overflow-x: auto; max-height: 200px; margin: 0.25em 0 0; }

/* Linked units in ticket sidebar */
.linked-units-list { list-style: none; padding-left: 0; }
.linked-units-list li { padding: 0.5em 0; border-bottom: 1px solid #eef0f4; }
.linked-units-list li:last-child { border-bottom: none; }
.linked-units-list .pill { font-size: 0.7rem; }

/* CSV import */
.csv-template-card { background: #fff; padding: 1em; border-radius: 8px; border: 1px solid #e5e8ee; margin: 1em 0; }
.csv-headers { width: 100%; font-size: 0.82rem; border-collapse: collapse; }
.csv-headers th, .csv-headers td { padding: 0.4em 0.6em; border: 1px solid #e5e8ee; text-align: left; vertical-align: top; }
.csv-headers th { background: #f6f7f9; font-family: ui-monospace, Menlo, Consolas, monospace; }
.csv-example { background: #1a1d24; color: #dfe3ea; padding: 0.75em; border-radius: 6px; overflow-x: auto; font-size: 0.82rem; line-height: 1.4; }
.preview-error { background: #fee; }
.error-cell { color: #c33; font-size: 0.82rem; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid #e5e8ee; }
  .ticket-layout { grid-template-columns: 1fr; padding: 1em; }
  .content, .container { padding: 1em; }
  table.tickets { font-size: 0.82rem; }
  .ticket-head { flex-direction: column; }
  .modal-card { padding: 1em; }
}

/* =====================================================
 * HTML email rendering
 * ===================================================== */
.body.html-body { max-width: 100%; overflow-x: auto; word-wrap: break-word; line-height: 1.2; white-space: normal; }
.body.html-body img { max-width: 100%; height: auto; }
.body.html-body table { border-collapse: collapse; max-width: 100%; }
.body.html-body td, .body.html-body th { border: 1px solid #e5e8ee; padding: 0.4em 0.7em; vertical-align: top; }
.body.html-body blockquote { border-left: 3px solid #d0d4dc; padding-left: 1em; color: #555; margin: 0.6em 0; }
.body.html-body pre { background: #f6f7f9; padding: 0.8em; border-radius: 4px; overflow-x: auto; }
.body.html-body a { color: #2260d8; }
.external-img-placeholder {
  display: inline-block; min-width: 80px; min-height: 60px;
  background: #f0f2f6; border: 1px dashed #b8bdc8; color: #888;
  font-size: 0.85em; font-style: italic; padding: 0.4em 0.8em; vertical-align: middle;
}
.external-images-bar { margin-top: 0.8em; padding-top: 0.6em; border-top: 1px dashed #d0d4dc; font-size: 0.85em; color: #888; }
.show-external-btn { background: none; border: none; color: #2260d8; cursor: pointer; padding: 0; text-decoration: underline; font-size: 0.9em; }
.show-external-btn:hover { color: #1a4dab; }
.body.plain-body pre { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; margin: 0; }

/* Tighten paragraph spacing inside HTML email bodies — Outlook-style */
.body.html-body p,
.body.html-body div { margin: 0; padding: 0; }
.body.html-body p + p { margin-top: 0; }
.body.html-body table { margin: 0.4em 0; }

/* Email template cards in Settings → Email */
.email-template-card { margin-bottom: 0.8em; border: 1px solid #d0d4dc; border-radius: 6px; padding: 0.7em 1em; background: #fbfcfd; }
.email-template-card summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 0.6em; }
.email-template-card[open] { background: #fff; }
.email-template-card label { display: block; margin-top: 0.6em; }
.email-template-card input[type="text"], .email-template-card textarea { width: 100%; box-sizing: border-box; }

/* Attachment picker on reply form */
.attach-list { display: flex; flex-wrap: wrap; gap: 0.4em; margin: 0.5em 0; }
.attach-item { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.3em 0.6em; background: #eef2f7; border: 1px solid #d0d4dc; border-radius: 4px; font-size: 0.9em; }
.attach-name { font-family: monospace; }
.attach-remove { background: transparent; border: none; cursor: pointer; color: #888; font-size: 1.2em; line-height: 1; padding: 0 0.2em; }
.attach-remove:hover { color: #c00; }
.attach-error { color: #c00; background: #fff0f0; border: 1px solid #f5b5b5; padding: 0.5em 0.8em; border-radius: 4px; margin: 0.4em 0; font-size: 0.9em; }
.reply-error { margin: 0 0 0.7em; padding: 0.5em 0.8em; background: #fff0f0; border: 1px solid #f5b5b5; border-radius: 4px; color: #c00; }
#attach-hint { margin-left: 0.4em; }

/* Drag-over visual feedback on reply box */
.reply-box.drag-over { box-shadow: 0 0 0 3px #014E80; outline: 2px dashed #014E80; outline-offset: -6px; }
.reply-box.drag-over textarea { background: #f4f8fc; }
.reply-box.drag-over::after {
  content: 'Drop files to attach';
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #014E80; color: white; padding: 0.6em 1.2em; border-radius: 4px;
  font-weight: 600; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 10;
}
.reply-box { position: relative; }

/* Advanced section in Settings → Email — collapsed by default */
.advanced-email-config {
  border: 1px solid #d0d4dc;
  border-radius: 6px;
  padding: 0.8em 1.2em;
  background: #fafbfc;
}
.advanced-email-config[open] { background: #fff; }
.advanced-email-config > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.2em 0;
}
.advanced-email-config > summary::-webkit-details-marker { display: none; }
.advanced-email-config > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5em;
  transition: transform 0.15s;
  color: #888;
}
.advanced-email-config[open] > summary::before { transform: rotate(90deg); }

/* =====================================================================
   Customer Portal styling
   ===================================================================== */

body.portal { background: #f4f6fa; }
.portal-main { max-width: 760px; padding-top: 2em; padding-bottom: 4em; }

.portal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1em; margin-bottom: 2em; flex-wrap: wrap; }
.portal-head h1 { margin: 0 0 0.3em 0; font-size: 1.6em; }

.topbar-cta { background: rgba(255,255,255,0.15); padding: 0.4em 0.9em; border-radius: 4px; transition: background 0.15s; }
.topbar-cta:hover { background: rgba(255,255,255,0.25); }

/* Section headers within the portal */
.portal-section-title { font-size: 1.05em; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.04em; margin: 1.4em 0 0.6em; }

/* Empty state */
.portal-empty { text-align: center; padding: 3em 1em; background: white; border-radius: 8px; border: 1px solid #e5e8ee; }
.portal-empty-icon { font-size: 4em; margin-bottom: 0.4em; opacity: 0.6; }
.portal-empty h2 { margin: 0 0 0.3em; }

/* Ticket list */
.portal-ticket-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5em; }
.portal-ticket { background: white; border: 1px solid #e5e8ee; border-radius: 6px; transition: border-color 0.15s, box-shadow 0.15s; }
.portal-ticket:hover { border-color: #2260d8; box-shadow: 0 2px 6px rgba(34,96,216,0.08); }
.portal-ticket.has-agent-reply { border-left: 3px solid #2260d8; }
.portal-ticket-resolved { opacity: 0.85; }
.portal-ticket-link { display: flex; justify-content: space-between; align-items: center; padding: 0.85em 1em; gap: 0.8em; color: inherit; text-decoration: none; flex-wrap: wrap; }
.portal-ticket-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 0.6em; }
.portal-ticket-id { color: #888; font-size: 0.85em; flex-shrink: 0; }
.portal-ticket-subject { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-ticket-meta { display: flex; align-items: center; gap: 0.5em; flex-shrink: 0; }
.pill-action { background: #e8efff; color: #2260d8; }

/* Resolved tickets details block */
.portal-resolved-block { margin-top: 2em; }
.portal-resolved-block > summary { cursor: pointer; list-style: none; padding: 0.4em 0; }
.portal-resolved-block > summary::-webkit-details-marker { display: none; }
.portal-resolved-block > summary::before { content: '▸'; display: inline-block; margin-right: 0.5em; transition: transform 0.15s; color: #888; }
.portal-resolved-block[open] > summary::before { transform: rotate(90deg); }

/* Detail page */
.portal-back { margin-bottom: 0.8em; }
.portal-back a { color: #2260d8; text-decoration: none; }
.portal-back a:hover { text-decoration: underline; }
.portal-detail-head { background: white; padding: 1.4em 1.5em; border: 1px solid #e5e8ee; border-radius: 8px; margin-bottom: 1.5em; }
.portal-detail-head h1 { margin: 0 0 0.4em; font-size: 1.4em; }

/* Thread */
.portal-thread { display: flex; flex-direction: column; gap: 0.8em; margin-bottom: 1.5em; }
.portal-msg { background: white; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1em 1.2em; }
.portal-msg-customer { background: #f6f8fb; border-left: 3px solid #888; }
.portal-msg-agent { background: white; border-left: 3px solid #2260d8; }
.portal-msg-system { background: #fffbe8; border-left: 3px solid #d8a000; font-size: 0.9em; }
.portal-msg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.6em; gap: 0.6em; }
.portal-msg-body { white-space: pre-wrap; line-height: 1.5; word-wrap: break-word; }
.portal-msg-body.html-body { white-space: normal; }
.portal-msg-body.html-body p { margin: 0; padding: 0; }
.portal-msg-body.html-body p + p { margin-top: 0; }
.portal-msg-body.html-body table { margin: 0.4em 0; }
.portal-msg-attachments { margin-top: 0.8em; padding-top: 0.6em; border-top: 1px solid #eaeef3; display: flex; flex-wrap: wrap; gap: 0.4em; }
.portal-attach { display: inline-flex; align-items: center; gap: 0.3em; background: #eef2f7; padding: 0.3em 0.6em; border-radius: 4px; color: inherit; text-decoration: none; font-size: 0.9em; }
.portal-attach:hover { background: #dde4ec; }

/* Closed/solved banners */
.portal-closed-banner, .portal-solved-banner { background: white; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1em 1.2em; margin-top: 1em; }
.portal-closed-banner p, .portal-solved-banner p { margin: 0.2em 0; }

/* Reply form */
.portal-reply-form { background: white; border: 1px solid #e5e8ee; border-radius: 8px; padding: 1.2em 1.4em; margin-top: 1em; }
.portal-reply-form h3 { margin: 0 0 0.6em; font-size: 1.05em; }
.portal-reply-form textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; padding: 0.6em 0.8em; border: 1px solid #d0d4dc; border-radius: 4px; }
.portal-reply-form textarea:focus { outline: 2px solid #2260d8; outline-offset: -2px; border-color: #2260d8; }
.portal-reply-actions { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-top: 0.8em; flex-wrap: wrap; }
.portal-reply-actions p { margin: 0; }

/* Login (sent state) */
.portal-mail-icon { font-size: 4em; text-align: center; margin: 0.4em 0 0.5em; }

/* Submit form when authenticated */
.portal-identity-banner { background: #f6f8fb; padding: 0.6em 0.9em; border-radius: 4px; margin-bottom: 1em; }

/* Rich-text editor in agent reply box */
.rt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.2em;
  padding: 0.4em 0.5em;
  background: #f6f7f9;
  border: 1px solid #d0d4dc; border-bottom: none;
  border-top-left-radius: 4px; border-top-right-radius: 4px;
}
.rt-btn {
  background: transparent; border: 1px solid transparent;
  padding: 0.25em 0.55em; border-radius: 3px;
  font-size: 0.9em; cursor: pointer;
  color: #2c333e; font-family: inherit;
  min-width: 1.8em; line-height: 1.2;
}
.rt-btn:hover { background: #e7eaef; border-color: #d0d4dc; }
.rt-btn:active { background: #d8dde4; }
.rt-btn.active { background: #d8e3f5; color: #014E80; border-color: #b5c8e7; }
.rt-sep { display: inline-block; width: 1px; height: 1.2em; background: #d0d4dc; margin: 0 0.3em; }

.rt-editor {
  min-height: 8em;
  padding: 0.6em 0.8em;
  border: 1px solid #d0d4dc;
  border-top: none;
  border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;
  background: white;
  font-family: inherit; font-size: 0.95em; line-height: 1.5;
  outline: none; overflow-y: auto; max-height: 30em;
}
.rt-editor:focus { border-color: #2260d8; box-shadow: inset 0 0 0 1px #2260d8; }
.rt-editor:empty::before {
  content: attr(data-placeholder);
  color: #999; pointer-events: none;
}
.rt-editor p { margin: 0 0 0.6em; }
.rt-editor p:last-child { margin-bottom: 0; }
.rt-editor ul, .rt-editor ol { margin: 0.4em 0; padding-left: 1.6em; }
.rt-editor pre {
  background: #f4f6fa; padding: 0.5em 0.7em; border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 0.85em;
  overflow-x: auto; white-space: pre-wrap;
}
.rt-editor code {
  background: #f4f6fa; padding: 0.1em 0.3em; border-radius: 3px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 0.88em;
}
.rt-editor a { color: #2260d8; }
.rt-editor blockquote {
  border-left: 3px solid #d0d4dc; padding-left: 0.8em; margin: 0.4em 0;
  color: #555;
}

/* Internal-note mode tints the editor area yellow to make the context obvious */
.reply-box.internal .rt-editor { background: #fffbe6; }
.reply-box.internal .rt-toolbar { background: #fff5cc; }

/* Bulk-action toolbar */
.bulk-toolbar {
  display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap;
  background: #f6f8fb;
  color: #2c333e;
  border: 1px solid #d9e0ea;
  border-left: 4px solid #2260d8;
  padding: 0.5em 0.9em;
  border-radius: 6px;
  margin-bottom: 0.8em;
}
.bulk-toolbar[hidden] { display: none; }
.bulk-toolbar .bulk-count { font-weight: 600; color: #014E80; }
.bulk-toolbar .bulk-sep { width: 1px; height: 1.4em; background: #d0d4dc; margin: 0 0.3em; }
.bulk-toolbar .bulk-form { display: inline-flex; align-items: center; gap: 0.3em; margin: 0; }
.bulk-toolbar select, .bulk-toolbar input {
  font-size: 0.88em; padding: 0.3em 0.5em;
  background: white; color: #2c333e;
  border: 1px solid #d0d4dc; border-radius: 3px;
}
.bulk-toolbar .btn {
  background: white; color: #2260d8;
  border: 1px solid #c0d0e8; padding: 0.3em 0.7em;
}
.bulk-toolbar .btn:hover { background: #eef2f7; border-color: #2260d8; }
.bulk-toolbar .btn.danger { background: white; color: #a00000; border-color: #f5b5b5; }
.bulk-toolbar .btn.danger:hover { background: #fff0f0; border-color: #c00000; }

table.tickets th.select-cell, table.tickets td.select-cell {
  text-align: center; padding: 0.4em 0.3em;
}
table.tickets td.select-cell input[type="checkbox"],
table.tickets th.select-cell input[type="checkbox"] {
  cursor: pointer;
}
table.tickets tr.row-selected { background: #eaf2fb !important; }
table.tickets tr.row-selected:hover { background: #dde7f5 !important; }

/* Close-reason modal */
.close-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1em;
}
.close-modal-backdrop[hidden] { display: none; }
.close-modal {
  background: white; border-radius: 8px;
  width: 100%; max-width: 480px;
  padding: 1.5em 1.6em;
  box-shadow: 0 6px 30px rgba(0,0,0,0.2);
}
.close-modal h3 { margin: 0 0 0.3em; }
.close-modal textarea {
  width: 100%; box-sizing: border-box;
  padding: 0.6em 0.8em;
  border: 1px solid #d0d4dc; border-radius: 4px;
  font: inherit; resize: vertical;
  min-height: 4em;
  margin-top: 0.6em;
}
.close-modal textarea:focus { outline: 2px solid #2260d8; outline-offset: -2px; border-color: #2260d8; }
.close-modal-actions {
  display: flex; justify-content: flex-end; gap: 0.5em;
  margin-top: 1em;
}

/* Closed-status banner on ticket detail */
.banner-closed {
  background: #fdf3f3;
  border: 1px solid #f0c8c8;
  border-left: 4px solid #c44;
  border-radius: 6px;
  padding: 0.7em 1em;
  margin-bottom: 1em;
  color: #5a2828;
}
.banner-closed-head { display: flex; align-items: center; gap: 0.5em; }
.banner-closed-icon { font-size: 1.1em; }
.banner-closed-reason {
  margin: 0.4em 0 0;
  padding-left: 1.6em; /* line up under "Closed" text, past the icon */
  font-style: italic;
}

/* Long message body collapse — applied via JS when contentHeight > threshold */
.body-collapsible {
  position: relative;
  max-height: 400px;
  overflow: hidden;
}
.body-collapsible::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 80px;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
  pointer-events: none;
}
.msg.msg-customer .body-collapsible::after {
  background: linear-gradient(to bottom, rgba(246,248,251,0) 0%, rgba(246,248,251,1) 100%);
}
.msg.msg-agent .body-collapsible::after {
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}
.body-collapsible.expanded { max-height: none; }
.body-collapsible.expanded::after { display: none; }
.show-more-btn {
  display: block; margin-top: 0.5em;
  background: transparent; border: 1px solid #d0d4dc;
  color: #2260d8; padding: 0.3em 0.8em;
  font: inherit; font-size: 0.88em; border-radius: 4px;
  cursor: pointer;
}
.show-more-btn:hover { background: #f0f4fa; border-color: #2260d8; }

/* HubSpot sidebar panel */
.hubspot-panel .hs-flash { padding: 0.5em 0.7em; border-radius: 4px; margin-bottom: 0.6em; font-size: 0.85em; }
.hubspot-panel .hs-flash-ok { background: #eaf5e8; color: #1e5a25; border: 1px solid #c8e2c5; }
.hubspot-panel .hs-flash-err { background: #fff0f0; color: #a00000; border: 1px solid #f5b5b5; }
.hubspot-panel .hs-notes { list-style: none; padding: 0; margin: 0.4em 0; }
.hubspot-panel .hs-notes li {
  padding: 0.4em 0.6em; background: #f6f8fb; border-left: 2px solid #d0d4dc;
  margin-bottom: 0.3em; border-radius: 3px;
  overflow: hidden; text-overflow: ellipsis;
}
.hubspot-panel .hs-log-note > summary {
  cursor: pointer; padding: 0.3em 0; color: #2260d8; user-select: none;
  list-style: none;
}
.hubspot-panel .hs-log-note > summary::-webkit-details-marker { display: none; }
.hubspot-panel .hs-log-note > summary:hover { text-decoration: underline; }
.hubspot-panel .hs-note-form textarea {
  width: 100%; box-sizing: border-box;
  padding: 0.4em 0.5em; font: inherit; font-size: 0.85em;
  border: 1px solid #d0d4dc; border-radius: 3px;
  resize: vertical; margin-top: 0.4em;
}
.hubspot-panel .hs-note-form textarea:focus { outline: 2px solid #2260d8; outline-offset: -2px; border-color: #2260d8; }

/* Ticket list pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.8em;
  margin-top: 1em; padding-top: 0.8em;
}
.pagination-nav { display: flex; align-items: center; gap: 0.25em; flex-wrap: wrap; }
.pagination .page-btn {
  display: inline-block; padding: 0.35em 0.7em;
  border: 1px solid #d0d4dc; border-radius: 4px;
  color: #2260d8; text-decoration: none; font-size: 0.88rem;
  background: #fff; min-width: 2.2em; text-align: center;
}
.pagination .page-btn:hover { background: #f0f4fa; border-color: #2260d8; }
.pagination .page-btn.current {
  background: #2260d8; color: #fff; border-color: #2260d8; font-weight: 600;
  cursor: default;
}
.pagination .page-btn.disabled {
  color: #b0b4bc; border-color: #e5e8ee; background: #f7f8fa;
  cursor: default;
}
.pagination .page-ellipsis { padding: 0 0.3em; color: #999; }

/* Inline-editable list cells */
td.editable-cell { cursor: pointer; }
td.editable-cell:hover { background: #f0f4fa; }
td.editable-cell:hover .pill { box-shadow: 0 0 0 1px #b8c8e8; }
.inline-edit-select {
  width: 100%; box-sizing: border-box;
  font: inherit; font-size: 0.85rem;
  padding: 0.2em 0.3em;
  border: 1px solid #2260d8; border-radius: 4px;
  background: #fff; color: #1a1d24;
}

/* Field wrapper for controls that can't live inside a <label> (e.g. the
   contenteditable rich-text editor — wrapping it in <label> makes clicks
   forward to the control and fight the caret placement). */
.field { display: flex; flex-direction: column; gap: 0.2em; margin-bottom: 0; }
form.stack .field { margin-bottom: 0; }
.field-label { font-weight: 500; font-size: 0.92rem; }

/* Clickable placeholder chips in the email-template editor */
code.ph-insert { background: #eef2f7; padding: 0.1em 0.4em; border-radius: 3px; transition: background 0.1s; }
code.ph-insert:hover { background: #d8e3f5; color: #014E80; }
