* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7f4;
    --card: #ffffff;
    --text: #1c2b22;
    --muted: #66756c;
    --line: #dce7df;
    --line-soft: #edf3ee;

    --primary: #155337;
    --primary-hover: #11462f;
    --primary-soft: #eaf4ef;
    --primary-soft-2: #dceee4;
    --primary-line: #bfd8c8;

    --danger: #d64545;
    --danger-hover: #bc3535;

    --shadow: 0 10px 28px rgba(21, 83, 55, 0.08);
    --radius: 16px;
    --radius-sm: 12px;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #f7faf8 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.45;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 16px auto 28px;
    padding: 0 12px;
}

.task-page {
    max-width: 1040px;
}

/* ===== Верх ===== */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #123824;
}

.muted {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.user-box {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 300px;
    max-width: 430px;
    width: 100%;
}

/* ===== Картки ===== */

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.compact-card {
    padding: 14px;
}

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

h2,
h3 {
    margin: 0 0 10px;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: #173b28;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 16px;
}

label {
    display: block;
    font-size: 12px;
    color: #456052;
    margin-bottom: 5px;
    font-weight: 700;
}

/* ===== Форми ===== */

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

.compact-grid {
    gap: 10px;
}

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

input,
select,
textarea,
button {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid #cadbce;
    transition: 0.18s ease;
    font-family: inherit;
}

input,
select,
textarea {
    background: #fff;
    color: var(--text);
}

input::placeholder,
textarea::placeholder {
    color: #8a9b91;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 83, 55, 0.12);
}

textarea {
    min-height: 82px;
    resize: vertical;
}

button {
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    border: none;
    font-weight: 700;
    box-shadow: none;
}

button:hover {
    background: var(--primary-hover);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-line);
}

.secondary-btn:hover {
    background: var(--primary-soft-2);
}

.danger-btn {
    background: var(--danger);
    color: #fff;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.danger-btn:hover {
    background: var(--danger-hover);
}

.danger-wide-btn {
    background: var(--danger);
    color: #fff;
}

.danger-wide-btn:hover {
    background: var(--danger-hover);
}

.copy-board-btn,
.delete-board-btn {
    width: auto;
    min-width: 120px;
    margin: 0;
}

.hidden {
    display: none !important;
}

/* ===== Статуси ===== */

.status-manager {
    margin-bottom: 14px;
    padding: 12px;
    background: #f7fbf8;
    border: 1px solid #d9e8de;
    border-radius: 12px;
}

.status-create-row {
    display: grid;
    grid-template-columns: 1fr 170px;
    gap: 8px;
    margin-bottom: 10px;
}

.statuses-manager-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d6e4db;
    border-radius: 12px;
    padding: 6px 8px 6px 10px;
    min-height: 40px;
}

.status-row span {
    font-size: 13px;
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-line);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1;
}

/* ===== Таблиці ===== */

.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
}

table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 13px;
}

th {
    font-size: 12px;
    color: #4f685a;
    background: #f7faf8;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
}

td a,
a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

td a:hover,
a:hover {
    text-decoration: underline;
}

/* ===== Назад ===== */

.page-actions {
    margin-bottom: 10px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #d4e2d8;
    border-radius: 12px;
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(21, 83, 55, 0.05);
}

.back-link:hover {
    background: #f5faf7;
    text-decoration: none;
}

/* ===== Шапка задачі ===== */

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

.task-head-row h2 {
    margin: 0 0 5px;
    font-size: 22px;
}

.task-meta-line {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 12px;
    color: #667a6f;
}

.task-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.task-head-actions button {
    margin: 0;
    width: auto;
    min-width: 118px;
    padding-left: 14px;
    padding-right: 14px;
}

/* ===== Дії ===== */

.inline-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0 12px;
    flex-wrap: wrap;
}

.inline-actions button {
    width: auto;
    min-width: 170px;
    margin: 0;
}

/* ===== Вставка скрінів ===== */

.paste-zone {
    border: 2px dashed #b7d0bf;
    background: #f7fbf8;
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: 0.18s ease;
}

.paste-zone:hover,
.paste-zone:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--primary-soft);
}

