/* =========================================================================
   Раздел «Контроль объектов». Подключается только на страницах /control/.
   Цвета берутся из переменных style.css (--steel, --heat, --line ...).
   ========================================================================= */
:root {
  --ok: #3f7d4e;        /* выполнен */
  --ok-bg: #eaf4ec;
  --work: #3b78c3;      /* в работе */
  --work-bg: #e8f0fa;
  --idle: #c3cbd4;      /* не начат */
  --skip-bg: #f3f5f7;   /* не требуется */
  --warn: #b7791f;      /* открытая проблема */
  --warn-bg: #fbf3e4;
  --alert-bg: #fbf1f0;  /* просрочено */
}

/* Таблицы шире, чем лента новостей */
.page-control .container { max-width: 1280px; }

input[type="number"], input[type="email"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--field); border-radius: var(--radius); padding: 8px 11px; min-height: 38px;
}

.txt-heat { color: var(--heat); }
.ctl-muted { color: var(--muted); font-size: 13px; }
.ctl-help { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Подменю раздела ---------- */
.ctl-subnav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.ctl-subnav > a:not(.btn) { color: var(--muted); text-decoration: none; font-weight: 500; padding: 6px 0; border-bottom: 2px solid transparent; }
.ctl-subnav > a:not(.btn):hover { color: var(--ink); }
.ctl-subnav > a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--heat); }
.ctl-subnav-spacer { flex: 1; }
.ctl-subnav .btn { margin-left: -12px; }

/* ---------- Сводные цифры ---------- */
.ctl-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.ctl-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); background: var(--bg); text-decoration: none; color: var(--text); }
.ctl-stat:hover { border-color: var(--field); color: var(--text); }
.ctl-stat-num { font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ctl-stat-label { font-size: 13px; color: var(--muted); }
div.ctl-stat:hover { border-color: var(--line); }
.ctl-stat.is-alert { border-color: #e6b8b5; background: var(--alert-bg); }
.ctl-stat.is-alert .ctl-stat-num { color: var(--heat); }

/* ---------- Полоса «На каком этапе сейчас объекты» ---------- */
.ctl-stagebar-wrap { margin-bottom: 18px; }
.ctl-stagebar-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.ctl-stagebar-head a { font-weight: 400; font-size: 13px; }
.ctl-stagebar { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); border: 1px solid var(--line); }
.ctl-stagebar li + li { border-left: 1px solid var(--line); }
.ctl-stagebar a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 6px; text-decoration: none; color: var(--muted); height: 100%; text-align: center; }
.ctl-stagebar a:hover { background: #f7f9fb; color: var(--ink); }
.ctl-stagebar-num { font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--field); font-variant-numeric: tabular-nums; }
.ctl-stagebar-label { font-size: 11px; line-height: 1.2; }
.ctl-stagebar a.has-items { background: var(--work-bg); color: var(--ink); }
.ctl-stagebar a.has-items .ctl-stagebar-num { color: var(--steel); }
.ctl-stagebar a.is-finished.has-items { background: var(--ok-bg); }
.ctl-stagebar a.is-finished.has-items .ctl-stagebar-num { color: var(--ok); }
.ctl-stagebar a.is-active { box-shadow: inset 0 -3px 0 var(--heat); }

/* ---------- Таблицы ---------- */
.ctl-table-wrap { overflow-x: auto; }
.ctl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ctl-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; padding: 8px 10px; border-bottom: 1px solid var(--field); white-space: nowrap; }
.ctl-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ctl-table tbody tr:hover { background: #fafbfc; }
.ctl-obj-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.ctl-obj-title:hover { color: var(--steel); text-decoration: underline; }

/* ---------- Значки ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 500; line-height: 1.4; padding: 1px 8px; border-radius: 10px; white-space: nowrap; text-decoration: none; }
.badge.st-done { background: var(--ok-bg); color: var(--ok); }
.badge.st-in_progress { background: var(--work-bg); color: var(--work); }
.badge.st-not_started { background: var(--skip-bg); color: var(--muted); }
.badge.st-not_required { background: transparent; color: var(--muted); border: 1px dashed var(--field); }
.badge.pst-open { background: var(--alert-bg); color: var(--heat); }
.badge.pst-in_work { background: var(--work-bg); color: var(--work); }
.badge.pst-resolved { background: var(--ok-bg); color: var(--ok); }

/* ---------- Карточка объекта ---------- */
.ctl-obj-head { display: flex; justify-content: space-between; gap: 20px; margin: 18px 0 16px; }
.ctl-obj-head h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.3; font-weight: 600; color: var(--ink); }
.ctl-obj-head p { margin: 0 0 6px; max-width: 90ch; }
.ctl-obj-actions { display: flex; gap: 6px; align-items: flex-start; }

