/* Diameb CRM — variant D «Робочий» */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --line: #dfe4ea;
  --line-soft: #eef1f4;
  --text: #1f2833;
  --text-2: #3b4552;
  --muted: #6c7784;
  --rail: #26303d;
  --rail-hover: #334051;
  --rail-text: #a9b4c2;
  --accent: #3d5a80;
  --accent-hover: #2f4767;
  --accent-soft: #e7edf4;
  --selected: #eef3f9;
  --late: #a4482a;
  --warn-bg: #f3e7e2;
  --col: #e6eaef;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Golos Text', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.push { margin-left: auto; }
.late { color: var(--late); font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.rail {
  flex: 0 0 68px; background: var(--rail); padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.rail-logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-content: center; font-weight: 700; text-decoration: none; margin-bottom: 12px;
}
.rail-logo:hover { color: #fff; }
.rail-item {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-content: center;
  color: var(--rail-text); text-decoration: none; background: transparent; border: 0; cursor: pointer;
}
.rail-item:hover { background: var(--rail-hover); color: #fff; }
.rail-item.is-active { background: var(--accent); color: #fff; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-rail { width: 34px; height: 34px; background: #3a4656; color: #e3e8ee; }

.subnav {
  flex: 0 0 220px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.subnav-title { font-size: 16px; font-weight: 700; padding: 0 10px; }
.subnav-group { display: flex; flex-direction: column; gap: 2px; }
.subnav-label { font-size: 11px; font-weight: 600; color: #7a8592; text-transform: uppercase; letter-spacing: .6px; padding: 0 10px 6px; }
.subnav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--text-2); text-decoration: none; font-size: 13px;
}
.subnav-item > span:first-child { flex: 1; }
.subnav-item:hover { background: var(--bg); color: var(--text); }
.subnav-item.is-active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.subnav-count { font-size: 12px; color: #7a8592; font-weight: 400; }
.square-dot { flex: 0 0 8px !important; width: 8px; height: 8px; border-radius: 2px; background: #8fa3b8; }

.content { flex: 1 1 0; min-width: 0; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 14px; }

/* Toolbar & controls */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segmented { display: flex; background: #e3e8ee; padding: 3px; border-radius: 8px; }
.seg-wrap { display: flex; align-items: center; gap: 6px; }
.seg {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 6px;
  font-size: 13px; text-decoration: none; color: #4a5562;
}
.seg:hover { color: var(--text); }
.seg.is-active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(31, 40, 51, .1); }

.search { position: relative; flex: 1 1 240px; display: flex; align-items: center; }
.search > svg { position: absolute; left: 11px; color: #7a8592; pointer-events: none; }
.search .input { padding-left: 34px; }
.input {
  width: 100%; height: 36px; border: 1px solid #d5dbe2; border-radius: var(--radius); background: #fff;
  padding: 0 12px; font: inherit; font-size: 13px; color: var(--text);
}
.input::placeholder { color: #8b95a1; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: #fff; border-color: #d5dbe2; color: var(--text-2); font-weight: 500; }
.btn-ghost:hover { border-color: #b9c4d1; color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 42px; font-size: 14px; }
.btn.is-disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff;
  color: #4a5562; display: grid; place-content: center; text-decoration: none;
}
.icon-btn:hover { border-color: #b9c4d1; color: var(--text); }

/* Table */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 10px 10px; border-bottom: 1px solid #e6eaee; white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: 14px; }
.table th:last-child, .table td:last-child { padding-right: 14px; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table th.right, .table td.right { text-align: right; white-space: nowrap; }
.table tbody tr:hover { background: #f6f8fa; }
.table tbody tr.is-selected { background: var(--selected); }
.table .empty { text-align: center; color: var(--muted); padding: 40px; }

.task-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prio-bar { flex: 0 0 3px; width: 3px; height: 30px; border-radius: 2px; }
.task-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-link { color: var(--text); text-decoration: none; font-weight: 500; }
.task-link:hover { color: var(--accent); }
.task-sub { display: flex; gap: 10px; color: #7a8592; font-size: 12px; min-width: 0; }
.inline-ico { display: inline-flex; align-items: center; gap: 4px; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }

.people { display: flex; align-items: center; gap: 4px; }
.people-name { margin-left: 4px; color: #4a5562; white-space: nowrap; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: #e2e7ed; color: #3b4552;
  display: inline-grid; place-content: center; font-size: 10px; font-weight: 700; flex: none;
}
.avatar-sm { width: 22px; height: 22px; font-size: 9px; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; font-size: 13px; }
.pager-btns { display: flex; align-items: center; gap: 10px; }

/* Kanban */
.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.board { display: flex; gap: 12px; align-items: flex-start; min-width: min-content; }
.column {
  flex: 0 0 264px; background: var(--col); border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 100px);
}
.column.is-warn { background: var(--warn-bg); }
.column.is-warn h2 { color: #8f3f22; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 0; }
.column-head h2 { font-size: 13px; font-weight: 600; }
.column-hint { font-size: 11px; color: #7a8592; padding: 0 4px; }
.column-body { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 2px; margin: -2px; }
.column-empty, .column-more { font-size: 12px; color: #8b95a1; text-align: center; padding: 12px 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px; text-decoration: none; color: var(--text);
}
.card:hover { border-color: #b9c4d1; color: var(--text); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-rel { font-size: 11px; color: #7a8592; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-size: 13px; font-weight: 500; line-height: 1.4; }
.card-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

/* Detail panel */
.detail {
  flex: 0 0 400px; max-width: 100%; background: var(--surface); border-left: 1px solid var(--line);
  padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.detail-head { display: flex; align-items: center; gap: 8px; }
.detail-title { font-size: 19px; font-weight: 600; line-height: 1.35; word-wrap: break-word; }
.props { margin: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); row-gap: 11px; column-gap: 8px; font-size: 13px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.detail-section { display: flex; flex-direction: column; gap: 10px; }
.detail-section h3 { font-size: 13px; font-weight: 600; display: flex; gap: 6px; }
.detail-section h3 .muted { font-weight: 500; }
.rich { font-size: 13px; color: var(--text-2); line-height: 1.55; overflow-wrap: anywhere; }
.rich p { margin: 0 0 6px; }
.rich ul, .rich ol { margin: 0 0 6px; padding-left: 18px; }
.rich img { max-width: 100%; }
.progress { height: 4px; border-radius: 2px; background: #e6eaef; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist li.is-done { color: #7a8592; text-decoration: line-through; }
.check-box {
  flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px; border: 1.5px solid #a7b1bd; border-radius: 4px;
  display: grid; place-content: center; color: #fff; background: #fff;
}
.is-done .check-box { background: var(--accent); border-color: var(--accent); }
.comment { display: flex; gap: 10px; font-size: 13px; }
.comment-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

/* Shared bits for other modules */
.rail-item { position: relative; }
.rail-badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #c47a55; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-content: center;
  border: 2px solid var(--rail); box-sizing: content-box;
}
.count-badge {
  flex: none !important; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 600; display: grid; place-content: center;
}
.nowrap { white-space: nowrap; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head h1 { font-size: 20px; font-weight: 700; }
.content-narrow { max-width: 960px; }
.content-feed { max-width: 760px; margin: 0 auto; width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }
.tag-neutral { background: #eceff3; color: #46505c; }
.badge-warn { background: #f6e6de; color: #8f3f22; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.meter { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.card-sub { font-size: 12px; color: #6c7784; margin-top: -4px; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.link-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link-list li a { color: var(--text); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-list li a:hover { color: var(--accent); }
.link-list li.is-done a { color: #8b95a1; text-decoration: line-through; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid #e6eaef; display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; display: flex; flex-direction: column; gap: 2px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: #b9c4d1; border: 2px solid #fff; }
.contact { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.contact:last-child { border-bottom: 0; }
.contact.is-muted { opacity: .6; }

/* Notifications */
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--text); }
.notice:hover { background: #f6f8fa; color: var(--text); }
.notice.is-unread { background: #f4f7fb; }
.notice .avatar { font-size: 9px; }
.notice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; font-size: 13px; }
.notice-subject { color: var(--text-2); }
.notice-extra { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }

/* News */
.post { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-meta { display: flex; flex-direction: column; font-size: 13px; }
.post-body { font-size: 14px; color: var(--text); }
.post-body img { border-radius: 6px; }
.post-foot { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-2); padding-top: 10px; border-top: 1px solid var(--line-soft); }
.post-foot .is-liked { color: #b0603f; }
.post-comments { display: flex; flex-direction: column; gap: 10px; background: #f6f8fa; border-radius: 8px; padding: 12px; }

/* Chat */
.chat-list .subnav-item { gap: 8px; }
.chat-list .subnav-item > span:first-child { flex: none; }
.avatar-group { background: #dfe6ee; color: var(--accent); border-radius: 6px; }
.chat-pane { padding: 0; gap: 0; height: 100vh; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-head h1 { font-size: 16px; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.chat-day { text-align: center; margin: 8px 0; }
.chat-day span { font-size: 11px; color: var(--muted); background: #e3e8ee; padding: 3px 10px; border-radius: 10px; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 72%; }
.msg.is-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble { background: #fff; border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 8px 12px; min-width: 0; }
.msg.is-mine .msg-bubble { background: #e4ebf3; border-color: #d3deea; border-radius: 12px 12px 4px 12px; }
.msg-author { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.msg-time { font-size: 11px; color: #8b95a1; text-align: right; margin-top: 2px; }
.msg-file { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.chat-compose { padding: 12px 20px; background: #fff; border-top: 1px solid var(--line); }
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; color: var(--muted); gap: 8px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; display: flex; flex-direction: column; gap: 10px;
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 8px; }
.login-brand .rail-logo { margin: 0; width: 34px; height: 34px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: 0 0 6px; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .input { height: 40px; font-size: 14px; }
.form-error { margin: 0; color: var(--late); font-size: 13px; }

/* Narrow screens */
@media (max-width: 1100px) {
  .shell { flex-wrap: wrap; }
  .detail { flex: 1 1 100%; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .rail { flex: 1 1 100%; flex-direction: row; height: auto; position: static; padding: 8px 12px; overflow-x: auto; }
  .rail-logo { margin: 0 8px 0 0; }
  .rail-bottom { margin: 0 0 0 auto; flex-direction: row; }
  .subnav { flex: 1 1 100%; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .subnav-group { flex-direction: row; flex-wrap: wrap; }
  .subnav-label, .subnav-title { display: none; }
  .content { padding: 12px 16px; }
}
