:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e3e7ec;
  --text: #1f2933;
  --muted: #7b8794;
  --accent: #0d6efd;

  --st-open: #6c757d;
  --st-in_progress: #0d6efd;
  --st-done: #198754;
  --st-closed: #343a40;
  --st-cancelled: #dc3545;

  --due-overdue: #dc3545;
  --due-active: #198754;
}

* { box-sizing: border-box; }

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

/* Каркас страницы: подвал прижат к низу даже на коротких страницах. */
body.app { min-height: 100vh; display: flex; flex-direction: column; }
body.app > main { flex: 1 0 auto; }
.footer {
  flex-shrink: 0;
  padding: 14px 20px; text-align: center;
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border);
}

/* Шапка */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 20px;
  background: #1f2933; color: #fff;
}
.topbar__brand { font-weight: 600; font-size: 16px; }
.topbar__nav { display: flex; align-items: center; gap: 16px; }
.topbar__user { color: #c7d0d9; text-decoration: none; }
a.topbar__user:hover { color: #fff; text-decoration: underline; }
.topbar__link { color: #fff; text-decoration: none; opacity: .9; }
.topbar__link:hover { opacity: 1; text-decoration: underline; }

/* Контейнер */
.container { max-width: 1180px; margin: 0 auto; padding: 18px 20px 48px; }

/* Фильтры */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.filters__select, .filters__search {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 14px; color: var(--text);
}
.filters__search { flex: 1; min-width: 220px; }
.export-btn {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--st-done); border-radius: 6px;
  color: #fff; background: var(--st-done); text-decoration: none; font-size: 14px;
}
.export-btn:hover { filter: brightness(1.06); }
.filters__count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* Объект — одна строка */
.object {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 12px;
}
.object__row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 16px; background: #fbfcfd;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none; color: var(--text); cursor: pointer;
}
.object__row:hover { background: #eef4ff; }
.object__code {
  font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums;
}
.object__name { font-weight: 600; }
.object__sep { color: #c3ccd5; }
.object__customer { color: #55606b; }
.object__addr { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.object__count {
  margin-left: auto; background: #eef1f4; color: #55606b;
  border-radius: 10px; padding: 1px 9px; font-size: 12px; flex: none;
}

/* Заявки */
.requests { padding: 4px 16px 8px 36px; }
.request {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px dashed #eef1f4;
}
.request:last-child { border-bottom: none; }
.request__id {
  color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 74px; flex: none;
}
.request__date {
  color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 78px; flex: none;
}
.request__text { flex: 1; min-width: 0; position: relative; }
.request__short {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.request__act {
  white-space: nowrap; font-size: 12px; color: var(--muted);
  min-width: 110px; text-align: right; flex: none;
}
.act-check { color: var(--st-done); font-weight: 700; }
.request__due {
  white-space: nowrap; font-size: 13px; color: var(--muted);
  min-width: 116px; text-align: right; flex: none;
}

/* Тултип с полным текстом по наведению */
.tooltip {
  display: none; position: absolute; left: 0; top: 100%; z-index: 20;
  margin-top: 4px; max-width: 560px; width: max-content;
  background: #2b333c; color: #f2f5f8;
  font-size: 12px; line-height: 1.5;
  padding: 8px 10px; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.request__text:hover .tooltip { display: block; }
.due-overdue { color: var(--due-overdue); font-weight: 600; }
.due-active { color: var(--due-active); font-weight: 600; }
.request--empty { color: var(--muted); font-style: italic; }
.request--act { padding: 1px 0; font-size: 11px; border-bottom: none; gap: 8px; }
.request--act .request__id { color: var(--st-done); font-weight: 600; }
.request--act .act__file { color: var(--accent); text-decoration: none; }
.request--act .act__file:hover { text-decoration: underline; }
.request--act-sub { padding-left: 24px; }
.request__id--wide { min-width: 96px; }

/* Бейджи статусов (кликабельные) */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff;
  white-space: nowrap; flex: none;
}
.js-status { cursor: pointer; user-select: none; }
.js-status:hover { filter: brightness(1.08); }
.js-status.is-saving { opacity: .5; pointer-events: none; }
.badge-open { background: var(--st-open); }
.badge-in_progress { background: var(--st-in_progress); }
.badge-done { background: var(--st-done); }
.badge-closed { background: var(--st-closed); }
.badge-cancelled { background: var(--st-cancelled); }

/* Выравнивание статусов в столбик на главной (фикс. ширина пилюль) */
.request .badge { text-align: center; }
.request .badge:not(.badge--outline) { min-width: 96px; }
.request .badge--outline { min-width: 152px; text-align: left; }

.badge--outline { background: transparent !important; border: 1px solid currentColor; font-weight: 500; }
.badge--outline.badge-open { color: var(--st-open); }
.badge--outline.badge-in_progress { color: var(--st-in_progress); }
.badge--outline.badge-done { color: var(--st-done); }
.badge--outline.badge-closed { color: var(--st-closed); }
.badge--outline.badge-cancelled { color: var(--st-cancelled); }

/* Скрытие при фильтрации */
.object.is-hidden { display: none; }

/* Страница загрузки */
.container--narrow { max-width: 720px; }
.page-title { font-size: 20px; margin: 0 0 16px; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert--error { background: #fdeaea; color: #a12; border: 1px solid #f5c2c2; }
.alert--ok { background: #e8f6ee; color: #1a6b3d; border: 1px solid #bfe6cd; }
.report {
  width: 100%; border-collapse: collapse;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; margin-bottom: 14px;
}
.report td { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.report tr:last-child td { border-bottom: none; }
.report td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
/* Широкая таблица (>2 колонок): шапка, выравнивание по левому краю. */
.report--wide th {
  padding: 8px 14px; text-align: left; font-weight: 600;
  background: #f0f3f7; border-bottom: 1px solid var(--border);
}
.report--wide td { text-align: left; font-weight: 400; }
.report--wide td:last-child { text-align: left; font-weight: 400; }
.upload {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-bottom: 14px;
}
.upload__file { flex: 1 1 200px; min-width: 0; }
.upload__btn {
  height: 36px; padding: 0 18px; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 14px; cursor: pointer;
  white-space: nowrap; flex: none;
}
.upload__btn:hover { filter: brightness(1.06); }
.hint { color: var(--muted); font-size: 13px; }
.hint code { background: #eef1f4; padding: 1px 6px; border-radius: 4px; }

/* Форма редактирования */
.form {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 18px;
}
.form__fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.form__row { margin-bottom: 14px; }
.form__field { margin-bottom: 14px; }
/* Несколько полей в одну строку. */
.form__grid { display: grid; gap: 14px; margin-bottom: 14px; }
.form__grid .form__field { margin-bottom: 0; }
.form__grid--code-name { grid-template-columns: minmax(110px, 1fr) 2fr; }
.form__grid--contacts { grid-template-columns: 1.6fr 1.3fr 0.8fr 1.5fr; }
@media (max-width: 640px) {
  .form__grid { grid-template-columns: 1fr; }
}
.form__label { display: block; font-size: 13px; color: #55606b; margin-bottom: 4px; }
.form input[type="text"], .form input[type="number"], .form input[type="email"],
.form input[type="password"], .form select, .form textarea {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text); background: #fff;
}
.form textarea { height: auto; padding: 8px 10px; }
.form input[type="checkbox"] { width: 18px; height: 18px; }
.form__err { color: #dc3545; font-size: 13px; margin-top: 4px; }
.form__actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* Акты */
.acts { list-style: none; margin: 0 0 12px; padding: 0; }
.act {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px;
}
.act__date { font-variant-numeric: tabular-nums; min-width: 92px; font-weight: 600; }
.act__date--btn {
  border: none; background: transparent; padding: 0; text-align: left;
  font: inherit; font-weight: 600; color: var(--accent); cursor: pointer;
}
.act__date--btn:hover { text-decoration: underline; }
.act__file { color: var(--accent); text-decoration: none; }
.act__file:hover { text-decoration: underline; }
.act__target { color: var(--muted); font-size: 13px; }
.acts--compact .act { padding: 6px 10px; background: #fbfcfd; }
.act__del { margin-left: auto; }
.act__delbtn {
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer; line-height: 1; padding: 2px 6px;
}
.act__delbtn:hover { color: #dc3545; }

/* Форма загрузки акта с drag-and-drop */
.actform {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 8px 0 4px;
}
.actform__date {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text); background: #fff;
}
.dropzone {
  flex: 1 1 240px; min-width: 0; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 12px; cursor: pointer;
  border: 1px dashed var(--border); border-radius: 6px;
  background: #fbfcfd; color: var(--muted); font-size: 13px;
  text-align: center;
}
.dropzone:hover { border-color: var(--accent); color: var(--accent); }
.dropzone--over { border-color: var(--accent); background: #eef4ff; color: var(--accent); }
.dropzone--filled { border-style: solid; color: var(--text); }
.req-card__acts { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* Страница входа */
.login-page {
  min-height: 100vh; margin: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px; width: min(360px, 92vw);
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.login-card__brand { font-size: 20px; font-weight: 700; }
.login-card__sub { color: var(--muted); margin: 2px 0 18px; }
.login-card__links { margin-top: 16px; text-align: center; font-size: 13px; }
.login-card__links a { color: var(--accent); text-decoration: none; }
.login-card__links a:hover { text-decoration: underline; }
.login-input {
  width: 100%; height: 40px; padding: 0 12px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text); background: #fff;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  width: 100%; height: 42px; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.login-btn:hover { filter: brightness(1.06); }

/* Кнопка «Выйти» в шапке (как ссылка) */
.topbar__logout { margin: 0; }
.topbar__logout button {
  border: none; background: transparent; color: #fff;
  font: inherit; cursor: pointer; opacity: .9; padding: 0;
}
.topbar__logout button:hover { opacity: 1; text-decoration: underline; }

/* Миниатюрная ссылка «загрузить акт» */
.act-link {
  display: inline-block; margin-top: 6px;
  font-size: 13px; color: var(--accent);
  text-decoration: none; cursor: pointer;
}
.act-link:hover { text-decoration: underline; }

/* Тост (уведомление без перезагрузки) */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 200; padding: 10px 18px; border-radius: 8px;
  color: #fff; font-size: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.toast--ok { background: var(--st-done); }
.toast--err { background: var(--st-cancelled); }

/* Модальное окно загрузки акта */
.modal { position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal__dialog {
  position: relative; background: #fff; border-radius: 10px;
  width: min(440px, 92vw); padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal__title { font-weight: 600; font-size: 16px; }
.modal__close {
  border: none; background: transparent; color: var(--muted);
  font-size: 16px; cursor: pointer; line-height: 1;
}
.modal__close:hover { color: var(--text); }
.actform--modal { flex-direction: column; align-items: stretch; gap: 12px; margin: 0; }
.actform--modal .dropzone { min-height: 96px; }
.actform--modal .upload__btn { align-self: flex-start; }

/* Заявки на карточке объекта */
.subtitle { font-size: 16px; margin: 22px 0 12px; }
.req-cards { display: flex; flex-direction: column; gap: 10px; }
.req-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 12px;
}
.req-card__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.req-card__text {
  font-size: 11px; line-height: 1.5; color: var(--text);
  white-space: normal;
}

/* Toolbar главной */
.toolbar-link {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--accent); border-radius: 6px;
  color: var(--accent); text-decoration: none; font-size: 14px; background: #fff;
}
.toolbar-link:hover { background: var(--accent); color: #fff; }

/* Пусто */
.empty {
  background: var(--card); border: 1px dashed var(--border);
  border-radius: 8px; padding: 40px; text-align: center; color: var(--muted);
}
.empty code { background: #eef1f4; padding: 1px 6px; border-radius: 4px; }
