/* ==========================================================================
   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;
  }
}

/* ==========================================================================
   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 {
  display: grid;
  gap: 16px;
}

.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__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin__tasks {
  margin-top: 2px;
}

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

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

/* ==========================================================================
   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;
}
