:root {
  --bg: #f3f4f4;
  --surface: #ffffff;
  --ink: #3a3d3e;
  --muted: #6a6f70;
  --line: #d5d8d8;
  --gray: #505455;
  --hover: #eceeee;
  --orange: #f0471c;
  --orange-dark: #d63d16;
  --ok: #1f7a4d;
  --warn: #b45309;
  --info: #1d4ed8;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--gray);
  color: #fff;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff;
}
.brand small { display: block; color: #c8cbcb; }
.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--gray);
  flex-shrink: 0;
}
.topbar nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: #fff; }
.user-menu {
  position: relative;
  margin-left: 4px;
}
.user-menu-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  max-width: 260px;
}
.user-menu-toggle::-webkit-details-marker { display: none; }
.user-menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.user-menu-chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #fff;
  flex-shrink: 0;
}
.user-menu[open] .user-menu-toggle {
  background: #fff;
  border-color: #fff;
  color: var(--ink);
}
.user-menu[open] .user-menu-label,
.user-menu[open] .user-menu-chevron {
  color: var(--ink);
  border-top-color: var(--ink);
}
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(80, 84, 85), 0.18);
  z-index: 20;
  display: grid;
  gap: 4px;
}
.topbar .user-menu-panel a,
.topbar .user-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink) !important;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
.topbar .user-menu-panel a:hover,
.topbar .user-menu-panel button:hover,
.topbar .user-menu-panel a:focus,
.topbar .user-menu-panel button:focus {
  background: var(--hover);
  text-decoration: none;
  color: var(--ink) !important;
}
.user-menu-panel form { margin: 0; }
.user-edit-card {
  width: 100%;
  max-width: none;
  overflow: hidden;
  box-sizing: border-box;
}
.user-edit-card label,
.user-edit-card .name-grid,
.user-edit-card .password-block,
.user-edit-card .form-actions {
  min-width: 0;
  width: 100%;
}
.user-edit-card input,
.user-edit-card select,
.user-edit-card textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.service-people {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}
.service-people > .card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-bottom: 0;
}
.section-head { margin-bottom: 12px; min-height: 4.5rem; }
.section-head h2 { margin: 0 0 4px; }
.service-people .section-head .meta {
  min-height: 2.6em;
  line-height: 1.3;
}
.people-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  gap: 8px;
  flex: 1;
}
.people-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.people-list li > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.people-list .meta { display: block; }
.people-empty {
  flex: 1;
  margin: 0 0 16px;
}
.service-people .add-member-form,
.add-member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  width: 100%;
  margin-top: auto;
}
.add-member-form label {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 6px;
}
.add-member-form select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.add-member-form .btn {
  white-space: nowrap;
}
@media (max-width: 800px) {
  .service-people,
  .service-people .add-member-form,
  .add-member-form { grid-template-columns: 1fr; }
}
.password-block {
  display: grid;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.password-block h2 { margin: 0; font-size: 18px; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--hover); }
.clickable-row:focus { outline: 2px solid var(--orange); outline-offset: -2px; }

.auth-card { max-width: 520px; }
.auth-card small { color: var(--muted); }
.name-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 800px) {
  .name-grid { grid-template-columns: 1fr; }
  .user-menu-toggle { max-width: 180px; }
}

