* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --bg: #e9e9e9;
    --surface: #ffffff;
    --surface-muted: #f3efe8;
    --surface-soft: #f7f3ec;
    --border: #ddd6c8;
    --border-strong: #c6bfb0;
    --text: #292524;
    --text-soft: #8d8d8d;
    --primary: #b45309;
    --primary-dark: #92400e;
    --primary-soft: #fff1dc;
    --accent: #059669;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --success-bg: #ecfdf3;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --shadow: 0 4px 12px rgba(41, 37, 36, 0.08);
}

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

body {
    font-family: "Liberation Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button,
input,
select,
.task-item,
.project-card,
.task-list {
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease, opacity 140ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.task-drag:focus-visible,
.task-toggle:focus-visible,
.modal-panel:focus-visible {
    outline: 2px solid rgba(180, 83, 9, 0.24);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 10px;
    align-items: start;
    margin-bottom: 16px;
}

.page-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.page-heading-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.1;
}

.page-header p {
    margin: 0;
    color: var(--text-soft);
}

.page-sort-form {
    margin: 0;
}

.page-sort-button {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.1;
    color: var(--text-soft);
}

.page-sort-button:hover {
    color: var(--text);
}
.page-heading-submeta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    min-width: 0;
    padding-bottom: 4px;
}

.page-heading-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 26px;
    padding: 4px 10px;
    /* border-radius: 999px;
    background: #f3f4f6; */
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.2;
}
.project-form,
.project-card,
.empty-state,
.page-note {
    /* background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px; */
}

.project-form,
.page-note,
.empty-state {
    /* padding: 16px; */
}

.project-form label,
.task-form label,
.modal-body label,
.inline-form span {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-soft);
}

.page-note {
    margin-bottom: 16px;
    background: var(--surface-soft);
}

.page-note p {
    margin: 0;
    color: var(--text-soft);
}

.row-inline,
.modal-actions,
.header-actions,
.task-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.project-form .row-inline {
    align-items: stretch;
    flex-wrap: nowrap;
}

.project-form .row-inline input[type="text"] {
    flex: 1 1 auto;
}

.project-form .row-inline button {
    flex: 0 0 auto;
}

.header-actions form,
.inline-form {
    margin: 0;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: 2px solid rgba(180, 83, 9, 0.15);
    outline-offset: 1px;
    border-color: var(--primary);
}

button {
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
}

button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.button-secondary,
.button-ghost {
    /* background: rgba(255, 255, 255, 0.72); */
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border);
    border: none !important;
}

.button-secondary:hover,
.button-ghost:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
    color: var(--text);
}

.button-secondary,
.button-ghost,
.button-danger,
.task-actions button {
    min-height: 36px;
    padding: 8px 12px;
    font-weight: 500;
}

.button-compact {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.2;
}

.button-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.button-icon::before {
    display: inline-block;
    font-size: 12px;
    line-height: 1;
    color: currentColor;
    opacity: 0.6;
}

.button-close::before {
    content: "−";
}

.button-delete::before {
    content: "×";
}

.button-save::before {
    content: "✓";
}

.button-cancel::before {
    content: "×";
}

.button-add::before {
    content: "+";
}

.button-more::before {
    content: "✏️";
    letter-spacing: -0.5px;
}

.icon-only-button {
    min-width: 30px;
    padding: 6px;
    justify-content: center;
    gap: 0;
}

.icon-only-button::before {
    font-size: 14px;
    opacity: 0.6;
}

.button-danger {
    background: rgba(254, 243, 242, 0.62);
    color: #b85a53;
    border-color: #efd0cd;
}

.button-danger:hover {
    background: #fde6e3;
    border-color: #f4c7c3;
    color: var(--danger);
}

.danger-text {
    color: var(--danger);
}

.flash {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-bg);
    border-color: #bbf7d0;
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    border-color: #fecaca;
    color: var(--error-text);
}

.project-list {
    display: flex;
    flex-direction: column;
    /* gap: 32px; */
}

.project-card {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 20px 32px;
    align-items: start;
    position: relative;
        padding: 18px 0px;
    border-bottom: 1px solid #ccc;
}

@media (hover: hover) and (pointer: fine) {
    .project-list:hover .project-card {
        opacity: 0.65;
    }

    .project-list:hover .project-card:hover,
    .project-list:hover .project-card:focus-within {
        opacity: 1;
    }
}

.project-card:hover {
    background: #e5e5e5;
}
.project-card.is-over {
    background: transparent;
}

.project-card.is-dragging {
    opacity: 0.55;
}

