:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-muted: #eef2f6;
    --ink: #18212f;
    --muted: #687385;
    --line: #dce3ea;
    --brand: #147d7e;
    --brand-dark: #0f5f60;
    --coral: #d96c55;
    --amber: #c7922b;
    --green: #2f8f5b;
    --nav: #162331;
    --nav-muted: #a9b6c5;
    --danger: #b64040;
    --shadow: 0 12px 30px rgba(31, 45, 61, 0.08);
}

[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

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

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

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

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.18s ease;
}

.sidebar-collapsed .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
}

.app-sidebar {
    background: var(--nav);
    color: #fff;
    padding: 24px 18px;
    position: relative;
}

.sidebar-head,
.brand,
.sidebar-user {
    display: flex;
    align-items: center;
}

.sidebar-head {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 34px;
}

.brand {
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--brand);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

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

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 0;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-weight: 800;
    height: 34px;
    width: 34px;
}

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
}

.sidebar-user strong,
.sidebar-user small {
    display: block;
}

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

.main-nav {
    display: grid;
    gap: 6px;
}

.main-nav a {
    align-items: center;
    border-radius: 8px;
    color: var(--nav-muted);
    display: flex;
    gap: 10px;
    padding: 11px 12px;
    transition: background 0.15s ease, color 0.15s ease;
}

.main-nav a::before {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    content: attr(data-icon);
    display: inline-flex;
    flex: 0 0 30px;
    font-size: 11px;
    font-weight: 900;
    height: 30px;
    justify-content: center;
}

.main-nav a:hover,
.main-nav a.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-collapsed .app-sidebar {
    padding-inline: 14px;
}

.sidebar-collapsed .nav-text,
.sidebar-collapsed .brand .nav-text,
.sidebar-collapsed .sidebar-user .nav-text {
    display: none;
}

.sidebar-collapsed .sidebar-head {
    justify-content: center;
}

.sidebar-collapsed .brand {
    display: none;
}

.sidebar-collapsed .main-nav a {
    justify-content: center;
    padding-inline: 8px;
}

.sidebar-collapsed .main-nav a::before {
    flex-basis: 34px;
}

.app-main {
    min-width: 0;
    padding: 30px;
}

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

.topbar h1 {
    font-size: clamp(26px, 3vw, 38px);
    line-height: 1.1;
    margin: 0;
}

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.calendar-toolbar,
.month-nav,
.inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-toolbar {
    justify-content: space-between;
}

