:root {
    color-scheme: light;
    --navy: #10243a;
    --navy-soft: #1d3854;
    --page: #f3f5f8;
    --white: #ffffff;
    --text: #263445;
    --muted: #647386;
    --border: #dce3eb;
    --success: #28735b;
    --success-bg: #e8f4ee;
    --warning: #a64c38;
    --warning-bg: #fff0eb;
    --shadow: 0 12px 32px rgb(16 36 58 / 6%);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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

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

button,
select {
    cursor: pointer;
}

a {
    color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #82a6ca;
    outline-offset: 3px;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px max(6%, calc((100% - 1120px) / 2));
    background: var(--navy);
    color: var(--white);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 28%);
    border-radius: 10px;
    color: var(--white);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

.primary-nav {
    display: flex;
    align-items: center;
    gap: 26px;
}

.primary-nav a {
    color: #d7e0e9;
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 160ms ease;
}

.primary-nav a:hover {
    color: var(--white);
}

.account-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #d7e0e9;
    font-size: 0.85rem;
}

.sign-out-button {
    background: rgb(255 255 255 / 12%);
    color: var(--white);
}

.sign-out-button:hover {
    background: rgb(255 255 255 / 22%);
}

.main-content {
    width: min(1120px, 88%);
    margin: 0 auto;
    padding: 54px 0 72px;
}

.auth-panel {
    max-width: 480px;
    margin: 0 auto;
}

.auth-panel h1 {
    margin-bottom: 8px;
    color: var(--navy);
    font-size: 1.6rem;
}

.auth-panel .panel-intro {
    margin-bottom: 22px;
}

[hidden] {
    display: none !important;
}

.dashboard-section + .dashboard-section {
    margin-top: 58px;
}

.page-heading {
    max-width: 680px;
    margin-bottom: 30px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.13em;
}

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

.page-heading h1 {
    margin-bottom: 10px;
    color: var(--navy);
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.page-heading > p:last-child,
.panel-intro {
    margin-bottom: 0;
    color: var(--muted);
}

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

.stat-card,
.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--white);
    box-shadow: var(--shadow);
}

.stat-card {
    min-height: 128px;
    padding: 20px 22px;
}

.stat-label {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-value {
    margin-bottom: 0;
    color: var(--navy);
    font-size: 2rem;
    font-weight: 750;
    line-height: 1;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin-bottom: 0;
    color: var(--navy);
    font-size: clamp(1.6rem, 3vw, 2rem);
    line-height: 1.2;
}

.task-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.78fr) minmax(0, 1.5fr);
    align-items: start;
    gap: 20px;
}

.panel {
    padding: 24px;
}

.panel h3 {
    margin-bottom: 5px;
    color: var(--navy);
    font-size: 1.12rem;
}

.panel-intro {
    font-size: 0.9rem;
}

.form-panel .panel-intro {
    margin-bottom: 22px;
}

.form-field {
    margin-bottom: 17px;
}

.form-field label,
.filter-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 650;
}

.optional-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 400;
}

.form-field input,
.form-field textarea,
.filter-field select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text);
}

.form-field input,
.filter-field select {
    min-height: 44px;
    padding: 9px 11px;
}

.form-field textarea {
    min-height: 108px;
    padding: 10px 11px;
    resize: vertical;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
    color: #8995a3;
}

.primary-button,
.task-action {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    transition: background 160ms ease, color 160ms ease;
}

.primary-button {
    width: 100%;
    min-height: 46px;
    padding: 10px 16px;
    background: var(--navy);
    color: var(--white);
}

.primary-button:hover {
    background: var(--navy-soft);
}

.status-message {
    margin: 0 0 18px;
    padding: 12px 15px;
    border: 1px solid #b9ddca;
    border-radius: 9px;
    background: var(--success-bg);
    color: #205b46;
    font-size: 0.9rem;
}

.status-message[data-type="error"] {
    border-color: #efc6ba;
    background: var(--warning-bg);
    color: #873a2b;
}

.task-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.filter-field {
    width: 150px;
}

.filter-field label {
    margin-bottom: 4px;
    font-size: 0.78rem;
}

.task-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.task-item {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-left: 4px solid #8a9bad;
    border-radius: 10px;
    background: var(--white);
}

.task-item.is-completed {
    border-left-color: var(--success);
}

.task-item.is-overdue {
    border-left-color: var(--warning);
}

.task-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.task-title {
    overflow-wrap: anywhere;
    margin-bottom: 6px;
    color: var(--navy);
    font-size: 1rem;
    line-height: 1.35;
}

.task-description {
    overflow-wrap: anywhere;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.task-badge {
    flex: 0 0 auto;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf1f5;
    color: #536477;
    font-size: 0.72rem;
    font-weight: 700;
}

.task-badge.is-completed {
    background: var(--success-bg);
    color: var(--success);
}

.task-badge.is-overdue {
    background: var(--warning-bg);
    color: var(--warning);
}

.task-meta {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.82rem;
}

.task-item.is-overdue .task-meta {
    color: var(--warning);
    font-weight: 650;
}

.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.task-action {
    padding: 7px 11px;
    background: #edf1f5;
    color: var(--navy);
}

.task-action:hover {
    background: #dfe6ed;
}

.task-action.delete-button {
    background: transparent;
    color: #873a2b;
}

.task-action.delete-button:hover {
    background: var(--warning-bg);
}

.task-action:disabled,
.primary-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.retry-button {
    display: block;
    margin: 12px auto 0;
}

.empty-state {
    margin: 0;
    padding: 28px 16px;
    border: 1px dashed #c8d2dd;
    border-radius: 10px;
    color: var(--muted);
    text-align: center;
}

.app-footer {
    padding: 18px 6%;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
}

.app-footer p {
    margin: 0;
}

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

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

@media (max-width: 560px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        padding: 16px 6%;
    }

    .brand {
        font-size: 0.92rem;
    }

    .primary-nav {
        gap: 22px;
    }

    .account-controls {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .main-content {
        width: 90%;
        padding: 36px 0 48px;
    }

    .dashboard-section + .dashboard-section {
        margin-top: 42px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        min-height: 108px;
        padding: 16px;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .panel {
        padding: 18px;
    }

    .task-panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .filter-field {
        width: 100%;
    }

    .task-item-header {
        flex-direction: column;
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
