:root {
  --bg: #070b10;
  --panel: #0f1722;
  --panel-alt: #101924;
  --border: #1f2c3e;
  --text: #dee6f5;
  --muted: #8ea2bd;
  --accent: #3ea6ff;
  --accent-muted: rgba(62, 166, 255, 0.16);
  --danger: #ff6b6b;
  --success: #3ecf8e;
  --warning: #f7b731;
}

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

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  display: flex;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  background: #0f131b;
  border-bottom: 1px solid var(--border);
}

.topbar-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  pointer-events: none;
}

.brand-icon {
  display: block;
  width: auto;
  height: 1.8em;
  border-radius: 10px;
  flex: 0 0 auto;
}

.brand-title {
  font-weight: 600;
  font-size: 24px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.user-shell {
  position: relative;
  flex: 0 0 auto;
}

.topbar-left input,
.topbar-left select {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.topbar-left input {
  width: 260px;
  min-width: 260px;
  flex: 0 0 260px;
}

.ghost-btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border 0.15s ease;
}

.ghost-btn:hover {
  background: #182232;
  border-color: var(--accent-muted);
}

.edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.edit-btn::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23eaf1f8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E");
}

.danger-btn {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ff9e9e;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border 0.15s ease;
  font-size: 14px;
  line-height: 1.2;
}

.danger-btn:hover {
  background: rgba(255, 107, 107, 0.2);
  border-color: #ff6b6b;
}

.ghost-btn:disabled,
.danger-btn:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.edit-lock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(113, 148, 183, 0.35);
  border-radius: 8px;
  background: rgba(22, 39, 58, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.edit-lock-banner.is-owned {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(12, 55, 44, 0.72);
  color: #cdf7e8;
}

.edit-lock-banner.is-blocked {
  border-color: rgba(250, 204, 21, 0.45);
  background: rgba(70, 52, 12, 0.72);
  color: #ffefb0;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.user-badge:hover,
.user-badge:focus-visible {
  background: #182232;
  border-color: var(--accent-muted);
  outline: none;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #1a2635, #0e1622);
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  position: relative;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  padding: 6px;
}

.user-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.user-menu button:hover {
  background: #182232;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  overflow: hidden;
}

.filters-panel {
  border-right: 1px solid var(--border);
  background: #0b1119;
  padding: 16px;
  overflow-y: auto;
}

.sidebar-search-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-search-row,
.sidebar-filter-row {
  display: flex;
  gap: 10px;
}

.sidebar-search-row .ghost-btn {
  flex: 0 0 auto;
}

.sidebar-search-row input,
.sidebar-filter-row select {
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

.sidebar-filter-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, #9fb2c7 50%),
    linear-gradient(135deg, #9fb2c7 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.sidebar-search-row input::placeholder {
  color: #7f92a6;
}

.sidebar-search-row input:focus,
.sidebar-filter-row select:focus {
  outline: none;
  border-color: #3d6fa7;
  box-shadow: 0 0 0 2px rgba(29, 110, 200, 0.18);
}

.panels {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.panel-actions select {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.ticket-list {
  overflow-y: auto;
  padding: 10px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-alt);
  cursor: pointer;
  transition: border 0.12s ease, transform 0.12s ease;
}

.ticket-row:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.ticket-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-muted);
}

.ticket-row .row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-weight: 600;
}

.ticket-row .row-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.row-head-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-row .row-head .status-pill {
  flex-shrink: 0;
}

.row-head-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.priority-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
  border: 1px solid var(--border);
  background: rgba(142, 162, 189, 0.14);
  color: var(--muted);
}
.priority-low {
  background: rgba(83, 160, 81, 0.12);
  border-color: rgba(83, 160, 81, 0.5);
  color: #9dd3a0;
}
.priority-medium {
  background: rgba(62, 166, 255, 0.12);
  border-color: rgba(62, 166, 255, 0.45);
  color: #9fccff;
}
.priority-high {
  background: rgba(247, 183, 49, 0.16);
  border-color: rgba(247, 183, 49, 0.45);
  color: #ffd27a;
}
.priority-urgent {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.5);
  color: #ff9e9e;
}
.ticket-row.ticket-ndtr {
  border-left: 4px solid #d07326;
  background: linear-gradient(90deg, rgba(208, 115, 38, 0.18), rgba(208, 115, 38, 0.04) 55%, transparent);
  box-shadow: inset 0 0 0 1px rgba(208, 115, 38, 0.18);
}
.row-head-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 4px;
  align-self: flex-start;
  margin-top: 2px;
}
.assignee-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
  border: 1px solid rgba(142, 162, 189, 0.35);
  background: rgba(142, 162, 189, 0.16);
  color: #c8d2e0;
}
.ndtr-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(201, 95, 29, 0.18);
  color: #ffb078;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid rgba(201, 95, 29, 0.4);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-open {
  background: rgba(62, 166, 255, 0.15);
  border-color: rgba(62, 166, 255, 0.4);
  color: #8fd1ff;
}