.paste-zone strong {
    display: block;
    margin-bottom: 5px;
    color: #123d28;
    font-size: 14px;
}

.paste-zone span {
    font-size: 12px;
    color: var(--muted);
}

/* ===== Зображення ===== */

.paste-preview,
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.image-item,
.paste-item {
    position: relative;
    display: block;
    background: #fff;
    border: 1px solid #d7e3da;
    border-radius: 12px;
    overflow: hidden;
    padding: 6px;
}

.image-item img,
.paste-item img {
    width: 100%;
    height: 104px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
    border: 1px solid #e7efe9;
}

.image-card {
    position: relative;
}

.image-open-link {
    display: block;
}

.image-card .delete-image-btn,
.paste-item .danger-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    margin: 0;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

/* ===== Коментарі / логи ===== */

.comment-item,
.log-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
}

.comment-item:last-child,
.log-item:last-child {
    border-bottom: none;
}

.compact-list p,
.comment-item p,
.log-item p {
    margin: 5px 0 0;
    font-size: 14px;
}

small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
    font-size: 12px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 12px 0;
}

/* ===== Телефон/планшет ===== */

@media (max-width: 900px) {
    .container {
        max-width: 760px;
        padding: 0 12px;
    }

    .topbar {
        align-items: stretch;
    }

    .user-box {
        min-width: 100%;
        max-width: none;
    }

    .form-grid,
    .grid,
    .compact-grid {
        grid-template-columns: 1fr;
    }

    .status-create-row {
        grid-template-columns: 1fr;
    }

    .task-head-row {
        flex-direction: column;
        align-items: stretch;
    }

    .task-head-actions {
        width: 100%;
    }

    .task-head-actions button {
        width: 100%;
    }

    .inline-actions {
        flex-direction: column;
    }

    .inline-actions button {
        width: 100%;
    }

    .back-link {
        width: 100%;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    .container {
        margin: 10px auto;
        padding: 0 10px;
    }

    .topbar {
        gap: 10px;
        margin-bottom: 10px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .muted {
        font-size: 12px;
    }

    .card,
    .compact-card {
        border-radius: 12px;
        padding: 12px;
        margin-top: 10px;
    }

    h2 {
        font-size: 17px;
    }

    h3 {
        font-size: 15px;
    }

    .task-head-row h2 {
        font-size: 18px;
    }

    input,
    select,
    textarea,
    button {
        padding: 10px 11px;
        font-size: 13px;
        border-radius: 10px;
    }

    textarea {
        min-height: 78px;
    }

    .status-badge {
        font-size: 10px;
        padding: 4px 8px;
    }

    .paste-zone {
        padding: 14px 12px;
    }

    .paste-preview,
    .images-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .image-item img,
    .paste-item img {
        height: 92px;
    }

    th,
    td {
        padding: 9px 7px;
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .container {
        padding: 0 8px;
    }

    .card,
    .compact-card {
        padding: 10px;
    }

    .user-box {
        flex-direction: column;
        align-items: stretch;
    }

    .paste-preview,
    .images-grid {
        grid-template-columns: 1fr 1fr;
    }

    .task-meta-line {
        gap: 6px;
    }

    .task-head-actions button,
    .copy-board-btn,
    .delete-board-btn {
        min-width: 100%;
    }
}

/* ===== Налаштування дошки ===== */

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-actions button {
    width: auto;
    min-width: 118px;
    margin: 0;
}

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

.settings-head .secondary-btn {
    width: auto;
    min-width: 120px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 16px;
}

.settings-status-list {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.settings-status-row,
.editable-status-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto auto;
    gap: 8px;
    align-items: center;
}

.settings-status-row .danger-btn,
.editable-status-row .danger-btn {
    margin: 0;
}

.editable-status-row .secondary-btn {
    width: auto;
    min-width: 110px;
    margin: 0;
}

.field-toggle-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.field-toggle-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
}

.field-toggle-row input {
    width: auto;
    min-width: 16px;
    margin: 0;
    padding: 0;
}

.settings-actions {
    margin-top: 14px;
}

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

    .field-toggle-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .settings-status-row,
    .editable-status-row {
        grid-template-columns: 1fr;
    }

    .editable-status-row .secondary-btn,
    .settings-head .secondary-btn,
    .table-actions button {
        width: 100%;
    }
}


.description-paste-zone {
    margin-top: 8px;
    padding: 12px;
    border-radius: 12px;
}

.description-paste-actions {
    margin-bottom: 0;
}


.notification-settings-box {
    display: grid;
    gap: 10px;
}

.notification-toggle-row {
    justify-content: flex-start;
}

.notification-fields {
    display: grid;
    gap: 10px;
}

/* ===== Вирішення / скріни в коментарях ===== */

.solution-block {
    background: #fbfdfb;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 12px;
}

.solution-block textarea {
    min-height: 96px;
}

.inline-image-section {
    margin-top: 12px;
}

.inline-image-section label {
    margin-bottom: 8px;
}

.comment-paste-zone {
    margin-top: 8px;
}

.comment-paste-actions {
    margin-top: 10px;
    margin-bottom: 12px;
}

.comment-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.comment-images-grid .image-item img {
    height: 86px;
}

.comment-images-grid .image-item {
    max-width: 160px;
}

@media (max-width: 640px) {
    .comment-images-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comment-images-grid .image-item {
        max-width: none;
    }

    .comment-images-grid .image-item img {
        height: 92px;
    }
}

/* ===== Клікабельний рядок задачі ===== */

.task-clickable-row {
    cursor: pointer;
}

.task-clickable-row:hover td {
    background: #f1f8f4;
}

.task-clickable-row:focus {
    outline: 2px solid var(--primary-line);
    outline-offset: -2px;
}

/* ===== Компактна сторінка задачі: завдання / вирішення ===== */

.task-page {
    max-width: 1240px;
}

.task-main-card {
    padding: 14px;
}

.task-top-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
}

