/* Общие стили сайта: крупный шрифт, спокойные цвета, ничего лишнего.
   Фирменные цвета «Энергострой»: чёрный и оранжевый #F05F23 (из логотипа). */
:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --text: #1c1c1c;
  --muted: #5f5f5f;
  --border: #dcdcd8;
  --brand: #f05f23;        /* фирменный оранжевый — акценты на чёрном фоне */
  --brand-dark: #111111;   /* фирменный чёрный — шапка */
  --accent: #c2410c;       /* оранжевый потемнее — кнопки и ссылки на белом (читаемый контраст) */
  --accent-hover: #a8380a;
  --accent-soft: #fff1ea;  /* светлый оранжевый фон */
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

.topbar {
  background: var(--brand-dark);
  border-bottom: 4px solid var(--brand);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  text-decoration: none;
}

.brand img { height: 44px; width: auto; display: block; }
.brand span { padding-left: 14px; border-left: 1px solid #444; }
.brand:hover { color: #fff; }

.usermenu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  color: #ddd;
}

.usermenu a,
.usermenu .link-button {
  color: #fff;
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.usermenu a:hover,
.usermenu .link-button:hover { color: #fff; border-bottom-color: var(--brand); }
.usermenu a.current { border-bottom-color: var(--brand); }
.usermenu .user-name { color: #aaa; font-size: 15px; }

.link-button {
  color: var(--accent);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.usermenu form { margin: 0; }

.login-box {
  max-width: 360px;
  margin: 0 auto;
}

.login-box label {
  display: block;
  margin-top: 16px;
  font-weight: 600;
}

.login-box input[type="text"],
.login-box input[type="password"] {
  width: 100%;
  padding: 10px;
  font-size: 17px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.button {
  margin-top: 20px;
  padding: 10px 24px;
  font-size: 17px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.button:hover { background: var(--accent-hover); color: #fff; }
a.button:hover { color: #fff; }

.error {
  color: #a4161a;
  background: #fdecea;
  padding: 10px;
  border-radius: 6px;
}

.warning {
  color: #6b4a00;
  background: #fff4d6;
  border: 1px solid #f0c75e;
  padding: 12px;
  border-radius: 6px;
}

.success {
  color: #1b5e20;
  background: #e8f5e9;
  padding: 10px;
  border-radius: 6px;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.inline-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.inline-form .row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-form input[type="text"] {
  padding: 10px;
  font-size: 17px;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 16em;
  max-width: 100%;
}

.inline-form .button { margin-top: 0; }

.contract-preview {
  margin: 12px 0;
  padding: 14px 18px;
  background: #fafaf7;
  border-left: 4px solid var(--accent);
  font-family: "Times New Roman", serif;
  font-size: 17px;
}

/* --- Форма договора --- */
.contract-form fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px 20px;
  margin: 0 0 20px;
}

.contract-form fieldset.danger { border-color: #f0c75e; background: #fff8e6; }

.contract-form legend {
  font-weight: 700;
  font-size: 19px;
  padding: 0 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px 18px;
}

.field.wide { grid-column: 1 / -1; }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: 9px 10px;
  font-size: 17px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.field label.checkbox { font-weight: 600; display: flex; gap: 10px; align-items: center; }
.field label.checkbox input { width: 20px; height: 20px; }

.field.has-error input,
.field.has-error select { border-color: #a4161a; background: #fdf3f2; }

.req { color: #a4161a; }
.help { color: var(--muted); font-size: 15px; margin-top: 4px; }
.help.ok { color: #1b5e20; }
.field-error { color: #a4161a; font-size: 15px; margin-top: 4px; }
.small { font-size: 15px; font-weight: normal; }

.actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.actions .button { margin-top: 0; }
.button.big { font-size: 19px; padding: 12px 32px; }
.button.secondary { background: #fff; color: var(--accent); border: 2px solid var(--accent); }
.button:disabled { background: #9aa5b1; cursor: not-allowed; }

.requisites {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.warning a { color: inherit; }

/* --- Реестр --- */
.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.title-row .button { margin-top: 0; }

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 20px;
  font-size: 16px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th { background: var(--bg); font-weight: 600; }
.table tbody tr:hover { background: var(--accent-soft); }

.row-actions { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }
.link-button.danger-link { color: #a4161a; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px 16px;
  align-items: end;
  padding: 14px;
  background: var(--bg);
  border-radius: 8px;
}

.filters .field input,
.filters .field select {
  width: 100%;
  padding: 8px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.filter-buttons { display: flex; gap: 14px; align-items: center; }
.filter-buttons .button { margin-top: 0; }

.badge {
  display: inline-block;
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 10px;
  background: #fdecea;
  color: #a4161a;
}

.pager { display: flex; gap: 20px; justify-content: center; margin: 10px 0; }

@media (max-width: 700px) {
  .table { display: block; overflow-x: auto; }
}

.help-steps li { margin-bottom: 12px; }

/* --- Короткая форма договора: блоки, краткие строки, панель «Осталось заполнить» --- */
.block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 20px 18px;
  margin: 0 0 16px;
}

.block.danger { border-color: #f0c75e; background: #fff8e6; }
.block h2 { font-size: 19px; margin: 0 0 10px; }
.block h3 { font-size: 17px; margin: 18px 0 8px; }

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.link-button.toggle {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.link-button.toggle::before { content: "✎ "; }
.link-button.toggle[aria-expanded="true"]::before { content: "▴ "; }

.block-fields { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }

.summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
}

.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.phrase { margin: 0; line-height: 1.6; }
.missing { color: #a4161a; font-style: italic; }

.field input.need,
.field select.need,
.field textarea.need { border-color: #e0a100; background: #fffbea; }

.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px -24px -24px;
  padding: 12px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.submit-buttons { display: flex; align-items: center; gap: 18px; }
.submit-buttons .button { margin-top: 0; }
.todo { font-size: 15px; color: #8a5a00; }
.todo.done { color: #1b5e20; }

/* Кнопка «Сообщить о проблеме» не должна закрывать панель с кнопкой «Проверить» */
.contract-form ~ .feedback-button,
body:has(.submit-bar) .feedback-button { bottom: 84px; }

/* Блок «Заполнить из карточки» */
.card-box {
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 20px;
  background: var(--accent-soft);
}

.card-box summary { font-weight: 600; cursor: pointer; color: var(--accent); }
.card-drop { margin-top: 12px; border-radius: 6px; }
.card-drop.dragging { outline: 3px dashed var(--accent); outline-offset: 4px; }

.card-drop textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.card-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.card-actions .button { margin-top: 0; }
.file-label { display: inline-block; }

input.from-card, textarea.from-card { background: #fff8d6 !important; }

/* Проверка номеров при вводе */
.live-check { font-size: 15px; margin-top: 4px; min-height: 0; }
.live-check.good { color: #1b5e20; }
.live-check.bad { color: #a4161a; }

/* --- Кнопка и окно «Сообщить о проблеме» --- */
.feedback-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 10;
}

.feedback-button:hover { background: var(--accent-soft); }

.feedback-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
}

.feedback-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.feedback-dialog h2 { margin-top: 0; }
.feedback-dialog label { display: block; font-weight: 600; margin: 12px 0 4px; }

.feedback-dialog textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

#feedback-preview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 10px;
  border: 1px solid var(--border);
}

#feedback-preview[hidden] { display: none; }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  font-size: 14px;
}

.link-button.dark { color: var(--text); }

.badge-count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e5484d;
  color: #fff;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

@media print {
  .feedback-button, .topbar { display: none; }
}

.muted { color: var(--muted); }

.info {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
}

.info dt { color: var(--muted); }
.info dd { margin: 0; }

.brand {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.page {
  max-width: 960px;
  margin: 24px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
