@import url("/crm-theme.css");

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
}
body {
  margin: 0;
  min-width: 0;
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin: 0;
}
h1,
h2,
h3,
h4,
strong {
  font-weight: 600;
}
h1 {
  font-size: 18px;
}
h2 {
  font-size: 16px;
}
h3 {
  font-size: 14px;
}
a,
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button,
a,
select,
summary {
  touch-action: manipulation;
  cursor: pointer;
}
a {
  text-decoration: none;
}
button {
  border: 0;
  background: transparent;
  padding: 0;
}
textarea,
input,
select {
  min-width: 0;
  background-color: var(--background);
  border-color: var(--input);
}
select option {
  background: var(--popover);
  color: var(--popover-foreground);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
}
button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
:focus-visible,
.chip:focus-within {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
small,
time,
.field-note,
.muted {
  font-size: 12px;
  color: var(--muted-foreground);
}
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.ticketno,
.code,
.case-codes span,
.issue-no {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

#shell {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
#rail {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 12px 0;
  position: relative;
  z-index: 6;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar);
  color: var(--foreground);
}
.brand,
.rail-link,
.rail-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
}
.brand {
  width: 40px;
  height: 40px;
  margin-bottom: 13px;
  padding: 0;
  border: 1px solid var(--sidebar-border);
  border-radius: 14px;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 10%), 0 1px 2px -1px rgb(0 0 0 / 10%);
}
.brand img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: white;
  object-fit: contain;
}
.rail-link .icon {
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.rail-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.rail-link {
  font-size: 0;
  position: relative;
  border: 1px solid transparent;
  background-clip: padding-box;
  color: inherit;
}
.rail-link:hover {
  background-color: var(--muted);
  color: var(--foreground);
}
.dark .rail-link:hover { background-color: color-mix(in oklab, var(--muted) 50%, transparent); }
.rail-link.current,
.rail-link[aria-current="page"] {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}
.rail-link:focus-visible {
  outline: 0;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}
.rail-profile {
  margin-top: auto;
}
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 20px;
  min-height: 40px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}
.topbar:empty {
  display: none;
}
.crumb,
.local-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted-foreground);
}
.crumb {
  min-width: 0;
}
.crumb strong {
  color: var(--foreground);
}
.crumb b {
  font-weight: 400;
}
.crumb > .icon {
  width: 14px;
  height: 14px;
}
.local-mode {
  white-space: nowrap;
}
.local-mode i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
#page {
  min-width: 0;
  min-height: 0;
  flex: 1;
  outline: 0;
}
.button,
.iconbtn,
.textbtn,
.side-work-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.button {
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--background);
  padding: 6px 12px;
  min-height: 32px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.button:hover,
