:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 16px rgba(15,23,42,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #3b82f6);
  padding: 16px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}
.login-logo { text-align: center; }
.login-logo img { height: 72px; width: auto; }
.topbar-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.topbar-logo { height: 28px; width: auto; }
.login-card h1 { text-align: center; font-size: 22px; margin-top: 8px; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 20px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 4px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(15,23,42,.06); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; margin-top: 18px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-user { margin-left: auto; color: var(--muted); font-size: 13px; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.nav-btn { border-radius: 8px; }
.nav-btn.nav-active { background: var(--primary); color: #fff; }
.nav-btn.nav-active:hover { background: var(--primary-dark); color: #fff; }
.zoom-ctl { display: flex; align-items: center; gap: 2px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.zoom-btn { padding: 4px 9px; font-size: 13px; border-radius: 6px; }
.zoom-val { min-width: 52px; font-variant-numeric: tabular-nums; }
.zoom-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* ---------- List ---------- */
#list-view { margin: 0 auto; padding: 20px; }
.list-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 220px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none;
}
.search-input:focus { border-color: var(--primary); }
.list-count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.filter-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.fgroup label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.fgroup select, .fgroup input[type=date] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: #fff; outline: none;
}
.filter-actions { display: flex; align-items: flex-end; gap: 8px; }

.table-wrap {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: auto;
}
.req-table { width: 100%; border-collapse: collapse; }
.req-table th {
  position: sticky; top: 0; background: #f8fafc; text-align: left;
  padding: 7px 10px; font-size: 12px; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.req-table th:hover { color: var(--text); }
.req-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap; font-size: 13px;
}
.req-table tbody tr { cursor: pointer; }
.req-table tbody tr:hover { background: #f1f5ff; }
.req-table tbody tr:last-child td { border-bottom: none; }
.cell-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.st-new { background: #e2e8f0; color: #475569; }
.st-inwork { background: #fef3c7; color: #92400e; }
.st-work { background: #ffedd5; color: #9a3412; }
.st-done { background: #dcfce7; color: #166534; }
.st-cancel { background: #ede9fe; color: #6d28d9; }

.list-empty { text-align: center; padding: 40px; color: var(--muted); }

/* ---------- Calendar (вид «Месяц») ---------- */
#cal-view { margin: 0 auto; padding: 20px; }
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-title { font-size: 17px; font-weight: 700; margin-left: 6px; }
.cal-toolbar .spacer { flex: 1; }
.cal-legend { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-layout { display: flex; gap: 14px; align-items: flex-start; }
.cal-side {
  flex: none; width: 216px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
  position: sticky; top: 64px;
}
.cal-side .btn-block { margin-bottom: 12px; }
.cal-mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-mini-title { font-size: 13px; font-weight: 700; }
.cal-mini-wd, .cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-mini-wd { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.cal-mini-day {
  font-size: 12px; padding: 4px 0; cursor: pointer; border-radius: 50%;
  width: 24px; height: 24px; line-height: 16px; margin: 0 auto;
}
.cal-mini-day:hover { background: #f1f5ff; }
.cal-mini-day.other { color: #cbd5e1; }
.cal-mini-day.today { background: var(--danger); color: #fff; }
.cal-side-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 12px 0 6px; }
.cal-side .cal-legend { flex-direction: column; align-items: stretch; }
.cal-side .cal-chip { justify-content: flex-start; }
.cal-main { flex: 1; min-width: 0; }
@media (max-width: 900px) {
  .cal-layout { flex-direction: column; }
  .cal-side { width: 100%; position: static; }
}
.cal-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text);
}
.cal-chip.off { opacity: .4; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cal-grid { padding: 12px; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-body { display: flex; flex-direction: column; }
.cal-week { flex: 1 1 0; display: flex; flex-direction: column; min-height: 0; }
.cal-nums, .cal-ovs { flex: none; }
.cal-lanes { flex: 1; min-height: 30px; }
.cal-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.cal-head > div { padding: 6px 8px; }
.cal-body { border-top: 1px solid var(--border); }
.cal-week { border-bottom: 1px solid var(--border); }
.cal-nums, .cal-ovs { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-numcell {
  border-left: 1px solid var(--border); padding: 4px 8px; background: #fff;
}
.cal-numcell:last-child { border-right: 1px solid var(--border); }
.cal-numcell.weekend { background: #f8fafc; }
.cal-search { max-width: 240px; flex: none; }
.cal-numcell.other .cal-num { color: #cbd5e1; }
.cal-numcell.today .cal-num {
  background: var(--danger); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
}
.cal-num { font-size: 13px; font-weight: 600; cursor: pointer; display: inline-block; padding: 1px 2px; }
.cal-num:hover { text-decoration: underline; }
.cal-lanes {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0;
  grid-auto-rows: max-content; align-content: start;
  background: repeating-linear-gradient(to right, transparent 0, transparent calc(100%/7 - 1px), var(--border) calc(100%/7 - 1px), var(--border) calc(100%/7));
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 2px 0;
  flex: 1; min-height: 30px;
}
.cal-bar { align-self: start; }
.cal-ovs { min-height: 20px; }
.cal-ovcell { border-left: 1px solid var(--border); padding: 0 4px; background: #fff; }
.cal-ovcell:last-child { border-right: 1px solid var(--border); }
.cal-more { font-size: 12px; color: var(--primary); cursor: pointer; padding: 0 7px; }
.cal-more:hover { text-decoration: underline; }
/* Полосы-блоки внутри недели: одна надпись на весь отрезок */
.cal-bar {
  font-size: 12px; line-height: 19px; padding: 0 7px; margin: 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  min-width: 0;
}
.cal-bar.k-request { background: #dbeafe; color: #1d4ed8; }
.cal-bar.k-task { background: #fef3c7; color: #92400e; }
.cal-bar.k-vacation { background: #dcfce7; color: #166534; }
.cal-bar.overdue { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.cal-bar.span-start { border-radius: 5px 0 0 5px; }
.cal-bar.span-mid { border-radius: 0; }
.cal-bar.span-end { border-radius: 0 5px 5px 0; }
.cal-bar.single { border-radius: 5px; }
/* Пилюли вида «Неделя» (полоса «Весь день») */
.cal-pill {
  font-size: 12px; line-height: 1.35; padding: 1px 7px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-pill.k-request { background: #dbeafe; color: #1d4ed8; }
.cal-pill.k-task { background: #fef3c7; color: #92400e; }
.cal-pill.k-vacation { background: #dcfce7; color: #166534; }
.cal-pill.overdue { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.cal-loading { padding: 30px; text-align: center; color: var(--muted); }
.cal-dayrow {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px;
  border-bottom: 1px solid #f1f5f9; cursor: pointer;
}
.cal-dayrow:last-child { border-bottom: none; }
.cal-dayrow:hover { background: #f8fafc; }

/* ---------- Calendar: вид «Неделя» ---------- */
.cal-create-btn { background: #ffcc00; color: #1a1a1a; font-weight: 700; }
.cal-create-btn:hover { background: #f5c000; color: #1a1a1a; }
#cal-viewsel { cursor: pointer; }
.calw-head, .calw-allday { display: grid; grid-template-columns: 64px repeat(7, 1fr); }
.calw-body {
  display: grid; grid-template-columns: 64px repeat(7, 1fr);
  max-height: 46vh; overflow-y: auto; border-top: 1px solid var(--border);
}
.calw-gutter { font-size: 11px; color: var(--muted); padding: 4px 6px 4px 0; text-align: right; }
.calw-dayhead { text-align: center; padding: 6px 4px; font-size: 13px; }
.calw-dayhead.today b {
  background: var(--danger); color: #fff; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
}
.calw-allday { border-top: 1px solid var(--border); border-bottom: 2px solid var(--border); }
.calw-allday-label { font-size: 11px; align-self: start; }
.calw-cell {
  border-left: 1px solid var(--border); padding: 4px; min-height: 54px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; max-height: 130px;
  background: #fff;
}
.calw-slot { border-left: 1px solid #eef2f7; border-bottom: 1px solid #f1f5f9; min-height: 28px; cursor: pointer; }
.calw-slot:hover { background: #f8fafc; }

/* ---------- Detail / Edit ---------- */
#detail-view { margin: 0 auto; padding: 20px; }
.detail-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); padding: 14px 20px;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.detail-head h2 { font-size: 18px; }
.detail-head .spacer { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin-bottom: 14px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.fgroup input[type=text], .fgroup input[type=number], .fgroup input[type=date], .fgroup textarea,
.fgroup select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: #fff; outline: none;
}
.fgroup input:focus, .fgroup select:focus, .fgroup textarea:focus { border-color: var(--primary); }
.fgroup textarea { resize: vertical; min-height: 70px; }
.fgroup-wide { grid-column: 1 / -1; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; }
.kv { border-bottom: 1px dashed #eef2f7; padding-bottom: 6px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 600; }
.kv .v.empty { color: #cbd5e1; font-weight: 400; }

/* ---------- Notes / children lists ---------- */
.plain-list { list-style: none; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.plain-list li:last-child { border-bottom: none; }
.plain-list .muted { color: var(--muted); font-size: 12px; }
a.contact-link { color: var(--primary); text-decoration: underline; }
a.contact-link:hover { color: var(--primary-dark); }

.rep-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rep-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap;
}
.rep-row input, .rep-row select { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; flex: 1; min-width: 120px; }
.rep-del { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 16px; }

.notes-box {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; white-space: pre-wrap; font-size: 13px;
}

.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Multi-selects, checkboxes, departments ---------- */
select[multiple] { min-height: 90px; }
.chk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 12px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.chk input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.dept-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fbfdff; }
.dept-block { border-bottom: 1px dashed var(--border); padding: 8px 0; }
.dept-block:last-child { border-bottom: none; }
.dept-chk { font-size: 13px; }
.asg-sel { width: 100%; margin-top: 6px; min-height: 64px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.asg-sub { margin: 2px 0 2px 8px; padding-left: 10px; border-left: 2px solid var(--border); }
.asg-sub > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.asg-sub .rep-row { margin-bottom: 6px; }

/* ---------- Autocomplete ---------- */
.ac-wrap { position: relative; }
.ac-wrap input[type=text] { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; outline: none; }
.ac-wrap input[type=text]:focus { border-color: var(--primary); }
.ac-wrap input[type=text]:disabled, .fgroup input:disabled, .fgroup textarea:disabled {
  background: #f1f5f9; color: #94a3b8; cursor: not-allowed;
}
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: #fff; border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.15); max-height: 240px; overflow-y: auto;
}
.ac-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: #f1f5ff; }
.ac-empty { padding: 8px 12px; font-size: 13px; color: var(--muted); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; pointer-events: none; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.err { background: var(--danger); }

@media (max-width: 700px) {
  .kv-grid, .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Modal ---------- */
.modal-ov {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  padding: 20px 22px;
}
.modal-card h3 { font-size: 16px; margin-bottom: 14px; }
.modal-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.ac-item.ac-create { color: var(--primary); font-weight: 600; }
.cp-sub { font-size: 12px; padding: 2px 0 0 2px; }
.cp-sub:empty { display: none; }
.totp-qr svg { width: 220px; height: 220px; display: block; }

/* ---------- Задачи ---------- */
.tasks-layout { display: flex; height: calc(100vh - 58px); }
.tasks-side {
  width: 236px; flex: 0 0 236px; border-right: 1px solid var(--border);
  background: var(--card); padding: 12px; display: flex; flex-direction: column;
  gap: 10px; overflow: auto;
}
.tasks-side .btn-block { margin-top: 0; }
.tasks-side-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; margin-top: 4px;
}
.task-projects-nav, .tasks-scope { display: flex; flex-direction: column; gap: 2px; }
.tp-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: var(--text); background: transparent;
  border: none; text-align: left; width: 100%; font-family: inherit;
}
.tp-item:hover { background: #f1f5f9; }
.tp-item.active { background: #e0e7ff; color: #1e3a8a; font-weight: 600; }
.tp-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; background: var(--primary); }
.tp-count { margin-left: auto; font-size: 11px; color: var(--muted); }
.tasks-scope .btn { justify-content: flex-start; }
.tasks-scope .btn.active { background: #e0e7ff; color: #1e3a8a; }
.tasks-main {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  padding: 12px; gap: 10px; overflow: auto;
}
.tasks-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tasks-toolbar .search-input { max-width: 380px; flex: 1 1 220px; }
.task-focus-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.task-focus-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.task-focus-head .muted { font-weight: 400; color: var(--muted); }
.task-focus-list { display: flex; flex-wrap: wrap; gap: 6px; }
.task-focus-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #fff7ed;
  border: 1px solid #fed7aa; color: #9a3412; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; max-width: 100%;
}
.task-focus-chip .x { opacity: .6; cursor: pointer; }
.task-focus-chip.done { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.task-group-title {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 6px 2px 2px;
}
.tasks-list { display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex; gap: 10px; align-items: flex-start; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.task-item:hover { border-color: #cbd5e1; box-shadow: var(--shadow); }
.task-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.task-item.done .task-item-title { text-decoration: line-through; color: var(--muted); }
.task-check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #cbd5e1;
  background: #fff; flex: 0 0 20px; cursor: pointer; margin-top: 1px; position: relative;
}
.task-check.on { background: var(--ok); border-color: var(--ok); }
.task-check.on::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.task-item-body { flex: 1 1 auto; min-width: 0; }
.task-item-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 3px; }
.task-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: #f1f5f9; color: #334155;
}
.task-due.overdue { color: var(--danger); font-weight: 700; }
.task-prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.task-prio.high { background: var(--danger); }
.task-prio.mid { background: var(--warn); }
.task-prio.low { background: #94a3b8; }
.task-star { background: none; border: none; cursor: pointer; font-size: 17px; line-height: 1; color: #cbd5e1; padding: 0 2px; }
.task-star.on { color: #f59e0b; }
.task-detail {
  width: 450px; flex: 0 0 450px; border-left: 1px solid var(--border);
  background: var(--card); overflow: auto; padding: 14px;
}
.task-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.task-detail-head h3 { font-size: 16px; flex: 1 1 auto; min-width: 0; }
.td-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.td-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.td-field { margin-bottom: 8px; }
.td-field label { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.td-field input, .td-field select, .td-field textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; font-family: inherit; background: #fff;
}
.td-field textarea { resize: vertical; min-height: 64px; }
.td-row { display: flex; gap: 8px; }
.td-row > * { flex: 1 1 0; min-width: 0; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.td-status-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.td-status-btns .btn.on { background: var(--primary); color: #fff; }
.check-list, .note-list, .attach-list { display: flex; flex-direction: column; gap: 5px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-row.done span { text-decoration: line-through; color: var(--muted); }
.check-row .x { margin-left: auto; opacity: .4; cursor: pointer; }
.attach-drop {
  border: 1.5px dashed #cbd5e1; border-radius: 10px; padding: 12px; text-align: center;
  color: var(--muted); font-size: 12px; cursor: pointer; margin-top: 6px;
}
.attach-drop.over { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.attach-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.attach-row a { color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-row .x { margin-left: auto; opacity: .5; cursor: pointer; }
.note { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.note-head { display: flex; gap: 8px; color: var(--muted); font-size: 11px; margin-bottom: 4px; flex-wrap: wrap; }
.note-body { white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.note-actions { margin-top: 4px; text-align: right; }
mark { background: #fef08a; padding: 0 1px; border-radius: 2px; }
.global-req { display: flex; align-items: center; gap: 8px; font-size: 13px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.global-req:hover { border-color: #cbd5e1; }
@media (max-width: 1100px) {
  .task-detail { position: fixed; right: 0; top: 58px; bottom: 0; width: min(460px, 96vw); z-index: 60; box-shadow: -8px 0 24px rgba(15,23,42,.16); }
}
.global-req { flex-wrap: wrap; }
.global-req .muted { font-size: 12px; }

/* Контакты в задаче */
.td-contacts { display: flex; flex-direction: column; gap: 6px; }
.td-contact { display: flex; gap: 8px; align-items: flex-start; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.td-contact-main { flex: 1 1 auto; min-width: 0; }
.td-contact-sub { font-size: 12px; }
.td-contact-role { width: 100%; margin-top: 5px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; background: #fff; font-family: inherit; }
.td-contact .x { opacity: .5; cursor: pointer; padding: 2px 4px; }

/* Повестка дня */
.cal-agenda { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.agenda-day-title { font-size: 15px; font-weight: 700; }
.agenda-section { display: flex; flex-direction: column; gap: 6px; }
.agenda-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; }
.agenda-card { background: var(--card); border: 1px solid var(--border); border-left: 4px solid #94a3b8;
  border-radius: 8px; padding: 8px 10px; }
.agenda-card.k-request { border-left-color: #2563eb; }
.agenda-card.k-task { border-left-color: #d97706; }
.agenda-card.k-vacation { border-left-color: #16a34a; }
.agenda-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.agenda-head .muted { font-size: 12px; margin-left: auto; }
.agenda-members { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.agenda-member { display: flex; gap: 8px; align-items: baseline; font-size: 13px;
  padding: 4px 8px; border-radius: 6px; background: #f8fafc; cursor: pointer; }
.agenda-member:hover { background: #eef2ff; }

/* Задача: метаданные, результат, приложения, история */
.td-meta { font-size: 12px; margin: -2px 0 8px; }
.td-footer { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px;
  display: flex; gap: 8px; flex-wrap: wrap; }
.td-footer .btn-block { width: 100%; }
.td-history { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.td-history summary { cursor: pointer; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.hist-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hist-row { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; }
.hist-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.hist-head .muted { font-size: 11px; }
.hist-result { margin-top: 4px; white-space: pre-wrap; word-break: break-word;
  color: var(--text); background: #fff; border-radius: 6px; padding: 5px 7px;
  max-height: 160px; overflow: auto; }

/* Справочники */
.refs-layout { display: flex; height: calc(100vh - 58px); }
.refs-side { width: 260px; flex: 0 0 260px; border-right: 1px solid var(--border);
  background: var(--card); padding: 12px; display: flex; flex-direction: column;
  gap: 8px; overflow: auto; }
.refs-side .btn-block { margin-top: 0; }
.refs-cats { display: flex; flex-direction: column; gap: 2px; }
.refs-main { flex: 1 1 auto; min-width: 0; padding: 12px; display: flex;
  flex-direction: column; gap: 10px; overflow: auto; }
.refs-main .search-input { max-width: 460px; flex: 1 1 auto; }
.refs-list { display: flex; flex-direction: column; gap: 6px; }
.ref-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; cursor: pointer; }
.ref-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow); }
.ref-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.ref-card-title { font-weight: 600; }
.ref-card-sub { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px;
  color: var(--muted); margin-top: 3px; }
.ref-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; background: #f1f5f9; }
.refs-more-wrap { text-align: center; padding: 6px 0; }
.ref-detail { width: 480px; flex: 0 0 480px; border-left: 1px solid var(--border);
  background: var(--card); overflow: auto; padding: 14px; }
.ref-detail-head { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.ref-detail-head h3 { font-size: 16px; flex: 1 1 auto; }
.ref-kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; font-size: 13px;
  margin: 8px 0; }
.ref-kv .k { color: var(--muted); }
.ref-contact { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px;
  margin-bottom: 5px; font-size: 13px; cursor: pointer; background: #f8fafc; }
.ref-contact:hover { background: #eef2ff; }
.ref-contact-sub { color: var(--muted); font-size: 12px; }
.ref-import-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  background: #f8fafc; }
.ref-del-row { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  margin-bottom: 6px; font-size: 13px; }

/* ---------- Графики ---------- */
.graphs-layout { display: flex; height: calc(100vh - 58px); }
.graphs-side { width: 250px; flex: 0 0 250px; border-right: 1px solid var(--border);
  background: var(--card); padding: 12px; overflow: auto; }
.graphs-main { flex: 1 1 auto; min-width: 0; padding: 12px; display: flex;
  flex-direction: column; gap: 10px; min-height: 0; }
.graphs-toolbar { margin-bottom: 0; }
.graphs-toolbar .search-input { max-width: 360px; }
.graphs-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--card); }
.graphs-table { min-width: 760px; }
.graphs-table th { white-space: nowrap; }
.graphs-table td { vertical-align: top; }
.graph-employee { font-weight: 600; }
.graph-muted { color: var(--muted); font-size: 12px; }
.graph-group-row td { background: #f8fafc; border-top: 2px solid var(--border); }
.graph-part-row td { color: #334155; }
.graph-actions { display: flex; gap: 5px; flex-wrap: nowrap; white-space: nowrap; }
.graphs-table:not(.graph-fixed-table) th:last-child, .graphs-table:not(.graph-fixed-table) td:last-child { min-width: 150px; }
.graphs-note { margin-top: 14px; padding: 8px 10px; border-radius: 8px;
  background: #f1f5f9; color: var(--muted); font-size: 12px; line-height: 1.4; }
.graph-days { font-variant-numeric: tabular-nums; white-space: nowrap; }
.graph-part-editor { display: grid; gap: 8px; margin-top: 10px; }
.graph-part-editor .graph-part-row { display: grid; grid-template-columns: 28px 145px 78px 115px minmax(120px,1fr) 30px;
  gap: 7px; align-items: center; }
.graph-part-editor .graph-part-row input { min-width: 0; }
.graph-part-no { color: var(--muted); font-size: 12px; text-align: center; }
.graph-part-editor .graph-part-row .btn { padding: 4px 7px; }
.graph-total { margin-top: 10px; font-weight: 600; }
.graph-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.graph-form-grid .wide { grid-column: 1 / -1; }
.graph-form-grid input, .graph-form-grid select, .graph-form-grid textarea {
  width: 100%; box-sizing: border-box; }
.graph-form-grid textarea { min-height: 64px; }
.graph-modal-card { width: min(820px, 96vw); max-width: min(820px, 96vw); max-height: 90vh; overflow: auto; }
.graph-delete-link { color: var(--danger); }
@media (max-width: 900px) {
  .graphs-side { width: 210px; flex-basis: 210px; }
  .graph-form-grid { grid-template-columns: 1fr; }
  .graph-part-editor .graph-part-row { grid-template-columns: 24px 1fr 70px; }
  .graph-part-editor .graph-part-row .graph-part-end, .graph-part-editor .graph-part-row .graph-part-notes { grid-column: 1 / -1; }
}

/* календарь: новые типы графиков */
.cal-bar.k-day_off { background: #e0f2fe; color: #075985; }
.cal-bar.k-training { background: #ede9fe; color: #5b21b6; }
.cal-bar.k-sick_leave { background: #fee2e2; color: #991b1b; }
.cal-bar.k-other { background: #e2e8f0; color: #334155; }
.cal-pill.k-day_off { background: #e0f2fe; color: #075985; }
.cal-pill.k-training { background: #ede9fe; color: #5b21b6; }
.cal-pill.k-sick_leave { background: #fee2e2; color: #991b1b; }
.cal-pill.k-other { background: #e2e8f0; color: #334155; }
.agenda-card.k-day_off { border-left-color: #0ea5e9; }
.agenda-card.k-training { border-left-color: #7c3aed; }
.agenda-card.k-sick_leave { border-left-color: #dc2626; }
.agenda-card.k-other { border-left-color: #64748b; }

.graph-access-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 6px 14px; max-height: 360px; overflow: auto; padding: 8px;
  border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.graph-access-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 4px; }
.graph-access-row .muted { margin-left: auto; font-size: 11px; }

.graphs-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); }
.graphs-table th, .graphs-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.graphs-table th { background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .02em; font-weight: 700; }
.graphs-table tbody tr:hover td { background: #f8fafc; }
.graphs-table td:first-child { min-width: 220px; }
.graphs-table td:nth-child(4) { white-space: nowrap; }
.graph-period { white-space: nowrap; }

.graphs-table.graph-fixed-table { table-layout: fixed; }

.graph-part-head { display: grid; grid-template-columns: 28px 145px 78px 115px minmax(120px,1fr) 30px;
  gap: 7px; margin-top: 12px; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .02em; font-weight: 700; }
@media (max-width: 900px) {
  .graph-part-head { grid-template-columns: 24px 1fr 70px; }
  .graph-part-head span:nth-child(n+4) { display: none; }
}

/* ================= Mobile ================= */
.mobile-section-title, .mobile-menu-btn, .mobile-nav-overlay, .mobile-nav { display: none; }
@media (max-width: 900px) {
  body { overflow-x: hidden; }
  body.mobile-nav-open { overflow: hidden; }
  .topbar { padding: 8px 12px; gap: 8px; min-height: 56px; }
  .topbar-title { font-size: 15px; gap: 6px; min-width: 0; }
  .topbar-name { display: none; }
  .topbar-logo { height: 25px; }
  .topnav, .topbar-user, .zoom-ctl, #settings-btn, #logout-btn { display: none !important; }
  .mobile-section-title {
    display: block; flex: 1 1 auto; min-width: 0; text-align: right;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--muted); font-size: 13px; font-weight: 700;
  }
  .mobile-menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; padding: 0; font-size: 22px; line-height: 1;
  }
  .mobile-nav-overlay {
    display: block; position: fixed; inset: 0; z-index: 1500;
    background: rgba(15,23,42,.45);
  }
  .mobile-nav {
    display: flex; flex-direction: column; position: fixed; z-index: 1501;
    top: 0; right: 0; bottom: 0; width: min(330px, 88vw);
    background: var(--card); box-shadow: -12px 0 32px rgba(15,23,42,.22);
    padding: 14px; overflow: auto;
  }
  .mobile-nav-head { display: flex; align-items: center; justify-content: space-between;
    font-size: 16px; margin-bottom: 4px; }
  .mobile-nav-head .btn { font-size: 20px; padding: 4px 8px; }
  .mobile-nav-user { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
  .mobile-nav-label { color: var(--muted); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; margin: 14px 2px 6px; }
  .mobile-nav-item {
    width: 100%; border: 0; background: transparent; color: var(--text);
    text-align: left; padding: 13px 12px; border-radius: 8px; font-family: inherit;
    font-size: 16px; font-weight: 600;
  }
  .mobile-nav-item:active, .mobile-nav-item.active { background: #e0e7ff; color: #1e3a8a; }
  .mobile-nav-zoom { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .mobile-nav-zoom .btn { padding: 11px 4px; }
  .mobile-nav-bottom { margin-top: auto; padding-top: 18px; display: flex;
    flex-direction: column; gap: 8px; }
  .mobile-nav-bottom .btn { padding: 12px; }

  #list-view { padding: 10px; }
  .list-toolbar, .tasks-toolbar, .cal-toolbar { gap: 7px; }
  .list-toolbar .search-input, .tasks-toolbar .search-input { flex: 1 1 100%; min-width: 0; }
  .list-toolbar .btn, .tasks-toolbar .btn { flex: 0 0 auto; }
  .filter-grid { grid-template-columns: 1fr; }
  .table-wrap { border-radius: 10px; }
  .req-table { min-width: 720px; }

  .refs-layout, .graphs-layout, .tasks-layout {
    flex-direction: column; height: calc(100dvh - 56px);
  }
  .refs-side, .graphs-side, .tasks-side {
    width: 100%; flex: 0 0 auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 8px 10px; overflow: visible;
  }
  .refs-side .tasks-side-label, .graphs-side .tasks-side-label, .tasks-side .tasks-side-label {
    display: none;
  }
  .refs-side .btn-block, .graphs-side .btn-block, .tasks-side .btn-block {
    width: auto; display: inline-flex; margin: 0 6px 6px 0; padding: 8px 12px;
  }
  .refs-cats, .task-projects-nav, .tasks-scope {
    flex-direction: row; overflow-x: auto; gap: 6px; padding: 2px 0 4px;
    scrollbar-width: thin;
  }
  .refs-cats .tp-item, .task-projects-nav .tp-item, .tasks-scope .btn {
    width: auto; flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--border);
    background: #f8fafc; padding: 8px 11px;
  }
  .refs-cats .tp-item.active, .task-projects-nav .tp-item.active,
  .tasks-scope .btn.active { border-color: #c7d2fe; background: #e0e7ff; }
  .refs-main, .graphs-main, .tasks-main {
    padding: 10px; overflow: auto; min-height: 0; flex: 1 1 auto;
  }
  .refs-main .search-input, .graphs-toolbar .search-input { max-width: none; width: 100%; flex: 1 1 100%; }
  .refs-main .tasks-toolbar { gap: 7px; }
  .ref-detail {
    position: fixed; inset: 56px 0 0 0; width: 100%; z-index: 90;
    border-left: 0; padding: 12px; background: var(--card);
  }
  .ref-detail-head { position: sticky; top: 0; background: var(--card); z-index: 2;
    padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .ref-kv { grid-template-columns: 105px 1fr; }
  .ref-contact { padding: 10px; }

  .graphs-side #graphs-tabs { flex-direction: row; overflow-x: auto; }
  .graphs-side #graphs-tabs .tp-item { width: auto; flex: 0 0 auto; white-space: nowrap;
    border: 1px solid var(--border); background: #f8fafc; padding: 9px 12px; }
  .graphs-side #graphs-tabs .tp-item.active { border-color: #c7d2fe; background: #e0e7ff; }
  .graphs-side #graphs-tabs .tp-count { margin-left: 6px; }
  .graphs-note { margin-top: 8px; }
  .graphs-toolbar { align-items: stretch; }
  .graphs-filters { display: none; flex-direction: column; gap: 7px; width: 100%; }
  .graphs-filters.open { display: flex; }
  .graphs-filter-toggle { display: inline-flex !important; }
  .graphs-toolbar #graphs-add { flex: 1 1 auto; }
  .graphs-count { flex: 1 1 100%; text-align: left; }
  .graphs-table-wrap { display: none; }
  .graphs-mobile-list { display: flex; }
  .graph-mcard { background: var(--card); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); }
  .graph-mcard-head { display: flex; gap: 8px; align-items: flex-start; }
  .graph-mcard-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  .graph-mcard-year { color: var(--muted); font-size: 12px; white-space: nowrap; }
  .graph-mcard-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted);
    font-size: 12px; margin-top: 4px; }
  .graph-mcard-parts { margin-top: 9px; border-top: 1px solid var(--border); padding-top: 8px; }
  .graph-mpart { display: grid; grid-template-columns: 24px 1fr auto; gap: 6px;
    font-size: 13px; padding: 4px 0; align-items: baseline; }
  .graph-mpart-note { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
  .graph-mcard-actions { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
  .graph-mcard-actions .btn { flex: 1 1 auto; padding: 9px 10px; }
  .graphs-mobile-empty { display: none; }
  .graphs-table-wrap.hidden + .graphs-mobile-empty { display: block; }

  .cal-layout { display: block; position: relative; }
  .cal-side {
    display: none; position: absolute; z-index: 70; left: 8px; right: 8px; top: 4px;
    width: auto; max-height: 72dvh; overflow: auto; box-shadow: 0 14px 40px rgba(15,23,42,.28);
  }
  .cal-side.open { display: block; }
  .cal-main { width: 100%; }
  .cal-toolbar { gap: 6px; padding: 0 2px 8px; }
  .cal-toolbar .cal-title { flex: 1 1 100%; order: -1; font-size: 16px; }
  .cal-toolbar .spacer { display: none; }
  .cal-toolbar .cal-search { max-width: none; flex: 1 1 100%; order: 8; }
  .cal-side-toggle { display: inline-flex !important; }
  .cal-grid { padding: 8px; }
  .cal-head > div { padding: 5px 3px; font-size: 10px; }
  .cal-numcell .cal-num { font-size: 11px; }
  .agenda-card { padding: 9px 10px; }

  .task-detail {
    position: fixed; top: 56px; right: 0; bottom: 0; left: 0; width: 100%;
    z-index: 90; box-shadow: none;
  }
  .task-detail-head { position: sticky; top: 0; background: var(--card); z-index: 2; }
  .task-search, .task-status-filter, .task-priority-filter { flex: 1 1 auto; }
  .task-search { flex-basis: 100%; }
  .task-item { padding: 11px 10px; }
  .task-focus-chip { max-width: 100%; }

  .modal-ov { padding: 8px; }
  .modal-card { max-height: 92dvh; padding: 16px; border-radius: 12px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }
  .graph-modal-card { max-height: 94dvh; }
  .graph-part-head { display: none; }
  .graph-part-editor .graph-part-row { grid-template-columns: 26px 1fr 70px;
    border-bottom: 1px solid var(--border); padding-bottom: 8px; }
  .graph-part-editor .graph-part-row .graph-part-end { grid-column: 2 / -1; }
  .graph-part-editor .graph-part-row .graph-part-notes { grid-column: 1 / -1; }
  #toast { left: 12px; right: 12px; bottom: 16px; }
}

/* Базовые мобильные компоненты (на десктопе скрыты/встроены) */
.graphs-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1 1 auto; }
.graphs-filter-toggle, .cal-side-toggle { display: none; }
.graphs-mobile-list { display: none; }
.cal-side { transition: none; }

/* Mobile overrides must follow base helpers */
@media (max-width: 900px) {
  .graphs-filters { display: none; }
  .graphs-filters.open { display: flex; }
  .graphs-mobile-list { display: flex; }
  .graphs-table-wrap { display: none; }
}

@media (max-width: 900px) {
  .graphs-mobile-list { display: flex; flex-direction: column; gap: 8px; }
  .graphs-filters select { width: 100%; }
  .graphs-filters .btn, .graphs-filters select { flex: 1 1 100%; }
}

@media (max-width: 900px) {
  .graphs-filters { display: none; flex-direction: column; flex-wrap: nowrap; height: auto; width: 100%; }
  .graphs-filters.open { display: flex; }
  .graphs-filters select, .graphs-filters .btn {
    width: 100%; flex: 0 0 auto; min-height: 42px;
  }
  .graphs-mobile-list { display: flex; flex-direction: column; gap: 8px; }
}

@media (max-width: 900px) {
  .graph-part-editor .graph-part-row {
    grid-template-columns: 26px minmax(0,1fr) 82px 34px;
    grid-template-areas:
      "no start start del"
      ". days end end"
      ". notes notes notes";
    gap: 6px;
  }
  .graph-part-editor .graph-part-no { grid-area: no; }
  .graph-part-editor .graph-part-start { grid-area: start; width: 100%; }
  .graph-part-editor .graph-part-days { grid-area: days; width: 100%; }
  .graph-part-editor .graph-part-end { grid-area: end; align-self: center; }
  .graph-part-editor .graph-part-notes { grid-area: notes; width: 100%; }
  .graph-part-editor .graph-part-del { grid-area: del; justify-self: end; }
}

@media (max-width: 900px) {
  #detail-view { padding: 10px; }
  .detail-head { padding: 12px; gap: 8px; }
  .detail-head h2 { font-size: 16px; flex: 1 1 100%; }
  .detail-head .spacer { display: none; }
  .card { padding: 12px; }
}

@media (max-width: 900px) {
  .graph-part-editor .graph-part-row .graph-part-no { grid-area: no; }
  .graph-part-editor .graph-part-row .graph-part-start { grid-area: start; }
  .graph-part-editor .graph-part-row .graph-part-days { grid-area: days; }
  .graph-part-editor .graph-part-row .graph-part-end { grid-area: end; grid-column: end; grid-row: end; }
  .graph-part-editor .graph-part-row .graph-part-notes { grid-area: notes; grid-column: notes; }
  .graph-part-editor .graph-part-row .graph-part-del { grid-area: del; }
}

.graph-part-mobile-hint { display: none; }
@media (max-width: 900px) {
  .graph-part-mobile-hint { display: block; color: var(--muted); font-size: 11px;
    margin-top: 10px; padding: 6px 8px; border-radius: 7px; background: #f8fafc; }
}

/* Выполненные задачи и заявки */
.cal-bar.done, .cal-pill.done {
  background: #dcfce7 !important; color: #166534 !important;
  font-weight: 700; box-shadow: inset 3px 0 0 #16a34a;
}
.cal-bar.done.overdue, .cal-pill.done.overdue {
  background: #dcfce7 !important; color: #166534 !important;
}
.agenda-card.done { background: #f0fdf4; border-left-color: #16a34a; }
.agenda-member.done { background: #f0fdf4; }
.cal-dayrow.done { background: #f0fdf4; border-radius: 8px; }
.cal-dayrow.done .cal-dot { background: #16a34a !important; }

/* ---------- Документы ---------- */
.docs-layout { display: flex; height: calc(100vh - 58px); }
.docs-side { width: 250px; flex: 0 0 250px; border-right: 1px solid var(--border);
  background: var(--card); padding: 12px; display: flex; flex-direction: column;
  gap: 8px; overflow: auto; }
.docs-side .btn-block { margin-top: 0; }
.docs-main { flex: 1 1 auto; min-width: 0; padding: 12px; display: flex;
  flex-direction: column; gap: 10px; overflow: auto; }
.docs-toolbar { margin-bottom: 0; flex-wrap: wrap; }
.docs-toolbar .search-input { max-width: 460px; flex: 1 1 260px; }
.docs-list { display: flex; flex-direction: column; gap: 7px; }
.doc-card { display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px;
  cursor: pointer; box-shadow: var(--shadow); }
.doc-card:hover { border-color: #cbd5e1; }
.doc-card-main { flex: 1 1 auto; min-width: 0; }
.doc-card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.doc-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  white-space: nowrap; }
.doc-status { font-size: 11px; border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.doc-status.draft { background: #fef3c7; color: #92400e; }
.doc-status.final { background: #dcfce7; color: #166534; }
.doc-detail-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.doc-detail-head > div { flex: 1 1 auto; min-width: 0; }
.doc-detail-head h3 { font-size: 18px; }
.doc-kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 10px;
  font-size: 13px; margin: 10px 0; }
.doc-kv > div { color: var(--muted); }
.doc-kv > span, .doc-kv > b { white-space: pre-wrap; }
.doc-body-preview { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; font-family: "Times New Roman", serif;
  font-size: 14px; line-height: 1.45; max-height: 42vh; overflow: auto; margin: 10px 0; }
.doc-detail-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px;
  display: flex; flex-direction: column; gap: 6px; }
.doc-attach { display: flex; gap: 8px; align-items: center; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 13px; }
.doc-attach a { color: var(--primary); text-decoration: none; flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-upload { display: inline-flex; align-items: center; width: fit-content; cursor: pointer; }
.doc-actions { justify-content: flex-start; flex-wrap: wrap; }
.doc-form-note { color: var(--muted); font-size: 12px; margin: -4px 0 8px; }
@media (max-width: 900px) {
  .docs-layout { flex-direction: column; height: calc(100dvh - 56px); }
  .docs-side { width: 100%; flex: 0 0 auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 8px 10px; overflow: visible; }
  .docs-side .tasks-side-label { display: none; }
  .docs-side .btn-block { width: auto; display: inline-flex; margin: 0 6px 6px 0; padding: 8px 12px; }
  .docs-main { padding: 10px; overflow: auto; min-height: 0; flex: 1 1 auto; }
  .docs-toolbar .search-input { max-width: none; flex: 1 1 100%; }
  .docs-toolbar select { flex: 1 1 auto; min-width: 0; }
  .doc-card { padding: 10px; }
  .doc-card-side { font-size: 12px; }
  .doc-detail-head h3 { font-size: 16px; }
  .doc-kv { grid-template-columns: 90px 1fr; }
  .doc-body-preview { max-height: 36dvh; font-size: 13px; }
  .doc-actions .btn { flex: 1 1 auto; }
}

@media (min-width: 901px) and (max-width: 1250px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .topbar-title { font-size: 15px; }
  .topnav { gap: 2px; margin-left: 0; }
  .nav-btn { padding: 7px 9px; font-size: 13px; }
  .topbar-user { font-size: 11px; }
  .zoom-ctl { display: none; }
}