.calendar-filter {
    margin-top: 14px;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.segmented {
    background: var(--surface-muted);
    border-radius: 8px;
    display: inline-flex;
    gap: 4px;
    padding: 4px;
}

.segmented a {
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
    padding: 8px 12px;
}

.segmented a.is-active {
    background: var(--surface);
    box-shadow: 0 3px 10px rgba(31, 45, 61, 0.08);
    color: var(--ink);
}

.content-stack {
    display: grid;
    gap: 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

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

.panel-header h2 {
    font-size: 18px;
    margin: 0;
}

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

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.metric:nth-child(2) {
    border-left-color: var(--coral);
}

.metric:nth-child(3) {
    border-left-color: var(--amber);
}

.metric:nth-child(4) {
    border-left-color: var(--green);
}

.metric strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin-top: 8px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

.data-table {
    border-collapse: collapse;
    min-width: 680px;
    width: 100%;
}

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

.data-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tr.is-over-budget td {
    background: #fff2f2;
}

.budget-table input {
    min-width: 96px;
}

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

.budget-status-card {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    display: grid;
    gap: 3px;
    padding: 10px 12px;
}

.budget-status-card strong {
    font-size: 13px;
}

.budget-status-card span {
    color: var(--muted);
    font-size: 13px;
}

.budget-status-card.is-over-budget {
    background: #fff2f2;
    border-left-color: var(--danger);
}

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

.planned-delete-panel h2 {
    font-size: 16px;
    margin: 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

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

.calendar-weekdays div {
    padding: 0 8px 8px;
}

.calendar-cell {
    background: #fff;
    border: 1px solid var(--line);
    cursor: pointer;
    min-height: 150px;
    padding: 8px;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.calendar-cell:hover {
    border-color: rgba(20, 125, 126, 0.35);
    box-shadow: inset 0 0 0 1px rgba(20, 125, 126, 0.18);
}

.calendar-cell:focus-visible {
    outline: 3px solid rgba(20, 125, 126, 0.22);
    outline-offset: -3px;
}

.calendar-cell.is-today {
    border-color: var(--brand);
    box-shadow: inset 0 0 0 1px var(--brand);
}

.calendar-cell.is-selected {
    background: #eef8f8;
}

.calendar-cell.is-overloaded {
    background: #fff1f1;
    border-color: #d85454;
    box-shadow: inset 0 0 0 1px #d85454;
}

.calendar-cell.is-muted {
    background: #f8fafc;
    color: var(--muted);
}

.calendar-day {
    border-radius: 6px;
    display: inline-flex;
    font-weight: 800;
    margin-bottom: 8px;
    min-width: 34px;
    padding: 2px 8px;
}

.calendar-day.is-today {
    background: var(--brand);
    color: #fff;
}

.calendar-grid-week .calendar-cell {
    min-height: 220px;
}

.calendar-cell-week .calendar-day {
    font-size: 13px;
}

.calendar-event {
    --progress: 0%;
    background: rgba(241, 245, 249, 0.7);
    border-left: 4px solid var(--brand);
    border-radius: 6px;
    display: grid;
    gap: 2px;
    margin-bottom: 6px;
    overflow: hidden;
    padding: 7px 8px;
    position: relative;
}

.calendar-event.has-real {
    background: #fff;
}

.calendar-event.is-pending-real {
    filter: saturate(0.7);
    opacity: 1;
}

.calendar-event > * {
    position: relative;
    z-index: 1;
}

.calendar-event.has-gradient-border {
    border-left: 0;
    padding-left: 12px;
}

.task-summary.has-gradient-border {
    border-left: 0;
    padding-left: 16px;
}

.calendar-event.has-gradient-border::before,
.task-summary.has-gradient-border::before {
    background: var(--task-border-gradient, var(--brand));
    bottom: 0;
    content: "";
    left: 0;
    position: absolute;
    top: 0;
    width: 4px;
    z-index: 0;
}

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

.task-summary {
    --progress: 0%;
    background: rgba(241, 245, 249, 0.7);
    border-left: 4px solid var(--brand);
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 8px;
    display: grid;
    gap: 2px;
    overflow: hidden;
    padding: 10px 12px;
    position: relative;
}

.task-choice {
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    width: 100%;
}

.task-choice:hover,
.task-choice.is-active {
    box-shadow: 0 0 0 2px rgba(20, 125, 126, 0.22);
}

.task-choice:focus-visible {
    outline: 3px solid rgba(20, 125, 126, 0.24);
    outline-offset: 2px;
}

.task-choice-new {
    background: #fff;
    border-left-color: var(--brand);
    border-style: dashed;
    border-width: 1px 1px 1px 4px;
}

.task-summary.has-real {
    background: #fff;
}

.task-summary.is-pending-real {
    filter: saturate(0.7);
    opacity: 1;
}

.task-summary > * {
    position: relative;
    z-index: 1;
}

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

.task-summary span,
.task-summary small {
    color: var(--muted);
}

.task-summary .task-name {
    color: var(--ink);
    font-weight: 700;
}

.task-progress {
    background: rgba(20, 125, 126, 0.08);
    border-radius: 6px;
    display: block;
    height: 12px;
    margin-top: 5px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.task-progress-fill {
    background: rgba(20, 125, 126, 0.48);
    border-radius: inherit;
    display: block;
    height: 100%;
    transition: width 0.2s ease;
}

.has-real .task-progress-fill {
    min-width: 5px;
}

.task-progress-label {
    color: rgba(21, 38, 43, 0.72);
    font-size: 9px;
    font-weight: 800;
    inset: 0;
    line-height: 12px;
    position: absolute;
    text-align: center;
    z-index: 1;
}

.task-collaborators {
    display: grid;
    gap: 7px;
    margin-top: 6px;
}

.task-collaborators-compact {
    gap: 5px;
    margin-top: 4px;
}

.task-collaborator {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.task-collaborator-line {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    min-width: 0;
}

.task-collaborator-line small {
    display: block;
    min-width: 0;
}

.task-collaborator-line small:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-collaborator-line small:last-child {
    color: rgba(21, 38, 43, 0.68);
    flex: 0 0 auto;
    font-weight: 800;
}

.task-collaborator-person .task-collaborator-line small:first-child {
    color: var(--person-color, var(--brand));
    font-weight: 800;
}

.task-collaborator-line-single small:first-child {
    color: rgba(21, 38, 43, 0.58);
    font-weight: 700;
}

.task-progress-person {
    background: rgba(21, 38, 43, 0.07);
    height: 9px;
    margin-top: 0;
}

.task-collaborators-compact .task-progress-person {
    height: 7px;
}

.task-progress-person .task-progress-fill {
    background: var(--person-color, var(--brand));
    min-width: 0;
    opacity: 0.5;
}

.task-progress-person .task-progress-label {
    display: none;
}


.calendar-event strong,
.calendar-event span,
.calendar-event small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event strong {
    font-size: 13px;
}

.calendar-event span,
.calendar-event small {
    color: var(--muted);
    font-size: 12px;
}

.calendar-event .task-name {
    color: var(--ink);
    font-weight: 700;
}

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

.btn {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
}

.btn:hover {
    border-color: var(--line);
}

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

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

.btn-danger {
    background: #fae7e7;
    color: var(--danger);
}

.btn-link {
    background: transparent;
    color: var(--brand);
    padding-inline: 0;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    min-height: 24px;
    padding: 3px 10px;
}

.badge-on {
    background: #e0f2e8;
    color: var(--green);
}

.badge-off {
    background: #edf0f3;
    color: var(--muted);
}

.badge-danger {
    background: #fae7e7;
    color: var(--danger);
}

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

.form-field {
    display: grid;
    gap: 7px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-section {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 16px;
    margin-top: 22px;
    padding-top: 20px;
}

.form-section h2 {
    font-size: 16px;
    margin: 0;
}

.form-field label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

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

.form-field textarea {
    min-height: 120px;
    resize: vertical;
}

.field-error {
    color: var(--danger);
    font-size: 13px;
}

.form-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

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

.notice-success {
    background: #e0f2e8;
    color: var(--green);
}

.notice-error {
    background: #fae7e7;
    color: var(--danger);
}

.empty-state {
    color: var(--muted);
    padding: 28px 10px;
    text-align: center;
}

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

.nowrap {
    white-space: nowrap;
}

.text-strong {
    font-weight: 800;
}

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

.swatch {
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-block;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
    width: 18px;
}

.login-page {
    background:
        linear-gradient(135deg, rgba(20, 125, 126, 0.14), transparent 42%),
        linear-gradient(315deg, rgba(217, 108, 85, 0.16), transparent 38%),
        var(--bg);
}

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

.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 430px;
    padding: 28px;
    width: 100%;
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
}

.login-brand h1,
.login-brand p {
    margin: 0;
}

.login-brand p {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 16px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        padding: 16px;
    }

    .brand {
        margin-bottom: 16px;
    }

    .main-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .main-nav a {
        white-space: nowrap;
    }

    .sidebar-collapsed .nav-text {
        display: inline;
    }

    .sidebar-collapsed .brand {
        display: flex;
    }

    .app-main {
        padding: 22px 16px;
    }

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

    .calendar-grid,
    .calendar-grid-week {
        min-width: 920px;
    }

    .calendar-weekdays,
    .calendar-grid:not(.calendar-weekdays) {
        width: 920px;
    }

    .panel:has(.calendar-grid) {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .topbar,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions,
    .row-actions,
    .form-actions {
        justify-content: flex-start;
        width: 100%;
    }

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