/* ==========================================================================
   Base / Reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f6f7fb;
  color: #111827;
}

a {
  color: inherit;
}

.muted {
  color: #6b7280;
}

.small {
  font-size: 12px;
  color: #6b7280;
}

.nowrap {
  white-space: nowrap;
}

.num {
  text-align: right;
  white-space: nowrap;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .grid--2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .user-role { display: none; }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  padding: 14px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.card + .card {
  margin-top: 14px;
}

.card-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form {
  display: grid;
  gap: 10px;
}

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

.form-actions--split {
  justify-content: space-between;
  align-items: center;
}

.form--spaced {
  margin-top: 10px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: #ffffff;
  font: inherit;
  color: inherit;
}

textarea {
  resize: vertical;
}

.checkbox {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* Modern aligned rows: 2 fields per row like in web-app forms */
.form-grid {
  display: grid;
  gap: 12px;
}

.form-row2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}

.field {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.field label {
  font-weight: 600;
  color: #374151;
}

.field .control {
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .form-row2 {
    grid-template-columns: 1fr;
  }
  .field {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .field label {
    margin-bottom: 4px;
  }
}

/* ==========================================================================
   Admin
   ========================================================================== */

/* Admin as a full-viewport dashboard (no page scroll) */
body.page-admin {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body.page-admin main.container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Main layout: header + (mobile tabs) + grid */
.admin {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.admin__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.admin__title {
  margin: 0;
}

.admin__subtitle {
  margin-top: 4px;
  color: #6b7280;
  font-size: 14px;
}

.admin-tabs {
  display: none; /* shown only on mobile */
  gap: 8px;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
}

.admin-tab.is-active {
  background: #e5e7eb;
}

/* Improve mobile vertical space: tabs in one row with horizontal scroll */
.admin-tabs {
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  padding-bottom: 2px;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab { flex: 0 0 auto; }

/* Prevent accidental horizontal page scroll */
body.page-admin { overflow-x: hidden; }
body.page-admin main.container { overflow-x: hidden; }
.admin, .admin__grid, .admin-card, .admin-card .card-scroll { min-width: 0; }

/* Tables: keep horizontal scroll inside wrapper */
.table-wrap { width: 100%; min-width: 0; -webkit-overflow-scrolling: touch; }

/* Description cell: don't let long unbroken strings expand layout */
.table--scroll td.desc-cell,
.table--scroll td.desc-cell .desc-clamp {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 600px) {
  body.page-admin .container { padding: 10px; }
  .admin { gap: 10px; }
  .admin__title { font-size: 32px; line-height: 1.15; }
  .admin__subtitle { display: none; }
  .admin-card { border-radius: 14px; }
}

.admin__grid {
  display: grid;
  gap: 14px;
  flex: 1;
  min-height: 0;
  min-width: 0;

  /* Desktop/tablet default: stack sections (full width) */
  grid-template-columns: 1fr;
  grid-template-areas:
    "users"
    "create"
    "tasks";
}

.admin__tasks {
  margin-top: 0;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.admin-card .card-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.admin-card--users { grid-area: users; }
.admin-card--create { grid-area: create; }
.admin-card--tasks { grid-area: tasks; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 980px) {
  .admin-tabs {
    display: flex;
  }

  .admin__grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "one";
  }

  /* One section per screen (no page scroll). */
  .admin-card {
    display: none;
  }

  .admin[data-active-tab="users"] .admin-card--users,
  .admin[data-active-tab="create"] .admin-card--create,
  .admin[data-active-tab="tasks"] .admin-card--tasks {
    display: flex;
    grid-area: one;
  }
}


/* ==========================================================================

/* Desktop wide: two cards on the top row, tasks full width below */
@media (min-width: 1100px) {
  .admin__grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "users create"
      "tasks tasks";
    align-items: stretch;
  }
}

 /* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #ffffff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: #f3f4f6;
}

.btn--primary {
  border-color: rgba(0, 0, 0, 0.20);
  font-weight: 600;
}

.btn--ghost {
  background: transparent;
}

.btn--ghost:hover {
  background: #f3f4f6;
}

.td-actions {
  white-space: nowrap;
}

.action-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn--danger {
  border-color: rgba(185, 28, 28, 0.35);
  color: #b91c1c;
  background: #ffffff;
}

.btn--danger:hover {
  background: #fef2f2;
}


/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  table-layout: fixed; /* prevents long text from expanding columns */
}

.table th,
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.table th {
  background: #f3f4f6;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.summary {
  margin: 12px 0;
}

.task-title {
  font-weight: 600;
}

/* Админка: фикс ширины колонки "Описание" */
#tasksTable th:nth-child(2),
#tasksTable td:nth-child(2) {
  width: 34%;
}

.table--compact th,
.table--compact td {
  padding: 8px 10px;
}

.table--scroll {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.table--scroll th,
.table--scroll td {
  white-space: nowrap;
  word-break: normal;
}

.table--scroll td.desc-cell {
  white-space: normal;
}

.table--admin td {
  vertical-align: middle;
}

.table-wrap--spaced {
  margin-top: 12px;
}

/* Подзадачи */
.indent {
  padding-left: 18px;
}

.sort-th {
  user-select: none;
}

.sort-th:hover {
  background: #e5e7eb;
}


/* ==========================================================================
   Row statuses (optional highlighting)
   ========================================================================== */

tr.ok {
  background: #ecfdf5;
}

tr.bad {
  background: #fef2f2;
}

tr.mid {
  background: #ffffff;
}

tr.overdue {
  background: #fff7ed;
}

tr.subrow td {
  border-top: 0;
  background: #ffffff;
  padding-top: 0;
}

/* ==========================================================================
   Day view helpers
   ========================================================================== */

.dayform .comment-input {
  min-width: 280px;
  flex: 1;
}

.dayform .prog-input {
  width: 90px;
}

.hoursbox {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hours-input {
  width: 120px;
}

.quick {
  display: flex;
  gap: 6px;
}

.qbtn {
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.qbtn:hover {
  background: #f3f4f6;
}

/* ==========================================================================
   Print
   ========================================================================== */

.noprint {
}

.pagebreak {
  height: 12px;
}

@media print {
  body {
    background: #ffffff;
  }

  .noprint {
    display: none !important;
  }

  .pagebreak {
    page-break-before: always;
  }

  .container {
    max-width: none;
    padding: 0;
  }
}

/* ==========================================================================
   Description cell clamp (prevents table shifting)
   ========================================================================== */

#tasksTable td.desc-cell {
  position: relative;
  overflow: hidden;
  min-width: 0;
}

#tasksTable td.desc-cell .desc-clamp {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 26px; /* space for button */
}

#tasksTable td.desc-cell .desc-open {
  position: absolute;
  right: 6px;
  top: 6px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 2px 6px;
  cursor: pointer;
}

#tasksTable td.desc-cell .desc-open:hover {
  background: #ffffff;
}

/* ==========================================================================
   Top navigation
   ========================================================================== */

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #374151;
  font-weight: 500;
}