.container { max-width: 1200px; margin: 0 auto; padding: 28px 20px 48px; }
.page-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.back-link {
  display: inline-block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.back-link:hover {
  color: var(--orange-dark);
  text-decoration: underline;
}
.page-head-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.page-head-stack p { margin: 0; }
.hero, .stats {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.hero h1, .page-head h1, .card h2 { margin: 0 0 8px; }
.page-head h1.page-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.help-tip {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.help-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.9em;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}
.help-tip-btn:hover,
.help-tip-btn:focus {
  border-color: var(--orange);
  color: var(--orange-dark);
}
.help-tip-pop {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(80, 84, 85, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.help-tip:hover .help-tip-pop,
.help-tip:focus-within .help-tip-pop {
  opacity: 1;
  visibility: visible;
}
.stats article, .card, .empty, .table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stats article { padding: 16px 18px; }
.stats strong { font-size: 28px; display: block; }

.filters label, .form label, aside label { display: grid; gap: 6px; }
select, input, textarea, button, .btn {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
}
.btn, button { cursor: pointer; }
.btn-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-primary:hover,
.btn-primary:focus {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
  color: #fff;
}
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c4c0; width: 100%; margin-top: 12px; }
.btn-inline { width: auto; margin-top: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.bulk-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.bulk-page-size select {
  width: auto;
  min-width: 72px;
  padding: 5px 8px;
  font-size: 12px;
}
.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bulk-target {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.bulk-target select {
  width: auto;
  min-width: 160px;
  padding: 5px 8px;
  font-size: 12px;
}
.bulk-bar .btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.bulk-bar .btn-danger {
  width: auto;
  margin-top: 0;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 0;
}
.pager-link,
.pager-gap {
  min-width: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.pager-link:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
}
.pager-link.is-current {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.pager-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.pager-gap {
  border: 0;
  background: none;
  min-width: 16px;
  padding: 6px 0;
}
.tickets-table-selectable th.col-check,
.tickets-table-selectable td.col-check {
  width: 48px;
  min-width: 48px;
  padding-left: 14px;
  padding-right: 6px;
  text-align: center;
}
.tickets-table-selectable th.col-check .th-filter {
  justify-items: center;
}
.col-check-label {
  display: block;
  font-size: inherit;
  font-weight: 600;
  line-height: normal;
}
.col-check-field {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 31px;
  padding: 0;
  border: 0;
}
.tickets-table-selectable td.col-check input,
.col-check-field input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: auto;
  accent-color: var(--orange);
}
.ticket-filters-form { display: none; }
.tickets-table th.col-check,
.tickets-table th.col-filter,
.tickets-table th.col-id,
.tickets-table th.col-subject,
.tickets-table th.col-created {
  vertical-align: bottom;
}
.tickets-table th.col-id { width: 92px; }
.tickets-table th.col-created { width: 138px; }
.tickets-table th.col-executor,
.tickets-table td.col-executor {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tickets-table tbody tr.has-unread {
  background: #fff4ec;
  box-shadow: inset 3px 0 0 var(--orange);
}
.tickets-table tbody tr.has-unread:hover {
  background: #fde7d4;
}
.ticket-subject {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
}
.ticket-clip {
  display: inline-flex;
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--muted);
}
.th-filter {
  display: grid;
  gap: 6px;
  font-weight: 600;
}
.th-filter select,
.th-filter input:not([type="checkbox"]),
.search-select input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 500;
}
.search-select { position: relative; }
.search-select-list {
  position: fixed;
  z-index: 40;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(80, 84, 85), 0.12);
  max-height: 220px;
  overflow: auto;
}
.search-select-list li {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.search-select-list li:hover,
.search-select-list li:focus {
  background: var(--hover);
}
.table-empty {
  padding: 28px 16px;
  text-align: center;
}
.table-empty strong {
  display: block;
  margin-bottom: 4px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.services-table th:nth-child(1),
.services-table td:nth-child(1) { width: 34%; }
.services-table th:nth-child(2),
.services-table td:nth-child(2) { width: 30%; }
.services-table th:nth-child(3),
.services-table td:nth-child(3),
.services-table th:nth-child(4),
.services-table td:nth-child(4) { width: 18%; }
.units-table th:nth-child(1),
.units-table td:nth-child(1) { width: 70%; }
.units-table th:nth-child(2),
.units-table td:nth-child(2) { width: 30%; }
.chip, .status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.chip-service { background: #fde7d4; }
.chip-incident { background: #fde2e0; }
.chip-info { background: #dbeafe; }
.status-new { background: #fff4d6; color: var(--warn); }
.status-in_progress { background: #dcfce7; color: var(--ok); }
.status-closed { background: #e5e7eb; color: #374151; }

.author-line { margin: 6px 0 0; }
.customers-block { margin: 8px 0 4px; }
.customers-block h2 { margin-top: 8px; }
.ticket-aside .customers-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 1px;
}
.ticket-aside .customers-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 1px 0;
  border: 0;
}
.ticket-aside .customers-list .author-link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
}
.ticket-aside .customers-list form {
  margin: 0;
  display: flex;
  width: auto;
}
.customer-remove {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ticket-aside .customer-remove {
  width: 20px;
  margin: 0;
  padding: 0;
  font-size: 16px;
}
.customer-remove:hover,
.customer-remove:focus {
  background: #f8e4de;
  color: var(--danger);
}
.ticket-aside .customers-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  margin-top: 0;
}
.ticket-aside .customers-add .btn {
  width: auto;
  margin-top: 0;
  padding: 8px 10px;
  white-space: nowrap;
}
.customer-picker {
  position: relative;
  min-width: 0;
}
.customer-picker input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}
.customer-picker-list {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(80, 84, 85), 0.12);
}
.customer-picker-list li { padding: 0; border: 0; }
.customer-picker-option {
  display: grid;
  width: 100%;
  gap: 1px;
  padding: 8px 10px;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.customer-picker-option:hover,
.customer-picker-option.is-active {
  background: var(--hover);
}
.customer-picker-option strong {
  font-size: 13px;
  font-weight: 600;
}
.customer-picker-option span {
  color: var(--muted);
  font-size: 12px;
}
.customer-picker-empty {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}
.reply-recipients {
  margin: 0;
  padding: 4px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
}
.reply-recipients legend {
  padding: 0 4px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
}
.reply-recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.history-reply-form .reply-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--hover);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}
.reply-chip input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}
.service-line {
  margin: 0;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: right;
}
.ticket-aside .aside-field-row h2 {
  margin: 0;
  font-size: 16px;
}
.aside-stamp {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
}
.aside-stamp + .aside-stamp { margin-top: 1px; }
.ticket-aside h2 {
  margin: 8px 0 4px;
  font-size: 14px;
}
.author-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--orange);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font: inherit;
}
.author-link:hover { color: var(--orange-dark); }
.author-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(520px, calc(100vw - 32px));
  width: 100%;
  background: transparent;
}
.author-dialog::backdrop {
  background: rgba(80, 84, 85), 0.45);
}
.author-dialog-card {
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  display: grid;
  gap: 16px;
}
.author-dialog-card > label {
  display: grid;
  gap: 6px;
}
.author-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.author-dialog-head h2 { margin: 0; }
.author-dialog-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.author-dialog-close:hover { background: var(--hover); color: var(--ink); }
.author-dialog-facts {
  margin: 0;
  display: grid;
  gap: 12px;
}
.author-dialog-facts div { display: grid; gap: 4px; }
.author-dialog-facts dt {
  color: var(--muted);
  font-size: 13px;
}
.author-dialog-facts dd { margin: 0; }
.author-dialog-facts a {
  color: var(--orange);
  text-decoration: none;
}
.author-dialog-facts a:hover { text-decoration: underline; }
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dialog-actions .btn { width: 100%; margin-top: 0; }
.author-dialog-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  box-sizing: border-box;
}
.completion-note {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}
.completion-note-block .meta { margin: 4px 0 0; font-size: 12px; }

