:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #d9e0ea;
    --line-strong: #b9c3d2;
    --text: #152033;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --blue: #2563eb;
    --amber: #d97706;
    --red: #dc2626;
    --green: #16a34a;
    --violet: #7c3aed;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    --radius: 8px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
}

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

button {
    cursor: pointer;
}

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 10px 11px;
    outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

code {
    background: #e2e8f0;
    border-radius: 5px;
    padding: 2px 5px;
}

.app-shell {
    min-height: 100vh;
}

.boot-screen,
.auth-shell,
.installer-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.boot-screen {
    gap: 12px;
    color: var(--muted);
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: #020617;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
    flex: 0 0 auto;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.boot-screen .brand-mark,
.auth-brand .brand-mark,
.installer-brand .brand-mark {
    width: 68px;
    height: 68px;
}

.sidebar .brand-mark {
    width: 42px;
    height: 42px;
}

.installer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.installer-brand .eyebrow {
    margin-bottom: 4px;
}

.auth-panel,
.installer-card {
    width: min(100%, 440px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.auth-brand h1,
.installer-card h1 {
    margin: 0;
    font-size: 25px;
    letter-spacing: 0;
}

.auth-tabs,
.view-tabs {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 4px;
    background: #e8eef6;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
}

.auth-tabs button,
.view-tabs button {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    padding: 8px 10px;
    font-weight: 800;
}

.auth-tabs button.active,
.view-tabs button.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

.stacked-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    min-height: 38px;
    padding: 8px 12px;
    font-weight: 800;
}

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

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

.secondary-btn {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text);
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--primary-strong);
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
}

.ghost-btn:hover {
    background: #e8eef6;
    color: var(--text);
}

.danger-btn {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.icon-btn {
    width: 38px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

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

.eyebrow {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.alert {
    border-radius: 8px;
    padding: 11px 12px;
    margin: 14px 0;
    border: 1px solid var(--line);
    font-weight: 700;
}

.alert.success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.alert.danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-title {
    font-size: 17px;
    font-weight: 900;
}

.sidebar-subtitle {
    color: #94a3b8;
    font-size: 12px;
}

.sidebar-section {
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-section h2 {
    color: #94a3b8;
    font-size: 12px;
    letter-spacing: 0.08em;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.board-list {
    display: grid;
    gap: 6px;
    overflow: auto;
    padding: 8px;
}

.board-link {
    border: 1px solid transparent;
    background: transparent;
    color: #dbe4ef;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    text-align: left;
}

.board-link:hover,
.board-link.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.09);
}

.board-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.board-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.board-role {
    color: #94a3b8;
    font-size: 11px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    flex: 0 0 auto;
}

.main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
}

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

.board-heading {
    min-width: 0;
}

.board-heading h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.top-actions,
.toolbar-row,
.inline-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar {
    background: #eef3f8;
    border-bottom: 1px solid var(--line);
    padding: 10px 18px;
    display: grid;
    gap: 10px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(130px, 180px));
    gap: 8px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 0;
    min-height: 0;
}

.board-stage {
    min-width: 0;
    overflow: auto;
    padding: 18px;
}

.kanban {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: calc(100vh - 190px);
}

.list {
    width: 292px;
    flex: 0 0 292px;
    background: #edf2f7;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    grid-template-rows: auto minmax(30px, 1fr) auto;
    max-height: calc(100vh - 205px);
}

.list-header {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.list-title {
    font-size: 14px;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.list-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.card-stack {
    display: grid;
    align-content: start;
    gap: 9px;
    overflow-y: auto;
    padding: 10px;
    min-height: 70px;
}

.card-stack.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: -6px;
    background: rgba(15, 118, 110, 0.08);
}

.card-item {
    background: var(--surface);
    border: 1px solid #dbe3ee;
    border-radius: var(--radius);
    box-shadow: 0 2px 7px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.card-item:hover {
    border-color: var(--line-strong);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.11);
}

.card-cover {
    height: 8px;
}

.card-body {
    padding: 10px;
    display: grid;
    gap: 8px;
}

.card-title {
    margin: 0;
    color: var(--text);
    font-weight: 850;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-align: left;
}

.card-open {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
}

.label-row,
.member-row,
.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.label-pill {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    max-width: 100%;
    color: #fff;
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 900;
}

.mini-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
}

.meta-badge {
    border: 1px solid var(--line);
    background: #f8fafc;
    color: var(--muted);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 800;
}

.meta-badge.overdue {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.meta-badge.due-soon {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.meta-badge.done {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.list-footer {
    padding: 10px;
    border-top: 1px solid var(--line);
}

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

.side-panel {
    background: var(--surface);
    border-left: 1px solid var(--line);
    overflow: auto;
    padding: 16px;
    display: grid;
    align-content: start;
    gap: 16px;
}

.panel-section {
    display: grid;
    gap: 10px;
}

.panel-section h2 {
    margin: 0;
    font-size: 14px;
}

.panel-list {
    display: grid;
    gap: 8px;
}

.member-card,
.activity-item,
.rule-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px;
    background: var(--surface-soft);
}

.member-card {
    display: flex;
    align-items: center;
    gap: 8px;
}

.small-title {
    font-weight: 900;
    overflow-wrap: anywhere;
}

.small-text {
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 300px;
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

.table-view {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.table-view th {
    background: #eef3f8;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.calendar-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.calendar-day,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    display: grid;
    gap: 9px;
}

.stat-number {
    font-size: 30px;
    font-weight: 950;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: grid;
    place-items: start center;
    padding: 30px 18px;
    z-index: 20;
    overflow: auto;
}

.modal {
    width: min(1040px, 100%);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    overflow: hidden;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    overflow-wrap: anywhere;
}

.modal-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 0;
}

.modal-main {
    padding: 16px;
    display: grid;
    gap: 16px;
}

.modal-aside {
    padding: 16px;
    border-left: 1px solid var(--line);
    background: #f8fafc;
    display: grid;
    gap: 14px;
    align-content: start;
}

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

.checkbox-line {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--text);
    font-size: 14px;
}

.checkbox-line input {
    width: auto;
}

.checklist {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    display: grid;
    gap: 10px;
}

.checklist-title {
    font-weight: 900;
}

.check-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.check-item input {
    width: auto;
}

.comment,
.attachment {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--surface-soft);
    display: grid;
    gap: 5px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}

.choice-button {
    min-height: 36px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 8px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.choice-button.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    max-width: min(420px, calc(100vw - 36px));
    background: #111827;
    color: #fff;
    border-radius: 8px;
    padding: 11px 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.noscript {
    padding: 12px;
    background: #fef2f2;
    color: #991b1b;
}

.hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 230px minmax(0, 1fr);
    }

    .content-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .side-panel {
        border-left: 0;
        border-top: 1px solid var(--line);
    }
}

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

    .sidebar {
        min-height: auto;
    }

    .main {
        min-height: 70vh;
    }

    .board-topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .filters,
    .field-grid,
    .modal-content {
        grid-template-columns: 1fr;
    }

    .modal-aside {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .kanban {
        min-height: auto;
    }

    .list {
        width: 86vw;
        flex-basis: 86vw;
    }
}