.chip button:hover,
.iconbtn:hover {
  background: var(--muted);
}
.button.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.button.primary:hover {
  background: color-mix(in srgb, var(--primary) 84%, var(--background));
}
.iconbtn {
  width: 32px;
  height: 32px;
  color: var(--muted-foreground);
  border-radius: 8px;
}
.textbtn,
.side-work-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}
.textbtn:hover,
.side-work-link:hover,
.issue-no:hover {
  text-decoration: underline;
}
.button .icon,
.textbtn .icon {
  width: 15px;
  height: 15px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--input);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--background);
  color: var(--muted-foreground);
}
.search:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--primary-ring);
}
.search input,
.search input:focus-visible {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  width: 100%;
  min-width: 0;
  color: var(--foreground);
  font-size: 12px;
}
.ticketno {
  font-size: 12px;
  font-weight: 500;
}
.counter {
  color: var(--muted-foreground);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 12px;
  font-weight: 600;
}
.avatar.large {
  width: 44px;
  height: 44px;
  font-size: 15px;
}
.tone-0 {
  color: var(--accent-foreground);
  background: var(--accent);
}
.tone-1 {
  color: var(--warning-foreground);
  background: var(--warning-soft);
}
.tone-2 {
  color: var(--success);
  background: var(--success-soft);
}
.tone-3 {
  color: var(--channel-accent-foreground);
  background: var(--channel-accent);
}
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.45;
  white-space: nowrap;
  background: var(--muted);
  color: var(--muted-foreground);
}
.status i {
  display: none;
}
.status.pending {
  background: var(--primary-10);
  color: var(--primary);
}
.status.processing {
  background: var(--processing-soft);
  color: var(--processing);
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  min-height: 130px;
  padding: 32px 16px;
  font-size: 14px;
  color: var(--muted-foreground);
}
.empty > span {
  display: grid;
  place-items: center;
}
.empty > span > .icon {
  width: 32px;
  height: 32px;
  opacity: 0.5;
}
.message,
.errorbox {
  padding: 20px;
}
.message {
  color: var(--muted-foreground);
}
.errorbox,
.validation,
.date-error,
.field-label b {
  color: var(--destructive);
}
.validation,
.date-error {
  font-size: 12px;
}
.notice {
  position: fixed;
  z-index: 40;
  bottom: 20px;
  left: 50%;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--popover-foreground);
  background: var(--popover);
  box-shadow: var(--elevation);
  opacity: 0;
  visibility: hidden;
}
.notice.visible {
  opacity: 1;
  visibility: visible;
}

