/* ============================================================
   Оболочка сервиса: список КП, вход, панели режимов.
   Палитра наследуется из document.css (переменные :root).
   ============================================================ */

.back-link {
  color: var(--c-teal);
  font-weight: 700;
  white-space: nowrap;
}
.back-link:hover { text-decoration: underline; }
.brand-sep {
  width: 1px; height: 18px;
  background: rgba(255,255,255,0.25);
  display: inline-block;
}

.btn-send {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-send:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  transform: translateY(-2px);
}

.badge-approved {
  background: rgba(16,185,129,0.18);
  color: #34d399;
  border: 1px solid rgba(16,185,129,0.4);
  padding: 5px 12px; border-radius: 6px;
  font-weight: 800; font-size: 11.5px;
}

/* ---------- диалоги ---------- */

.send-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  z-index: 100000;
  opacity: 0; visibility: hidden;
  transition: all 0.25s ease;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.send-overlay.active { opacity: 1; visibility: visible; }

.send-dialog {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%; max-width: 520px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}
.send-dialog h3 {
  margin: 0 0 10px 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 17px; font-weight: 800;
  color: var(--primary-dark);
}
.send-note { font-size: 13px; color: var(--text-muted); margin: 0 0 16px 0; line-height: 1.5; }
.send-link-row { display: flex; gap: 8px; }
.send-link-row input {
  flex: 1; padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px;
  background: #f8fafc;
}
.send-status { font-size: 12.5px; margin: 12px 0 0 0; line-height: 1.45; }
.send-status.warn { color: #b45309; }
.send-status.ok { color: #047857; }
.send-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.approve-check-list { margin: 4px 0 14px 0; }
.approve-check-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: #f1f5f9; margin-bottom: 6px; font-size: 13px;
}
.approve-check-row.muted { color: var(--text-muted); font-style: italic; }
.approve-comment-label {
  display: block; font-size: 12.5px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 4px;
}
.approve-comment-label textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 2px solid var(--border-color);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 13px;
  resize: vertical;
}

/* ---------- полоса согласования у клиента ---------- */

.approve-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--c-black);
  border-top: 2px solid var(--c-teal);
  padding: 12px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; z-index: 9999;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
}
.approve-summary { color: var(--c-cream); font-size: 13px; font-weight: 600; }
.approve-bar.done { border-top-color: #10b981; }
.btn-approve {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff; font-size: 14.5px; padding: 11px 26px;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-approve:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
}
.btn-approve:disabled { opacity: 0.75; cursor: default; }

body.mode-client .document-wrapper { margin-bottom: 90px; }

/* Панели сервиса не должны попадать в PDF и на печать. */
body.pdf-capture .control-bar,
body.pdf-capture .approve-bar,
body.pdf-capture .send-overlay { display: none !important; }
@media print {
  .control-bar, .approve-bar, .send-overlay, .history-drawer, .history-overlay {
    display: none !important;
  }
  body.mode-client .document-wrapper { margin-bottom: 0; }
}

/* ---------- вход ---------- */

.auth-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--c-black); padding: 20px;
}
.auth-card {
  background: var(--c-cream);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-card);
}
.auth-card h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 20px; font-weight: 900;
  margin: 0 0 4px 0; color: var(--primary-dark);
  letter-spacing: 0.5px;
}
.auth-card .sub { font-size: 13px; color: var(--text-muted); margin: 0 0 22px 0; }
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 5px;
}
.auth-field input {
  width: 100%; padding: 11px 13px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; background: #fff;
}
.auth-field input:focus { outline: none; border-color: var(--c-teal); }
.auth-error {
  background: rgba(187,68,48,0.1);
  border: 1px solid rgba(187,68,48,0.35);
  color: var(--c-red);
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 12px;
}
.btn-block { width: 100%; padding: 12px; font-size: 14.5px; }

/* ---------- список КП ---------- */

.app-page { min-height: 100vh; background: var(--c-black); padding-top: 64px; }
.app-main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px 20px; }

.list-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; margin-bottom: 18px;
}
.list-search {
  flex: 1; min-width: 220px;
  padding: 11px 14px;
  border: 2px solid transparent; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  background: rgba(255,255,255,0.1); color: #fff;
}
.list-search::placeholder { color: rgba(255,255,255,0.5); }
.list-search:focus { outline: none; border-color: var(--c-teal); }

.filter-chip {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: var(--transition-smooth);
  white-space: nowrap;
}
.filter-chip:hover { background: rgba(255,255,255,0.18); }
.filter-chip.active {
  background: var(--c-teal); color: #0f172a;
  border-color: var(--c-teal); font-weight: 800;
}

