:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #f9fafc;
    --text: #202434;
    --muted: #6a7280;
    --border: #d9dee8;
    --border-strong: #c4cad6;
    --accent: #1f76ff;
    --success: #0f8f62;
    --danger: #c9344d;
    --sidebar: #222636;
    --sidebar-muted: #a8b0c2;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

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

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

button,
.button-link {
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    min-height: 34px;
    padding: 0 14px;
}

button:hover,
.button-link:hover {
    filter: brightness(0.95);
}

.archive-button {
    background: #ffffff;
    border-color: #f2b7c0;
    color: var(--danger);
}

.restore-button {
    background: #ffffff;
    border-color: #bce5d2;
    color: var(--success);
}

.archive-button.wide,
.restore-button.wide {
    width: 100%;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.auth-page,
.setup-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card,
.setup-card {
    width: min(420px, 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 28px;
    box-shadow: 0 18px 50px rgba(25, 35, 62, 0.08);
}

.setup-card.wide {
    width: min(860px, 100%);
}

.auth-card h1,
.setup-card h1 {
    margin: 0 0 10px;
    font-size: 26px;
}

.setup-header {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.setup-status {
    border-radius: 6px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    padding: 7px 10px;
    text-transform: uppercase;
}

.setup-status-ok {
    background: var(--success);
}

.setup-status-warning {
    background: #fdab3d;
}

.setup-status-error {
    background: var(--danger);
}

.setup-check-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
}

.setup-check {
    align-items: center;
    border: 1px solid var(--border);
    border-left: 5px solid var(--border-strong);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 12px;
}

.setup-check strong,
.setup-check span {
    display: block;
}

.setup-check span {
    color: var(--muted);
    margin-top: 3px;
}

.setup-check small {
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
}

.setup-check-ok {
    border-left-color: var(--success);
}

.setup-check-warning {
    border-left-color: #fdab3d;
}

.setup-check-error {
    border-left-color: var(--danger);
}

.setup-command-block {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.setup-command-block h2 {
    font-size: 16px;
    margin: 0 0 10px;
}

.setup-command-block pre {
    background: #202434;
    border-radius: 8px;
    color: #ffffff;
    margin: 0;
    overflow: auto;
    padding: 14px;
}

.setup-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 18px;
}

.auth-copy {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.45;
}

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

.setup-link {
    color: var(--accent);
    display: inline-block;
    font-weight: 700;
    margin-top: 16px;
}

.auth-form label {
    color: var(--muted);
    font-weight: 700;
}

.auth-form input,
.group-create-form input,
.board-filter-form input,
.board-filter-form select,
.settings-form input,
.settings-form select,
.subitem-form input,
.comment-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    min-height: 38px;
    padding: 0 10px;
}

.comment-form textarea {
    min-height: 96px;
    padding: 10px;
    resize: vertical;
}

.alert,
.flash {
    border-radius: 6px;
    margin-bottom: 16px;
    padding: 10px 12px;
}

.alert,
.flash-error {
    background: #fff0f2;
    border: 1px solid #f2b7c0;
    color: var(--danger);
}

.flash-success {
    background: #ebf8f2;
    border: 1px solid #bce5d2;
    color: var(--success);
}

.app-body {
    overflow: hidden;
}

.app-frame {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px;
}

.sidebar-brand {
    align-items: center;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    min-height: 48px;
    padding: 8px;
}

.brand-mark {
    align-items: center;
    background: #ffffff;
    border-radius: 6px;
    color: var(--sidebar);
    display: inline-flex;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.sidebar-brand small {
    color: var(--sidebar-muted);
    display: block;
    margin-top: 2px;
}

.sidebar-nav {
    overflow-y: auto;
    padding-right: 4px;
}

.workspace-block {
    margin-bottom: 18px;
}

.workspace-block h2 {
    color: var(--sidebar-muted);
    font-size: 11px;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.workspace-block ul {
    display: grid;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.workspace-block a {
    align-items: center;
    border-radius: 6px;
    color: #eef2fa;
    display: flex;
    gap: 9px;
    min-height: 34px;
    padding: 7px 8px;
}

.workspace-block a:hover,
.workspace-block a.active {
    background: rgba(255, 255, 255, 0.11);
}

.board-dot {
    background: #9aa4b5;
    border-radius: 3px;
    display: inline-block;
    flex: 0 0 auto;
    height: 12px;
    width: 12px;
}

.board-dot-tasks {
    background: #fdab3d;
}

.board-dot-clients {
    background: #00c875;
}

.board-dot-library {
    background: #579bfc;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    min-height: 72px;
    padding: 12px 22px;
}

.topbar h1 {
    font-size: 22px;
    margin: 0;
}

.topbar-user {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 12px;
}

.topbar-user a {
    color: var(--accent);
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    gap: 22px;
    overflow: auto;
    padding: 22px;
}

.dashboard-intro h2 {
    font-size: 24px;
    margin: 0;
}

.dashboard-intro p:last-child {
    color: var(--muted);
    margin: 8px 0 0;
}

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

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--border-strong);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    min-height: 116px;
    padding: 16px;
}

.metric-card span {
    color: var(--muted);
    font-weight: 800;
}

.metric-card strong {
    font-size: 34px;
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
}

.metric-card.danger {
    border-left-color: var(--danger);
}

.metric-card.warning {
    border-left-color: #fdab3d;
}

.metric-card.success {
    border-left-color: var(--success);
}

.metric-card.neutral {
    border-left-color: #579bfc;
}

.dashboard-panels {
    align-items: start;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
}

.dashboard-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.dashboard-section-header {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dashboard-section-header h3 {
    font-size: 18px;
    margin: 0;
}

.compact-table-wrap {
    overflow: auto;
}

.compact-table {
    border-collapse: collapse;
    min-width: 620px;
    width: 100%;
}

.compact-table th,
.compact-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
}

.compact-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.compact-table td:first-child {
    display: grid;
    gap: 3px;
}

.compact-table td:first-child a {
    font-weight: 800;
}

.compact-table td:first-child small {
    color: var(--muted);
}

.compact-table tr:last-child td {
    border-bottom: 0;
}

.priority-pill {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    min-height: 26px;
    padding: 5px 8px;
}

.status-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.status-list li {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 10px;
}

.status-list span {
    color: var(--muted);
    font-weight: 700;
}

.status-list strong {
    font-size: 18px;
}

.board-card-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.board-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    min-height: 138px;
    padding: 18px;
}

.board-card:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 24px rgba(25, 35, 62, 0.08);
}