.inbox {
  display: grid;
  grid-template-columns: clamp(215px, 21%, 320px) minmax(0, 1fr) clamp(
      230px,
      25%,
      358px
    );
  height: 100%;
  min-height: 0;
}
.contacts,
.conversation,
.customer-panel,
.work-list,
.work-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.contacts,
.work-list {
  border-right: 1px solid var(--border);
}
.customer-panel {
  border-left: 1px solid var(--border);
}
.pane-title,
.person-head,
.ticket-side-head,
.section-head,
.list-header,
.detail-top,
.work-head,
.dialog-head,
.number-line,
.detail-heading,
.field-label,
.actions,
.detail-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pane-title,
.person-head {
  flex: none;
  min-height: 56px;
  padding: 10px 16px;
}
.person-head,
.customer-panel .pane-title {
  border-bottom: 1px solid var(--border);
}
.person-head h1,
.pane-title h1 {
  font-size: 16px;
}
.pane-title .mobile-side,
.person-head .mobile-side {
  margin-left: auto;
}
.filter-pad {
  padding: 0 12px 12px;
}
.contact-list,
.side-list,
.work-items {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 6px;
  border-radius: 8px;
}
.contact:hover {
  background: var(--muted);
}
.contact.selected {
  background: var(--accent);
  color: var(--accent-foreground);
}
.contact-body {
  min-width: 0;
  flex: 1;
}
.contact-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.contact-body small,
.contact-line strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact time,
.bubble-wrap time {
  font-size: 11px;
}
.thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding: 20px clamp(14px, 3vw, 40px);
  background: var(--canvas);
}
.day-line {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 11px;
}
.day-line::before,
.day-line::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}
.bubble-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.bubble-line.out {
  flex-direction: row-reverse;
}
.bubble-line .avatar {
  width: 28px;
  height: 28px;
  font-size: 10px;
}
.bubble-wrap {
  min-width: 0;
  max-width: 80%;
}
.bubble-wrap time {
  display: block;
  padding-top: 3px;
}
.out time {
  text-align: right;
}
.bubble {
  padding: 9px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px 12px 12px;
}
.out .bubble {
  border-color: var(--primary-ring);
  background: var(--accent);
  color: var(--accent-foreground);
  border-radius: 12px 3px 12px 12px;
}
.activity {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: center;
  width: min(100%, 455px);
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.activity > div {
  min-width: 0;
  flex: 1;
}
.activity strong,
.activity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity strong {
  font-size: 13px;
}
.activity-link {
  text-align: right;
}
.activity-link time {
  display: block;
  font-size: 10px;
}
.activity-icon {
  color: var(--primary);
  background: var(--primary-10);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}
.composer {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--border);
}
.compose-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}
.compose-tab,
.create-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  min-height: 28px;
  color: var(--muted-foreground);
}
.compose-tab.active,
.create-trigger:hover {
  color: var(--foreground);
  background: var(--secondary);
}
.separator {
  height: 14px;
  width: 1px;
  margin: 0 3px;
  background: var(--border);
}
.composer textarea {
  width: 100%;
  padding: 8px 5px;
  border: 0;
  resize: none;
  line-height: 1.6;
  color: var(--foreground);
}
.composer small {
  display: block;
  text-align: right;
  font-size: 10px;
}
.person-profile {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}
.person-profile h2 {
  font-size: 16px;
  margin-top: 8px;
}
.person-profile p {
  font-size: 12px;
  color: var(--muted-foreground);
}
.ticket-side-head {
  padding: 14px 14px 8px;
  justify-content: space-between;
}
.ticket-side-head h2 {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.side-search,
.side-filters {
  margin: 0 14px 8px;
}
.side-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.side-list {
  flex: 1;
  padding: 0 14px;
}
.side-work-link {
  margin: 10px 14px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  justify-content: space-between;
}
.mobile-only,
.mobile-side {
  display: none;
}

.work {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--background);
}
.work-head {
  height: 48px;
  flex: none;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.work-head h1 {
  font-size: 16px;
  font-weight: 600;
}
.title-icon {
  display: grid;
  place-items: center;
  color: var(--primary);
  flex: 0 0 16px;
}
.title-icon > .icon {
  width: 16px;
  height: 16px;
}
.work-head-actions,
.work-head > .button {
  margin-left: auto;
}
.work-head-actions,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.work-controls,
.work-dates,
.matter-selection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 0;
}
.work-result-count {
  display: block;
  margin: 6px 20px 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.work-dates {
  padding-top: 8px;
  padding-bottom: 12px;
}
.work-dates small {
  font-size: 12px;
}
.matter-selection {
  padding-top: 0;
  padding-bottom: 12px;
}
.matter-selection:empty,
.date-error:empty {
  display: none;
}
.selected-matter,
.matter-selection > button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--primary-5);
  color: var(--primary);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.matter-selection button:focus-visible {
  outline-offset: 0;
}
.work-filter,
#type-filters label,
.child-panel label,
#mutation > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted-foreground);
}
.work-filter.search-field {
  flex: 1 1 180px;
  max-width: 576px;
}
.work-filter .search {
  width: 100%;
}
.work-filter select,
.side-filters select,
.date-filter select,
.date-filter input,
#type-filters input,
#type-filters select,
#mutation select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--background);
  font-size: 12px;
  color: var(--foreground);
}
.work-filter select {
  width: 148px;
  max-width: 100%;
}
.work-filter #work-status {
  width: 144px;
}
.date-filter {
  position: relative;
  max-width: 100%;
  min-width: 0;
}
.date-value {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
}
.date-filter input,
.date-filter select {
  min-width: 0;
  max-width: 100%;
}
.date-filter input[type="number"] {
  width: 80px;
}
fieldset.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.date-filter > span,
.date-filter legend {
  color: var(--muted-foreground);
  font-size: 12px;
}
.date-filter select,
.date-filter input {
  height: 32px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
}
.date-filter legend {
  padding: 0 4px;
  font-size: 11px;
  color: var(--muted-foreground);
}
.date-error:not(:empty) {
  padding: 0 20px 10px;
}
.work-grid {
  display: grid;
  grid-template-columns: min(42%, 600px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
}
.work-grid .work-items {
  flex: 1;
  min-height: 0;
  padding: 8px 12px 18px;
}
.list-header,
.detail-top {
  flex: none;
  min-height: 36px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
}
.list-header h2,
.detail-top h2 {
  font-size: 12px;
  font-weight: 500;
}
.detail-top {
  justify-content: space-between;
}
.list-back {
  display: none;
}
.work-detail > .empty {
  flex: 1;
}
.work-card,
.side-card,
.ticket-group {
  width: 100%;
  min-width: 0;
  margin: 0 0 12px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--background);
}
.side-card {
  padding: 12px;
}
.work-card:hover,
.side-card:hover {
  background: color-mix(in srgb, var(--muted) 60%, var(--background));
}
.work-card.selected,
.side-card.selected {
  border-color: var(--primary-border);
  background: var(--primary-5);
  box-shadow: 0 0 0 1px var(--primary-ring);
}
.number-line,
.ticket-card-main,
.ticket-card-detail,
.group-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.number-line,
.ticket-card-detail {
  justify-content: space-between;
}
.work-card > strong,
.side-card > strong,
.ticket-card-main > strong {
  display: block;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.ticket-card-main {
  margin: 8px 0;
  flex-wrap: wrap;
}
.ticket-card-main small {
  display: inline;
  color: var(--muted-foreground);
  font-size: 12px;
}
.ticket-card-detail {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin: 8px 0;
  font-size: 12px;
  line-height: 20px;
  color: var(--muted-foreground);
}
.group-line .counter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--primary-10);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
}
.ticket-group > button > small {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ticket-group > button > small > span {
  color: var(--primary);
}
.ticket-card-main .avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.work-card > small,
.side-card > small {
  font-size: 11px;
  color: var(--muted-foreground);
}
.work-card small,
.ticket-card-detail {
  flex-wrap: wrap;
}
.work-card > small {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.ticket-card-detail {
  margin-top: 8px;
}
.ticket-group {
  padding: 0;
  overflow: hidden;
}
.ticket-group > button {
  display: block;
  width: 100%;
  padding: 16px;
  text-align: left;
}
.ticket-group > button:hover {
  background: var(--muted);
}
.group-line {
  justify-content: space-between;
  flex-wrap: wrap;
}
.group-line strong {
  font-size: 14px;
}
.ticket-group > button > small {
  margin-top: 12px;
}
.group-members {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 35%, var(--background));
}
.group-members .work-card,
.group-members .side-card {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.group-members > :last-child {
  margin-bottom: 0;
}
.urgency-note {
  font-size: 12px;
  color: var(--muted-foreground);
  margin: 0 0 8px;
}
.side-list > .button {
  display: block;
  margin: 8px auto;
}

.detail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 24px;
  min-width: 0;
}
.case-overview {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.case-overview > div:first-child {
  flex: 1 1 260px;
  min-width: 0;
}
.detail-heading {
  gap: 12px;
  flex-wrap: wrap;
}
.detail-heading .ticketno {
  color: var(--muted-foreground);
  font-weight: 400;
  font-size: 14px;
}
.detail-heading .ticketno .icon {
  width: 14px;
  height: 14px;
}
.detail-title {
  font-size: 24px;
  line-height: 1.5;
  margin: 16px 0 12px;
  overflow-wrap: anywhere;
}
.case-codes,
.leaf-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.case-codes span,
.leaf-counts span {
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted-foreground);
}
.case-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.case-who strong,
.case-who small {
  display: block;
  overflow-wrap: anywhere;
}
.case-who small {
  margin-top: 3px;
}
.case-who > div {
  min-width: 0;
}
.case-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 28px;
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  min-width: 0;
}
.case-meta dl {
  display: contents;
}
.case-meta > div,
.case-meta dl > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.case-meta dt {
  font-size: 12px;
  color: var(--muted-foreground);
}
.case-meta dd {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.detail-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.detail-section h3,
.section-heading h3 {
  font-size: 14px;
  margin-bottom: 10px;
}
.section-heading,
.detail-crosslinks,
.event-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.description,
.event-description,
.description-history p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.85;
}
.description-history,
.event-diff {
  margin-top: 10px;
}
.description-history > summary,
.event-diff > summary {
  font-size: 12px;
  color: var(--primary);
}
.description-history ol {
  margin: 8px 0;
  padding: 0 0 0 16px;
  border-left: 2px solid var(--border);
  list-style: none;
}
.description-history li + li {
  margin-top: 8px;
}
.leaf-counts {
  padding: 12px 0;
  align-items: center;
  font-size: 12px;
  color: var(--muted-foreground);
}
.family-tree {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 192px;
  overflow: auto;
}
.family-node {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.family-node:last-child {
  border-bottom: 0;
}
.family-node:hover {
  background: var(--muted);
}
.family-node.focused {
  background: var(--primary-5);
}
.family-node .ticketno,
.family-kind {
  color: var(--muted-foreground);
}
.family-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.events {
  list-style: none;
  padding: 0;
  margin: 0;
}
.events li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  position: relative;
  padding: 0 0 18px;
  line-height: 1.6;
  font-size: 13px;
}
.events li:last-child {
  padding-bottom: 0;
}
.events li:not(:last-child)::before {
  position: absolute;
  content: "";
  left: 3px;
  top: 13px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.event-main {
  min-width: 0;
}
.event-title time,
.description-history small {
  font-size: 11px;
}
.event-diff {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
}
.event-diff table,
.report-section table {
  width: 100%;
  border-collapse: collapse;
}
.event-diff table {
  margin: 6px 0;
  font-size: 12px;
  table-layout: fixed;
}
.event-diff th,
.event-diff td {
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-top: 1px solid var(--border);
  padding: 5px;
}
.event-diff th:first-child {
  width: 64px;
}
.event-diff .changed {
  background: var(--accent);
}
.missing-history {
  color: var(--muted-foreground);
}
.detail-crosslinks {
  margin-top: 14px;
}
.detail-duty:not(:empty) {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.detail-duty,
.ticket-card-presence {
  color: var(--working);
  font-size: 12px;
}
.ticket-card-presence {
  display: block;
  margin: 8px 0 0;
  padding: 4px 8px;
  border: 1px solid var(--working-border);
  border-radius: 4px;
  background: var(--working-soft);
}
.case-meta dd {
  display: flex;
  align-items: center;
  gap: 8px;
}
.case-meta dd .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}
.case-meta {
  padding-block: 24px;
}
.case-who a {
  white-space: normal;
}
.detail-heading .ticketno .icon {
  display: none;
}
.work-head-actions button[data-do="refresh"] {
  border-color: transparent;
  min-width: 32px;
  width: 32px;
  padding: 0;
  gap: 0;
  font-size: 0;
}
.work-head-actions button[data-do="refresh"]:hover {
  background: var(--muted);
}
@media (min-width: 768px) {
  .work-grid .detail-top {
    display: none;
  }
}
.detail-duty span + span {
  margin-left: 8px;
}
.detail-footer,
.dialog-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--background);
}
.detail-footer .button {
  min-height: 36px;
}
.detail-footer .button.primary {
  min-height: 40px;
}
#working-session {
  position: fixed;
  bottom: 10px;
  left: 64px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 76px);
  padding: 7px 10px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--elevation);
  font-size: 12px;
}
#working-session > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
#working-session > .textbtn {
  white-space: nowrap;
}
body:has(#working-session:not([hidden])) .composer {
  padding-bottom: 48px;
}