.ticket-aside form { margin-top: 8px; display: grid; gap: 6px; }
.ticket-aside form .btn { margin-top: 2px; }
.ticket-aside .btn { width: 100%; padding: 8px 12px; font-size: 14px; }
.ticket-aside .btn-danger { margin-top: 8px; }
.ticket-aside label { gap: 4px; font-size: 13px; }
.ticket-aside .aside-field-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.ticket-aside .aside-field-row > span {
  flex: 0 0 auto;
  white-space: nowrap;
}
.ticket-aside .aside-field-row select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 5px 8px;
  font-size: 12px;
}
.ticket-aside select,
.ticket-aside textarea { padding: 8px 10px; font-size: 13px; }
.ticket-aside .status {
  display: inline-block;
  margin: 0;
  padding: 4px 8px;
  font-size: 13px;
}
.aside-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.aside-block h2 { margin-bottom: 4px; }
.form small,
.ticket-aside small { color: var(--muted); display: block; margin-top: 4px; }
.card { padding: 20px; margin-bottom: 16px; }
.form { display: grid; gap: 16px; }
.form-actions, .inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  grid-template-columns: none;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.user-edit-card .checkbox-row input[type="checkbox"] {
  display: inline-block;
  width: auto;
}
.people-list .chip,
.services-table .chip {
  margin-left: 8px;
  vertical-align: middle;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  align-items: start;
  gap: 16px;
  width: 100%;
  min-width: 0;
  margin-bottom: 20px;
}
.detail-main {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}
.detail-main > .card {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.ticket-aside {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 14px 14px;
  margin-bottom: 0;
  min-width: 0;
}
.description,
.history-body {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: normal;
  max-width: 100%;
  min-width: 0;
}
.description.is-plain,
.history-body.is-plain { white-space: pre-wrap; }
.description.is-html,
.history-body.is-html {
  white-space: normal;
  overflow-x: auto;
  overflow-wrap: anywhere;
  contain: inline-size;
}
.description.is-html *,
.history-body.is-html * {
  max-width: 100% !important;
  box-sizing: border-box;
}
.description.is-html img,
.history-body.is-html img {
  max-width: 100% !important;
  width: auto !important;
  height: auto !important;
}
.description.is-html table,
.history-body.is-html table {
  width: auto;
  max-width: 100% !important;
  border: 0;
  border-collapse: collapse;
}
.description.is-html td,
.description.is-html th,
.history-body.is-html td,
.history-body.is-html th {
  padding: 0;
  border: 0;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.description.is-html a,
.history-body.is-html a {
  color: var(--orange-dark);
  text-decoration: underline;
  overflow-wrap: anywhere;
}
.description.is-html h1,
.description.is-html h2,
.description.is-html h3,
.history-body.is-html h1,
.history-body.is-html h2,
.history-body.is-html h3 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0.6em 0 0.35em;
}
.description.is-html p,
.history-body.is-html p {
  margin: 0 0 0.7em;
}
.description.is-html p:empty,
.description.is-html div:empty,
.description.is-html span:empty,
.description.is-html font:empty,
.history-body.is-html p:empty,
.history-body.is-html div:empty,
.history-body.is-html span:empty,
.history-body.is-html font:empty {
  display: none !important;
}
.meta { color: var(--muted); }
.files { list-style: none; padding: 0; margin: 0 0 16px; }
.card-compact {
  padding: 14px 16px;
}
.card-compact h2 {
  margin: 0 0 10px;
  font-size: 16px;
}
.files-compact {
  gap: 6px;
  margin: 0 0 10px;
}
.files-compact .file-preview,
.files-compact .saved-file {
  width: 72px;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
}
.files-compact .file-preview-thumb,
.files-compact .file-preview-ext {
  border-radius: 5px;
  font-size: 10px;
}
.files-compact .file-preview-play {
  width: 22px;
  height: 22px;
}
.files-compact .file-preview-play::before {
  border-width: 5px 0 5px 8px;
}
.files-compact .file-chip-remove {
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  font-size: 12px;
}
.add-files-form-compact {
  gap: 8px;
  margin-top: 10px;
}
.add-files-form-compact .file-picker-button,
.add-files-form-compact .btn-primary {
  padding: 7px 10px;
  font-size: 13px;
}
.history-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  gap: 10px;
}
.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.history-item.history-author { border-left: 3px solid #94a3b8; }
.history-item.history-staff { border-left: 3px solid var(--orange); }
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}
.history-meta strong { color: var(--ink); }
.history-to { color: var(--muted); }
.history-to-failed { color: var(--danger); }
.history-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}
.history-body.is-html { white-space: normal; }
.history-reply-form {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}
.history-reply-form label { display: grid; gap: 6px; }
.history-reply-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  box-sizing: border-box;
}
.history-reply-form .btn { width: fit-content; }
.history-reply-form .file-picker { margin-top: 4px; }
.message-files {
  margin: 8px 0 0;
  gap: 6px;
}
.message-files .file-preview,
.message-files .saved-file {
  width: 56px;
  gap: 3px;
  padding: 3px;
  border-radius: 7px;
}
.message-files .file-preview-thumb,
.message-files .file-preview-ext {
  border-radius: 4px;
  font-size: 9px;
}
.message-files .file-preview-name {
  font-size: 10px;
  line-height: 1.2;
}
.message-files .file-preview-size {
  font-size: 9px;
}

