:root {
    --bg: #f5f5f7;
    --panel: #ffffff;
    --panel-soft: #fbfbfd;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: #d9d9df;
    --accent: #1769e0;
    --accent-soft: #e8f1ff;
    --green-soft: #eaf6ef;
    --amber-soft: #fff3d7;
    --red-soft: #ffe7e3;
    --red: #b42318;
    --shadow: 0 12px 34px rgb(0 0 0 / 7%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 18px;
    background: rgb(255 255 255 / 82%);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand {
    font-weight: 700;
    letter-spacing: 0;
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-label {
    color: var(--muted);
    font-size: 12px;
}

.app-shell {
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
    min-height: calc(100vh - 48px);
}

.sidebar {
    position: sticky;
    top: 48px;
    height: calc(100vh - 48px);
    overflow: auto;
    padding: 14px;
    border-right: 1px solid var(--line);
    background: var(--panel-soft);
}

.sidebar-section + .sidebar-section {
    margin-top: 20px;
}

.section-head,
.editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

.sidebar h2 {
    font-size: 13px;
    font-weight: 700;
}

.filters {
    display: grid;
    gap: 11px;
    margin-top: 12px;
}

label,
fieldset {
    display: grid;
    gap: 7px;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    border: 0;
    padding: 0;
}

.filters fieldset {
    max-height: 118px;
    overflow: auto;
    padding-right: 2px;
}

legend {
    padding: 0 0 6px;
}

.check-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    color: var(--text);
    min-height: 24px;
    line-height: 1.25;
}

.form-control,
input,
select {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    background: white;
    color: var(--text);
    font-size: 13px;
}

input[type="checkbox"],
input[type="radio"] {
    width: 14px;
    min-height: 14px;
    height: 14px;
    margin: 0;
    padding: 0;
    justify-self: center;
}

select[multiple] {
    min-height: 94px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 0 11px;
    cursor: pointer;
    font-size: 13px;
}

.primary-button {
    background: var(--accent);
    color: white;
}

.ghost-button {
    background: white;
    border-color: var(--line);
    color: var(--text);
}

.danger-button {
    background: #fff4f2;
    border-color: #ffc9c0;
    color: var(--red);
}

.icon-button {
    width: 32px;
    padding: 0;
    background: var(--accent);
    color: white;
    font-size: 20px;
}

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

.top-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.top-card {
    display: grid;
    gap: 4px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.top-card span {
    font-weight: 650;
    font-size: 12px;
    line-height: 1.25;
}

.top-card small,
.empty-text {
    color: var(--muted);
    font-size: 11px;
}

.board {
    overflow: auto;
    padding: 14px 16px 20px;
}

.board-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 880px;
    margin: -14px -16px 14px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line);
    background: rgb(245 245 247 / 88%);
    backdrop-filter: blur(16px);
}

.board-toolbar h1 {
    font-size: 15px;
    line-height: 1.2;
}

.board-toolbar span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.create-task-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 11px 0 9px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 13px;
}

.create-task-button span {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin: 0;
    color: white;
    font-size: 18px;
    line-height: 1;
}

.swimlane {
    min-width: 880px;
    margin-bottom: 18px;
}

.swimlane-header {
    margin-bottom: 8px;
}

.swimlane-header h1 {
    font-size: 16px;
    line-height: 1.25;
}

.columns {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 9px;
}

.kanban-column {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 136px;
    border-radius: 8px;
    background: rgb(255 255 255 / 64%);
    border: 1px solid var(--line);
}

.kanban-column h2 {
    padding: 8px 9px;
    font-size: 12px;
    line-height: 1.2;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}

.card-list {
    display: grid;
    align-content: start;
    gap: 7px;
    min-height: 96px;
    padding: 7px;
}

.task-card {
    display: grid;
    gap: 5px;
    min-height: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgb(0 0 0 / 4%);
}

.task-card[draggable="true"] {
    cursor: grab;
}

.task-card.dragging {
    opacity: 0.55;
}

.task-card.watch {
    background: #fffaf0;
    border-color: #f3d69b;
}

.task-card.soon {
    background: var(--amber-soft);
    border-color: #e7bd62;
}

.task-card.critical {
    background: var(--red-soft);
    border-color: #f0a397;
}

.task-card.overdue {
    background: #fff0f0;
    border-color: #e38178;
    box-shadow: inset 3px 0 0 var(--red), 0 4px 12px rgb(0 0 0 / 4%);
}

.card-meta,
.card-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.card-edit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgb(255 255 255 / 72%);
    color: var(--text);
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
}

.card-copy-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgb(255 255 255 / 72%);
    color: var(--muted);
    cursor: pointer;
}

.card-copy-button::before,
.card-copy-button::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 5px;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    transform: rotate(-35deg);
}

.card-copy-button::before {
    left: 6px;
    top: 8px;
}

.card-copy-button::after {
    right: 6px;
    bottom: 8px;
}

