:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6f9;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f9; color: #172033; }
a { color: #315efb; text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid #e5e9f0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
}
.brand { font-weight: 800; color: #172033; font-size: 18px; }
.userbox { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.container { max-width: 1120px; margin: 34px auto; padding: 0 20px; }
.narrow-container { max-width: 760px; }
.card {
  background: #fff; border: 1px solid #e4e8ef; border-radius: 16px; padding: 24px;
  box-shadow: 0 8px 24px rgba(20, 30, 55, .04); margin-bottom: 22px;
}
.narrow { max-width: 440px; margin: 70px auto; }
h1 { margin: 0 0 12px; font-size: 28px; }
h2 { margin-top: 0; font-size: 20px; }
h3 { margin-bottom: 8px; }
.muted { color: #697386; }
.small { font-size: 12px; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.button, button {
  display: inline-block; border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer;
  font: inherit; font-weight: 700; background: #315efb; color: white;
}
.button:hover, button:hover { opacity: .92; text-decoration: none; }
.form { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; font-size: 14px; font-weight: 700; }
input, textarea {
  width: 100%; border: 1px solid #cfd6e1; border-radius: 10px; padding: 11px 12px; font: inherit; background: #fff;
}
textarea { resize: vertical; }
.actions { display: flex; gap: 14px; align-items: center; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash.success { background: #eaf8ee; color: #176b37; }
.flash.error { background: #fff0f0; color: #a02727; }
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid #edf0f4; vertical-align: top; }
th { font-size: 12px; color: #697386; text-transform: uppercase; letter-spacing: .05em; }
.status { display: inline-block; background: #eef3ff; color: #244fc2; padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.status.big { padding: 8px 12px; }
.grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 22px; }
dl { display: grid; grid-template-columns: 170px 1fr; gap: 12px 16px; margin: 0; }
dt { color: #697386; }
dd { margin: 0; }
.pre { white-space: pre-wrap; }
.copybox { padding: 12px; border-radius: 10px; background: #f4f6f9; word-break: break-all; font-size: 13px; }
hr { border: 0; border-top: 1px solid #edf0f4; margin: 22px 0; }
.timeline { display: grid; gap: 16px; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 10px; }
.dot { width: 10px; height: 10px; background: #315efb; border-radius: 50%; margin-top: 6px; }
.back { display: inline-block; margin-bottom: 12px; }
.client-page { min-height: 100vh; background: #eef2f8; padding-top: 18px; }
.client-card { padding: 34px; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: 12px; font-weight: 800; color: #697386; margin-bottom: 8px; }
.hero-status { font-size: 18px; margin: 14px 0 8px; }
.progress { display: grid; gap: 15px; margin: 30px 0; }
.progress-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; color: #8a94a6; }
.progress-step.done { color: #172033; font-weight: 650; }
.progress-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #e7ebf1; font-size: 13px; }
.progress-step.done .progress-dot { background: #315efb; color: white; }

.container-wide { max-width: 1360px; }
.bitrix-main { max-width: 1360px; }
.dp-bitrix-table .col-deal-id { width: 9%; }
.dp-bitrix-table .col-deal-title { width: 21%; }
.dp-bitrix-table .col-product { width: 23%; }
.dp-bitrix-table .col-status { width: 10%; }
.dp-bitrix-table .col-dp { width: 16%; }
.dp-bitrix-table .col-created { width: 10%; }
.dp-bitrix-table .col-actions { width: 11%; }
.dp-bitrix-table td:nth-child(2), .dp-bitrix-table td:nth-child(3) { min-width: 0; }
.dp-bitrix-table td:nth-child(7) { white-space: nowrap; }
.dp-bitrix-table .actions.compact-actions { justify-content: flex-end; }
@media (max-width: 1200px) { .container-wide, .bitrix-main { max-width: 1180px; } }
@media (max-width: 760px) {
  .grid, .two-col { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .page-head { flex-direction: column; }
  dl { grid-template-columns: 1fr; gap: 5px; }
  dd { margin-bottom: 10px; }
  .topbar { padding: 0 16px; }
}

.topnav { display: flex; gap: 16px; align-items: center; margin-left: auto; margin-right: 24px; }
.topnav a { font-size: 14px; font-weight: 700; color: #465166; }
select {
  width: 100%; border: 1px solid #cfd6e1; border-radius: 10px; padding: 11px 12px; font: inherit; background: #fff;
}
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid #e4e8ef; border-radius: 14px; padding: 16px 18px; display: grid; gap: 5px; }
.stat-card span { color: #697386; font-size: 13px; }
.stat-card strong { font-size: 26px; }
.filter-card { padding: 18px; }
.filter-grid { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.filter-search { min-width: 220px; }
.filter-actions { display: flex; gap: 9px; align-items: center; }
.button.secondary { background: #eef1f6; color: #33405a; }
.result-line { margin: 0 0 10px 4px; font-size: 13px; }
.small-date { white-space: nowrap; font-size: 12px; color: #586174; }
.row-closed { background: #fafbfc; }
.status-closed { background: #eaf8ee; color: #176b37; }
.closed-summary { border-color: #cfe9d7; background: #fbfffc; }
.section-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.section-head h2 { margin-bottom: 5px; }
.history-list { display: grid; }
.history-row { display: grid; grid-template-columns: 170px 1fr 120px; gap: 18px; padding: 18px 0; border-bottom: 1px solid #edf0f4; align-items: start; }
.history-row:last-child { border-bottom: 0; }
.history-time { font-size: 12px; color: #697386; }
.history-order { display: inline-block; font-weight: 800; margin-bottom: 9px; }
.history-note { margin-top: 8px; }
.history-actor { text-align: right; font-size: 13px; }

@media (max-width: 1000px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { min-width: 0; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .topnav { order: 3; width: 100%; margin: 0; }
  .filter-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .history-row { grid-template-columns: 1fr; gap: 7px; }
  .history-actor { text-align: left; }
  .section-head { flex-direction: column; }
}

.inline-form { display: inline; margin: 0; }
.link-button { background: transparent; color: #315efb; padding: 0; border-radius: 0; font-weight: 600; }
.link-button:hover { text-decoration: underline; opacity: 1; }
.admin-grid { grid-template-columns: .8fr 1.2fr; }
.user-list { display: grid; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid #edf0f4; }
.user-row:last-child { border-bottom: 0; }
.user-actions { display: flex; align-items: center; gap: 10px; }
.badge { display: inline-block; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 700; }
.badge-ok { background: #eaf8ee; color: #176b37; }
.badge-off { background: #f0f2f5; color: #697386; }
.small-button { padding: 7px 10px; font-size: 12px; }
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .user-row { align-items: flex-start; flex-direction: column; }
}

.compact-head { margin-bottom: 12px; }
.compact-head h3 { margin: 0 0 5px; }
.compact-actions { gap: 8px; flex-wrap: wrap; }
.attachment-list { display: grid; gap: 10px; }
.attachment-item {
  display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 12px; align-items: start;
  border: 1px solid #e4e8ef; border-radius: 12px; padding: 12px 14px; background: #fafbfc;
}
.attachment-select { padding-top: 3px; }
.attachment-select input { width: auto; }
.attachment-body { display: block; font-weight: 400; cursor: pointer; }
.attachment-body strong { display: block; margin-bottom: 4px; }
.comment-preview { margin-top: 7px; padding: 8px 10px; background: #fff; border-radius: 8px; white-space: pre-wrap; }
.empty-box { border: 1px dashed #cfd6e1; border-radius: 12px; padding: 14px; color: #697386; background: #fafbfc; }
.document-list { display: grid; gap: 5px; }
@media (max-width: 760px) {
  .attachment-item { grid-template-columns: 28px minmax(0,1fr); }
  .attachment-item > a { grid-column: 2; }
}

.history-details { padding: 0; }
.history-details > summary {
  list-style: none; cursor: pointer; padding: 20px 24px; display: flex;
  justify-content: space-between; gap: 16px; align-items: center;
}
.history-details > summary::-webkit-details-marker { display: none; }
.history-details > summary::after { content: "▾"; color: #697386; font-size: 18px; }
.history-details[open] > summary::after { content: "▴"; }
.history-details-body { border-top: 1px solid #edf0f4; padding: 20px 24px 24px; }
.history-tools { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.document-edit-list { display: grid; gap: 8px; margin-top: 10px; }
.document-edit-row {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  border: 1px solid #e4e8ef; border-radius: 10px; padding: 10px 12px; background: #fafbfc;
}
.inline-check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; font-weight: 600; }
.inline-check input { width: auto; }
@media (max-width: 760px) {
  .history-details > summary { align-items: flex-start; flex-direction: column; }
  .document-edit-row { align-items: flex-start; flex-direction: column; }
}

/* Case details v1.10 */
.history-collapsible-card { padding: 20px 24px; }
.history-collapsible-head {
  display: flex; justify-content: space-between; gap: 18px; align-items: center;
}
.history-collapsible-head h2 { margin-bottom: 5px; }
.case-history[hidden] { display: none !important; }
.case-history { border-top: 1px solid #edf0f4; margin-top: 18px; padding-top: 20px; }
.history-toggle { white-space: nowrap; }
@media (max-width: 760px) {
  .history-collapsible-head { align-items: flex-start; flex-direction: column; }
}

.file-preview-list {
  margin-top: 10px;
}
.file-preview-summary {
  margin-bottom: 8px;
  font-weight: 700;
}
.file-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.file-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #dfe5ef;
  border-radius: 12px;
  background: #f8fafc;
}
.file-preview-image,
.file-preview-file {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 9px;
  border: 1px solid #dfe5ef;
  background: #fff;
}
.file-preview-image {
  object-fit: cover;
}
.file-preview-file {
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #526174;
}
.file-preview-meta {
  min-width: 0;
}
.file-preview-name {
  overflow-wrap: anywhere;
  font-weight: 600;
}
.file-existing-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-existing-thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid #dfe5ef;
}
.file-existing-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* File queue controls v1.14 */
.file-preview-item { position: relative; }
.file-preview-meta { flex: 1 1 auto; }
.file-remove-button {
  flex: 0 0 auto;
  border: 1px solid #efb4b4;
  background: #fff5f5;
  color: #b42318;
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.file-remove-button:hover { background: #ffe7e7; }
.button.danger {
  background: #fff5f5;
  color: #b42318;
  border: 1px solid #efb4b4;
}
.button.danger:hover { background: #ffe7e7; }
.inline-delete-form { margin-left: auto; }
@media (max-width: 760px) {
  .inline-delete-form { margin-left: 0; }
  .file-preview-item { align-items: flex-start; flex-wrap: wrap; }
}

/* Live updates + lawyer notifications */
.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: #315efb;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.nav-count[hidden] { display: none !important; }
.notification-center { position: relative; }
.notification-button {
  border: 0;
  background: transparent;
  color: #465166;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.notification-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 12px);
  right: 0;
  width: min(380px, 90vw);
  max-height: 480px;
  overflow: auto;
  background: #fff;
  border: 1px solid #dfe5ef;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(30, 41, 59, .18);
  padding: 10px;
}
.notification-panel[hidden] { display: none !important; }
.notification-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid #edf0f4;
}
.notification-list { display: grid; padding-top: 6px; }
.notification-row {
  display: grid;
  gap: 4px;
  padding: 11px 9px;
  border-radius: 10px;
  color: #1d2939;
  text-decoration: none;
}
.notification-row:hover { background: #f5f7fb; }
.notification-row span { color: #667085; font-size: 12px; line-height: 1.4; }
.toast-container {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  width: min(480px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  pointer-events: none;
}
.site-toast {
  pointer-events: auto;
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid #dbe3f0;
  border-left: 4px solid #315efb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(30, 41, 59, .18);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.site-toast.visible { opacity: 1; transform: translateY(0); }
.site-toast strong { color: #172033; }
.site-toast .small { color: #667085; line-height: 1.4; }
.flash-toast {
  grid-template-columns: 32px minmax(0, 1fr) 28px;
  align-items: start;
  gap: 14px;
  min-height: 110px;
  box-sizing: border-box;
  padding: 24px 20px;
  border: 1px solid #1d4ed8;
  background: #2563eb;
  color: #fff;
  cursor: default;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .25);
}
.flash-toast-error { background: #dc2626; border-color: #b91c1c; }
.flash-toast-success { background: #15803d; border-color: #166534; }
.flash-toast-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
}
.flash-toast-message { font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
.flash-toast-close {
  padding: 0;
  width: 28px;
  height: 32px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.flash-toast-close:hover { background: rgba(255, 255, 255, .15); }
.flash-toast-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .site-toast { transition: none; transform: none; }
}
@media (max-width: 760px) {
  .notification-panel { right: -80px; }
  .toast-container { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

/* Bitrix comment library: independent, responsive document workspace. */
.bitrix-library {max-width:1100px;margin-inline:auto;}
.bitrix-library .section-head {align-items:flex-start;margin-bottom:16px;}
.bitrix-library-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,290px),1fr));gap:16px;margin-top:22px;}
.bitrix-library-card {display:flex;gap:14px;padding:18px;border:1px solid #e1e7f0;border-radius:15px;background:#fafbfd;min-width:0;}
.bitrix-library-icon {display:grid;place-items:center;flex:0 0 56px;height:72px;border-radius:11px;background:#e8eeff;color:#355bd4;font-weight:800;font-size:13px;letter-spacing:.03em;}
.bitrix-library-content {display:flex;flex-direction:column;align-items:stretch;gap:9px;min-width:0;flex:1;}
.bitrix-library-name {overflow-wrap:anywhere;line-height:1.35;}
.bitrix-library-ready {font-size:13px;color:#176b37;font-weight:700;}
.bitrix-library-details {border-top:1px solid #e2e7f0;padding-top:11px;font-size:13px;}
.bitrix-library-details summary {cursor:pointer;color:#315efb;font-weight:700;}
.bitrix-library-import {display:flex;flex-direction:column;gap:8px;margin-top:10px;}
.bitrix-library-import input,.bitrix-library-import button {width:100%;min-width:0;}

/* Browser-assisted capture for Bitrix comment attachments. */
.bitrix-capture-panel { padding: 20px; border: 1px solid #d7e2f0; border-radius: 15px; background: #f7faff; margin: 20px 0; }
.bitrix-capture-panel h2 { margin-top: 0; font-size: 1.15rem; }
.bitrix-steps { padding-left: 22px; line-height: 1.55; }
.bitrix-capture-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.bitrix-capture-result { background: #fff; border: 1px solid #c6d6ef; border-radius: 12px; padding: 16px; margin-top: 16px; }
.bitrix-capture-result[hidden] { display: none; }

/* Imported Bitrix files on the New Case page.
   Explicit three-column layout prevents file names or controls from collapsing.
   All three cells are in the SAME grid row on desktop; no nested flex widths. */
.bitrix-case-files {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  width: 100%;
  min-width: 0;
}
.bitrix-case-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 210px;
  column-gap: 16px;
  row-gap: 12px;
  align-items: end;
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid #dfe5ef;
  border-radius: 12px;
  background: #f8fafc;
}
.bitrix-case-file-info {
  display: flex;
  gap: 14px;
  align-items: center;
  align-self: center;
  min-width: 0;
}
.bitrix-case-file-icon {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 58px;
  border-radius: 10px;
  background: #e8eeff;
  color: #355bd4;
  font-size: 12px;
  font-weight: 800;
}
.bitrix-case-file-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.bitrix-case-file-name {
  display: block;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.4;
}
.bitrix-case-file-size {
  display: block;
  margin-top: 5px;
  color: #697386;
  font-size: 13px;
  font-weight: 400;
}
/* The action and select have identical heights and share a bottom baseline. */
.bitrix-case-file-view {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  align-self: end;
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  font-size: 14px;
}
.bitrix-case-file-category {
  display: grid;
  gap: 6px;
  align-self: end;
  width: 100%;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}
.bitrix-case-file-category-title { line-height: 17px; }
.bitrix-case-file-category select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 500;
  color: #172033;
}
@media (max-width: 800px) {
  .bitrix-case-file {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bitrix-case-file-info {
    grid-column: 1 / -1;
  }
}
@media (max-width: 500px) {
  .bitrix-case-file {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
  }
  .bitrix-case-file-info { grid-column: 1; }
  .bitrix-case-file-view,
  .bitrix-case-file-category { grid-column: 1; }
}

/* DP workspace v3: three principal tabs, picked tasks and document drawer. */
.topnav { gap: 6px; flex-wrap: wrap; }
.topnav a { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 13px; border-radius: 10px; color: #49546a; }
.topnav a:hover { background: #f1f4fb; text-decoration: none; }
.topnav a.nav-selected { background: #e9efff; color: #315efb; }
.dp-picked-section h2 { margin: 0; }
.dp-picked-list { margin-top: 14px; }
.dp-picked-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid #ebeff5; }
.dp-picked-content { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dp-picked-content strong { overflow-wrap: anywhere; font-size: 15px; }
.dp-picked-actions { flex: 0 0 auto; flex-wrap: wrap; }
.dp-history-filter { display: flex; align-items: end; gap: 12px; }
.dp-history-filter label { min-width: 0; flex: 1; }
.dp-history-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; }
.lawyer-docs-disclosure { padding: 0; overflow: hidden; }
.lawyer-docs-summary { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 23px 25px; cursor: pointer; list-style: none; user-select: none; }
.lawyer-docs-summary::-webkit-details-marker { display: none; }
.lawyer-docs-summary:hover { background: #f8faff; }
.lawyer-docs-summary:focus-visible { outline: 3px solid #315efb; outline-offset: -3px; }
.lawyer-docs-heading { display: flex; flex-direction: column; gap: 5px; }
.lawyer-docs-heading strong { font-size: 20px; }
.lawyer-docs-chevron { flex: 0 0 auto; display: grid; place-items: center; height: 34px; width: 34px; border-radius: 9px; background: #edf2ff; color: #315efb; font-size: 25px; transition: transform 160ms ease; }
.lawyer-docs-disclosure[open] .lawyer-docs-chevron { transform: rotate(180deg); }
.lawyer-docs-body { border-top: 1px solid #e4e8ef; padding: 22px 25px 26px; animation: lawyerDocumentsIn 170ms ease-out; }
@keyframes lawyerDocumentsIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 640px) {
  .topnav { gap: 3px; }
  .topnav a { font-size: 13px; padding: 8px 10px; }
  .dp-picked-item { flex-direction: column; align-items: stretch; }
  .dp-picked-actions { justify-content: flex-start; }
  .dp-history-filter { flex-wrap: wrap; }
  .dp-history-filter label { flex-basis: 100%; }
  .lawyer-docs-summary { padding: 17px; }
  .lawyer-docs-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .lawyer-docs-body { animation: none; } .lawyer-docs-chevron { transition: none; } }

/* Tabular data becomes legible cards on small DP screens. */
@media (max-width: 760px) {
  .dp-case-table, .dp-bitrix-table, .dp-completed-table { display: block; width: 100%; border-collapse: separate; }
  .dp-case-table thead, .dp-bitrix-table thead, .dp-completed-table thead { display: none; }
  .dp-case-table tbody, .dp-bitrix-table tbody, .dp-completed-table tbody { display: grid; gap: 12px; }
  .dp-case-table tbody tr, .dp-bitrix-table tbody tr, .dp-completed-table tbody tr {
    display: grid; width: 100%; gap: 9px; padding: 14px 12px;
    border: 1px solid #e5e9f0; border-radius: 12px; background: #fff;
  }
  .dp-case-table tbody td, .dp-bitrix-table tbody td, .dp-completed-table tbody td {
    display: flex; justify-content: space-between; align-items: flex-start;
    min-width: 0; gap: 12px; padding: 4px 0; border: 0;
    overflow-wrap: anywhere; text-align: right;
  }
  .dp-case-table tbody td::before, .dp-bitrix-table tbody td::before, .dp-completed-table tbody td::before {
    content: attr(data-label); flex: 0 0 90px; text-align: left;
    font-size: 12px; font-weight: 650; color: #697386;
  }
  .dp-case-table .status, .dp-bitrix-table .status { white-space: normal; text-align: left; }
  .dp-bitrix-table .compact-actions { justify-content: flex-end; max-width: calc(100% - 90px); }
  .dp-case-table .small-date, .dp-bitrix-table .small-date, .dp-completed-table .small-date { white-space: normal; }
  .dp-case-table tbody td[colspan], .dp-bitrix-table tbody td[colspan], .dp-completed-table tbody td[colspan] { text-align: left; }
  .dp-case-table tbody td[colspan]::before, .dp-bitrix-table tbody td[colspan]::before, .dp-completed-table tbody td[colspan]::before { content: none; }
}

/* Bitrix task list: compact user-facing view; sync diagnostics remain admin-only. */
.bitrix-queue-head { align-items: center; margin-bottom: 20px; }
.bitrix-queue-head h1 { margin: 0; }
.bitrix-queue-refresh { flex: 0 0 auto; }
.bitrix-refresh-feedback { margin: -10px 0 18px; font-size: 13px; color: #536279; }
.bitrix-queue-settings { margin: -4px 0 20px; color: #657187; font-size: 13px; }
.bitrix-queue-settings summary { cursor: pointer; display: inline-block; padding: 4px 0; }
.bitrix-queue-settings summary:hover { color: #315efb; }
.bitrix-queue-settings-content { margin-top: 10px; padding: 16px; background: #fff; border: 1px solid #e4e8ef; border-radius: 12px; }
.bitrix-queue-settings-content p { margin: 0 0 12px; line-height: 1.5; }
.bitrix-queue-settings-content form { margin: 0; }
.bitrix-queue-sync-error { color: #a02727; overflow-wrap: anywhere; }
.bitrix-search-card { padding: 20px 24px; }
.bitrix-queue-search-form { display: grid; gap: 10px; }
.bitrix-task-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 6px 0; }
.bitrix-task-filters select { max-width: 100%; min-width: 0; }
.stage-edits summary { cursor: pointer; font-weight: 700; }
.stage-reset-confirm { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
.stage-reset-confirm input { width: auto; margin-top: 3px; flex-shrink: 0; }
.bitrix-queue-search-form label { font-size: 14px; }
.bitrix-queue-search-controls { display: flex; align-items: stretch; gap: 10px; min-width: 0; }
.bitrix-queue-search-controls input { flex: 1 1 auto; min-width: 0; width: auto; max-width: 520px; }
.bitrix-queue-search-controls button, .bitrix-queue-search-controls .button { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.bitrix-queue-table-card { padding: 0; overflow-x: auto; }
.bitrix-queue-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 24px; border-bottom: 1px solid #edf0f4; }
.bitrix-queue-list-head h2 { margin: 0; font-size: 18px; }
.bitrix-queue-list-head .muted { font-size: 13px; white-space: nowrap; }
.bitrix-queue-table-card td { overflow-wrap: anywhere; }
@media (min-width: 761px) {
  .bitrix-queue-table-card td[data-label="DP"] {
    min-width: 210px;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }
}
.bitrix-queue-pagination { justify-content: center; flex-wrap: wrap; padding: 18px 20px; }
@media (max-width: 600px) {
  .bitrix-queue-head { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .bitrix-search-card { padding: 16px; }
  .bitrix-queue-search-controls { flex-wrap: wrap; }
  .bitrix-queue-search-controls input { flex-basis: 100%; max-width: none; }
  .bitrix-queue-search-controls button, .bitrix-queue-search-controls .button { flex: 1 1 auto; }
  .bitrix-queue-list-head { padding: 16px; }
  .bitrix-queue-list-head .muted { white-space: normal; text-align: right; }
  .bitrix-queue-table-card { padding: 0 14px 14px; }
  .bitrix-queue-list-head { margin: 0 -14px 14px; }
}

/* RU / RO language switch, available even before sign-in. */
.language-switch { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border-radius: 10px; border: 1px solid #dce3f0; background: #f4f6fb; margin: 0 12px 0 0; flex: 0 0 auto; }
.language-choice { padding: 6px 11px; border: 0; border-radius: 7px; background: transparent; color: #58647b; font-size: 12px; font-weight: 800; line-height: 1.4; cursor: pointer; }
.language-choice.current { background: #315efb; color: #fff; }
.language-choice:focus-visible { outline: 2px solid #315efb; outline-offset: 2px; }
@media(max-width: 950px) { .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; } .language-switch { margin-left: auto; } }

/* Lawyer has returned a result: distinguish completed handoff from pending steps. */
.status-lawyer-replied { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* Workflow stage colors: DP blue, signature yellow, lawyer handling green. */
.status-stage-blue { background: #eaf1ff; color: #2457bb; border: 1px solid #cbdcff; }
.status-stage-yellow { background: #fff3cd; color: #8a5700; border: 1px solid #f5d978; }
.status-stage-green { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* Define stage variables in the stylesheet: CSP disallows inline style attributes. */
[data-stage-color="#9CA3AF"] { --stage-color: #9CA3AF; }
[data-stage-color="#F97316"] { --stage-color: #F97316; }
[data-stage-color="#FACC15"] { --stage-color: #FACC15; }
[data-stage-color="#A3E635"] { --stage-color: #A3E635; }
[data-stage-color="#22C55E"] { --stage-color: #22C55E; }
[data-stage-color="#15803D"] { --stage-color: #15803D; }

/* Business workflow: red is reserved for errors and overdue work. */
.status-workflow {
  background-color: var(--stage-color, #9CA3AF);
  color: var(--stage-text, #17202a);
  border: 1px solid var(--stage-color, #9CA3AF);
  padding: 8px 12px;
  font-weight: 700;
  line-height: 1.4;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px #17202a12;
}
.status-workflow[data-stage-color="#15803D"] { color: var(--stage-text, #fff); }
.flash.error, .bitrix-queue-sync-error { color: #DC2626; }
.workflow-group-nav { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.workflow-group-nav a { padding: 10px 16px; background: #fff; border: 1px solid #d9e0e8; border-radius: 8px; }
.workflow-group-nav span { margin-left: 8px; font-weight: 700; }
.workflow-group { scroll-margin-top: 24px; margin: 30px 0; }


/* Compact service lists and expandable document sheets. */
select { max-width: 100%; padding: 9px; border: 1px solid #cfd6e1; border-radius: 8px; background: #fff; font: inherit; }
.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; }
.workspace-table { min-width: 1100px; }
.workspace-table th, .workspace-table td { padding: 16px 12px; }
.workspace-table td { max-width: 340px; overflow-wrap: anywhere; }
.workspace-table .status { min-width: 130px; max-width: 200px; }
.workspace-table .small-date { min-width: 125px; font-size: 12px; }
.workspace-table .case-task-text { min-width: 170px; white-space: pre-wrap; }
.workspace-table .case-open-cell { width: 150px; min-width: 150px; }
.workspace-table .case-open-cell .button { white-space: nowrap; }
.workspace-table .row-upload-form { min-width: 220px; max-width: 300px; }
.workflow-icon { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; font-size: 22px; }
.service-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.service-selector select { min-width: 120px; width: 180px; font-size: 12px; }
.case-service { margin: 8px 0; }
.row-upload-form { display: grid; gap: 9px; }
.row-upload-form input[type=file] { padding: 6px; font-size: 12px; }
.row-upload-form label { font-size: 12px; }
.row-upload-form .file-preview-grid { grid-template-columns: 1fr; }
.row-upload-form .file-preview-image { height: 90px; }
.document-sheet { margin-top: 12px; }
.document-sheet summary { cursor: pointer; color: #315efb; font-size: 13px; }
.document-export-selection { flex-basis: 100%; width: 100%; }
.document-export-checkbox { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.document-export-checkbox input { width: auto; }
.document-export-selection textarea { max-width: 520px; }
.document-export-controls { margin-top: 16px; padding-top: 16px; border-top: 1px solid #dfe5ef; }
.document-export-controls p { margin: 0; }
.document-export-controls [hidden], .document-export-selection [hidden] { display: none; }
.bitrix-passport-choice { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0; }
.bitrix-passport-choice label { display: flex; align-items: flex-start; gap: 8px; overflow-wrap: anywhere; }
.bitrix-passport-choice input { width: auto; flex-shrink: 0; }
.bitrix-passport-choice a { margin-left: auto; }
.document-sheet-body { display: grid; gap: 12px; margin-top: 12px; }
.document-sheet-file { display: grid; gap: 7px; padding: 10px; border: 1px solid #e4e8ef; border-radius: 8px; font-size: 12px; background: #f8fafc; }
.document-sheet-file .actions { gap: 12px; flex-wrap: wrap; }
.document-sheet-thumbnail { width: 100%; max-height: 200px; object-fit: contain; }
.row-upload-form [hidden] { display: none !important; }

.continue-case-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid #dfe5ef;
  border-radius: 16px;
  color: inherit;
  background: #f5f7fb;
  box-shadow: 0 24px 80px #18243b40;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.continue-case-dialog::backdrop { background: #18243b80; }
.delete-case-dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid #e3e8ef;
  border-radius: 16px;
  padding: 24px;
  color: inherit;
  box-shadow: 0 24px 80px #18243b40;
}
.delete-case-dialog::backdrop { background: #18243b80; }
.delete-case-dialog h2 { margin-top: 0; }
.delete-case-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.delete-case-dialog button:disabled { opacity: .45; cursor: not-allowed; }
body:has(.delete-case-dialog[open]) { overflow: hidden; }
.continue-case-dialog > .section-head { margin-bottom: 16px; }
.continue-case-dialog > .section-head h2 { margin: 0; }
.continue-case-dialog .card { margin-bottom: 16px; }
body:has(.continue-case-dialog[open]) { overflow: hidden; }
@media (max-width: 600px) {
  .continue-case-dialog { padding: 16px; max-height: calc(100dvh - 24px); }
}

/* Stage colors identify statuses; alternating neutral backgrounds distinguish rows. */
.workflow-legend { display: flex; flex-wrap: wrap; gap: 12px 20px; padding: 16px 20px; background: #fff; border: 1px solid #dfe5ef; border-radius: 14px; }
.workflow-legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.workflow-swatch { display: inline-block; flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--stage-color); }
.workflow-legend-note { display: flex; align-items: center; gap: 8px; flex-basis: 100%; margin: 0; color: #64748b; font-size: 12px; }
.workflow-problem-swatch { background: #DC2626; }
.workspace-table tbody > tr:nth-child(odd) > td,
.dp-bitrix-table tbody > tr:nth-child(odd) > td { background-color: #FFFFFF; }
.workspace-table tbody > tr:nth-child(even) > td,
.dp-bitrix-table tbody > tr:nth-child(even) > td { background-color: #EEF2F7; }
.workspace-table tbody > tr:hover > td,
.dp-bitrix-table tbody > tr:hover > td { background-color: #E2E8F0; }
.workspace-table .workflow-row > td:first-child { border-left: 4px solid var(--stage-color); }
.workflow-row .workflow-icon { color: var(--stage-text, #17202a); background: var(--stage-color); border-radius: 8px; font-size: 18px; }
.workflow-row[data-stage-color="#15803D"] .workflow-icon { color: var(--stage-text, #fff); }

.service-process-settings summary { cursor: pointer; color: #315efb; font-weight: 600; }
.process-editor { margin-top: 18px; }
.process-editor fieldset { min-width: 0; padding: 0; border: 0; }
.process-editor fieldset:disabled { opacity: .55; }
.process-enabled { display: flex; align-items: center; gap: 10px; }
.process-enabled input { width: auto; }
.process-step-list { display: grid; gap: 14px; padding-left: 30px; }
.process-step { padding: 16px; border: 1px solid #dfe5ef; border-radius: 12px; background: #f5f7fb; }
.process-step::marker { font-weight: 700; }
.process-step label { display: block; margin-bottom: 10px; }
.process-step input, .process-step select { display: block; width: 100%; box-sizing: border-box; margin-top: 5px; }
.process-step-controls { margin-top: 12px; flex-wrap: wrap; }
.process-progress { margin-top: 8px; }

.process-step input[type=color] { width: 64px; height: 42px; padding: 3px; cursor: pointer; }
.process-color-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.process-color-controls output { font-family: monospace; }

.case-comments { margin-top: 12px; }
.case-comments > summary { cursor: pointer; font-weight: 600; }
.case-comment { margin: 10px 0; padding-bottom: 10px; border-bottom: 1px solid #dfe5ef; }
.dossier-number-control { margin-top: 12px; }
