:root {
  --paper: #f3eee4;
  --card: #faf7f1;
  --ink: #1c1916;
  --muted: #6b635b;
  --line: #ddd4c6;
  --forest: #1f3d34;
  --forest-fg: #f3eee4;
  --stamp: #9a3412;
  --amber: #b45309;
  --moss: #3f6b4a;
  --wash: #efe8db;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 Manrope, Segoe UI, sans-serif; }
h1, h2 { font-family: Georgia, "Iowan Old Style", serif; font-weight: 500; letter-spacing: -0.03em; }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-family: Georgia, serif; font-size: 22px; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav a, .btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font: inherit; }
.btn.primary { background: var(--forest); color: var(--forest-fg); border-color: var(--forest); }
.btn.danger { color: var(--stamp); border-color: #e8b4a4; background: #fff8f5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; align-items: center; }
.actions form { display: inline; margin: 0; }

.deal {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  border-left: 6px solid var(--line);
  padding: 16px 18px 16px 16px;
  margin: 12px 0;
}
.deal:hover { box-shadow: 0 6px 18px rgba(28, 25, 22, 0.06); }
.deal-overdue { border-left-color: var(--stamp); background: #fbf6f3; }
.deal-wait { border-left-color: var(--amber); background: #fbf8f1; }
.deal-addendum { border-left-color: #7c3aed; background: #f7f3fb; }
.deal-ok { border-left-color: var(--moss); }
.deal-party { font-size: 20px; margin: 4px 0 2px; }
.deal-svc { font-family: Georgia, "Iowan Old Style", serif; font-size: 10px; font-weight: 500; letter-spacing: -0.03em; color: var(--ink); margin: 0 0 4px; }
.card-dup { border-color: #9a3412; background: #fbf6f3; }
.deal-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--wash);
  border-radius: 10px;
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--ink);
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 14px 0 0; }
.meta-row > div { background: var(--wash); border-radius: 10px; padding: 8px 10px; }
.meta-row b { display: block; font-size: 14px; margin-top: 2px; word-break: break-word; }
@media (max-width: 640px) { .meta-row { grid-template-columns: 1fr; } }

.row { display: grid; gap: 12px; }
@media (min-width: 720px) { .row.cols-2 { grid-template-columns: 1fr 1fr; } .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
label.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); font-size: 14px; }
label.chk input { width: auto; min-height: 0; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font: inherit; background: #fffcf7; }
textarea { min-height: 88px; }
.muted { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--wash); margin: 0 6px 6px 0; }
.badge.stamp { background: #f4e1d8; color: var(--stamp); }
.badge.amber { background: #f8e8d2; color: var(--amber); }
.badge.ok { background: #dcead9; color: var(--moss); }
.badge.violet { background: #efe6fb; color: #5b21b6; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi b { font-family: Georgia, serif; font-size: 28px; display: block; }
.matrix { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px; text-align: center; font-size: 12px; }
th:first-child, td:first-child { text-align: left; }
.cell { width: 18px; height: 18px; border-radius: 4px; display: inline-block; }
.cell.ok { background: var(--moss); }
.cell.overdue { background: var(--stamp); }
.cell.current { background: var(--amber); }
.cell.none { border: 1px solid var(--line); }
.flash { background: #dcead9; padding: 10px 14px; border-radius: 12px; margin: 12px 0; }
.error { background: #f4e1d8; color: var(--stamp); padding: 10px 14px; border-radius: 12px; }
.deal-next { border-left-color: #1d4ed8; background: #f3f6fd; }
.deal-child { margin-left: 24px; }
.filters { display: grid; gap: 8px; grid-template-columns: 1fr; margin: 16px 0; }
@media (min-width: 1100px) { .filters { grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr auto auto; align-items: end; } }
.st { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.st-draft { background: #ece7dc; color: #57534e; }
.st-active { background: #dcead9; color: #3f6b4a; }
.st-paused { background: #f8e8d2; color: #b45309; }
.st-expired { background: #f4e1d8; color: #9a3412; }
.st-terminated { background: #e7e5e4; color: #44403c; }
.deal-st-draft { border-left-color: #a8a29e; }
.deal-st-active { border-left-color: #3f6b4a; }
.deal-st-paused { border-left-color: #b45309; }
.deal-st-expired { border-left-color: #9a3412; }
.deal-st-terminated { border-left-color: #57534e; }
.badge.next { background: #dbe4fe; color: #1d4ed8; }
.deal-pin { box-shadow: 0 0 0 1px #1f3d34 inset; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 0 6px 6px 0; }
.tag-court { background: #f4e1d8; color: #9a3412; }
.tag-claim { background: #f8e8d2; color: #b45309; }
.tag-important { background: #dcead9; color: #3f6b4a; }
.tag-hold { background: #e7e5e4; color: #44403c; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.scan-card { display: block; margin: 12px 0; background: #1f3d34; color: #f3eee4; border-radius: 16px; }
.scan-card label { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 88px; padding: 18px; cursor: pointer; color: #f3eee4; font-size: 18px; margin: 0; }
.scan-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scan-card span { font-family: Georgia, serif; }
.st-proc-watch { background: #ece7dc; color: #57534e; }
.st-proc-prepare { background: #f8e8d2; color: #b45309; }
.st-proc-submitted { background: #dbe4fe; color: #1d4ed8; }
.st-proc-admitted { background: #dcead9; color: #3f6b4a; }
.st-proc-rejected { background: #f4e1d8; color: #9a3412; }
.st-proc-bidding { background: #efe6fb; color: #5b21b6; }
.st-proc-won { background: #dcead9; color: #3f6b4a; }
.st-proc-lost { background: #e7e5e4; color: #44403c; }
.st-proc-contract { background: #dcead9; color: #1f3d34; }
.st-proc-refused { background: #f4e1d8; color: #9a3412; }
.st-proc-complaint { background: #f8e8d2; color: #b45309; }
/* Учёт сотрудников / Мед книжки / Уведомления РГ */
.nav a.nav-staff { border-color: var(--forest); }
.sv-wide { width: min(1400px, 96vw); margin-left: 50%; transform: translateX(-50%); }
.sv-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 16px 0; }
.sv-card { background: var(--card); border: 1px solid var(--line); border-left: 6px solid #667eea; border-radius: 12px; padding: 14px; }
.sv-card span { color: var(--muted); font-size: 13px; } .sv-card b { display: block; font-family: Georgia, serif; font-size: 28px; }
.sv-c-ok { border-left-color: #28a745; } .sv-c-warning { border-left-color: #ffc107; } .sv-c-expired { border-left-color: #dc3545; }
.sv-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; margin: 2px 4px; }
.sv-ok { background: #d4edda; color: #155724; } .sv-warning { background: #fff3cd; color: #856404; font-weight: 600; } .sv-expired { background: #fee; color: #c33; font-weight: 600; }
.sv-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sv-filters input[name=search] { flex: 1 1 260px; width: auto; } .sv-filters select { width: auto; }
.sv-fbtns { display: flex; flex-wrap: wrap; gap: 6px; } .sv-export { margin-left: auto; background: #dcead9; }
.sv-scroll { overflow-x: auto; } .sv-table { background: var(--card); }
.sv-table th { background: var(--forest); color: var(--forest-fg); position: sticky; top: 0; }
.sv-table th, .sv-table td { border: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
.sv-emp, .sv-rg { min-width: 1300px; }
.sv-table tr:hover td { filter: brightness(0.98); }
.sv-row-expired td:first-child { border-left: 4px solid #dc3545; } .sv-row-expired { background: #fff5f5; }
.sv-row-warning td:first-child { border-left: 4px solid #ffc107; } .sv-row-warning { background: #fffbeb; }
.sv-row-ok td:first-child { border-left: 4px solid #28a745; }
.sv-actions { white-space: nowrap; } .sv-actions form { display: inline; margin: 0; } .sv-actions .btn { min-height: 34px; padding: 0 10px; }
.sv-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.sv-dot-expired { background: #e74c3c; } .sv-dot-warning { background: #f39c12; } .sv-dot-ok { background: #2ecc71; }
.sv-editing { box-shadow: 0 0 0 2px var(--amber) inset; }
.sv-history { max-height: 500px; overflow-y: auto; } .sv-hist-item { border-bottom: 1px solid var(--line); padding: 8px 0; }
.sv-user { color: #1d4ed8; } .sv-old { color: #c33; } .sv-new { color: #155724; }
.nav a.nav-dj { background: #2f5d7c; color: #fff; border-color: #2f5d7c; }
.sv-viewonly{background:#fff4d6;border:1px solid #e6c46a;border-radius:10px;padding:8px 12px;margin:10px 0}
.sv-perm-matrix{border-collapse:collapse;font-size:13px}.sv-perm-matrix th,.sv-perm-matrix td{border:1px solid #ddd;padding:4px 6px;text-align:center}
.sv-perm-matrix th span{writing-mode:vertical-rl;transform:rotate(180deg);white-space:nowrap}.sv-perm-matrix td:first-child{text-align:left;white-space:nowrap}
.sv-perm-matrix .lv0{color:#aaa}.sv-perm-matrix .lv1{background:#eef4ff}.sv-perm-matrix .lv2{background:#e6f4ea}
.sv-perm-grid{border-collapse:collapse;margin-bottom:8px}.sv-perm-grid td,.sv-perm-grid th{padding:3px 10px;border-bottom:1px solid #eee;text-align:center}.sv-perm-grid td:first-child{text-align:left}
.orgs-table{width:100%;border-collapse:collapse}.orgs-table th,.orgs-table td{padding:6px 8px;border-bottom:1px solid #e5e0d6;text-align:left;vertical-align:middle}.orgs-table input,.orgs-table select{width:100%;min-width:7rem}.orgs-off td{opacity:.55}.orgs-add{margin-top:12px;align-items:flex-end;gap:10px}
/* узкие экраны: широкие таблицы прокручиваются внутри, страница не уезжает вбок */
@media (max-width:700px){main table,.wrap table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}.card{max-width:100%;overflow-wrap:anywhere}}