.status-in-progress {
  background: rgba(247, 183, 49, 0.15);
  border-color: rgba(247, 183, 49, 0.4);
  color: #ffd27a;
}

.status-resolved {
  background: rgba(62, 207, 142, 0.15);
  border-color: rgba(62, 207, 142, 0.4);
  color: #7ce0b5;
}

.status-closed {
  background: rgba(181, 78, 78, 0.15);
  border-color: rgba(181, 78, 78, 0.4);
  color: #f4aaaa;
}

.status-waiting {
  background: rgba(198, 93, 20, 0.22);
  border-color: rgba(198, 93, 20, 0.5);
  color: #ffb36a;
}

.status-snoozed {
  background: rgba(147, 112, 219, 0.15);
  border-color: rgba(147, 112, 219, 0.4);
  color: #c9b3f2;
}

.status-default {
  background: rgba(142, 162, 189, 0.15);
  border-color: rgba(142, 162, 189, 0.3);
  color: var(--muted);
}

.ticket-row .row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 0;
}
.row-meta-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-meta.meta-primary,
.row-meta.meta-secondary {
  flex-wrap: wrap;
  gap: 10px;
}
.row-meta.meta-primary {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.row-meta.meta-secondary {
  flex-wrap: nowrap;
}
.row-meta.meta-secondary span {
  white-space: nowrap;
}
.ticket-row .requester-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ticket-row .ticket-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #1c2735, #111824);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  position: relative;
}
.presence-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0b1119;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.presence-available { background: #4ade80; }
.presence-busy { background: #f97316; }
.presence-dnd { background: #ef4444; }
.presence-away { background: #facc15; }
.presence-ooo { background: #f472b6; }
.presence-offline { background: #6b7280; }
.presence-unknown { background: #374151; }

.detail-panel {
  overflow-y: auto;
  padding: 0 0 20px 0;
}

/* Dark scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(62, 166, 255, 0.35) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(62, 166, 255, 0.35);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(62, 166, 255, 0.6);
}

.detail {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ticket-number {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-head h1 {
  margin: 6px 0 0;
  font-size: 22px;
}

.status-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-controls select {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
}

.status-controls button {
  min-height: 36px;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  white-space: nowrap;
}

/* The rule above (0-1-1) outranks .hidden (0-1-0), so hidden buttons in the
   status controls rendered anyway — this restores what the JS toggles intend. */
.status-controls button.hidden {
  display: none;
}

.trend-quarantine-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(62, 166, 255, 0.3);
  border-radius: 8px;
  background: rgba(62, 166, 255, 0.09);
}

.trend-quarantine-action.hidden {
  display: none;
}

.trend-quarantine-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.trend-quarantine-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.trend-quarantine-action .ghost-btn {
  white-space: nowrap;
}

.offboarding-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
}

.offboarding-actions-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.offboarding-section-title {
  width: 100%;
  text-align: center;
}

.offboarding-primary-action {
  display: flex;
  justify-content: center;
}

.offboarding-primary-btn {
  min-width: min(420px, 100%);
}

.offboarding-action-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.offboarding-group-title {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.offboarding-action-btn {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

@media (max-width: 1200px) {
  .offboarding-actions-grid {
    grid-template-columns: 1fr;
  }
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.meta-grid .meta-span-2 {
  grid-column: span 2;
}

.meta-grid label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

#assigneeSelect,
#secondaryAssigneeSelect,
#newTicketAssignee,
#watcherInput,
#commentInput {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

#commentInput {
  min-height: 76px;
  line-height: 1.45;
  resize: vertical;
}
select#assigneeSelect,
select#secondaryAssigneeSelect {
  appearance: none;
}

#newTicketAttachments {
  width: 100%;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

#newTicketAttachments::file-selector-button {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
}

#newTicketAttachments::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

#newTicketAttachments::file-selector-button:active {
  background: var(--accent-muted);
}


.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-alt);
  padding: 16px;
}

.card-head {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.status-pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pill {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}

.pill.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.metric-card:hover {
  border-color: var(--accent-muted);
  background: #152133;
  transform: translateY(-1px);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
}

.trend {
  margin-top: 14px;
}

.trend-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.trend-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.agent-load {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-load li {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.agent-load li:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.detail-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.assign-actions,
.watch-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.assign-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.assign-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assign-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.assign-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.comments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.comment-attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.comment-attachment-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.paste-hint {
  font-size: 12px;
  color: var(--muted);
}

#commentInput.drag-over {
  border-style: dashed;
  border-color: var(--accent);
  background: rgba(41, 116, 255, 0.08);
}

.comment {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel);
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comment .comment-meta {
  font-size: 11px;
  color: var(--muted);
}

.comment-body {
  margin-top: 6px;
}

.comment-actions {
  display: flex;
  justify-content: flex-end;
}
.assignment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.assignment-header .title {
  margin: 0;
}

.inline-danger-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--danger);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}

.inline-danger-btn:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: var(--danger);
}

.attachments,
.watchers {
  list-style: none;
  padding: 0;
  margin: 0;
}

.attachments.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments.inline li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
}