.nav-link:hover {
  background: #f3f4f6;
}

.nav-link.active {
  background: #e5e7eb;
  color: #111827;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.user-name {
  font-weight: 600;
}

.user-role {
  color: #6b7280;
  font-size: 12px;
}

.logout {
  margin-left: 8px;
  text-decoration: none;
  color: #b91c1c;
}

.logout:hover {
  text-decoration: underline;
}


/* ==========================================================
   Admin layout overrides (v3)
   Fixes: desktop grid placement, no page scroll, tab bar overflow, page horizontal overflow
   ========================================================== */

body.page-admin {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body.page-admin .topbar {
  flex: 0 0 auto;
}

body.page-admin main.container {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden; /* no page scroll; cards scroll internally */
}

/* Admin wrapper */
body.page-admin .admin {
  height: 100%;
  min-height: 0;
}

/* Desktop / tablet: stack sections full width */
body.page-admin .admin__grid{
  display: grid;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  grid-template-columns: 1fr;
  grid-template-areas:
    "users"
    "create"
    "tasks";
}

/* Desktop wide: users + create in two columns on top, tasks full width below */
@media (min-width: 1100px){
  body.page-admin .admin__grid{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "users create"
      "tasks tasks";
    align-items: stretch;
  }
}

body.page-admin .admin-card { min-width: 0; min-height: 0; }
body.page-admin .admin-card--users { grid-area: users; }
body.page-admin .admin-card--create { grid-area: create; }
body.page-admin .admin-card--tasks { grid-area: tasks; }

/* Card internal scroll */
body.page-admin .admin-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.page-admin .admin-card .card-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* Prevent page horizontal scroll: allow horizontal only inside table wrapper */
body.page-admin { overflow-x: hidden; }
body.page-admin .admin-card--tasks .card-scroll { overflow-x: hidden; }
body.page-admin .table-wrap { max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Long strings in description must not widen the layout */
body.page-admin td.desc-cell,
body.page-admin td.desc-cell .desc-clamp {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Mobile: one card per screen, tabs are scrollable horizontally */
@media (max-width: 980px) {
  body.page-admin main.container { overflow: hidden; }

  body.page-admin .admin-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  body.page-admin .admin-tabs::-webkit-scrollbar { display: none; }
  body.page-admin .admin-tab { flex: 0 0 auto; white-space: nowrap; }

  body.page-admin .admin__grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "one";
  }

  /* hide all; show only active */
  body.page-admin .admin-card { display: none; }
  body.page-admin .admin[data-active-tab="users"] .admin-card--users,
  body.page-admin .admin[data-active-tab="create"] .admin-card--create,
  body.page-admin .admin[data-active-tab="tasks"] .admin-card--tasks {
    display: flex;
    grid-area: one;
  }

  /* Save vertical space on small screens */
  body.page-admin .admin__subtitle { display: none; }
  body.page-admin .admin { gap: 10px; }
  body.page-admin .container { padding: 10px; }
}

/* Make sure the tasks table cannot force page width */
@media (max-width: 980px) {
  body.page-admin .admin-card--tasks table { min-width: 760px; }
}


/* ===== Topbar responsive layout ===== */
@media (max-width: 700px) {
  .topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 12px;
    min-width: 0;
  }

  .brand {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  .user-box {
    order: 2;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .nav {
    order: 3;
    flex: 0 0 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    min-width: 0;
  }

  .nav-link {
    white-space: nowrap;
  }
}

/* Prevent horizontal page scroll on mobile */
body { overflow-x: hidden; }


/* ===========================================================
   Admin: page scroll (no internal card scroll)
   =========================================================== */
body.page-admin {
  display: block;
  height: auto;
  overflow: visible;
}

body.page-admin main.container {
  overflow: visible;
}

/* Внутренний скролл карточек выключаем */
body.page-admin .admin-card {
  overflow: visible;
}

body.page-admin .admin-card .card-scroll {
  overflow: visible;
  padding-right: 0; /* можно оставить, но обычно уже не нужно */
}

/* На всякий случай: чтобы ничего не ограничивало рост */
body.page-admin .admin,
body.page-admin .admin__grid {
  height: auto;
  min-height: 0;
}


/* ===== Tasks filters layout ===== */
.tasks-filters .form-row1 {
  display: block;
}

/* Мобильные: типы по одному в строку */
@media (max-width: 600px) {
  .tasks-filters .filter-chips--types {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .tasks-filters .filter-chips--types .checkbox {
    display: block;
    width: 100%;
  }
}

/* Tasks filters: text on the left, checkbox on the right */
.tasks-filters .checkbox {
  display: flex;
  align-items: center;
  justify-content: space-between; /* текст слева, чекбокс справа */
  gap: 10px;
}

.tasks-filters .checkbox input {
  order: 2; /* чекбокс справа */
}

.tasks-filters .checkbox {
  text-align: left;
}


/* ===========================================================
   Topbar mobile layout:
   Row1: logo (left) + title (right)
   Row2: user name (left) + logout (right)
   Row3+: nav links (wrap)
   =========================================================== */

@media (max-width: 700px) {

  .topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 12px;
    min-width: 0;
  }

  /* Row 1 */
  .brand-wrap {
    order: 1;
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    text-decoration: none;
    color: inherit;
    min-width: 0;
  }

  .brand-logo {
    max-height: 28px;
    width: auto;
    flex: 0 0 auto;
  }

  .brand-title {
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
    white-space: nowrap;
  }

  /* Row 2 */
  .user-box {
    order: 2;
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
  }

  .user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .logout {
    white-space: nowrap;
  }

  /* Row 3+ */
  .nav {
    order: 3;
    flex: 0 0 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    min-width: 0;
  }

  .nav-link {
    white-space: nowrap;
  }
}

/* Brand (desktop): keep logo compact */
.brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-wrap .brand-logo {
  height: 32px;      /* десктопный размер */
  width: auto;
  max-height: 32px;
  display: block;
}

/* На всякий случай — если где-то есть img{width:100%} */
.brand-wrap .brand-logo {
  max-width: none;
}

/* ===== Modal ===== */
.modal { display: none; }
.modal.is-open { display: block; position: fixed; inset: 0; z-index: 50; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
}
.modal__head {
  display:flex; justify-content: space-between; align-items:flex-start;
  padding: 14px 16px; border-bottom: 1px solid rgba(0,0,0,0.08);
}
.modal__title { margin: 0; font-size: 18px; }
.modal__body { padding: 14px 16px; }
.modal__actions {
  display:flex; justify-content:flex-end; gap: 10px;
  padding: 14px 16px; border-top: 1px solid rgba(0,0,0,0.08);
}

.day-row--done td{background:rgba(46,204,113,.10);} 
.day-row--overdue td{background:rgba(231,76,60,.10);} 


/* ===== Day page enhancements ===== */
.day-card{
  min-height: calc(100dvh - 140px);
  display: flex;
  flex-direction: column;
}

/* Day filter: labels close to inputs */
.day-filter{
  gap: 10px;
  flex-wrap: wrap;
}
.day-filter .field--inline{
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.day-filter .field--inline > label{
  margin: 0;
  white-space: nowrap;
}
.day-filter .field--inline .control{
  margin: 0;
}

.table th.td-center,
.table td.td-center{
  text-align: center;
  vertical-align: middle;
}

.text-clamp{
  display: inline-block;
  max-width: 15ch;          /* ~10-15 символов */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.text-open{
  margin-left: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0 4px;
  color: inherit;
  opacity: .75;
}
.text-open:hover{ opacity: 1; }

.day-row--fast td{ background: rgba(155, 89, 182, 0.10); }   /* мягкий фиолетовый */
.day-row--delay td{ background: rgba(243, 156, 18, 0.12); }  /* мягкий оранжевый */

/* ensure done/overdue stay primary if both classes present in future */
.day-row--done td{ background: rgba(46, 204, 113, 0.10); }
.day-row--overdue td{ background: rgba(231, 76, 60, 0.10); }

/* sorted hint */
.sort-th{ cursor: pointer; }
.sort-th.is-sorted-asc::after{ content: " ▲"; opacity: .65; font-size: 12px; }
.sort-th.is-sorted-desc::after{ content: " ▼"; opacity: .65; font-size: 12px; }

/* ==========================================================================
   Week / Month calendar
   ========================================================================== */

.week-head{
  display:flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.week-head__right{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.week-toolbar{
  display:flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.week-toolbar__group{
  display:flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.week-toolbar__group--right{
  margin-left: auto;
}

.field--inline{
  display:flex;
  gap: 10px;
  align-items: center;
}

.field--inline > label{
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.field--inline .control{
  min-width: 180px;
}

.week-toolbar__check{
  margin-left: 4px;
}

.btn--sm{
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.seg{
  display:inline-flex;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 999px;
  overflow: hidden;
}

.seg__btn{
  padding: 6px 10px;
  text-decoration: none;
  background: #fff;
  font-weight: 600;
  font-size: 13px;
  border-right: 1px solid rgba(0,0,0,0.10);
}

.seg__btn:last-child{ border-right: none; }

.seg__btn:hover{ background: #f3f4f6; }

.seg__btn.is-active{
  background: #111827;
  color: #fff;
}

.cal-scroll{
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cal-grid{
  display:grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  gap: 10px;
  min-width: 980px;
}

.cal-dow{
  font-weight: 700;
  color: #374151;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.08);
  text-align: left;
}

.cal-dow.is-weekend{
  background: rgba(245,158,11,0.10);
}

.cal-cell{
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  background: #fff;
  padding: 10px 10px 8px;
  min-height: 120px; /* ~минимум под 5 строк */
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.cal-cell.is-out{
  background: rgba(0,0,0,0.03);
}

.cal-cell.is-weekend{
  border-color: rgba(245,158,11,0.22);
}

.cal-cell.is-today{
  outline: 2px solid rgba(17,24,39,0.35);
  outline-offset: 2px;
}

.cal-cell__head{
  display:flex;
  justify-content: space-between;
  align-items: center;
}

.cal-daynum{
  font-weight: 800;
  color: #111827;
}

.cal-daylink{
  text-decoration: none;
  font-size: 13px;
  opacity: 0.75;
}

.cal-daylink:hover{ opacity: 1; }

.cal-tasks{
  display:flex;
  flex-direction: column;
  gap: 6px;
}

.cal-task{
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 12px;
  padding: 7px 8px;
  display:flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.cal-task:hover{
  background: #f9fafb;
}

.cal-task.is-group{
  font-weight: 400;
}

.cal-task.is-overdue{
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(185, 28, 28, 0.05);
}

.cal-task__title{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-task__who{
  width: 18px;
  text-align: right;
  font-weight: 800;
  color: #6b7280;
}

.cal-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 8px;
  background: #9ca3af;
}

.cal-dot--todo{ background: #9ca3af; }
.cal-dot--in_progress{ background: #2563eb; }
.cal-dot--done{ background: #16a34a; }

.cal-marker{
  color: #6b7280;
  font-weight: 800;
  margin-right: 2px;
}

/* Agenda (list view) */
.agenda{
  margin-top: 12px;
  display:grid;
  gap: 12px;
}

.agenda-day{
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.agenda-day.is-weekend{
  border-color: rgba(245,158,11,0.22);
}

.agenda-day.is-today{
  outline: 2px solid rgba(17,24,39,0.35);
  outline-offset: 2px;
}

.agenda-day__head{
  padding: 12px 12px;
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.03);
}

.agenda-day__date{
  display:flex;
  gap: 10px;
  align-items: center;
}

.agenda-day__num{
  font-size: 22px;
  font-weight: 900;
  width: 38px;
  text-align: center;
}

.agenda-day__body{
  padding: 12px 12px;
}

.agenda-list{
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.agenda-task{
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 12px;
  padding: 9px 10px;
  display:flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.agenda-task:hover{ background: #f9fafb; }
.agenda-task.is-group{ font-weight: 400; }
.agenda-task.is-overdue{
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(185, 28, 28, 0.05);
}

.agenda-task__title{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-task__who{
  width: 18px;
  text-align: right;
  font-weight: 800;
  color: #6b7280;
}

/* Modal content helpers */
.kv{
  display:grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px 14px;
  margin-bottom: 12px;
}

@media (max-width: 900px){
  .kv{ grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

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

.kv__item{
  display:grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
}

.kv__k{ color: #6b7280; font-size: 12px; }
.kv__v{ color: #111827; min-width: 0; overflow-wrap: anywhere; }

.kv__k{ color: #6b7280; font-weight: 700; }
.kv__v{ color: #111827; font-weight: 600; }

.modal-block{
  margin-top: 12px;
}

.pre{
  margin-top: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px 10px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  background: rgba(0,0,0,0.02);
}

@media (max-width: 900px){
  .cal-grid{ grid-template-columns: repeat(7, minmax(160px, 1fr)); }
}

@media (max-width: 520px){
  .field--inline .control{ min-width: 160px; }
  .cal-grid{ grid-template-columns: repeat(7, minmax(140px, 1fr)); }
}


/* ===== Week page: wider container on desktop ===== */
.container--wide{
  max-width: 1600px;
  width: min(1600px, calc(100vw - 24px));
  padding-left: 12px;
  padding-right: 12px;
}
@media (max-width: 700px){
  .container--wide{
    max-width: 1200px;
    width: auto;
    padding: 14px;
  }
}

/* ===== Week page: compact task cards ===== */
.cal-cell{
  min-height: 108px;
  padding: 8px 8px 6px;
  gap: 6px;
}
.cal-tasks{ gap: 4px; }
.cal-task{
  padding: 5px 6px;
  border-radius: 10px;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.15;
}
.cal-task__who{
  width: 14px;
  font-size: 11px;
}

.agenda-list{ gap: 6px; }
.agenda-task{
  padding: 6px 8px;
  border-radius: 10px;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.15;
}
.agenda-task__who{
  width: 14px;
  font-size: 11px;
}

/* ===== Modal: wider + edit layout ===== */
.modal__panel--wide{
  width: min(860px, calc(100% - 24px));
}

/* Make the task modal fit in viewport height (scroll inside body) */
#taskModal .modal__panel{
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
}

#taskModal .modal__body{
  overflow: auto;
}
.modal__headActions{
  display:flex;
  gap: 8px;
  align-items: flex-start;
}
.modal__actions--split{
  justify-content: space-between;
  align-items: center;
}
.modal__actionsRight{
  display:flex;
  gap: 10px;
}

.modal-block__title{
  font-weight: 800;
  margin-bottom: 10px;
}

/* Make form rows in modal fit better */
.modal__panel .field{
  grid-template-columns: 120px minmax(0, 1fr);
}

.field--span2{
  grid-column: 1 / -1;
}

#taskEditLogBlock.is-disabled{
  opacity: 0.55;
}