.task-work-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
}

.task-side-card {
    border-radius: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    min-width: 0;
}

.task-source-card {
    background: #f8fbff;
    border-color: #cddff0;
}

.task-solution-card {
    background: #f7fcf8;
    border-color: #c8e3d1;
}

.task-side-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.task-side-head h3 {
    margin: 0;
}

.task-side-label {
    font-size: 11px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 8px;
    white-space: nowrap;
}

.compact-images-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.compact-images-grid .image-item img,
.compact-images-grid .paste-item img {
    height: 78px;
}

.compact-paste-zone {
    padding: 10px;
    margin-top: 8px;
}

.compact-paste-zone strong {
    font-size: 13px;
}

.compact-paste-zone span {
    font-size: 11px;
}

.compact-actions {
    margin: 8px 0 10px;
}

.compact-actions button {
    min-width: 150px;
    padding-top: 9px;
    padding-bottom: 9px;
}

.compact-textarea {
    min-height: 92px;
}

.history-card {
    padding-top: 12px;
    padding-bottom: 12px;
}

.history-compact-list {
    display: grid;
    gap: 4px;
    max-height: 220px;
    overflow: auto;
}

.history-compact-row {
    display: grid;
    grid-template-columns: 150px 90px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: #fbfdfb;
    font-size: 12px;
}

.history-time {
    color: var(--muted);
    white-space: nowrap;
}

.history-actor {
    font-weight: 700;
    color: #173b28;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-action {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1000px) {
    .task-top-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .task-work-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .task-page {
        max-width: 100%;
    }

    .task-top-grid {
        grid-template-columns: 1fr;
    }

    .task-side-card {
        padding: 10px;
    }

    .task-side-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-compact-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .history-action {
        white-space: normal;
    }
}

/* ===== Відповідальний / online users ===== */

.assignee-badge {
    display: inline-flex;
    align-items: center;
    background: #eef6ff;
    color: #16456f;
    border: 1px solid #c8dff4;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1;
}

.muted-cell {
    color: var(--muted);
}
/* ===== Обмеження редагування завдання ===== */

.task-locked-note {
    margin: 8px 0 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff7e6;
    border: 1px solid #f0d79a;
    color: #7a5214;
    font-size: 12px;
    font-weight: 700;
}