.project-card-header {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 12px;
    row-gap: 0;
    min-width: 0;
    margin: 0;
    padding: 8px 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.project-card-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    grid-column: 2;
}

.project-card-header > .project-drag {
    grid-column: 1;
}

.project-title-row {
    display: flex;
    align-items: start;
    gap: 0;
    min-width: 0;
}

.project-title-shell,
.task-title-shell {
    min-width: 0;
    flex: 1 1 auto;
}

.project-title-view,
.task-title-view {
    min-width: 0;
}

.project-title-view {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.project-title-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.project-awards {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.project-award {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    min-height: 20px;
    font-size: 15px;
    line-height: 1;
}

.project-title-view h2,
.task-title-view h3 {
    margin: 0;
}

.project-card-heading h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    color: #57534e;
}

.project-card-header .header-actions {
    grid-column: 3;
    justify-content: flex-end;
    align-self: start;
    gap: 8px;
    padding-top: 0;
    border-top: 0;
}

@media (hover: hover) and (pointer: fine) {
    .project-card::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -40px;
        width: 40px;
        z-index: 1;
    }

    .project-card-header {
        position: relative;
    }

    .project-card-header > .project-drag {
        position: absolute;
        top: 8px;
        left: -36px;
        z-index: 2;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        justify-self: auto;
        grid-column: auto;
    }

    .project-card-header .header-actions {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .project-card:hover .project-card-header > .project-drag,
    .project-card:focus-within .project-card-header > .project-drag,
    .project-card.is-dragging .project-card-header > .project-drag,
    .project-card-header > .project-drag:focus-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .project-card:hover .project-card-header .header-actions,
    .project-card:focus-within .project-card-header .header-actions,
    .project-card-header .header-actions.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

.project-card-header .header-actions-menu {
    left: auto;
    right: 0;
}

.project-card.is-over .project-card-header {
    background: transparent;
    box-shadow: none;
}

.project-title-button,
.task-title-button,
.task-history-detail-button {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    border-radius: 0;
    font: inherit;
    font-weight: inherit;
    text-align: left;
    position: relative;
    padding-right: 18px;
}

.project-title-button::after,
.task-title-button::after,
.task-history-detail-button::after {
    content: "✎";
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    font-size: 12px;
    line-height: 1;
    color: var(--primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
}

.project-title-button:hover,
.project-title-button:focus-visible,
.task-title-button:hover,
.task-title-button:focus-visible,
.task-history-detail-button:hover,
.task-history-detail-button:focus-visible {
    background: transparent;
    border-color: transparent;
    color: inherit;
}

.project-title-button:hover::after,
.project-title-button:focus-visible::after,
.task-title-button:hover::after,
.task-title-button:focus-visible::after,
.task-history-detail-button:hover::after,
.task-history-detail-button:focus-visible::after {
    opacity: 0.85;
}

.project-title-button {
    font-size: 18px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text-soft);
}

.project-amount-total {
    color: #6b6458;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
    white-space: nowrap;
}

.task-title-button {
    font-size: 16px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--text);
}

.inline-edit-form {
    margin: 0;
}

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

.inline-edit-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-edit-form input[type="text"] {
    min-height: 36px;
    font-size: 18px;
    font-weight: 600;
}

.task-edit-form input[type="text"] {
    min-height: 34px;
}

.project-count {
    margin: 0;
    color: var(--text-soft);
}

.project-drag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-height: 30px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: #8d867a;
    border-radius: 7px;
    font-size: 15px;
    line-height: 1;
}

.project-drag:hover {
    background: var(--surface-muted);
    border-color: var(--surface-muted);
    color: var(--text);
}

.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
    /* border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff; */
    overflow: visible;
    min-width: 0;
}

.task-list[data-has-tasks="false"]::before {
    content: attr(data-empty-text);
    display: block;
    padding: 18px 16px;
    color: var(--text-soft);
    /* background: #fff; */
}

.task-list.is-over {
    border-color: var(--primary);
    background: #fffaf5;
    box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.15);
}

.task-list.is-over[data-has-tasks="false"]::before {
    content: attr(data-drop-text);
    color: var(--primary-dark);
    background: #fffaf5;
}

.task-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto 19px;
    gap: 14px;
    align-items: center;
    position: relative;
    padding: 9px 14px;
    margin: 6px 0;
    /* border: 1px solid #57534e; */
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(84, 84, 84, 0.16);
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    background: #fff;
     box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.25);
}

.task-item.is-dragging {
    opacity: 0.5;
    background: var(--surface-soft);
}

.task-item.is-drop-target {
    border-top: 2px solid var(--primary);
}