.doc-table {
  width: 100%; border-collapse: collapse;
  background: var(--c-cream);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.doc-table thead th {
  background: var(--c-black); color: var(--c-cream);
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 12px 14px; text-align: left;
}
.doc-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px; vertical-align: middle;
}
.doc-table tbody tr:last-child td { border-bottom: none; }
.doc-table tbody tr { transition: background 0.15s ease; cursor: pointer; }
.doc-table tbody tr:hover { background: #fff; }
.doc-client { font-weight: 800; color: var(--primary-dark); }
.doc-num { font-size: 12px; color: var(--text-muted); }
.doc-total { font-weight: 800; text-align: right; white-space: nowrap; }

.st {
  display: inline-block; padding: 4px 10px;
  border-radius: 12px; font-size: 10.5px;
  font-weight: 900; text-transform: uppercase;
  letter-spacing: 0.4px; white-space: nowrap;
}
.st-draft    { background: #e2e8f0; color: #475569; }
.st-sent     { background: rgba(56,189,248,0.2); color: #0369a1; }
.st-approved { background: rgba(16,185,129,0.2); color: #047857; }
.st-paid     { background: rgba(16,185,129,0.35); color: #065f46; }
.st-archived { background: #f1f5f9; color: #94a3b8; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn {
  background: #fff; border: 1px solid var(--border-color);
  border-radius: 6px; padding: 5px 10px;
  font-size: 11.5px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: var(--transition-smooth);
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--c-teal); color: var(--c-teal); }
.mini-btn.danger:hover { border-color: var(--c-red); color: var(--c-red); }

.list-empty {
  background: var(--c-cream); border-radius: var(--radius-md);
  padding: 60px 24px; text-align: center;
  color: var(--text-muted); font-size: 14px;
}

@media (max-width: 720px) {
  .doc-table thead { display: none; }
  .doc-table tbody tr {
    display: block; padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
  }
  .doc-table tbody td {
    display: flex; justify-content: space-between;
    gap: 12px; padding: 4px 0; border: none;
  }
  .doc-table tbody td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 800;
    color: var(--text-muted); text-transform: uppercase;
  }
  .doc-total { text-align: left; }
  .row-actions { justify-content: flex-start; margin-top: 8px; }
  .approve-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .approve-summary { text-align: center; font-size: 12px; }
}

/* ---------- ответ клиента (виден менеджеру) ---------- */

.client-response {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 330px;
  max-width: calc(100vw - 36px);
  background: #ffffff;
  border: 2px solid var(--c-teal);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
  z-index: 9998;
}
.cr-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.cr-title { font-weight: 800; font-size: 13px; color: var(--primary-dark); }
.cr-when { font-size: 11px; color: var(--text-muted); }
.cr-picks { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.cr-pick {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; padding: 5px 9px;
  background: rgba(56,189,248,0.12); border-radius: 6px;
}
.cr-pick strong { color: var(--primary-dark); }
.cr-comment {
  font-size: 12.5px; line-height: 1.45; color: var(--text-main);
  background: #f8fafc; border-left: 3px solid var(--c-teal);
  padding: 8px 10px; border-radius: 4px; margin-bottom: 10px;
  white-space: pre-wrap; word-break: break-word;
}
.client-response .btn-sm { width: 100%; font-size: 12px; padding: 7px 10px; }

body.pdf-capture .client-response { display: none !important; }
@media print { .client-response { display: none !important; } }
@media (max-width: 768px) {
  .client-response { right: 10px; left: 10px; width: auto; bottom: 10px; }
}

/* отметка о комментарии в списке КП */
.has-comment {
  margin-left: 6px; cursor: help;
  font-size: 13px; vertical-align: middle;
}

/* ---------- предупреждение о конфликте правок ---------- */

.conflict-bar {
  position: fixed; left: 0; right: 0; top: 64px;
  background: #7f1d1d; color: #fff;
  padding: 12px 22px; z-index: 100002;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.conflict-bar .btn { flex-shrink: 0; }
@media print { .conflict-bar { display: none !important; } }


/* --- Архив: строка в корзине ------------------------------------------- */
/* Приглушена, чтобы удалённое не читалось как рабочий документ,
   и не реагирует на курсор — по ней не открывают, а восстанавливают. */
.doc-table tr.row-trashed {
  opacity: .62;
  cursor: default;
}
.doc-table tr.row-trashed:hover {
  background: transparent;
}
.doc-table tr.row-trashed .doc-client {
  text-decoration: line-through;
}