.attachments.inline .remove-attachment {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
}

.attachments.inline .remove-attachment:hover {
  color: var(--text);
}

.attachments li,
.watchers li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.watchers button {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.device-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.device-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  cursor: pointer;
  transition: border 0.12s ease, background 0.12s ease;
}

.device-btn:hover, .device-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.device-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.device-field {
  font-size: 13px;
  color: var(--muted);
}

.device-value {
  color: var(--text);
  font-weight: 500;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.device-search {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--panel-alt);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.device-search input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  min-width: 240px;
}

.device-search-results {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-alt);
  max-height: 200px;
  overflow-y: auto;
}

.device-search-results .result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.device-search-results .result-row:last-child {
  border-bottom: none;
}

.device-search-results .result-row button {
  padding: 4px 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 14, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  position: relative;
}
.report-close {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 6px 12px;
  font-weight: 700;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.report-close:hover {
  background: var(--panel);
}
.modal-head-center {
  flex: 1;
  text-align: center;
}

#confirmPromptMessage {
  margin: 0;
  font-size: 14px;
}

#inputPromptValue {
  width: 100%;
  margin-top: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

.waiting-reason-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.waiting-reason-chip {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease, border 0.15s ease;
}

.waiting-reason-chip:hover {
  background: #182232;
  border-color: var(--accent-muted);
}

.waiting-reason-chip.selected {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--text);
}

#waitingReasonOther {
  width: 100%;
  margin-top: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

.waiting-reason-hint {
  margin: 8px 0 0;
  color: #ff9e9e;
  font-size: 12px;
}

.waiting-reason-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 8px;
  background: rgba(70, 52, 12, 0.72);
  color: #ffefb0;
  font-size: 13px;
}

.waiting-reason-banner.hidden {
  display: none;
}

/* Seat the WAITING ON bar directly beneath the Read-only bar. The two banners are
   already adjacent in the DOM, but the .detail flex gap (18px) plus each banner's
   own vertical margin (12px 0 14px) left a ~44px gap between them. Collapse it to a
   tight ~6px so WAITING ON stacks right under Read-only. Only fires when BOTH bars
   are visible, so hidden-state spacing is unchanged. */
.edit-lock-banner:not(.hidden) + .waiting-reason-banner:not(.hidden) {
  margin-top: -26px;
}

.waiting-reason-banner-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
}

#waitingReasonValue {
  font-weight: 600;
}

.waiting-reason-pinged {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.16);
  color: #ffe27a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.waiting-reason-pinged.hidden {
  display: none;
}