.ticket-thread-card h2 { margin-bottom: 12px; }
.history-item.history-event {
  border-left: 0;
  background: transparent;
  padding: 4px 2px;
  box-shadow: none;
}
.history-event-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  color: #8a8e8e;
  font-size: 12px;
  line-height: 1.35;
}
.history-event-line time {
  color: #9aa0a0;
  font-variant-numeric: tabular-nums;
  min-width: 7.5rem;
}
.history-event-line .stage-history-action {
  font-weight: 500;
  color: #7a7f7f;
}
.history-event-line .stage-history-actor {
  color: #9aa0a0;
}

.file-picker { display: grid; gap: 10px; justify-items: start; }
.file-picker-label {
  display: grid;
  gap: 8px;
  cursor: pointer;
  width: fit-content;
}
.file-picker-button {
  display: inline-flex;
  width: fit-content;
  align-items: center;
}
.file-chip-list,
.file-preview-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
}
.file-preview,
.saved-file {
  position: relative;
  width: 140px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-sizing: border-box;
}
.file-preview-thumb,
.file-preview-ext {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: var(--hover);
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.file-preview-thumb-link {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
}
.file-preview-video-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.file-preview-video-wrap .file-preview-thumb {
  display: block;
  background: #1b1c1d;
}
.file-preview-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.file-preview-play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #1b1c1d;
  transform: translate(-50%, -50%);
}
.file-preview-name-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}
.file-preview-name-btn:hover { text-decoration: underline; color: var(--orange-dark); }
.files-compact .file-preview-name-btn { font-size: 11px; }
.message-files .file-preview-name-btn { font-size: 10px; }