dialog {
  padding: 0;
  border: none;
  border-radius: 16px;
  width: calc(100% - 32px);
  max-height: 90dvh;
  overflow: hidden;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--foreground) 10%, transparent),
    var(--elevation);
}
dialog::backdrop {
  background: rgb(0 0 0 / 60%);
  backdrop-filter: blur(2px);
}
.create-dialog {
  max-width: 780px;
}
.detail-dialog {
  max-width: 860px;
}
.create-dialog[open],
.detail-dialog[open],
#create-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dialog-head {
  padding: 20px 24px;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.dialog-head h2 {
  font-size: 20px;
}
.detail-dialog .dialog-head h2 {
  font-size: 18px;
}
.dialog-body,
.detail-dialog .detail-body {
  padding: 20px 24px;
  overflow: auto;
  min-height: 0;
  min-width: 0;
}
.dialog-footer {
  padding: 16px 24px;
  gap: 12px;
}
.dialog-footer > .button {
  min-height: 40px;
  padding: 8px 16px;
}
.create-customer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.create-customer strong,
.create-customer small {
  display: block;
}
.field-label {
  justify-content: space-between;
  margin-bottom: 8px;
}
.field-label label,
.field {
  font-size: 14px;
  font-weight: 600;
}
.field {
  display: block;
  margin: 20px 0 8px;
}
.dialog-body > .search,
.inline-picker > .search {
  height: 40px;
}
.matter-group {
  margin-top: 18px;
}
.matter-group h3,
.matter-group h4 {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 8px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
}
.chip:hover,
.chip.chosen {
  border-color: var(--primary-border);
}
.chip.chosen {
  color: var(--primary);
  background: var(--primary-5);
}
.chip label {
  min-width: 0;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  position: relative;
  cursor: pointer;
  padding: 8px 4px 8px 12px;
  font-size: 14px;
  line-height: 20px;
}
.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}
.chip .code {
  font-size: 12px;
}
.chip button {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-right: 3px;
  border-radius: 6px;
  color: var(--muted-foreground);
}
.chip .icon {
  width: 14px;
  height: 14px;
}
.field-note,
.validation {
  font-size: 12px;
  line-height: 1.65;
  margin-top: 10px;
}
#ticket-matter-tooltip {
  position: fixed;
  inset: auto;
  width: max-content;
  max-width: min(320px, calc(100vw - 12px));
  margin: 0;
  padding: 6px 12px;
  overflow: visible;
  border: 0;
  border-radius: 8px;
  background: var(--foreground);
  color: var(--background);
  font: 400 12px/20px var(--font-sans);
  text-align: start;
  overflow-wrap: anywhere;
}
#ticket-matter-tooltip::after {
  position: absolute;
  left: var(--tip-arrow-x);
  top: 100%;
  width: 10px;
  height: 10px;
  content: "";
  border-radius: 2px;
  background: inherit;
  transform: translate(-50%, -60%) rotate(45deg);
}
#ticket-matter-tooltip[data-side="bottom"]::after {
  top: 0;
}
/* A pointer can travel from the info icon to the explanation across the arrow. */
#ticket-matter-tooltip::before {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 7px;
}
#ticket-matter-tooltip[data-side="bottom"]::before {
  inset: auto 0 100%;
}
#description,
#mutation-description,
.child-panel textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--input);
  border-radius: 10px;
  padding: 12px;
  line-height: 1.55;
}
#description {
  min-height: 112px;
}
#mutation {
  border: 1px solid var(--primary-ring);
  background: color-mix(in srgb, var(--muted) 35%, var(--background));
  border-radius: 12px;
  padding: 20px;
  margin: 18px 0;
}
#mutation h3 {
  margin-bottom: 8px;
}
#mutation p {
  font-size: 12px;
  color: var(--muted-foreground);
}
#mutation .actions {
  justify-content: flex-end;
  margin-top: 14px;
}
.child-panel {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 10px 0;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  background: var(--background);
}
.child-panel legend {
  padding: 0 4px;
  font-size: 12px;
}
.child-panel .textbtn {
  justify-self: end;
}
.inline-picker .field-label {
  margin: 8px 0;
}
.inline-picker .search {
  margin-bottom: 10px;
}
.type-screen {
  height: 100%;
  overflow: auto;
  background: var(--background);
}
.type-wrapper {
  min-width: 0;
  padding: 20px;
  display: grid;
  gap: 18px;
}
#type-filters,
.report-kpis,
.report-pager {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
#type-filters select {
  max-width: 200px;
}
.report-kpis {
  align-items: center;
  margin: 0 0 20px;
  gap: 16px;
}
.report-kpis > div {
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.report-kpis strong {
  margin-left: 12px;
  font-size: 24px;
}
.report-kpis span {
  font-size: 12px;
  color: var(--muted-foreground);
}
.report-section {
  min-width: 0;
  margin-bottom: 16px;
}
.report-section h2 {
  font-size: 16px;
  margin-bottom: 8px;
}
.report-scroll {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.report-section th,
.report-section td {
  padding: 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.report-section th {
  white-space: nowrap;
  background: var(--muted);
}
.report-section td {
  min-width: 72px;
}
.report-empty {
  padding: 16px;
  color: var(--muted-foreground);
}
.report-pager {
  justify-content: flex-end;
  align-items: center;
  font-size: 12px;
}
.report-pager .button {
  min-height: 28px;
}

@media (min-width: 1024px) {
  .work-result-count {
    margin-inline: 28px;
  }
  .work-head,
  .work-controls,
  .work-dates,
  .matter-selection {
    padding-inline: 28px;
  }
  .work-grid .work-items {
    padding-inline: 16px;
  }
  .work-detail .detail-body {
    padding-inline: 32px;
  }
  .type-wrapper {
    padding: 28px;
  }
}
@media (max-width: 950px) {
  .inbox {
    grid-template-columns: minmax(180px, 28%) minmax(0, 1fr);
    position: relative;
  }
  .customer-panel {
    display: none;
  }
  .inbox.mobile-panel > .customer-panel {
    display: flex;
    position: absolute;
    z-index: 3;
    inset: 0 0 0 auto;
    width: min(340px, 95%);
    background: var(--background);
    box-shadow: var(--elevation);
  }
  .mobile-side {
    display: inline-grid;
  }
}
@media (max-width: 767px) {
  #shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .workspace {
    grid-row: 1;
  }
  #rail {
    grid-row: 2;
    flex-direction: row;
    justify-content: center;
    min-height: 44px;
    padding: 0 4px max(0px, env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--sidebar-border);
  }
  .rail-links {
    width: auto;
    flex-direction: row;
    gap: 4px;
  }
  .rail-link {
    width: auto;
    min-width: 36px;
    padding: 0 8px;
    gap: 5px;
    font-size: 11px;
  }
  .rail-link .icon {
    width: 16px;
    height: 16px;
  }
  .brand {
    display: none;
  }
  .rail-profile {
    margin: 0;
  }
  .topbar {
    padding-inline: 12px;
    min-height: 38px;
  }
  .topbar:empty {
    display: none;
  }
  .work-head {
    padding-inline: 14px;
  }
  .work-head-actions {
    gap: 4px;
  }
  .work-head-actions .button {
    font-size: 12px;
    padding-inline: 7px;
  }
  .work-result-count {
    margin-inline: 12px;
  }
  .work-controls,
  .work-dates,
  .matter-selection {
    padding-inline: 12px;
  }
  .work-filter {
    flex: 1 1 100px;
  }
  .work-filter select,
  .work-filter #work-status {
    width: 100%;
  }
  .work-filter.search-field {
    flex: 1 0 100%;
    max-width: none;
    order: 5;
  }
  .work-controls {
    position: relative;
  }
  .work-grid {
    display: flex;
    flex: 1;
    min-height: 0;
  }
  .work-list {
    flex: 1;
    border-right: none;
  }
  .work-detail {
    display: none;
  }
  .work-grid.mobile-detail .work-list {
    display: none;
  }
  .work-grid.mobile-detail .work-detail {
    display: flex;
    flex: 1;
  }
  .work-grid.mobile-detail .list-back {
    display: inline-flex;
  }
  .work-grid.mobile-detail .detail-top h2 {
    display: none;
  }
  .work-detail .detail-body,
  .detail-dialog .detail-body {
    padding: 18px 16px;
  }
  .case-overview {
    gap: 12px;
    padding-bottom: 16px;
  }
  .case-overview > div:first-child {
    flex-basis: 180px;
  }
  .detail-title {
    font-size: 20px;
    margin-top: 10px;
  }
  .case-meta {
    gap: 8px 16px;
    padding-block: 14px;
  }
  .detail-footer,
  .dialog-footer {
    padding: 10px 14px;
    gap: 6px;
  }
  .detail-footer .actions {
    gap: 5px;
  }
  .detail-footer .button {
    font-size: 12px;
    padding-inline: 8px;
  }
  .dialog-head,
  .dialog-body,
  .issue-modal-body {
    padding: 15px 16px;
  }
  .dialog-head h2 {
    font-size: 18px;
  }
  dialog {
    width: calc(100% - 24px);
    max-height: 92dvh;
  }
  .type-wrapper {
    padding: 14px;
    gap: 12px;
  }
  #type-filters label {
    max-width: 100%;
  }
  #working-session {
    left: 8px;
    right: 8px;
    bottom: 52px;
    max-width: none;
  }
  .notice {
    bottom: 54px;
  }
}
@media (max-width: 620px) {
  .inbox {
    display: flex;
  }
  .contacts {
    display: none;
  }
  .conversation {
    flex: 1;
  }
  .mobile-only {
    display: inline-flex;
  }
  .inbox.mobile-contacts > .contacts {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 2;
    background: var(--background);
  }
  .thread {
    padding: 14px 10px;
  }
  .bubble-wrap {
    max-width: 84%;
  }
  .person-head,
  .pane-title {
    padding-inline: 12px;
  }
  .work-controls {
    gap: 6px;
  }
  .work-dates {
    gap: 6px;
  }
  .work-filter {
    flex: 1 1 86px;
  }
  .detail-title {
    font-size: 19px;
  }
  .family-kind {
    display: none;
  }
  .report-kpis {
    gap: 7px;
  }
  .report-kpis > div {
    padding: 8px 12px;
  }
  .report-kpis strong {
    font-size: 19px;
  }
}
@media (max-height: 650px) and (max-width: 767px) {
  .work {
    overflow-y: auto;
  }
  .work-grid {
    flex: none;
    min-height: 270px;
  }
  .work-grid .work-items,
  .work-grid .detail-body {
    max-height: 68dvh;
  }
}
@media (any-pointer: coarse) {
  #shell
    input:is([type="text"], [type="search"], [type="date"], [type="number"]),
  #shell textarea,
  #shell select,
  dialog
    input:is([type="text"], [type="search"], [type="date"], [type="number"]),
  dialog textarea,
  dialog select {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.work .avatar,
.create-customer .avatar,
.detail-dialog .avatar,
.type-screen .avatar {
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  font-weight: 500;
}
.section-heading .edit-description {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--foreground);
}
@media (max-width: 767px) {
  .work-controls.board-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .work-filter.search-field {
    grid-column: 1/-1;
    order: 5;
  }
  .work-filter select {
    padding-inline: 4px;
  }
  .work-dates {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .work-dates > small {
    grid-column: 1/-1;
  }
  .work-dates .date-filter {
    min-width: 0;
    padding: 4px 6px;
    gap: 4px;
  }
  .date-filter select {
    min-width: 0;
    width: 0;
    flex: 1 1 38px;
  }
  .date-filter .date-value {
    flex: 0 0 100%;
    min-width: 0;
  }
  .date-filter input {
    width: 100%;
  }
  .date-filter > span {
    overflow-wrap: anywhere;
  }
}
@media (max-width: 380px) {
  .work-controls.board-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .work-dates > .date-filter {
    flex-direction: column;
    align-items: stretch;
  }
  .work-dates .date-filter select {
    width: 100%;
    flex-basis: auto;
  }
}
