@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@600;700;800&display=swap");

:root {
  --navy: #2d3f5e;
  --dark-navy: #1e2c42;
  --teal: #3a9fa8;
  --teal-hover: #2f8a92;
  --light-teal: #eef8f9;
  --beige: #f7f9fb;
  --ink: #1a2740;
  --muted: #6b7a94;
  --line: #d7dee8;
  --card: #ffffff;
  --accent: var(--teal);
  --accent2: #c45c26;
  --bg: var(--beige);
  --bg2: #ffffff;
  --shadow: 0 8px 28px rgba(30, 44, 66, 0.08);
  --radius: 12px;
  --font: "Inter", system-ui, sans-serif;
  --font-display: "Montserrat", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--beige);
  min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--teal-hover); }

/* ---- Layout ---- */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(45, 63, 94, 0.04);
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}
.wrap-auth {
  max-width: none;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, var(--dark-navy) 0%, var(--navy) 55%, #35506f 100%);
}
.wrap-auth .site-header {
  background: rgba(255, 255, 255, 0.96);
}
.wrap-auth .wrap-inner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 48px;
}
.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.wrap-auth .top { justify-content: center; }
.wrap-auth .brand { pointer-events: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--navy);
}
.brand:hover { text-decoration: none; color: var(--navy); }
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--navy);
  text-transform: uppercase;
}
.brand-sub {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand-sub em {
  font-style: normal;
  color: var(--teal);
}

nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
nav a {
  color: var(--navy);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 10px;
}
nav a:hover {
  background: var(--light-teal);
  color: var(--teal);
  text-decoration: none;
}
nav a.active {
  background: var(--light-teal);
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
}
nav .user-chip {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 8px 6px;
}
nav a.logout-link {
  color: var(--muted);
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 18px; }
.stat .n { font-size: 1.8rem; font-weight: 750; color: var(--navy); font-family: var(--font-display); }
.stat .l { color: var(--muted); margin-top: 4px; font-size: 0.92rem; }

.card { padding: 22px; margin-top: 18px; }
.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0;
  padding: 28px 26px;
  border: none;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
.auth-card .auth-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 8px;
}
.auth-card h1 {
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 800;
}

h1, h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  color: var(--navy);
}
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px;
}
<label { display: grid; gap: 4px; font-size: 0.82rem; color: var(--muted); font-weight: 600; min-width: 0; }
.filter-field { display: grid; gap: 4px; min-width: 0; }
.filter-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
input, select, textarea, button, .btn {
  font: inherit; border-radius: 10px; border: 1px solid var(--line);
  padding: 10px 12px; background: #fff; color: var(--ink);
}
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(58, 159, 168, 0.35);
  border-color: var(--teal);
}
textarea { resize: vertical; min-height: 120px; }
button, .btn {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  cursor: pointer;
  font-weight: 650;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
  text-decoration: none;
  color: #fff;
}
button.secondary, .btn.secondary {
  background: #fff;
  color: var(--navy);
  border-color: var(--line);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--light-teal);
  color: var(--navy);
  border-color: rgba(58, 159, 168, 0.4);
}

.form-card {
  display: grid;
  gap: 14px;
  max-width: 720px;
  width: 100%;
  overflow: hidden;
}
.form-row {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.form-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line);
  vertical-align: top; font-size: 0.95rem;
}
th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.table-row-link { cursor: pointer; }
.table-row-link:hover { background: var(--light-teal); }
.table-row-link:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }

.roles-matrix-wrap {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px 4px;
}
.roles-matrix {
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
}
.roles-matrix th,
.roles-matrix td {
  text-align: center;
  vertical-align: middle;
  padding: 8px 6px;
  white-space: nowrap;
}
.roles-matrix .roles-matrix-role {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  min-width: 140px;
  max-width: 200px;
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
  border-right: 1px solid var(--line);
}
.roles-matrix thead .roles-matrix-role {
  z-index: 3;
  background: #fff;
}
.roles-matrix th.perm-col {
  vertical-align: bottom;
  min-width: 2.4rem;
  max-width: 3.2rem;
  height: 9.5rem;
  padding: 6px 4px;
}
.roles-matrix th.perm-col span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: 0.72rem;
  line-height: 1.2;
  font-weight: 650;
  color: var(--navy);
  text-transform: none;
  letter-spacing: 0;
}
.roles-matrix td.cell-yes {
  color: #1b7a45;
  font-weight: 800;
  font-size: 1.05rem;
  background: #f3faf6;
}
.roles-matrix td.cell-no {
  color: #c5cad3;
  font-weight: 500;
}
.roles-matrix tbody tr:hover td.cell-yes { background: #e7f6ee; }
.roles-matrix tbody tr:hover .roles-matrix-role { background: var(--light-teal); }
.muted { color: var(--muted); }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: var(--light-teal); color: var(--navy); font-size: 0.78rem; font-weight: 700;
}
.badge.warn { background: #f8ebe3; color: var(--accent2); }
.badge.status-done { background: #e3f5ea; color: #1b7a45; }
.badge.status-in_progress { background: var(--light-teal); color: var(--navy); }
.badge.status-todo { background: #f8ebe3; color: var(--accent2); }
.badge.status-planned { background: #eeeef2; color: #5a5f6d; }
.badge.status-partial { background: #fff3d6; color: #8a6400; }
.phase-list { margin: 0; padding-left: 1.2rem; line-height: 1.55; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.meta div {
  background: var(--light-teal); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.meta .k { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.meta .v { margin-top: 4px; font-weight: 650; color: var(--navy); }
.timeline { display: grid; gap: 10px; }
.event, .comment {
  border-left: 3px solid var(--teal); padding: 8px 12px; background: #fff;
  border-radius: 0 10px 10px 0; border: 1px solid var(--line); border-left-width: 3px;
}
.pre {
  white-space: pre-wrap; font-family: Consolas, monospace; font-size: 0.88rem;
  background: var(--dark-navy); color: #e8eef5; padding: 12px; border-radius: 12px; overflow: auto;
}
.page-hero {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.page-hero h1 { color: #fff; margin: 0 0 6px; }
.page-hero .muted { color: rgba(255, 255, 255, 0.72); }
.page-hero .eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7ac5cd;
  margin: 0 0 8px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: start;
  margin-top: 14px;
  overflow-x: auto;
}
.kanban-col {
  background: var(--light-teal);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 280px;
  min-width: 180px;
}
.kanban-col-h {
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col-b { padding: 10px; display: grid; gap: 8px; }
.kanban-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  cursor: grab;
  box-shadow: var(--shadow);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card a { color: var(--navy); font-weight: 600; font-size: 0.9rem; }

/* Client picker + multi filters */
.client-picker { position: relative; min-width: 220px; }
.client-picker .cp-row { display: flex; gap: 6px; align-items: center; }
.client-picker .cp-search { flex: 1; }
.client-picker .cp-clear {
  flex: 0 0 auto; padding: 8px 10px; font-size: 0.85rem;
  background: #fff; color: var(--navy); border: 1px solid var(--line);
}
.cp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cp-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--light-teal); color: var(--navy);
  border-radius: 999px; padding: 4px 8px 4px 10px; font-size: 0.8rem; font-weight: 650;
}
.cp-chip-x {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; width: auto;
}
.cp-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 260px; overflow: auto;
}
.cp-item {
  display: block; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: #fff; color: var(--ink); padding: 10px 12px; font-weight: 500;
}
.cp-item:hover { background: var(--light-teal); color: var(--navy); }
.cp-empty { padding: 10px 12px; color: var(--muted); font-size: 0.85rem; }

.multi-filter {
  position: relative;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0;
}
.multi-filter > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 650;
  color: var(--navy);
  font-size: 0.85rem;
  user-select: none;
}
.multi-filter > summary::-webkit-details-marker { display: none; }
.multi-filter[open] { z-index: 30; }
.multi-filter-panel {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  min-width: 200px;
}
.multi-filter .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.85rem;
  min-width: 0;
}
.multi-filter .check input {
  width: auto;
  margin: 0;
  accent-color: var(--teal);
}
.filters .hint {
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin: -4px 0 0;
}

/* Task hierarchy tree */
.task-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task-tree .task-tree {
  margin: 6px 0 0;
  padding-left: 18px;
  border-left: 2px solid var(--line);
}
.task-tree-item { margin: 4px 0; }
.task-tree-row details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
}
.task-tree-row details > summary::-webkit-details-marker { display: none; }
.task-tree-row details > summary::before {
  content: "▾";
  color: var(--muted);
  font-size: 0.75rem;
  width: 1em;
}
.task-tree-row details:not([open]) > summary::before { content: "▸"; }
.task-tree-leaf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 28px;
  border-radius: 8px;
}
.task-tree-item.is-current > .task-tree-row > details > summary,
.task-tree-item.is-current > .task-tree-row > .task-tree-leaf {
  background: var(--light-teal);
  font-weight: 650;
}
.task-tree-item.is-done > .task-tree-row a { color: var(--muted); }
.task-tree-meta { font-size: 0.8rem; }
.task-tree-path {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.7;
}
.task-tree-path .is-current { color: var(--navy); }
.task-tree-ancestors { margin-bottom: 8px; }
.filter-bar .btn { font-size: 0.85rem; padding: 6px 12px; }

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; }
  table:not(.roles-matrix) th:nth-child(n+4),
  table:not(.roles-matrix) td:nth-child(n+4) { display: none; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .brand-logo { width: 44px; height: 44px; }
  .kanban { grid-template-columns: 1fr; }
  .cal-grid { font-size: 0.8rem; }
  .planner-week { grid-template-columns: 1fr; }
}

/* Deadline planner (Bitrix-like) */
.wrap:has(.planner-page) { max-width: 1480px; }
.planner-page { max-width: none; }
.planner-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
}
.planner-tab {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-weight: 650;
  font-size: 0.9rem;
}
.planner-tab:hover { text-decoration: none; border-color: var(--teal); color: var(--teal); }
.planner-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.planner-board { grid-template-columns: repeat(6, minmax(170px, 1fr)); }
.planner-col-overdue .kanban-col-h { color: #b42318; }
.planner-col-today .kanban-col-h,
.planner-col-today .kanban-col-h { color: var(--teal-hover); }
.planner-nodl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.cal-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 10px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.cal-wd {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 0;
}
.cal-day {
  min-height: 110px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day.cal-empty {
  background: transparent;
  border-color: transparent;
  min-height: 0;
}
.cal-day.cal-today {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px rgba(58, 159, 168, 0.25);
}
.cal-day-n {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
}
.cal-day-tasks { display: grid; gap: 3px; }
.cal-task {
  background: var(--light-teal);
  border-radius: 6px;
  padding: 3px 5px;
  font-size: 0.72rem;
  line-height: 1.25;
  cursor: grab;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-task a { color: var(--navy); font-weight: 600; }
.planner-week { grid-template-columns: repeat(7, minmax(140px, 1fr)); }