.task-drag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-height: 30px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: #8d867a;
    border-radius: 7px;
    letter-spacing: 0;
    font-size: 15px;
    line-height: 1;
    justify-self: end;
    grid-column: 4;
}

.task-drag:hover {
    background: var(--surface-muted);
    border-color: var(--surface-muted);
    color: var(--text);
}

.task-toggle {
    position: relative;
    width: 20px;
    height: 20px;
    min-height: auto;
    padding: 0;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border-strong);
}

.task-toggle::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 999px;
    background: transparent;
}

.task-toggle:hover {
    background: #fff;
    border-color: var(--primary);
}

.task-toggle:hover::after {
    background: rgba(180, 83, 9, 0.15);
}

.task-main {
    min-width: 0;
    grid-column: 2;
}

.task-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    grid-column: 3;
    width: fit-content;
    max-width: 100%;
}

.task-title-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.task-title {
    font-size: 16px;
    line-height: 1.4;
}

.importance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding: 2px 8px;
    /* border-radius: 7px; */
    font-size: 13px;
    line-height: 1.4;
    /* border: 1px solid var(--border);
    background: var(--surface-muted); */
}

.task-business-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 600;
    white-space: nowrap;
}

.task-business-badge-cash {
    /* background: #dcfce7;
    color: #166534; */
}

.task-amount {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    color: #6b6458;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.importance-1 {
    /* border-color: #f5c27a;
    background: #fff1dc; */
}

.importance-2 {
    /* border-color: #e8b26c;
    background: #fde7c8; */
}

.importance-3 {
    /* border-color: #d9974f;
    background: #f6d5ad; */
}

.header-actions,
.task-actions {
    position: relative;
    display: flex;
    justify-content: flex-end;
}

@media (hover: hover) and (pointer: fine) {
    .task-item::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -40px;
        width: 40px;
        z-index: 1;
    }

    .task-item .task-drag {
        position: absolute;
        top: 50%;
        left: -36px;
        z-index: 2;
        transform: translateY(-50%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        justify-self: auto;
        grid-column: auto;
    }

    .task-item:hover .task-drag,
    .task-item:focus-within .task-drag,
    .task-item.is-dragging .task-drag,
    .task-item .task-drag:focus-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .task-item .task-actions {
        position: absolute;
        top: 50%;
        right: -36px;
        z-index: 2;
        transform: translateY(-50%);
        opacity: 0;
        pointer-events: none;
    }

    .task-item:hover .task-actions,
    .task-item:focus-within .task-actions,
    .task-item .task-actions.is-open,
    .task-item .task-actions:focus-within {
        opacity: 1;
        pointer-events: auto;
    }

    .task-item .task-actions-menu {
        right: calc(100% + 8px);
    }
}

.header-actions-toggle,
.task-actions-toggle {
    align-self: start;
}

.header-actions.is-open .header-actions-toggle,
.task-actions.is-open .task-actions-toggle {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
}

.header-actions-menu[hidden],
.task-actions-menu[hidden] {
    display: none;
}

.header-actions-menu,
.task-actions-menu {
    position: absolute;
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(280px, calc(100vw - 24px));
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(41, 37, 36, 0.18);
}

.header-actions-menu {
    top: calc(100% + 8px);
}

.task-actions-menu {
    top: calc(100% + 8px);
    bottom: auto;
    max-height: min(82vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.task-actions-menu[data-direction="up"] {
    top: auto;
    bottom: calc(100% + 8px);
}

.task-actions-menu[data-direction="down"] {
    top: calc(100% + 8px);
    bottom: auto;
}

.header-actions-menu form,
.task-actions-menu .inline-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-actions-label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-actions-label-checkbox {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
}

.task-actions-label span {
    font-size: 13px;
    line-height: 1.2;
    color: var(--text-soft);
}

.task-actions-label-checkbox span {
    flex: 1 1 auto;
    white-space: nowrap;
}

.task-actions-label-checkbox input[type="checkbox"] {
    width: auto;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.cash-in-helper {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-soft);
}

.task-actions-menu .inline-form label {
    margin: 0;
}

.task-actions-menu .inline-form input,
.task-actions-menu .inline-form select {
    width: 100%;
    min-width: 0;
}

.task-actions-menu .inline-form select {
    min-height: 38px;
    padding: 6px 10px;
}

.action-menu-button {
    width: 100%;
    justify-content: flex-start;
}

.inline-form label {
    margin: 0;
}

.inline-form select {
    width: 68px;
    min-height: 36px;
    padding: 6px 8px;
}

.task-form {
    padding-top: 4px;
    border-top: 1px solid var(--surface-muted);
}

.task-form-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
}

.task-form-header label {
    margin: 0;
}

.task-form-hint {
    color: var(--text-soft);
    font-size: 13px;
}

.task-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 150px;
    gap: 10px;
    align-items: start;
}

