:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --border: #e5e7ef;
  --text: #1e2230;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --secondary: #0ea5a4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 6px; }
.nav__link {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__link.is-active { color: var(--primary); background: var(--primary-soft); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.whoami { display: flex; align-items: center; gap: 8px; }
.whoami__name { font-weight: 600; font-size: 14px; }

main.container { padding-top: 26px; padding-bottom: 60px; min-height: calc(100vh - 58px - 60px); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer__inner { display: flex; gap: 10px; align-items: baseline; padding: 18px 20px; font-size: 13px; }
.footer__muted { color: var(--muted); }

/* ---------- Headings / text ---------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-head__title { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
.h1 { font-size: 22px; margin: 0 0 8px; }
.h2 { font-size: 17px; margin: 0 0 6px; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.center { text-align: center; }
.rule { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.stack > * + * { margin-top: 14px; }
.prose { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card--narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.empty { padding: 40px 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background .12s, border-color .12s, color .12s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: var(--secondary); color: #fff; }
.btn--secondary:hover { filter: brightness(0.94); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn--danger:hover { background: #fee2e2; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 15px; padding: 4px 6px; border-radius: 6px;
  line-height: 1; font-family: inherit;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.inline-form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form--tight { gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.select { appearance: auto; }
.form__actions { display: flex; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fieldset { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; }
.plain-list { margin: 0; padding-left: 18px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 6px; }
.alert--error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert--success { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }

/* ---------- Auth ---------- */
.auth { display: flex; justify-content: center; padding-top: 40px; }
.auth__card { width: 100%; max-width: 400px; }
.auth__title { margin: 0 0 4px; font-size: 22px; }

/* ---------- Badges / pills / chips ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge--role { background: var(--primary-soft); color: var(--primary-dark); border-color: #dfe3ff; }
.badge--open { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }
.badge--in_progress { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.badge--done { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.badge--cancelled { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

.pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.pill--paid { background: var(--green-soft); color: var(--green); }
.pill--unpaid { background: var(--amber-soft); color: var(--amber); }

.chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.chip:hover { text-decoration: none; border-color: #d1d5e6; color: var(--text); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.status-dot--open { background: #3b82f6; }
.status-dot--in_progress { background: #f59e0b; }
.status-dot--done { background: #22c55e; }
.status-dot--cancelled { background: #9ca3af; }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.summary__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.summary__label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.summary__value { font-size: 22px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.summary__card--paid .summary__value { color: var(--green); }
.summary__card--unpaid .summary__value { color: var(--amber); }

/* Единственная карточка сводки внизу дашборда — компактная, прижата вправо */
.summary--compact { display: flex; justify-content: flex-end; grid-template-columns: none; margin: 8px 0 0; }
.summary--compact .summary__card { width: auto; min-width: 150px; padding: 10px 14px; }
.summary--compact .summary__label { font-size: 11px; }
.summary--compact .summary__value { font-size: 17px; }

/* ---------- Filters ---------- */
.filters { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.filters__group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- List sections ---------- */
.list-section { margin-bottom: 24px; }
.list-section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.list-section__title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0; }
.drag-hint { margin-left: auto; }
.task-list--muted .task-row { opacity: 0.72; }
.task-list--muted .task-row:hover { opacity: 1; }

/* ---------- Task list ---------- */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px;
}
.task-row--draggable { cursor: grab; }
.task-row--draggable:active { cursor: grabbing; }
.task-row.is-dragging { opacity: 0.5; border-style: dashed; box-shadow: none; }
.drag-handle {
  color: #c3c7d4; font-size: 18px; line-height: 1; letter-spacing: -2px;
  cursor: grab; user-select: none; flex-shrink: 0; padding-right: 2px;
}
.task-row--draggable:hover .drag-handle { color: var(--muted); }
.task-row__main { flex: 1; min-width: 0; }
.task-row__main:hover { text-decoration: none; }
.task-row__title { font-weight: 700; font-size: 15.5px; color: var(--text); }
.task-row__meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 13px; }
.task-row__money { text-align: right; white-space: nowrap; }
.task-row__amount { font-weight: 800; font-size: 15px; }

/* ---------- Task page ---------- */
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.back-link { font-size: 13px; color: var(--muted); }
.task-head__title { font-size: 24px; margin: 8px 0 8px; letter-spacing: -0.02em; }
.task-head__meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.task-head__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Masonry-раскладка инфо-блоков: карточки упаковываются по высоте, без пустот */
.task-info { columns: 2; column-gap: 18px; }
.task-info > .card { break-inside: avoid; -webkit-column-break-inside: avoid; margin-bottom: 18px; }
@media (max-width: 760px) { .task-info { columns: 1; } }

.status-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.status-form__row { display: flex; gap: 10px; margin-top: 6px; max-width: 320px; }
.status-form__row .select { flex: 1; }

/* ---------- Links ---------- */
.link-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-list__item { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.link-list__item .link { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-list__item .muted { flex-shrink: 0; white-space: nowrap; }
.link-list__item .inline-form { flex-shrink: 0; }
.link { font-weight: 600; min-width: 0; }
.link-add { display: flex; gap: 8px; flex-wrap: wrap; }
.link-add .input { flex: 1; min-width: 140px; }
.file-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.file-input { flex: 1; min-width: 200px; padding: 7px 10px; }
.file-input::file-selector-button {
  margin-right: 10px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}

/* «Ссылки» и «Файлы» рядом в одну строку, компактно */
.attach-row { display: flex; gap: 14px; align-items: flex-start; }
.attach-row > .card { flex: 1 1 0; min-width: 0; margin-bottom: 18px; }
.card--compact { padding: 12px 14px; }
.card--compact .section-title { margin-bottom: 8px; }
.card--compact p { margin: 0 0 8px; }
.card--compact .link-list { margin: 0 0 8px; gap: 6px; }
.card--compact .link-add,
.card--compact .file-add { margin-top: 0; }
.card--compact .link-add .input,
.card--compact .file-input { padding: 7px 10px; min-width: 120px; }
@media (max-width: 620px) { .attach-row { flex-direction: column; } }
.link-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row .input:first-child { flex: 1.4; }
.link-row .input:nth-child(2) { flex: 1; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tfoot td { border-bottom: none; border-top: 2px solid var(--border); padding-top: 12px; }
.table .num { text-align: right; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.report-body { white-space: pre-wrap; word-break: break-word; min-width: 160px; }
.row--paid { background: var(--green-soft); }
.row-actions { display: flex; gap: 2px; white-space: nowrap; }

/* ---------- Reports (карточки отчётов) ---------- */
.reports { display: flex; flex-direction: column; gap: 10px; }
.report { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.report--paid { background: var(--green-soft); border-color: #bbf7d0; }
.report__head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.report__date { font-weight: 700; white-space: nowrap; }
.report__hours { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.report__amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report__pay { white-space: nowrap; }
.report__actions { margin-left: auto; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.report__body { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.reports-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--border); }
.reports-total__nums { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }

/* Индикатор таймера работы над задачей */
.timer-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 14px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.timer-chip__clock { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.timer-chip__label { color: var(--muted); }
.timer-chip--running { background: var(--amber-soft); border-color: #fde68a; color: var(--amber); }
.timer-chip--running .timer-chip__label { color: var(--amber); }

/* ---------- Dropdown (report edit) ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown__panel {
  position: absolute; right: 0; top: 28px; z-index: 10;
  width: 300px; margin: 0; box-shadow: 0 10px 30px rgba(16,24,40,0.16);
}

.add-report { margin-top: 16px; }
.add-report__toggle { list-style: none; cursor: pointer; display: inline-flex; }
.add-report__toggle::-webkit-details-marker { display: none; }
.add-report__form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---------- Comments ---------- */
.comments { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.comment { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.comment--mine { background: var(--primary-soft); border-color: #dfe3ff; }
.comment__head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.comment__author { font-weight: 700; font-size: 13px; }
.comment__del { margin-left: auto; }
.comment__body { font-size: 14px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar__inner { gap: 10px; }
  .nav { display: none; }
  .whoami__name { display: none; }
  .summary { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .task-head { flex-direction: column; }
  .two-col { grid-template-columns: 1fr; }
  .dropdown__panel { width: 260px; }
}
