:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #eef3f2;
    --ink: #1d2630;
    --muted: #64727f;
    --line: #d9e1e6;
    --accent: #147a74;
    --accent-strong: #0f5f5a;
    --amber: #b7791f;
    --red: #b42318;
    --blue: #2456a6;
    --green: #237044;
    --shadow: 0 14px 32px rgba(29, 38, 48, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

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

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

button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

button:hover {
    background: var(--accent-strong);
}

button:disabled {
    cursor: progress;
    opacity: 0.62;
}

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

textarea {
    resize: vertical;
}

.app-shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-form {
    display: grid;
    width: min(420px, 100%);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 22px;
    box-shadow: var(--shadow);
}

.login-form h1 {
    margin-bottom: 8px;
}

.login-error {
    min-height: 22px;
    margin: 0;
    color: var(--red);
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    padding: 0 13px;
    white-space: nowrap;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 0;
    font-size: 1.25rem;
}

h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.ghost-button:hover {
    background: var(--surface-soft);
}

.workbench {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.task-form {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(170px, 0.8fr) 160px 160px auto;
    gap: 10px;
}

.import-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
    justify-self: end;
    width: min(520px, 100%);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.summary-tile {
    min-height: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 13px;
}

.summary-tile strong {
    display: block;
    margin-top: 4px;
    font-size: 1.8rem;
    line-height: 1;
}

.summary-tile span {
    color: var(--muted);
    font-size: 0.9rem;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 220px auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.segmented {
    display: inline-grid;
    grid-template-columns: repeat(2, 1fr);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.segmented button {
    min-width: 94px;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
}

.segmented button.active {
    background: var(--accent);
    color: #fff;
}

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

.task-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 170px 160px 124px;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    padding: 13px;
}

.task-card[data-status="backlog"] {
    border-left-color: var(--muted);
}

.task-card[data-status="in_progress"] {
    border-left-color: var(--blue);
}

.task-card[data-status="review"] {
    border-left-color: var(--amber);
}

.task-card[data-status="blocked"] {
    border-left-color: var(--red);
}

.task-card[data-status="done"] {
    border-left-color: var(--green);
}

.task-main {
    min-width: 0;
}

.task-title {
    margin: 0 0 5px;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 2px 9px;
}

.priority-urgent,
.priority-high {
    color: var(--red);
}

.task-actions {
    display: flex;
    justify-content: flex-end;
}

.small-button {
    min-height: 36px;
    padding: 0 12px;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(210px, 1fr));
    gap: 12px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.board-column {
    min-width: 210px;
}

.board-column header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 10px;
}

.board-column .task-card {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 10px;
}

.board-column .task-card > select,
.board-column .task-card > .task-actions {
    display: none;
}

.task-dialog {
    width: min(760px, calc(100% - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 24px 60px rgba(29, 38, 48, 0.24);
}

.task-dialog::backdrop {
    background: rgba(29, 38, 48, 0.42);
}

.profile-dialog {
    width: min(460px, calc(100% - 28px));
}

.task-dialog form {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.task-dialog header,
.task-dialog footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.task-dialog label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.task-dialog label span {
    font-size: 0.86rem;
}

.image-panel {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding: 16px 18px 18px;
}

.image-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px;
    align-items: center;
}

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

.image-gallery .empty-state {
    grid-column: 1 / -1;
}

.image-item {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) 38px;
    gap: 10px;
    align-items: center;
    min-height: 90px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.image-item img {
    display: block;
    width: 88px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--surface-soft);
}

.image-item span {
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-item small {
    color: var(--muted);
}

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

.icon-button {
    width: 38px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0;
    background: #fff;
    color: var(--ink);
    font-size: 1.35rem;
}

.icon-button:hover {
    background: var(--surface-soft);
}

.danger-button {
    background: var(--red);
}

.danger-button:hover {
    background: #8f1d14;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100% - 40px));
    transform: translateY(20px);
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    padding: 12px 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1060px) {
    .workbench,
    .task-form,
    .task-card {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 20px, 1320px);
        padding-top: 16px;
    }

    .topbar,
    .topbar-actions,
    .filters,
    .import-form,
    .image-form,
    .image-gallery,
    .dialog-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
    }

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

    .segmented {
        width: 100%;
    }
}
