/* ЭКОСИСТЕМА · пробная версия. Тема: рабочий документ.
   Гарнитура PT (гос. шрифты РФ), акцент — чертёжная синька. */

:root {
  --paper: #EDF0F3;
  --card: #FFFFFF;
  --ink: #17222B;
  --ink-soft: #5B6B77;
  --line: #D3DAE1;
  --accent: #1D5CA0;
  --accent-deep: #14477E;
  --accent-wash: #E7EEF6;
  --red: #B3362B;
  --red-wash: #F8ECEA;
  --amber: #9A6B00;
  --amber-wash: #F7F0DD;
  --green: #2E7D4F;
  --green-wash: #E7F2EB;
  --gray-wash: #ECEFF1;
  --radius: 6px;
  --shadow: 0 8px 28px rgba(23, 34, 43, .14);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PT Sans", "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

.mono { font-family: "PT Mono", ui-monospace, Consolas, monospace; }

/* ---------- кнопки, поля ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 8px 14px;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-wash); }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--card);
}
.input:focus, .btn:focus-visible, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea.input { width: 100%; resize: vertical; min-height: 90px; }

/* ---------- вход ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: 4px; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; }
.login-error {
  background: var(--red-wash); color: var(--red);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 12px; font-size: .9rem;
}
.login-note { margin-top: 14px; font-size: .8rem; color: var(--ink-soft); text-align: center; }

/* ---------- шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  border: 2px solid var(--accent); color: var(--accent);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: "PT Sans Narrow", "PT Sans", sans-serif;
  font-weight: 700; font-size: 1.35rem;
}
.brand-name {
  font-family: "PT Sans Narrow", "PT Sans", sans-serif;
  font-weight: 700; letter-spacing: .12em; font-size: 1.05rem;
}
.brand-sub { font-size: .72rem; color: var(--ink-soft); letter-spacing: .04em; }
.topnav { display: flex; gap: 4px; margin-left: 10px; }
.nav-btn {
  border: none; background: none; padding: 8px 12px;
  border-radius: var(--radius); color: var(--ink-soft); font-weight: 700;
}
.nav-btn.active { color: var(--accent); background: var(--accent-wash); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 14px; text-align: right; }
.user-name { font-weight: 700; font-size: .95rem; }
.user-role { font-size: .75rem; color: var(--ink-soft); }

/* ---------- страница ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 18px 22px 60px; }
.page-title { font-family: "PT Sans Narrow", sans-serif; letter-spacing: .04em; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; min-width: 108px;
}
.chip b { display: block; font-size: 1.35rem; line-height: 1.2; }
.chip span { font-size: .78rem; color: var(--ink-soft); }
.chip.alert { border-color: var(--red); background: var(--red-wash); }
.chip.alert b { color: var(--red); }
.chip.attn { border-color: var(--amber); background: var(--amber-wash); }
.chip.attn b { color: var(--amber); }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; background: var(--gray-wash); border-radius: var(--radius); padding: 3px; }
.tab {
  border: none; background: none; padding: 6px 11px;
  border-radius: 4px; color: var(--ink-soft); font-size: .9rem;
}
.tab.active { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tab .cnt { font-size: .78rem; color: var(--ink-soft); margin-left: 4px; }
.tab.tab-overdue.active, .tab.tab-overdue .cnt { color: var(--red); }
.toolbar-right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.search { width: 220px; }

/* ---------- таблица ---------- */
.table-wrap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.tasks-table { width: 100%; border-collapse: collapse; }
.tasks-table th {
  text-align: left; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #F7F9FA;
}
.tasks-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tasks-table tbody tr { cursor: pointer; }
.tasks-table tbody tr:hover { background: var(--accent-wash); }
.tasks-table tbody tr.active-row { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.tasks-table tbody tr:last-child td { border-bottom: none; }

/* фирменная деталь: номер-штамп */
.stamp {
  font-family: "PT Mono", monospace; font-size: .82rem;
  border: 1.5px solid var(--ink); border-radius: 3px;
  padding: 2px 7px; white-space: nowrap; letter-spacing: .05em;
  display: inline-block;
}
tr.row-done .stamp, tr.row-canceled .stamp { border-color: var(--ink-soft); color: var(--ink-soft); }

.t-title { font-weight: 700; }
.t-sub { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }
.due { white-space: nowrap; font-family: "PT Mono", monospace; font-size: .88rem; }
.due.overdue { color: var(--red); font-weight: 700; }
.overdue-mark {
  font-family: "PT Sans", sans-serif; font-size: .72rem; display: block; color: var(--red);
}

.pill {
  display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.pill-new { background: var(--accent-wash); color: var(--accent); }
.pill-in_progress { background: #E9E6F5; color: #4A3E8F; }
.pill-review { background: var(--amber-wash); color: var(--amber); }
.pill-done { background: var(--green-wash); color: var(--green); }
.pill-canceled { background: var(--gray-wash); color: var(--ink-soft); }

.prio { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.prio-important { color: var(--amber); font-weight: 700; }
.prio-urgent { color: var(--red); font-weight: 700; }

tr.row-done td, tr.row-canceled td { color: var(--ink-soft); }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }

/* ---------- панель поручения ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(23,34,43,.35); z-index: 30;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(680px, 100%);
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  transform: translateX(0);
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--card); z-index: 2;
}
.drawer-head .stamp { font-size: .95rem; }
.drawer-close { margin-left: auto; border: none; background: none; font-size: 1.5rem; color: var(--ink-soft); line-height: 1; }
.drawer-body { padding: 18px 20px 40px; }
.drawer-title { font-family: "PT Sans Narrow", sans-serif; font-size: 1.45rem; margin: 0 0 14px; letter-spacing: .02em; }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 18px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  background: #FAFBFC;
}
.meta-item span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.meta-item b { font-weight: 700; font-size: .95rem; }
.meta-item .due.overdue { font-size: .95rem; }

.section-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin: 18px 0 8px; font-weight: 700;
}
.descr { white-space: pre-wrap; margin: 0 0 6px; }
.descr.empty-descr { color: var(--ink-soft); font-style: italic; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }

.files-list { list-style: none; margin: 0; padding: 0; }
.files-list li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; }
.files-list a { color: var(--accent); text-decoration: none; font-weight: 700; }
.files-list a:hover { text-decoration: underline; }
.file-meta { font-size: .78rem; color: var(--ink-soft); }
.upload-row { margin-top: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: var(--card); }
.timeline li.kind-system { background: var(--gray-wash); border-style: dashed; font-size: .9rem; }
.timeline li.kind-report { background: var(--amber-wash); border-color: var(--amber); }
.c-head { display: flex; gap: 10px; font-size: .78rem; color: var(--ink-soft); margin-bottom: 3px; }
.c-head b { color: var(--ink); }
.c-text { white-space: pre-wrap; }
.kind-tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }

.comment-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-start; }
.comment-form textarea { flex: 1; min-height: 60px; }

/* ---------- модальное окно ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23,34,43,.45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px;
  overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 520px; padding: 22px;
  border-top: 4px solid var(--accent);
}
.modal h3 { margin: 0 0 16px; font-family: "PT Sans Narrow", sans-serif; letter-spacing: .03em; font-size: 1.3rem; }
.modal .field input, .modal .field select, .modal .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-error { color: var(--red); font-size: .88rem; margin-top: 8px; }

/* ---------- пользователи ---------- */
.user-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.user-add .input { flex: 1; min-width: 140px; }
.u-off td { color: var(--ink-soft); }
.role-tag { font-size: .8rem; color: var(--ink-soft); }
.users-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.users-actions .btn { padding: 4px 10px; font-size: .85rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius);
  z-index: 50; box-shadow: var(--shadow); font-size: .92rem; max-width: 90vw;
}
.toast.error { background: var(--red); }

/* ---------- мобильный ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .userbox { margin-left: auto; }
  .page { padding: 14px 12px 60px; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .search { flex: 1; width: auto; }

  .tasks-table thead { display: none; }
  .tasks-table, .tasks-table tbody, .tasks-table tr, .tasks-table td { display: block; width: 100%; }
  .tasks-table tbody tr { border-bottom: 6px solid var(--paper); padding: 8px 4px; }
  .tasks-table td { border: none; padding: 4px 10px; }
  .tasks-table td[data-label]::before {
    content: attr(data-label) ": ";
    font-size: .75rem; color: var(--ink-soft);
  }
  .drawer { width: 100%; }
}

/* ================================================================ ТАБЕЛИ */

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select.input { width: auto; min-width: 180px; }
.weeknav { display: flex; gap: 6px; align-items: center; }
.weeknav-label { min-width: 205px; text-align: center; font-weight: 600; color: var(--ink); }

.tb-status { display: flex; gap: 10px; align-items: baseline; margin: 4px 0 10px; }

.tb-wrap { overflow-x: auto; }
.tb-table { min-width: 760px; }
.tb-table th.tb-day, .tb-table td.tb-day { text-align: center; padding: 6px 4px; }
.tb-daynum { font-size: .72rem; color: var(--ink-soft); font-weight: 400; }
.tb-table td.tb-name { min-width: 170px; }
.tb-earned { font-size: .8rem; color: var(--accent); margin-top: 2px; }

.tb-in {
  width: 54px; padding: 5px 4px; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: .88rem; background: var(--paper);
  -moz-appearance: textfield;
}
.tb-in::-webkit-outer-spin-button, .tb-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tb-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(29,92,160,.15); }
.tb-in:disabled { background: var(--paper-soft); color: var(--ink-soft); }
.tb-in[readonly] { background: var(--paper-soft); }
.tb-extra { margin-top: 3px; border-style: dashed; }
.tb-money { width: 74px; }
.tb-weekin { width: 92px; font-weight: 600; }
.tb-att input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.tb-week { text-align: center; white-space: nowrap; }
.tb-sum { font-size: .85rem; font-weight: 600; color: var(--ink); }

.req-card { border-left: 3px solid var(--accent); }
.req-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ведомости */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); }
.tab {
  border: none; background: none; padding: 9px 16px; cursor: pointer;
  font: inherit; font-size: .92rem; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.vd-table td.num, .vd-table th.num { text-align: right; }
.vd-table td { white-space: nowrap; }
.bal-plus { color: #1c7a3d; }
.bal-minus { color: var(--danger, #b3261e); }

.norm-label { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--ink-soft); }
.check-line { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: .92rem; cursor: pointer; }
.check-line input { accent-color: var(--accent); }
.two-col { display: grid; grid-template-columns: 1fr 130px; gap: 10px; }

@media (max-width: 720px) {
  .toolbar { gap: 8px; }
  .weeknav-label { min-width: 106px; font-size: .85rem; }
  .tb-in { width: 44px; }
  .tb-money { width: 62px; }
  .two-col { grid-template-columns: 1fr; }
}

.tb-total td { border-top: 2px solid var(--line); background: var(--paper-soft); }
.wk-link { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--accent); }
.wk-link:hover { color: var(--accent); }

.tb-flat { border-color: #cdd8e4; background: #fbfcfe; }

/* компактная ведомость и кликабельные строки */
.vd-table { font-size: .86rem; }
.vd-table td, .vd-table th { padding: 7px 8px; }
.vd-actions { flex-wrap: nowrap; }
.vd-actions .btn { padding: 4px 9px; font-size: .84rem; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--paper-soft); }
.tb-wk-rub { font-size: .82rem; color: var(--accent); margin-top: 2px; }
.table-wrap { overflow-x: auto; }

/* строки видов оплаты */
.tb-kind { min-width: 128px; }
.tb-kind-fixed { font-size: .84rem; color: var(--ink-soft); }
.tb-kind-sel { font: inherit; font-size: .82rem; padding: 4px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--paper); max-width: 108px; }
.tb-rate { width: 76px; margin-top: 3px; display: block; }
.tb-label { width: 104px; margin-top: 3px; display: block; font-size: .78rem; text-align: left; }
.tb-del-line { color: var(--danger, #b3261e); text-decoration: none; font-weight: 700;
  margin-left: 4px; }
.tb-addrow td { border-bottom: 1px solid var(--line); padding: 2px 8px 8px; }
.tb-add-line { font-size: .82rem; color: var(--accent); text-decoration: none; }
.tb-tot { text-align: right; white-space: nowrap; min-width: 76px; }
.tb-total td { border-top: 2px solid var(--line); background: var(--paper-soft); }

.reg-filter { margin-bottom: 10px; padding: 8px 10px; background: var(--paper-soft);
  border: 1px solid var(--line); border-radius: 8px; }
.reg-filter select.input { min-width: 140px; }

.numcol { width: 36px; text-align: right; color: var(--ink-soft); font-size: .84rem;
  white-space: nowrap; }