.file-lightbox {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(920px, calc(100vw - 24px));
  width: 100%;
  background: transparent;
}
.file-lightbox::backdrop {
  background: rgba(80, 84, 85), 0.55);
}
.file-lightbox-card {
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 48px);
}
.file-lightbox-body {
  min-height: 120px;
  max-height: min(70vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
}
.file-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
}
.file-lightbox-video {
  display: block;
  width: 100%;
  max-height: min(70vh, 720px);
  background: #111;
}
.file-lightbox-text {
  margin: 0;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.file-lightbox-actions {
  margin-top: 0;
}
.file-lightbox-actions .btn {
  width: auto;
  margin-top: 0;
}
.file-preview-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.file-preview-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}
.file-preview-name:hover { text-decoration: underline; }
.file-preview-size { color: var(--muted); font-size: 12px; }
.file-chip-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #f3c4c0;
  background: rgba(255, 255, 255, 0.95);
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.file-chip-remove:hover { background: #fee2e2; }
.saved-file form { margin: 0; }
.add-files-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  justify-items: start;
}
.add-files-form .btn-primary { width: fit-content; }
.empty { text-align: center; padding: 48px 20px; }
.flash-list { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 12px; border-radius: 10px; }
.flash-success { background: #dcfce7; }
.flash-error { background: #fee2e2; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.board-column {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  min-height: 280px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.board-column.is-drag-over {
  border-color: var(--orange);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(234, 88, 12, 0.18);
}
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.board-head h2 {
  margin: 0;
  font-size: 16px;
}
.board-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
}
.board-sub {
  margin: 0 0 10px;
  font-size: 12px;
}
.board-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.board-card {
  display: grid;
  gap: 6px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.board-card.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.board-card-link {
  display: grid;
  gap: 6px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
}
.board-card:hover {
  border-color: var(--orange);
  box-shadow: 0 6px 16px rgba(80, 84, 85), 0.06);
}
.board-card strong {
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.board-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.board-empty-item {
  list-style: none;
}
.board-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 800px) {
  .stats, .detail-grid { grid-template-columns: 1fr; }
  .hero, .page-head { flex-direction: column; align-items: flex-start; }
  .board-grid { grid-template-columns: 1fr; }
  .ticket-aside {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
