/* CRM ЦУМ — веб-панель. Без внешних библиотек и шрифтов: работает в закрытой сети. */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6b7486;
  --line: #e3e7ee;
  --side: #172033;
  --side-ink: #c9d1e0;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e8effd;
  --ok: #1f9d55;
  --ok-soft: #e5f6ec;
  --warn: #c77c02;
  --warn-soft: #fff4dc;
  --bad: #d23c3c;
  --bad-soft: #fde9e9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 15px; margin: 16px 0 8px; font-weight: 650; }
p { margin: 0 0 10px; line-height: 1.5; }
small, .muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: 0 0 232px; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--side-ink); padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(47,111,237,.22); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav-new { margin: 6px 0 12px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.me { padding: 4px 12px 10px; font-size: 13px; }
.me b { color: #fff; display: block; font-weight: 600; }
.side-foot form { margin: 0; }
.side-foot button.linkish { justify-content: flex-start; color: var(--side-ink); padding: 9px 12px; width: 100%; text-align: left; border-radius: 8px; }
.side-foot button.linkish:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- панели ---------- */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: 1fr 1fr; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: block; color: inherit; border-left: 4px solid var(--line); }
.stat:hover { text-decoration: none; box-shadow: 0 2px 12px rgba(20,30,50,.12); }
.stat .num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.blue { border-left-color: var(--accent); }
.stat.red { border-left-color: var(--bad); }
.stat.red .num { color: var(--bad); }
.stat.amber { border-left-color: var(--warn); }
.stat.green { border-left-color: var(--ok); }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfd; }
tbody tr:hover { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.task-title { font-weight: 550; }
.task-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

/* ---------- метки ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550; white-space: nowrap; background: #eef1f6; color: #3d4659; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.st-new { background: #eef1f6; color: #4d5870; }
.st-progress { background: var(--accent-soft); color: #2257c4; }
.st-paused { background: #f1ecfb; color: #6b45b8; }
.st-help { background: var(--warn-soft); color: #a86400; }
.st-done { background: var(--ok-soft); color: #18803f; }
.st-cancelled { background: #f0f0f0; color: #7a7a7a; }
.st-overdue { background: var(--bad-soft); color: var(--bad); }
.pr-low { color: #3e8d5a; }
.pr-normal { color: var(--muted); }
.pr-high { color: #c46a00; font-weight: 600; }
.pr-critical { color: var(--bad); font-weight: 700; }
.resp-yes { color: var(--ok); } .resp-no { color: var(--bad); } .resp-waiting { color: var(--muted); }

/* ---------- формы ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #394256; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd6e2; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,237,.35); border-color: var(--accent); }
input[type=file] { font: inherit; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 16px; height: 16px; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary, button.secondary { background: #fff; color: var(--ink); border-color: #cfd6e2; }
.btn.danger, button.danger { background: var(--bad); }
.btn.ghost-danger, button.ghost-danger { background: #fff; color: var(--bad); border-color: #f1c2c2; }
.btn.small, button.small { padding: 5px 10px; font-size: 13px; }
button.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
.btn.block { width: 100%; }
.filters { display: grid; gap: 10px; grid-template-columns: 2fr repeat(5, minmax(120px, 1fr)) auto; align-items: end; padding: 16px 20px; }
.filters label { font-size: 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 20px 0; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 550; font-size: 14px; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pager { display: flex; gap: 6px; justify-content: center; padding: 14px; }
.pager a, .pager span { padding: 5px 11px; border-radius: 7px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.pager span.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- сообщения ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b7e3c8; color: #145f31; }
.flash.error { background: var(--bad-soft); border-color: #f2c1c1; color: #962626; }
.flash.info { background: var(--accent-soft); border-color: #c9d9fa; color: #1f4ea8; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; background: #fff; border: 1px dashed #9db4e8; padding: 8px 12px; border-radius: 8px; display: inline-block; user-select: all; }

/* ---------- карточка задачи ---------- */
.meta { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14.5px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.desc { white-space: pre-wrap; line-height: 1.55; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.files li:last-child { border-bottom: 0; }
.files .fname { flex: 1; min-width: 180px; }
.files img { max-width: 220px; max-height: 160px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.files audio { height: 36px; max-width: 280px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 0 9px 16px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: #b8c2d4; }
.timeline .when { color: var(--muted); font-size: 12.5px; }
.bubble { background: #f6f8fc; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.bubble .who { font-weight: 600; font-size: 13.5px; }
.bubble .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.bubble .body { white-space: pre-wrap; margin-top: 4px; line-height: 1.45; }
details.box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-top: 12px; background: #fff; }
details.box summary { cursor: pointer; font-weight: 600; }
details.box[open] summary { margin-bottom: 12px; }

/* ---------- диаграммы ---------- */
.bar { height: 10px; border-radius: 5px; background: #edf0f5; overflow: hidden; display: flex; min-width: 80px; }
.bar i { display: block; height: 100%; }
.bar .b-open { background: var(--accent); }
.bar .b-done { background: var(--ok); }
.bar .b-bad { background: var(--bad); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- выбор людей ---------- */
.people { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.people .grp { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 10px 0 4px; }
.people label { font-weight: 500; display: flex; gap: 8px; align-items: center; padding: 3px 0; margin: 0; }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #172033 0%, #25355a 100%); }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login .brand { color: var(--ink); padding: 0 0 18px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .grid.two, .grid.halves { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .side { position: static; width: auto; height: auto; flex: none; padding: 10px; }
  .brand { padding-bottom: 8px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .side-foot { display: flex; align-items: center; border: 0; padding: 0; margin-top: 6px; }
  .me { display: none; }
  .main { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > div:first-of-type { grid-column: 1 / -1; }
  .meta { grid-template-columns: 1fr; }
  th, td { padding: 8px 10px; }
  .hide-sm { display: none; }
}