.ctl-kv { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin-bottom: 24px; }
.ctl-kv > div { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ctl-kv span { font-size: 12px; color: var(--muted); }
.ctl-kv b { font-weight: 600; color: var(--ink); font-size: 14px; }

.ctl-block { margin: 0 0 32px; }
.ctl-block h2 { font-size: 17px; font-weight: 600; color: var(--ink); margin: 0 0 12px; }
.ctl-block-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.ctl-block-head h2 { margin: 0; }

/* Лента этапов */
.ctl-timeline { list-style: none; margin: 0; padding: 0; }
.ctl-timeline li { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 0 0 14px; }
.ctl-timeline li::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.ctl-timeline li:last-child::before { display: none; }
.ctl-tl-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 3px; background: var(--bg); border: 2px solid var(--idle); position: relative; z-index: 1; }
.ctl-timeline .st-done .ctl-tl-dot { background: var(--ok); border-color: var(--ok); }
.ctl-timeline .st-in_progress .ctl-tl-dot { background: var(--work); border-color: var(--work); }
.ctl-timeline .st-not_required .ctl-tl-dot { border-style: dashed; }
.ctl-timeline .is-overdue .ctl-tl-dot { background: var(--heat); border-color: var(--heat); }
.ctl-timeline .st-not_required .ctl-tl-title { color: var(--muted); }
.ctl-timeline .is-current .ctl-tl-title { font-weight: 700; }
.ctl-tl-title { color: var(--ink); font-weight: 500; }
.ctl-tl-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin-top: 2px; }
.ctl-shifts { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 13px; margin-top: 3px; }
.ctl-shifts-count { color: var(--warn); font-weight: 600; }
.ctl-shifts-chain { color: var(--muted); }
.ctl-shifts-chain s { text-decoration-color: rgba(107, 118, 132, .6); }
.ctl-shifts-chain b { color: var(--ink); font-weight: 600; }
.ctl-shift-mark { color: var(--warn); }
.ctl-tl-comment { font-size: 13px; color: var(--text); margin-top: 3px; max-width: 90ch; }

/* Проблемы */
.ctl-problems { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ctl-problem { border: 1px solid var(--line); border-left: 4px solid var(--field); padding: 10px 14px; display: grid; gap: 4px; }
.ctl-problem.pst-border-open { border-left-color: var(--warn); }
.ctl-problem.pst-border-in_work { border-left-color: var(--work); }
.ctl-problem.pst-border-resolved { border-left-color: var(--ok); opacity: .75; }
.ctl-problem.is-overdue { border-left-color: var(--heat); }
.ctl-problem-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ctl-problem-obj { font-size: 14px; }
.ctl-problem-actions { margin-left: auto; display: flex; gap: 14px; align-items: baseline; font-size: 14px; }
.ctl-problem-actions form { margin: 0; }
.ctl-problem-title { font-weight: 600; color: var(--ink); }
.ctl-problem-desc { font-weight: 400; color: var(--text); }
.ctl-problem-foot { display: flex; gap: 6px 20px; flex-wrap: wrap; font-size: 14px; }
.ctl-resolved { margin-top: 12px; }
.ctl-resolved summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }

.ctl-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.ctl-chip { font-size: 13px; padding: 3px 10px; border: 1px solid var(--field); border-radius: 14px; text-decoration: none; color: var(--text); }
.ctl-chip:hover { border-color: var(--ink); color: var(--ink); }

.ctl-dl { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.ctl-dl dt { color: var(--muted); }
.ctl-dl dd { margin: 0; }

/* Журнал */
.ctl-journal-form { background: #f7f9fb; border: 1px solid var(--line); padding: 14px; margin-bottom: 16px; }
.ctl-journal-grid { display: grid; grid-template-columns: 240px 1fr; gap: 12px 16px; margin-bottom: 12px; }
.ctl-journal-grid textarea { min-height: 80px; }
.ctl-journal-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 2px; }
.ctl-journal-meta b { font-weight: 600; color: var(--ink); }
.ctl-journal-meta form { margin: 0; }
.ctl-link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ctl-link-btn:hover { color: var(--heat); }
.ctl-journal { list-style: none; margin: 0; padding: 0; }
.ctl-journal li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.5; }
.ctl-journal .ctl-muted { font-size: 14px; }

/* Форма этапов */
.ctl-stage-table td { padding: 8px 6px; vertical-align: middle; }
.ctl-stage-table select { min-width: 140px; }
.ctl-stage-table input[type="date"] { min-width: 140px; }
.ctl-stage-name { font-weight: 500; color: var(--ink); min-width: 220px; }
.ctl-stage-table td:last-child { width: 32%; min-width: 240px; }
.ctl-form { max-width: 900px; }
.ctl-danger-zone { max-width: 760px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn-danger { background: var(--bg); color: var(--heat); border-color: #e6b8b5; }
.btn-danger:hover { background: var(--alert-bg); color: var(--heat); border-color: var(--heat); }

/* ---------- Адаптивность ---------- */
@media (max-width: 980px) {
  .ctl-stats { grid-template-columns: repeat(2, 1fr); }
  .ctl-stagebar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ctl-stagebar li { border-bottom: 1px solid var(--line); }
  .ctl-stagebar li:nth-child(5n + 1) { border-left: 0; }
  .ctl-kv { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .ctl-stats, .ctl-kv, .grid-3, .ctl-journal-grid { grid-template-columns: 1fr; }
  .ctl-obj-head { flex-direction: column; }
  .ctl-dl { grid-template-columns: 1fr; }
  .ctl-subnav-spacer { display: none; }
}