.card-copy-button.copied::before {
    content: "";
    width: 10px;
    height: 6px;
    border: 0;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    border-radius: 0;
    transform: rotate(-45deg);
    left: 6px;
    top: 7px;
}

.card-copy-button.copied::after {
    display: none;
}

.card-edit-button:hover,
.card-copy-button:hover {
    border-color: #aac8f8;
    background: var(--accent-soft);
    color: #164b91;
}

.priority {
    color: var(--text);
    font-weight: 700;
}

.card-title {
    font-weight: 700;
    line-height: 1.22;
    font-size: 12.5px;
}

.card-description {
    color: var(--muted);
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 11.5px;
    line-height: 1.28;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    max-width: 100%;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #164b91;
    font-size: 11px;
    line-height: 1.25;
}

.drop-placeholder {
    min-height: 34px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    display: grid;
    place-items: center;
    font-size: 12px;
}

.empty-board,
.auth-page,
.form-page {
    min-height: calc(100vh - 48px);
    padding: 28px;
}

.empty-board {
    display: grid;
    place-content: center;
    gap: 16px;
}

.auth-page {
    display: grid;
    place-items: center;
}

.auth-card,
.card-editor {
    width: min(100%, 900px);
    display: grid;
    gap: 18px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-card {
    max-width: 380px;
    padding: 26px;
}

.card-editor {
    margin: 0 auto;
    padding: 24px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
}

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

.rich-toolbar {
    display: flex;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: var(--panel-soft);
}

.rich-toolbar button {
    width: 34px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
    cursor: pointer;
}

.rich-editor {
    min-height: 210px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    background: white;
    color: var(--text);
    line-height: 1.5;
}

.card-chat {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

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

.chat-head h2 {
    font-size: 14px;
}

.chat-head span,
.chat-empty {
    color: var(--muted);
    font-size: 12px;
}

.chat-thread {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow: auto;
    padding: 4px 2px;
}

.chat-message {
    display: flex;
}

.chat-message.own {
    justify-content: flex-end;
}

.chat-message.other {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: min(78%, 620px);
    display: grid;
    gap: 5px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}

.chat-message.own .chat-bubble {
    border-color: #b9d3fb;
    background: var(--accent-soft);
}

.chat-author {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
}

.chat-author time {
    color: #8c8c91;
}

.chat-text {
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
}

.chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.chat-form textarea {
    min-height: 64px;
    resize: vertical;
}

.tag-editor {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 44px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.single-picker {
    position: relative;
    display: block;
}

.tag-chip-list {
    display: contents;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #164b91;
}

.tag-chip button {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
}

.tag-editor input {
    flex: 1 1 160px;
    min-height: 28px;
    padding: 3px;
    border: 0;
    outline: 0;
}

.suggestions {
    position: absolute;
    left: 8px;
    right: 8px;
    top: calc(100% + 4px);
    z-index: 10;
    display: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.suggestions.open {
    display: grid;
}

.suggestions button {
    padding: 10px;
    border: 0;
    text-align: left;
    background: white;
    cursor: pointer;
}

.suggestions button:hover {
    background: var(--accent-soft);
}

.attachments {
    display: grid;
    gap: 8px;
}

.attachments h2 {
    font-size: 15px;
}

.attachments a {
    color: var(--accent);
}

.delete-form {
    width: min(100%, 900px);
    margin: 14px auto 0;
}

.messages {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 36px));
    pointer-events: none;
}

.message,
.form-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--green-soft);
    border: 1px solid #b9dfc6;
    box-shadow: 0 10px 24px rgb(0 0 0 / 10%);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.message-fading {
    opacity: 0;
    transform: translateY(6px);
}

.form-error {
    background: #fff4f2;
    border-color: #ffc9c0;
    color: var(--red);
}

.users-page {
    min-height: calc(100vh - 48px);
    padding: 18px;
}

.users-layout {
    width: min(100%, 1080px);
    display: grid;
    gap: 14px;
    margin: 0 auto;
}

.users-panel {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 8px 22px rgb(0 0 0 / 5%);
}

.users-panel h1 {
    font-size: 18px;
}

.users-panel h2 {
    font-size: 14px;
}

.user-form,
.user-row {
    display: grid;
    gap: 10px;
}

.user-form-create,
.user-row {
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(150px, 220px) auto;
    align-items: end;
}

.user-list {
    display: grid;
    gap: 10px;
}

.user-row {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.user-row-title {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-row-title strong {
    font-size: 13px;
}

.user-row-title span {
    color: var(--muted);
    font-size: 12px;
}

.errorlist {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--red);
    font-size: 12px;
}

@media (max-width: 920px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .board {
        padding: 10px;
    }

    .board-toolbar {
        min-width: 0;
        margin: -10px -10px 12px;
        padding: 10px;
    }

    .swimlane {
        min-width: 0;
    }

    .columns {
        grid-template-columns: minmax(240px, 1fr);
    }

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

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

    .chat-bubble {
        max-width: 92%;
    }

    .user-form-create,
    .user-row {
        grid-template-columns: 1fr;
    }
}