.board-card strong {
    font-size: 18px;
}

.board-card span,
.board-card small {
    color: var(--muted);
}

.board-kind {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
    font-size: 12px;
    justify-self: start;
    padding: 3px 7px;
}

.board-toolbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 16px 22px;
}

.board-toolbar h2 {
    font-size: 24px;
    margin: 0;
}

.board-control-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.board-filter-form,
.group-create-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.board-filter-form {
    width: min(560px, 100%);
}

.group-create-form {
    width: min(360px, 100%);
}

.board-filter-form input,
.board-filter-form select,
.group-create-form input {
    min-width: 0;
    width: auto;
}

.board-filter-form input,
.group-create-form input {
    flex: 1 1 160px;
}

.board-filter-form select {
    flex: 0 1 170px;
}

.ghost-link {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    display: inline-flex;
    font-weight: 700;
    min-height: 34px;
    padding: 0 12px;
}

.archive-toggle {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    display: inline-flex;
    min-height: 34px;
    overflow: hidden;
}

.archive-toggle a {
    color: var(--muted);
    font-weight: 700;
    padding: 8px 10px;
}

.archive-toggle a.active {
    background: var(--accent);
    color: #ffffff;
}

.board-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.board-settings-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 22px;
}

.board-settings-panel summary {
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
    list-style-position: inside;
    padding: 12px 0;
}

.settings-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    padding: 0 0 16px;
}

.settings-form {
    align-items: end;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
}

.settings-form label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.settings-form input,
.settings-form select {
    min-height: 34px;
}

.settings-form input[type="color"] {
    padding: 3px;
}

.settings-form button {
    grid-column: 1 / -1;
    justify-self: start;
}

.board-table-area {
    min-width: 0;
    overflow: auto;
    padding: 18px 22px 32px;
}

.group-panel {
    margin-bottom: 22px;
}

.group-header {
    align-items: center;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.group-header > div {
    align-items: center;
    display: flex;
    gap: 8px;
}

.group-header h3 {
    color: var(--text);
    font-size: 16px;
    margin: 0;
}

.group-color {
    background: var(--group-color);
    border-radius: 3px;
    display: inline-block;
    height: 18px;
    width: 18px;
}

.board-forms {
    display: none;
}

.table-scroll {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: auto;
    background: var(--surface);
}

.board-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
}

.board-table th,
.board-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    height: 44px;
    padding: 5px;
    vertical-align: middle;
}

