:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #d9e2ec;
    --text: #1e242b;
    --text-soft: #20262d;
    --muted: #667280;
    --primary: #2f6fae;
    --primary-strong: #214c7d;
    --primary-soft: #e8f1fb;
    --gold: #f6b34f;
    --teal: #66d5c0;
    --danger: #c53333;
    --warning: #b7791f;
    --focus: #2f6fae;
    --shadow: 0 10px 24px rgba(31, 42, 55, 0.12);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 52%, #e5ebf3 100%);
    font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
    line-height: 1.5;
}

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

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

code {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    padding: 1px 5px;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(9, 27, 43, 0.96), #07111c);
    color: #eef6fc;
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gold), #ffdf8a 60%, #f3a11d);
    color: #102030;
    font-size: 0.85rem;
    font-weight: 800;
}

.login-brand small,
.sidebar-user small,
.task-row small,
.table-title + small,
.card-people,
.panel-head span,
.topbar p,
.timeline-item small,
.comment small {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
}

.nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    border-radius: 8px;
    padding: 10px 12px;
    color: #a9bfd2;
    font-weight: 650;
}

.nav-item:hover,
.nav-item.is-active {
    background: #2f6fae;
    color: #fff;
}

.online-panel {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    color: #a9bfd2;
    font-size: 0.72rem;
}

.online-panel > span {
    color: #eef6fc;
    font-weight: 750;
    line-height: 22px;
}

.online-list {
    display: flex;
    min-width: 0;
    flex: 1 1 120px;
    flex-wrap: wrap;
    gap: 5px;
}

