:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #687286;
    --line: #dde3ee;
    --primary: #126b63;
    --primary-dark: #0d514b;
    --accent: #d6842a;
    --danger: #c2413d;
    --shadow: 0 16px 40px rgba(23, 32, 51, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.login-body {
    display: grid;
    place-items: center;
    background:
        linear-gradient(120deg, rgba(18, 107, 99, .92), rgba(20, 32, 51, .86)),
        url("https://images.unsplash.com/photo-1552566626-52f8b828add9?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-shell { width: min(440px, calc(100% - 32px)); }

.login-panel {
    background: rgba(255, 255, 255, .95);
    padding: 34px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.brand, .topbar, .panel-head, .field-row, .member-stats, .roadmap footer, .task-card-head, .task-meta, .roadmap-card-head, .roadmap-meta, .actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
}

.brand span, small, .eyebrow, .panel-head span, .timeline-item p, .member-card p {
    color: var(--muted);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    padding: 24px;
    background: #101827;
    color: #fff;
}

.topbar-menu {
    display: none;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(16, 24, 39, .45);
}

.brand { margin-bottom: 34px; }
.brand span { display: block; font-size: 12px; }

nav { display: grid; gap: 8px; }

nav a, .logout {
    color: #c9d3e4;
    padding: 12px 14px;
    border-radius: 8px;
}

nav a.active, nav a:hover, .logout:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.logout {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 24px;
}

.app {
    margin-left: 248px;
    padding: 28px;
}

.topbar {
    justify-content: space-between;
    margin-bottom: 22px;
}

.topbar h1, .login-panel h1 {
    margin: 0;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-chip {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 800;
}

.stat-grid, .grid {
    display: grid;
    gap: 18px;
}

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

.mini-stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-grid article, .stat-grid .stat-card, .mini-stat-grid article, .mini-stat-grid a, .panel, .member-card, .roadmap article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-grid article, .stat-grid .stat-card { padding: 20px; }
.stat-grid .stat-card {
    display: block;
    color: var(--ink);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-grid .stat-card:hover {
    transform: translateY(-2px);
    border-color: #c8d3e3;
    box-shadow: 0 18px 38px rgba(23, 32, 51, .12);
}
.stat-grid span { color: var(--muted); font-weight: 700; }
.stat-grid strong { display: block; margin-top: 8px; font-size: 32px; }
.mini-stat-grid article, .mini-stat-grid a {
    padding: 12px;
    box-shadow: none;
    background: #fbfcfe;
    color: var(--ink);
}
.mini-stat-grid span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.mini-stat-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
}

.two { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.form-grid { grid-template-columns: 360px 1fr; align-items: start; }
.task-layout { grid-template-columns: minmax(360px, 460px) 1fr; align-items: start; }
.roadmap-layout { grid-template-columns: minmax(360px, 430px) 1fr; align-items: start; }
.board-only {
    grid-template-columns: 1fr;
}
.task-editor-column {
    display: grid;
    gap: 18px;
    align-self: start;
}

.task-board-column {
    min-width: 0;
}

.panel { padding: 20px; }
.panel-head { justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 18px; }

.form-stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 800; }

.filter-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

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

.input-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-action input {
    flex: 1;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    font: inherit;
    background: #fff;
}

input[readonly] {
    background: #f3f6fa;
    color: var(--muted);
    cursor: not-allowed;
}

.check-label {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.check-label input {
    width: auto;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

textarea { resize: vertical; }
.field-row { align-items: end; }
.field-row > label { flex: 1; }

.primary-btn {
    border: 0;
    border-radius: 8px;
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

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

.secondary-btn, .small-btn, .danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.secondary-btn {
    min-height: 42px;
    color: var(--primary);
}

.danger-btn {
    border-color: #ffd5d1;
    color: var(--danger);
}

.danger-btn:hover {
    background: #fff0ef;
}

.small-btn:hover, .secondary-btn:hover {
    background: #f3f6fa;
}

.inline-form {
    margin: 0;
}

.actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.card-actions {
    justify-content: flex-start;
    margin-top: 16px;
}

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

.comments-panel {
    align-self: start;
}

.comment-form {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.comments-list {
    display: grid;
    gap: 12px;
}

.comment-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.comment-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.comment-item p {
    margin: 0;
    color: #374154;
    line-height: 1.5;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 800;
}

.alert.success { background: #e8f7f2; color: #126b63; }
.alert.error { background: #fff0ef; color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td small { display: block; margin-top: 4px; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef2f7;
    color: #445066;
    font-size: 12px;
    font-weight: 900;
}

.badge.done, .badge.live { background: #e8f7f2; color: #126b63; }
.badge.blocked, .badge.critical { background: #fff0ef; color: var(--danger); }
.badge.in_progress, .badge.onboarding { background: #fff6e8; color: #9a5a00; }
.badge.review, .badge.lead { background: #edf4ff; color: #225ea8; }

.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 32px;
    gap: 12px;
    align-items: center;
    margin: 14px 0;
}

.bar {
    display: block;
    height: 11px;
    background: #edf1f7;
    border-radius: 999px;
    overflow: hidden;
}

.bar.mini {
    height: 7px;
    margin: 8px 0;
}

.bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.bar i.critical { background: var(--danger); }
.bar i.high { background: #d6842a; }
.bar i.medium { background: #225ea8; }
.bar i.low { background: var(--primary); }

.alert-row {
    display: grid;
    gap: 4px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.alert-row strong {
    color: var(--danger);
}

.alert-row span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.timeline-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 4px;
    background: var(--accent);
}

.dot.done { background: var(--primary); }
.dot.blocked { background: var(--danger); }
.timeline-item p { margin: 5px 0; }

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

.roadmap article { padding: 18px; box-shadow: none; }
.roadmap.detailed { grid-template-columns: 1fr; }
.roadmap.detailed article { border-left: 4px solid var(--primary); }
.roadmap-date { color: var(--accent); font-weight: 900; }
.roadmap h3 { margin: 10px 0 8px; }
.roadmap p { color: var(--muted); min-height: 72px; }
.roadmap footer { justify-content: space-between; margin-top: 12px; color: var(--muted); font-weight: 800; }
.roadmap-card-head { justify-content: space-between; align-items: start; }
.roadmap-meta {
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.roadmap-meta span, .task-meta span:not(.badge) {
    background: #f3f6fa;
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.linked-tasks {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.linked-tasks > div {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.linked-tasks small {
    grid-column: 2;
}

.linked-task-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

pre {
    margin: 10px 0;
    padding: 12px;
    white-space: pre-wrap;
    border-radius: 8px;
    background: #f7f9fc;
    border: 1px solid var(--line);
    color: #374154;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.task-cards {
    display: grid;
    gap: 14px;
}

.task-card {
    position: relative;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(248, 251, 253, .96));
    box-shadow: 0 8px 24px rgba(23, 32, 51, .06);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.task-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--primary);
}

.task-card.priority-critical::before { background: var(--danger); }
.task-card.priority-high::before { background: var(--accent); }
.task-card.priority-medium::before { background: #225ea8; }
.task-card.priority-low::before { background: var(--primary); }

.task-card:hover {
    transform: translateY(-2px);
    border-color: #c8d3e3;
    box-shadow: 0 18px 38px rgba(23, 32, 51, .12);
}

.task-card-head {
    justify-content: space-between;
    align-items: start;
    padding-left: 4px;
}

.task-card h3 {
    margin: 0 0 4px;
    font-size: 17px;
    line-height: 1.3;
}

.task-card p {
    color: var(--muted);
    margin: 10px 0;
    line-height: 1.5;
}

.task-meta {
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    padding: 10px;
    border: 1px solid #e9eef6;
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
}

.task-card footer {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    color: var(--muted);
    font-weight: 900;
}

.task-summary {
    font-size: 14px;
}

.task-value {
    padding: 10px 12px;
    border-radius: 8px;
    background: #f3f8f7;
    color: #31453f !important;
}

.task-criteria {
    max-height: 150px;
    overflow: auto;
}

.task-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.task-progress-head strong {
    color: var(--ink);
    font-size: 14px;
}

.task-card .small-btn,
.task-card .danger-btn {
    opacity: .92;
    transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.task-card:hover .small-btn,
.task-card:hover .danger-btn {
    opacity: 1;
}

.task-card .small-btn:hover,
.task-card .danger-btn:hover {
    transform: translateY(-1px);
}

.task-card-comments {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid #e5ebf4;
    border-radius: 8px;
    background: rgba(247, 250, 252, .88);
}

.task-card-comments-head,
.task-comment-actions,
.task-card-comment > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.task-card-comments-head {
    margin-bottom: 10px;
}

.task-card-comments-head strong {
    font-size: 13px;
}

.task-card-comments-head span {
    min-width: 26px;
    min-height: 26px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #e8f7f2;
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
}

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

.task-card-comment {
    padding: 10px;
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    background: #fff;
}

.task-card-comment strong {
    font-size: 12px;
}

.task-card-comment small {
    white-space: nowrap;
}

.task-card-comment p {
    margin: 6px 0 0;
    color: #374154;
    font-size: 13px;
}

.task-comment-actions {
    justify-content: flex-end;
    margin-top: 10px;
}

.task-comment-actions a {
    font-size: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 24, 39, .58);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-panel {
    width: min(560px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 28px 70px rgba(16, 24, 39, .28);
}

.wide-modal {
    width: min(820px, 100%);
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

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

.member-card { padding: 18px; }
.avatar {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #eef7f6;
    color: var(--primary);
    font-weight: 900;
}

.member-card h3 { margin: 12px 0 4px; }
.member-stats { justify-content: space-between; margin-top: 18px; font-weight: 900; }

@media (max-width: 980px) {
    .topbar-menu {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        z-index: 40;
        width: min(280px, 84vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 18px 0 38px rgba(16, 24, 39, .22);
    }

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

    .logout { position: static; display: block; margin-top: 24px; }
    .app { margin-left: 0; padding: 18px; }
    .stat-grid, .mini-stat-grid, .two, .form-grid, .task-layout, .roadmap-layout, .roadmap, .filter-panel { grid-template-columns: 1fr; }
    .team-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .topbar, .field-row { align-items: stretch; flex-direction: column; }
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }
    .stat-grid strong { font-size: 26px; }
    .login-panel { padding: 24px; }
    .modal-backdrop {
        padding: 10px;
    }
}