.board-table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
}

.board-table tr:last-child td {
    border-bottom: 0;
}

.board-table th:first-child,
.board-table td:first-child {
    left: 0;
    position: sticky;
    z-index: 2;
}

.board-table th:first-child {
    z-index: 3;
}

.board-table td:first-child {
    background: var(--surface);
}

.create-row td {
    background: #fbfcfe;
}

.selected-row td {
    background: #eef5ff;
}

.selected-row td:first-child {
    background: #eef5ff;
}

.subitem-row td:first-child .item-title-input {
    padding-left: 24px;
}

.cell-input {
    background: #ffffff;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text);
    height: 32px;
    outline: none;
    padding: 0 8px;
    width: 100%;
}

.cell-input:hover,
.cell-input:focus {
    border-color: var(--border-strong);
}

.item-title-input {
    font-weight: 700;
}

.status-select {
    border-left: 5px solid var(--status-color);
    font-weight: 700;
}

.readonly-cell {
    align-items: center;
    color: var(--muted);
    display: flex;
    min-height: 32px;
    overflow: hidden;
    padding: 0 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-actions-header,
.row-actions {
    width: 150px;
}

.row-actions {
    text-align: center;
}

.row-actions button {
    min-height: 30px;
    padding: 0 10px;
}

.row-action-stack {
    align-items: center;
    display: flex;
    gap: 6px;
    justify-content: center;
}

.detail-link {
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    min-height: 30px;
    padding: 6px 8px;
}

.side-panel {
    background: var(--surface);
    border-left: 1px solid var(--border);
    bottom: 0;
    box-shadow: -18px 0 40px rgba(25, 35, 62, 0.12);
    overflow: auto;
    padding: 18px;
    position: absolute;
    right: 0;
    top: 0;
    width: min(430px, 100%);
    z-index: 10;
}

.side-panel h3 {
    margin: 0 0 14px;
}

.detail-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin: -2px 0 16px;
    padding-bottom: 14px;
}

.detail-header h3 {
    font-size: 18px;
    line-height: 1.25;
    margin: 0;
}

.detail-header a {
    color: var(--accent);
    font-weight: 700;
}

.detail-tabs {
    align-items: center;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    margin: -4px 0 14px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.detail-tabs a {
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 10px;
}

.detail-tabs a.active {
    background: #eaf2ff;
    border-color: #c7ddff;
    color: var(--accent);
}

.detail-archive-form {
    margin: -4px 0 14px;
}

.detail-section {
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: 12px;
    padding: 16px 0;
}

.detail-section:first-of-type {
    padding-top: 0;
}

.detail-section:last-child {
    border-bottom: 0;
}

.detail-section h4 {
    font-size: 14px;
    margin: 0;
}

.detail-fields {
    display: grid;
    gap: 8px;
    margin: 0;
}

.detail-fields div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px;
}

.detail-fields dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 4px;
}

.detail-fields dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.comment-form {
    display: grid;
    gap: 8px;
}

.comment-form button,
.subitem-form button {
    justify-self: start;
}

.subitem-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.subitem-form input {
    min-width: 0;
}

.activity-list {
    display: grid;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-list li {
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 10px;
}

.activity-list span,
.activity-list small {
    color: var(--muted);
}

.comment-list {
    display: grid;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.subitem-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.subitem-list li {
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 10px;
}

.subitem-list a {
    color: var(--text);
    font-weight: 700;
}

.subitem-list small {
    color: var(--muted);
}

.comment-list li {
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    padding: 10px;
}

.comment-list p {
    line-height: 1.45;
    margin: 0;
    overflow-wrap: anywhere;
}

.comment-list small {
    color: var(--muted);
}

.empty-state {
    display: grid;
    gap: 12px;
    justify-items: start;
    padding: 32px;
}

.empty-state h2,
.empty-state p {
    margin: 0;
}

.compact-empty {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

    .sidebar {
        display: none;
    }

    .board-workspace {
        grid-template-columns: 1fr;
    }

    .side-panel {
        border-left: 0;
        border-top: 1px solid var(--border);
        bottom: 0;
        left: 0;
        max-height: 70vh;
        top: auto;
        width: 100%;
    }

    .dashboard-panels,
    .metric-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .topbar,
    .board-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .board-control-bar,
    .board-filter-form,
    .group-create-form {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .row-action-stack {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-panels,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-section-header {
        align-items: stretch;
        flex-direction: column;
    }
}
