/* СТРОЯК Контроль — оформление «панель прораба».
   Глубокий синий бренда СТРОЯК + сигнальный оранжевый разметки.
   Оранжевый — только главные действия, активные состояния и приоритет. */
:root {
  --bg: #eceef0;
  --panel: #ffffff;
  --text: #17242f;
  --muted: #5c6a77;
  --line: #d8dde2;
  --navy: #0c4a6e;
  --navy-deep: #082f45;
  --signal: #e8590c;
  --signal-soft: #fdeee3;
  --accent: #0c4a6e;
  --accent-soft: #e3eef5;
  --danger: #b3261e;
  --danger-soft: #fbeaea;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --ok: #2e7d32;
  --ok-soft: #e7f4e8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 8px rgba(20, 30, 40, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }

/* ---- каркас ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 2px solid var(--signal);
  color: #fff; padding: 0 16px; height: 52px;
}
.top .logo { font-weight: 700; font-size: 16.5px; margin-right: 18px; color: #fff; letter-spacing: .01em; }
.top .logo::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  background: var(--signal); border-radius: 2px; margin-right: 8px;
  transform: translateY(1px);
}
.top .logo:hover { text-decoration: none; }
.top nav { display: flex; gap: 2px; flex: 1; }
.top nav a { color: #c3d9e8; padding: 8px 12px; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; }
.top nav a.on { box-shadow: inset 0 -2px 0 var(--signal); border-radius: 6px 6px 0 0; }
.top .me { color: #c3d9e8; cursor: pointer; padding: 8px; }
.btn-new { background: var(--signal); color: #fff; border: 0; border-radius: 6px; padding: 7px 14px; font-weight: 600; cursor: pointer; margin-right: 8px; }
.btn-new:hover { background: #d74f07; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 90px; }
.bottom { display: none; }

@media (max-width: 760px) {
  .top nav { display: none; }
  .top .logo { flex: 1; }
  main { padding: 14px 12px 90px; }
  .bottom {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom a { flex: 1; text-align: center; padding: 10px 2px; font-size: 12px; color: var(--muted); }
  .bottom a.on { color: var(--signal); font-weight: 600; }
}

/* ---- элементы ---- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-deep); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--signal-soft); border-color: var(--signal); }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 4px; margin: 6px 0 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.tabs a.on { background: var(--signal-soft); color: var(--signal); font-weight: 600; }
.admin-tabs { position: sticky; top: 58px; z-index: 10; width: fit-content; max-width: 100%; overflow-x: auto;
  background: var(--bg); padding: 4px 0 8px; margin-bottom: 4px; white-space: nowrap; }
.admin-section > h2:first-child, .admin-section > .row:first-child h2 { margin-top: 10px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 140px; }

/* ---- задачи ---- */
.tlist { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.titem { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.titem:last-child { border-bottom: 0; }
.titem:hover { background: #f6f8fa; }
.titem .main { flex: 1; min-width: 0; }
.titem .title { font-weight: 500; overflow-wrap: anywhere; }
.titem.closed .title { color: var(--muted); text-decoration: line-through; }
.titem .meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.titem .right { text-align: right; font-size: 13px; white-space: nowrap; }
.group-h { font-size: 14px; font-weight: 600; color: var(--muted); margin: 16px 2px 6px; }
.group-h::before {
  content: ""; display: inline-block; width: 4px; height: 12px;
  background: var(--signal); border-radius: 2px; margin-right: 7px;
  transform: translateY(1px);
}
.group-h.danger { color: var(--danger); }
.group-h.danger::before { background: var(--danger); }
.st { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eceff2; color: #44505c; white-space: nowrap; }
.st.in_progress { background: var(--accent-soft); color: var(--accent); }
.st.review { background: var(--warn-soft); color: var(--warn); }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.cancelled { background: #eee; color: #888; }
.due.over { color: var(--danger); font-weight: 600; }
.prio { color: var(--signal); font-weight: 700; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; font-size: 12.5px; margin: 1px 2px 1px 0; }
a.tag:hover { text-decoration: none; background: #cfe2ee; }
.tag.sugg { background: #fff; border: 1px dashed var(--signal); color: var(--signal); cursor: pointer; }
.tag .x { cursor: pointer; margin-left: 4px; opacity: .6; }
.tag .x:hover { opacity: 1; }
.wl { color: var(--accent); border-bottom: 1px dotted var(--accent); }
.wl.dead { color: var(--warn); border-bottom-color: var(--warn); }

/* ---- карточка задачи ---- */
.task-head { display: flex; gap: 12px; align-items: flex-start; }
.task-head h1 { flex: 1; overflow-wrap: anywhere; }
.task-head .num { color: var(--muted); font-weight: 400; }
.fields { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; align-items: center; }
.fields > .k { color: var(--muted); font-size: 13px; }
@media (max-width: 600px) { .fields { grid-template-columns: 1fr; gap: 2px; } .fields > .k { margin-top: 8px; } }
.desc { white-space: normal; line-height: 1.5; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.comment { border-top: 1px solid var(--line); padding: 10px 0; }
.comment .who { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.event { font-size: 13px; color: var(--muted); padding: 3px 0; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
.layout2 { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .layout2 { grid-template-columns: 1fr; } }
.edit-pen { cursor: pointer; color: var(--muted); font-size: 13px; margin-left: 6px; }

/* ---- проекты ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; cursor: pointer; border-top: 3px solid transparent; }
.card:hover { box-shadow: 0 2px 12px rgba(20, 30, 40, .12); border-top-color: var(--signal); }
.card .name { font-weight: 600; font-size: 16px; }
.counters { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; }
.counters b { font-size: 17px; display: block; }
.counters .danger b { color: var(--danger); }

/* ---- доска ---- */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 10px; overflow-x: auto; }
.col { background: #e2e6ea; border-radius: var(--radius); padding: 8px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--signal); }
.col h4 { margin: 2px 4px 8px; font-size: 13px; color: var(--muted); }
.bcard { background: var(--panel); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; font-size: 14px; border-left: 3px solid var(--line); }
.bcard .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- таблицы ---- */
table.t { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.t th, table.t td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.t th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f6f8fa; }
table.t td.n { text-align: right; }
table.t td.act { text-align: right; white-space: nowrap; }
table.t td.n.danger { color: var(--danger); font-weight: 600; }
table.t tr.sum-row td { background: #f6f8fa; font-weight: 600; }
/* связи между задачами */
.rel { padding: 3px 0; }
.rel .x { cursor: pointer; margin-left: 4px; }
.rel-list { max-height: 280px; overflow: auto; margin-top: 6px; }
.rel-opt { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.rel-opt:hover { background: var(--accent-soft); }
.waits { color: var(--danger); }

/* сумма задачи: плюс — доход, минус — расход */
.amt { font-weight: 600; white-space: nowrap; }
.amt.plus { color: #1a7f37; }
.amt.minus { color: var(--danger); }
.money-sum { margin: -4px 0 10px; color: var(--muted); }
#f-amount { width: 140px; }

/* сводка: слева дерево, справа задачи выбранного узла */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.split-r { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.split-r h2 { margin-top: 0; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } .split-r { position: static; max-height: none; } }
table.sum-tree tr[data-k] { cursor: pointer; }
table.sum-tree th:not(:first-child) { width: 62px; }
table.sum-tree th, table.sum-tree td { padding: 7px 8px; }
table.sum-tree tr.lvl1 td { background: #fbfcfd; }
table.sum-tree tr[data-k]:hover td, table.sum-tree tr.sel td { background: var(--accent-soft); }
table.sum-tree tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
table.sum-tree .tw { display: inline-block; width: 18px; color: var(--muted); }
table.sum-tree .tg:hover { color: var(--accent); }
.scroll-x { overflow-x: auto; }

/* ---- окна и подсказки ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 35, .4); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 10px; width: 100%; max-width: 620px; padding: 18px 18px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.modal h2 { margin-top: 0; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.ac { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); max-height: 260px; overflow-y: auto; min-width: 220px; }
.ac div { padding: 6px 10px; cursor: pointer; font-size: 14px; }
.ac div.on, .ac div:hover { background: var(--accent-soft); }
.ac .kind { color: var(--muted); font-size: 12px; margin-left: 6px; }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--navy-deep); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 70; max-width: 90vw; }
.toast.err { background: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: #fff; }
.chips input { border: 0; outline: 0; flex: 1; min-width: 120px; padding: 3px; }

/* ---- уведомления ---- */
.bell { position: relative; color: #fff; font-size: 18px; padding: 6px 8px; margin-right: 4px; }
.bell:hover { text-decoration: none; }
.bell span { position: absolute; top: 0; right: -2px; background: var(--signal); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; }
.titem.unread { background: var(--signal-soft); }
.titem.unread .title { font-weight: 600; }
.titem.read .title { font-weight: 400; color: var(--muted); }

/* ---- фото и файлы ---- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.thumb { position: relative; }
.thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.thumb .del { position: absolute; top: -6px; right: -6px; background: #fff; border: 1px solid var(--line); border-radius: 50%;
  width: 20px; height: 20px; line-height: 17px; text-align: center; cursor: pointer; color: var(--danger); font-weight: 700; }
.doc { padding: 3px 0; }
#files-panel .btn.small { margin-left: 6px; }
code { background: #eceff2; padding: 1px 5px; border-radius: 4px; }

/* ---- вход ---- */
.login { max-width: 340px; margin: 12vh auto 0; border-top: 4px solid var(--signal); }
.login h1 { text-align: center; color: var(--navy); font-size: 20px; }
.login h1::after {
  content: ""; display: block; width: 44px; height: 3px; margin: 10px auto 0;
  background: var(--signal); border-radius: 2px;
}
.login .btn.primary { width: 100%; padding: 9px; }