.online-panel strong,
.online-panel em {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    min-width: 0;
    max-width: 100%;
    padding: 0 8px;
    border: 1px solid rgba(31, 130, 92, 0.28);
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    color: #8ff0c5;
    font-style: normal;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-panel em {
    border-color: rgba(169, 191, 210, 0.18);
    background: rgba(169, 191, 210, 0.08);
    color: #a9bfd2;
}

.online-panel i {
    width: 6px;
    height: 6px;
    margin-right: 5px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.sidebar-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user small {
    color: #a9bfd2;
}

.avatar {
    display: inline-grid;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    background: var(--avatar-color, #64748b);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
}

.avatar.small {
    width: 28px;
    height: 28px;
    font-size: 0.68rem;
}

.main {
    min-height: 100vh;
    margin-left: 260px;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    font-size: 1.72rem;
    line-height: 1.2;
}

.topbar p {
    margin: 2px 0 0;
}

.topbar-actions,
.form-actions,
.detail-actions,
.actions-cell,
.inline-form,
.inline-add-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sidebar-toggle {
    display: none;
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
    white-space: nowrap;
}

.button-primary {
    background: #2f6fae;
    color: #fff;
}

.button-primary:hover {
    background: #214c7d;
}

.button-muted {
    border-color: var(--line);
    background: var(--surface);
    color: var(--text-soft);
}

.button-danger {
    background: #fff1f1;
    color: var(--danger);
    border-color: #efc0c0;
}

.button-full {
    width: 100%;
}

.panel,
.metric,
.login-panel,
.install-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
}

.panel + .panel {
    margin-top: 18px;
}

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

.panel-head h2,
.detail-side h2 {
    margin: 0;
    font-size: 1rem;
}

.panel-head a {
    color: var(--primary-strong);
    font-weight: 750;
}

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

.metric {
    display: grid;
    gap: 6px;
    padding: 18px;
}

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

.metric strong {
    font-size: 2rem;
    line-height: 1;
}

.metric-alert {
    border-color: #efd7a6;
    background: #fff7e8;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 18px;
}

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

.task-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.task-row:hover,
.task-card:hover {
    border-color: rgba(47, 111, 174, 0.38);
}

.task-row strong,
.card-title {
    display: block;
    overflow-wrap: anywhere;
}

.badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-open {
    background: #e8f1fb;
    color: #2f6fae;
}

.status-in_progress {
    background: #eef6f2;
    color: #176447;
}

.status-waiting {
    background: #fff5db;
    color: #9a5b00;
}

.status-done {
    background: #eaf7ec;
    color: #135f43;
}

.status-archived {
    background: #f1f4f8;
    color: #667280;
}

.priority-low {
    background: #eaf7ec;
    color: #135f43;
}

.priority-normal {
    background: #e8f1fb;
    color: #2f6fae;
}

.priority-high {
    background: #fff2dc;
    color: #a45312;
}

.priority-critical,
.badge-overdue {
    background: #ffe1e1;
    color: #8f1d1d;
}

.is-overdue {
    color: var(--danger);
    font-weight: 800;
}

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

.flash {
    margin: 0 0 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 650;
}

.flash-success {
    border: 1px solid #cbe7d1;
    background: #eaf7ec;
    color: #135f43;
}

.flash-error {
    border: 1px solid #efb5ba;
    background: #fff2f3;
    color: #8b1f28;
}

.flash-warning {
    border: 1px solid #efd08f;
    background: #fff8e7;
    color: #86570f;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 12%, rgba(246, 179, 79, 0.18), transparent 30%),
        radial-gradient(circle at 86% 10%, rgba(102, 213, 192, 0.15), transparent 24%),
        linear-gradient(180deg, #0c1b2b 0%, #07111c 48%, #030810 100%);
    color: #eef6fc;
}

.auth-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    opacity: 0.32;
}

.login-shell,
.install-shell {
    width: min(100%, 460px);
}

.install-shell {
    width: min(100%, 620px);
}

.login-panel,
.install-panel {
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(9, 27, 43, 0.88), rgba(4, 15, 25, 0.96));
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
}

.auth-body .login-brand small,
.auth-body .install-panel small,
.auth-body .muted {
    color: #a9bfd2;
}

.auth-body .brand-mark {
    background: linear-gradient(135deg, var(--gold), #ffdf8a 60%, #f3a11d);
    color: #102030;
}

.auth-body .button-primary {
    min-height: 48px;
    border-radius: 999px;
    color: #102030;
    background: linear-gradient(135deg, var(--gold), #ffdf8a 60%, #f3a11d);
}

.auth-body .button-primary:hover {
    background: linear-gradient(135deg, #ffc46f, #ffdf8a 60%, #f6b34f);
}

.auth-body .flash-success {
    border: 1px solid rgba(102, 213, 192, 0.28);
    background: rgba(102, 213, 192, 0.12);
    color: #d9fff7;
}

.auth-body .flash-warning,
.auth-body .config-box {
    border: 1px solid rgba(246, 179, 79, 0.28);
    background: rgba(246, 179, 79, 0.10);
    color: #ffdf8a;
}

.auth-body .flash-error {
    border: 1px solid rgba(255, 120, 120, 0.28);
    background: rgba(255, 80, 80, 0.12);
    color: #ffd6d6;
}

.login-panel h1,
.install-panel h1 {
    margin: 28px 0 18px;
    font-size: 1.8rem;
}

.auth-body .login-panel h1,
.auth-body .install-panel h1 {
    margin-bottom: 18px;
    color: #eef6fc;
    font-family: "Avenir Next Condensed", "Franklin Gothic Medium", sans-serif;
    font-size: clamp(2.2rem, 8vw, 4rem);
    line-height: 0.98;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.stacked-form,
.task-form,
.comment-form {
    display: grid;
    gap: 16px;
}

label span,
fieldset legend {
    display: block;
    margin-bottom: 6px;
    color: var(--text-soft);
    font-size: 0.88rem;
    font-weight: 800;
}

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

.auth-body label span {
    color: #a9bfd2;
}

.auth-body input,
.auth-body select,
.auth-body textarea {
    min-height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: #eef6fc;
    background: rgba(255, 255, 255, 0.055);
}

.auth-body input:focus,
.auth-body select:focus,
.auth-body textarea:focus {
    border-color: rgba(246, 179, 79, 0.7);
    box-shadow: 0 0 0 3px rgba(246, 179, 79, 0.12);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(45, 191, 69, 0.16);
}

.config-box {
    display: grid;
    gap: 5px;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 12px;
    color: var(--muted);
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.assignee-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.assignee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.check-tile,
.toggle-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-tile {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px;
}

.check-tile input,
.toggle-line input {
    width: auto;
}

.view-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.view-tabs a {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    padding: 8px 12px;
    font-weight: 800;
    color: var(--text-soft);
}

.view-tabs a.is-active {
    border-color: rgba(47, 111, 174, 0.72);
    background: #2f6fae;
    color: #fff;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(190px, 1.4fr) repeat(4, minmax(140px, 1fr)) auto auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

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

.task-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

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

.task-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.task-table tbody tr:hover {
    background: #f8fafc;
}

.table-title {
    display: block;
    color: var(--primary-strong);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.task-card {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.detail-header h2 {
    margin: 8px 0 4px;
    font-size: 1.55rem;
    overflow-wrap: anywhere;
}

.detail-header p {
    margin: 0;
    color: var(--muted);
}

.detail-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.prose {
    white-space: normal;
    color: var(--text-soft);
}

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

.checklist-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px;
}

.check-button {
    width: 22px;
    height: 22px;
    border: 2px solid #98a69d;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.check-button.is-done {
    border-color: var(--primary);
    background: var(--primary);
}

.is-complete {
    color: var(--muted);
    text-decoration: line-through;
}

.inline-add-form {
    margin-top: 12px;
}

.inline-add-form input {
    flex: 1 1 220px;
}

.comments {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

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

.comment header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.comment p {
    margin: 4px 0 0;
}

.meta-list {
    display: grid;
    gap: 12px;
    margin: 14px 0 0;
}

.meta-list div {
    display: grid;
    gap: 2px;
}

.meta-list dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.meta-list dd {
    margin: 0;
}

.timeline {
    position: relative;
    display: grid;
    gap: 16px;
    margin-top: 14px;
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 10px;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    margin-top: 7px;
    border-radius: 50%;
    background: var(--primary);
}

.timeline-item p {
    display: grid;
    gap: 4px;
    margin: 6px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.empty-state {
    display: grid;
    gap: 10px;
    justify-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 28px;
}

.empty-state.in-panel {
    margin-top: 16px;
    box-shadow: none;
}

.empty-state h2 {
    margin: 0;
}

.empty-state p {
    margin: 0 0 8px;
    color: var(--muted);
}

.user-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.actions-cell {
    min-width: 310px;
}

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

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

    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 160ms ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        padding: 18px;
    }

    .sidebar-toggle {
        display: inline-flex;
        min-height: 38px;
        align-items: center;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        padding: 8px 12px;
        font-weight: 800;
    }

    .topbar,
    .detail-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .metric-grid,
    .form-grid.two,
    .form-grid.three,
    .filter-bar {
        grid-template-columns: 1fr;
    }

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

    .login-panel,
    .install-panel {
        padding: 22px;
    }
}