.timeline-email-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
  line-height: 1.5;
  max-height: 320px;
  overflow-y: auto;
}
.timeline-email-body:not(.email-html) {
  color: var(--muted);
}
.timeline-email-body.email-html {
  background: #ffffff;
  color: #0b1119;
  border-color: #e0e6ef;
}
.timeline-email-body.email-html a {
  color: #2974ff;
}
.link-button {
  background: var(--accent-muted);
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.link-button:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
.modal.rating-modal {
  width: min(1600px, 96vw);
  max-height: 92vh;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.rating-table-wrap {
  max-height: calc(92vh - 200px);
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.rating-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}
.rating-table th,
.rating-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.rating-table th {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--muted);
}
.rating-row {
  cursor: pointer;
  transition: background 0.2s ease;
}
.rating-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.rating-row.selected {
  background: rgba(255, 255, 255, 0.08);
}
.rating-comment {
  max-height: 96px;
  overflow: hidden;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--muted);
}
.ai-research-card header,
.ai-research-actions,
.ai-feedback-actions,
.ai-doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-research-card header {
  justify-content: space-between;
}
.ai-research-toggle {
  min-width: 68px;
}
.ai-research-body {
  display: grid;
  gap: 12px;
}
.ai-research-content {
  display: grid;
  gap: 12px;
}
.ai-research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.ai-research-grid span,
.ai-research-block span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.ai-research-grid p,
.ai-research-block p,
.ai-research-block ul {
  margin: 0;
}
.ai-research-block ul {
  padding-left: 20px;
}
.ai-research-block a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
.ai-research-block a:hover {
  text-decoration: underline;
}
.ai-research-block pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.45;
}
.ai-feedback-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.44);
}
.ai-feedback-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.ai-feedback-header strong,
.ai-feedback-field span,
.ai-feedback-notes span {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
.ai-feedback-header span,
.ai-feedback-field span,
.ai-feedback-notes span {
  margin-bottom: 5px;
}
.ai-feedback-header div span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 2px 0 0;
}
.ai-feedback-row,
.ai-knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.ai-feedback-field,
.ai-feedback-notes,
.ai-knowledge-grid label,
.ai-active-row {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.ai-feedback-field select,
.ai-feedback-notes textarea {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.ai-feedback-field select:focus,
.ai-feedback-notes textarea:focus {
  outline: none;
  border-color: #3d6fa7;
  box-shadow: 0 0 0 2px rgba(29, 110, 200, 0.18);
}
.ai-feedback-check,
.ai-active-row {
  display: grid;
  align-items: center;
  grid-template-columns: auto 1fr;
  gap: 8px;
}
.ai-feedback-check {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-alt);
  font-size: 13px;
  font-weight: 700;
}
.ai-feedback-check input {
  accent-color: var(--accent);
}
.ai-knowledge-modal {
  width: min(980px, calc(100vw - 32px));
}
.ai-knowledge-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.ai-knowledge-list {
  display: grid;
  gap: 10px;
  max-height: 42vh;
  overflow: auto;
}
.ai-doc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}
.ai-doc-title {
  font-weight: 800;
}
.ai-doc-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.rating-detail-row td {
  padding: 0;
  border: none;
  background: transparent;
}
.rating-detail-body {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rating-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.rating-detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.rating-detail-text {
  font-size: 13px;
  line-height: 1.6;
}
.rating-detail-open-btn {
  align-self: flex-end;
  padding: 6px 14px;
  font-size: 12px;
  letter-spacing: 0.3px;
}
.modal-status {
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.report-modal {
  width: min(1200px, 96vw);
  padding: 28px;
  max-height: 90vh;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(12, 20, 34, 0.96), rgba(9, 15, 26, 0.94));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.report-card {
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 16px;
  background: radial-gradient(circle at 20% 20%, rgba(60, 104, 255, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(118, 255, 214, 0.08), transparent 25%),
    linear-gradient(145deg, rgba(22, 34, 54, 0.9), rgba(13, 20, 32, 0.95));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.report-card.report-span-full {
  grid-column: 1 / -1;
}

.report-card.report-span-two {
  grid-column: span 2;
}

@media (max-width: 900px) {
  .report-card.report-span-two {
    grid-column: 1 / -1;
  }
}

.report-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.26em;
  color: #c6d4f5;
}

.report-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.report-chart-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-bar-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.report-bar-label {
  color: #e6edff;
}

.report-bar-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.report-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4da8ff, #5ae8ff);
  box-shadow: 0 6px 14px rgba(90, 232, 255, 0.35);
  transition: width 0.2s ease;
}

.report-bar-value {
  font-weight: 600;
  color: #f5f9ff;
  text-align: right;
  letter-spacing: 0.3px;
}

.report-value {
  font-size: 28px;
  font-weight: 600;
  color: #f5f9ff;
}

.att-cal-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.att-cal-month {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(6, 12, 22, 0.45);
  padding: 10px;
}

.att-cal-month-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #cdd7ef;
  margin-bottom: 8px;
}

.att-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.att-cal-day {
  height: 190px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(12, 20, 33, 0.7);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.att-cal-day.today {
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(20, 83, 45, 0.55);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.28);
}

.att-cal-day.today .att-cal-daynum {
  color: #86efac;
}

.att-cal-day.empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.45;
}