.empty-state {
    color: var(--text-soft);
}

.empty-state p {
    margin: 0;
}

.project-summary-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(84, 84, 84, 0.12);
}

.summary-card strong {
    font-size: 22px;
    line-height: 1.2;
    color: var(--text);
}

.summary-card span {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.4;
}

.task-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-history-item {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 16px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(84, 84, 84, 0.12);
}

.task-history-status-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.task-history-status-label {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.task-history-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-history-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.task-history-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.35;
    color: var(--text);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
}

.status-active {
    background: #fff1dc;
    color: #9a5b0c;
}

.status-completed {
    background: #ecfdf3;
    color: #166534;
}

.status-closed {
    background: #f1f5f9;
    color: #475569;
}

.task-history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.task-history-detail-shell {
    display: inline-flex;
    align-items: center;
}

.task-history-detail {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    /* padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-soft); */
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.35;
}

.task-history-edit-form {
    margin: 0;
}

@media (max-width: 720px) {
    .task-history-item {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .task-history-status-column {
        gap: 6px;
    }
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(41, 37, 36, 0.42);
}

.modal-panel {
    position: relative;
    width: min(480px, calc(100% - 32px));
    margin: 10vh auto 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(41, 37, 36, 0.18);
}

.modal-header,
.modal-body,
.modal-actions {
    padding: 18px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--surface-muted);
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-body p {
    margin: 0;
    color: var(--text-soft);
}

.modal-body strong {
    font-size: 18px;
    line-height: 1.35;
}

.modal-actions {
    border-top: 1px solid var(--surface-muted);
    justify-content: flex-end;
}

@media (max-width: 920px) {
    .page-header {
        grid-template-columns: 1fr;
    }

    .project-form {
        max-width: 560px;
    }

    .project-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .task-item {
        grid-template-columns: 28px minmax(0, 1fr) 36px;
        align-items: start;
    }

    .task-main {
        grid-column: 2;
    }

    .task-side {
        grid-column: 2 / -1;
        justify-content: flex-start;
        padding-top: 4px;
        flex-wrap: wrap;
    }

    .task-actions {
        padding-top: 0;
    }

    .task-drag {
        grid-column: 3;
        grid-row: 1;
        align-self: start;
    }

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

@media (max-width: 720px) {
    .page-shell {
        padding: 20px 14px 36px;
    }

    .project-card {
        gap: 8px;
        padding: 14px 0;
    }

    .project-card-header {
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr) auto;
        align-items: start;
        column-gap: 10px;
        row-gap: 0;
        padding: 4px 0;
    }

    .project-title-row {
        gap: 0;
    }

    .project-card-heading h2 {
        font-size: 18px;
        line-height: 1.25;
    }

    .project-title-meta {
        gap: 6px;
    }

    .project-awards {
        gap: 2px;
    }

    .project-card-header > .project-drag {
        width: 24px;
        min-height: 24px;
        margin-top: 1px;
    }

    .project-card-header .header-actions {
        justify-content: flex-end;
        gap: 4px;
    }

    .project-card-header .header-actions-menu {
        left: auto;
        right: 0;
    }

    .task-item {
        grid-template-columns: 24px minmax(0, 1fr) 24px;
        gap: 10px 12px;
        padding: 12px;
        align-items: start;
    }

    .task-main {
        grid-column: 2;
        grid-row: 1;
    }

    .task-side {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 12px;
        row-gap: 8px;
        grid-column: 2 / 4;
        grid-row: 2;
        width: 100%;
        max-width: none;
        padding-top: 0;
    }

    .task-actions {
        padding-top: 0;
        justify-self: end;
    }

    .task-drag {
        grid-column: 3;
        grid-row: 1;
        align-self: center;
        justify-self: end;
        width: 24px;
        min-height: 24px;
    }

    .task-amount {
        min-height: 0;
        justify-content: flex-start;
        white-space: normal;
    }

    .task-form-header {
        flex-direction: column;
        align-items: start;
    }

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

    .task-history-item {
        padding: 14px;
    }

    .row-inline {
        flex-direction: column;
    }

    .row-inline button,
    .task-form-grid button {
        width: 100%;
    }

    .modal-panel {
        margin-top: 5vh;
    }

    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-actions button {
        width: 100%;
    }
}