.att-cal-daynum {
  font-size: 11px;
  font-weight: 700;
  color: #dbe5f8;
}

.att-cal-event {
  font-size: 10px;
  color: #d6e2fa;
  border: 1px solid rgba(77, 168, 255, 0.24);
  border-radius: 8px;
  padding: 4px;
  background: rgba(38, 80, 131, 0.22);
}

.att-cal-events {
  display: grid;
  grid-template-rows: repeat(3, 34px) auto;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.att-cal-event {
  height: 34px;
  overflow: hidden;
}

.att-cal-event > span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.att-cal-event.att-state-yes {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(22, 101, 52, 0.35);
}

.att-cal-event.att-state-no {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.35);
}

.att-cal-event.att-state-pending {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(120, 53, 15, 0.28);
}

.att-cal-event.att-state-excluded {
  border-color: rgba(148, 163, 184, 0.5);
  background: rgba(51, 65, 85, 0.38);
}

.att-cal-actions {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.att-cal-event small {
  display: block;
  color: #97aacd;
  margin-top: 2px;
}

.att-cal-resched {
  margin-top: 4px;
  width: 100%;
  padding: 2px 4px;
  font-size: 10px;
}

.att-cal-resend {
  margin-top: 4px;
  width: 100%;
  padding: 2px 4px;
  font-size: 10px;
}

.att-cal-more {
  font-size: 10px;
  color: #93a5c7;
}

.att-cal-viewall {
  margin-top: 2px;
  width: 100%;
  padding: 3px 5px;
  font-size: 10px;
  flex-shrink: 0;
}

.att-cal-delete {
  margin-top: 4px;
  width: 100%;
  padding: 2px 4px;
  font-size: 10px;
}

.att-preview {
  margin-top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
}

.att-day-body {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.att-day-event {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  padding: 10px;
  background: rgba(12, 20, 33, 0.68);
}

.door-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.door-rating .door-chip {
  --open: 0deg;
  position: relative;
  width: 22px;
  height: 36px;
  border-radius: 3px 3px 2px 2px;
  border: 1.5px solid #b59c78;
  border-bottom-width: 2px;
  background: linear-gradient(180deg, #241f18 0%, #0e0b07 100%);
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.18);
  perspective: 200px;
  overflow: visible;
  line-height: 1;
}

.door-rating .door-chip .leaf {
  position: absolute;
  inset: 1px;
  border-radius: 2px;
  transform-origin: left center;
  transform: rotateY(var(--open));
  transition: transform 0.5s cubic-bezier(0.33, 1.15, 0.45, 1);
  transform-style: preserve-3d;
  background: linear-gradient(98deg, #f3ddb0 0%, #e7c78d 50%, #d6ac6f 100%);
  box-shadow: inset 0 0 0 1.5px rgba(120, 80, 30, 0.38), 0 2px 4px rgba(0, 0, 0, 0.35);
}

.door-rating .door-chip .leaf::before,
.door-rating .door-chip .leaf::after {
  content: '';
  position: absolute;
  left: 3px;
  right: 4px;
  height: 39%;
  border-radius: 1.5px;
  box-shadow: inset 0 0 0 1px rgba(120, 80, 30, 0.45);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(120, 80, 30, 0.06));
}

.door-rating .door-chip .leaf::before { top: 4px; }
.door-rating .door-chip .leaf::after { bottom: 4px; }

.door-rating .door-chip .knob {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  z-index: 3;
  background: radial-gradient(circle at 35% 35%, #fff4d2, #cda44f 65%, #8a6a2d);
  box-shadow: 0 0 0 1px rgba(80, 55, 12, 0.6), 0 1px 1px rgba(0, 0, 0, 0.4);
  transform: translateY(-50%);
}

.door-rating .door-chip.is-empty .leaf {
  filter: saturate(0.72) brightness(0.92);
}

.door-rating-label {
  font-size: 12px;
  color: var(--muted);
}

.report-range-wrap {
  display: inline-flex;
}

.report-range {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
}

.reopened-ticket-search-wrap {
  width: 100%;
}

.reopened-ticket-search-input {
  min-width: min(560px, 95%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-body {
  margin-bottom: 16px;
  color: var(--text);
  font-size: 14px;
}

.modal-body p {
  margin: 0;
}

#newTicketForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#newTicketForm input,
#newTicketForm select,
#newTicketForm textarea {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  gap: 8px;
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-entry {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel);
  position: relative;
}

.timeline-entry.has-email-toggle {
  padding-right: 200px;
}

.timeline-entry .title {
  font-weight: 600;
}

.timeline-entry .meta {
  font-size: 11px;
  color: var(--muted);
}

.timeline-email-toggle {
  position: static;
  top: auto;
  right: auto;
  padding: 5px 12px;
}

.timeline-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}

.edit-modal {
  max-width: 1100px;
  width: 96vw;
  background: linear-gradient(135deg, rgba(12, 19, 30, 0.96), rgba(8, 12, 20, 0.94));
  border: 1px solid var(--border);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.55);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.edit-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edit-form input,
.edit-form select,
.edit-form textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
}

.edit-form textarea {
  min-height: 120px;
  resize: vertical;
}

.merge-source {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
}

.merge-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.merge-icon-btn {
  min-width: 40px;
  height: 34px;
  padding: 0 12px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.merge-icon-btn img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}

.edit-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.mini-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  color: var(--text);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  body {
    display: block;
  }

  .app {
    min-height: 100dvh;
  }

  .topbar {
    padding: 12px 14px;
  }

  .topbar-main {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .topbar-left,
  .topbar-right,
  .brand {
    justify-content: center;
  }

  .topbar-left,
  .topbar-right {
    flex-wrap: wrap;
  }

  .user-shell {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .user-badge {
    max-width: min(100%, 320px);
    width: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .filters-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    padding: 12px;
  }

  .sidebar-search-row,
  .sidebar-filter-row {
    flex-direction: column;
  }

  .sidebar-search-row .ghost-btn,
  .sidebar-search-row input,
  .sidebar-filter-row select {
    width: 100%;
  }

  .panels {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    overflow: visible;
  }

  .panel,
  .detail-panel,
  .queue-panel {
    overflow: visible;
  }

  .ticket-list {
    max-height: none;
    overflow: visible;
    padding: 10px 12px 16px;
  }

  .detail {
    padding: 16px 12px 20px;
  }

  .detail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .trend-quarantine-action {
    flex-direction: column;
    align-items: stretch;
  }

  .trend-quarantine-action .ghost-btn {
    width: 100%;
  }

  .status-controls,
  .panel-actions {
    flex-wrap: wrap;
  }

  .status-controls > *,
  .panel-actions > * {
    width: 100%;
  }

  .status-controls button,
  .status-controls select,
  .panel-actions button,
  .panel-actions select {
    width: 100%;
  }

  .meta-grid,
  .offboarding-actions-grid,
  .edit-two-col,
  .edit-grid {
    grid-template-columns: 1fr;
  }

  .offboarding-primary-btn {
    min-width: 100%;
  }

  .meta-grid .meta-span-2 {
    grid-column: auto;
  }

  .ticket-row .row-head {
    flex-direction: column;
    align-items: stretch;
  }

  .row-head-status {
    align-items: flex-start;
  }

  .row-meta.meta-secondary {
    flex-wrap: wrap;
  }

  .timeline-entry.has-email-toggle {
    padding-right: 10px;
  }

  .timeline-actions {
    position: static;
    margin-top: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .modal-card,
  .edit-modal {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
}


/* TTS ticket-tagging styles (promoted from test) */
/* Ticket tags (triage / filtering) */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-chip {
  --tag-color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}
.tag-chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tag-color);
  flex-shrink: 0;
}
.tag-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin-left: 2px;
}
.tag-chip-remove:hover {
  color: var(--danger);
}
.tag-empty {
  font-size: 12px;
}
.row-meta.meta-tags {
  gap: 6px;
  margin-top: 2px;
}
.row-meta.meta-tags .tag-chip {
  font-size: 10px;
  padding: 2px 7px;
}
#tagFilter {
  width: 100%;
}
#tagInput {
  flex: 1;
  min-width: 120px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
#tagInput::placeholder {
  color: var(--muted);
}

/* Manage-tags panel: admin-only affordance to remove tags from the Add-tag pick-list. */
.manage-tags-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
}
.manage-tags-hint {
  font-size: 12px;
  margin-bottom: 8px;
}
.manage-tags-list {
  gap: 6px;
}
.manage-tag-chip {
  cursor: default;
}
#manageTagsBtn {
  margin-left: 6px;
}
