:root{
    --bg: #edf4f7;
    --panel: #ffffff;
    --panel-soft: #f6fafb;
    --text: #1f2d35;
    --muted: #647680;
    --line: #d9e5ea;
    --primary: #2f7d9b;
    --primary-dark: #22647f;
    --success: #357f54;
    --warning: #a66a13;
    --danger: #bf3d3d;
    --shadow: 0 18px 45px rgba(31, 45, 53, 0.12);
}

*{
    box-sizing: border-box;
}

body{
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(135deg, #edf4f7 0%, #f8fbfc 52%, #e3eff2 100%);
    color: var(--text);
}

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

.todo-container{
    background-color: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

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

.eyebrow{
    display: block;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 6px;
}

h1{
    margin: 0;
    color: #1b3f52;
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.08;
}

#task-counter{
    margin: 0;
    color: var(--primary-dark);
    background-color: #e9f5f8;
    border: 1px solid #c9e4ec;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    white-space: nowrap;
}

.stats-grid{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card{
    background-color: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stat-card span{
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #1f5268;
}

.stat-card p{
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.progress-wrap{
    background-color: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 18px;
}

.progress-label{
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    margin-bottom: 10px;
}

.progress-label strong{
    color: var(--text);
}

.progress-track{
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background-color: #d9e8ee;
}

.progress-bar{
    width: 0;
    height: 100%;
    border-radius: inherit;
    background-color: var(--success);
    transition: width 0.25s ease;
}

.input-area,
.toolbar{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background-color: var(--panel-soft);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field,
.search-box{
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-wide{
    grid-column: span 2;
}

label{
    color: #3d515b;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea{
    width: 100%;
    min-height: 42px;
    padding: 10px 11px;
    font: inherit;
    color: var(--text);
    background-color: #fff;
    border: 1px solid #b9cbd3;
    border-radius: 5px;
    outline: none;
}

textarea{
    resize: vertical;
    min-height: 78px;
}

input:focus,
select:focus,
textarea:focus{
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 125, 155, 0.16);
}

button,
.calendar-link{
    min-height: 38px;
    padding: 9px 13px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: var(--primary);
    color: white;
    text-decoration: none;
    text-align: center;
}

button:hover,
.calendar-link:hover{
    opacity: 0.9;
}

.primary-action{
    align-self: end;
    min-height: 44px;
    background-color: var(--primary-dark);
}

.toolbar{
    margin-top: 16px;
    grid-template-columns: 1.4fr 2fr;
    align-items: end;
}

.tool-controls{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

ul{
    list-style: none;
    padding: 0;
    margin: 18px 0 0;
}

li{
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 16px;
    margin-top: 12px;
    background-color: #fff;
    border: 1px solid var(--line);
    border-left: 6px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(31, 45, 53, 0.07);
}

li.priority-high{
    border-left-color: var(--danger);
}

li.priority-medium{
    border-left-color: var(--warning);
}

li.priority-low{
    border-left-color: var(--success);
}

li.completed{
    opacity: 0.68;
}

li.completed .task-title{
    text-decoration: line-through;
}

li.overdue{
    background-color: #fff8f8;
}

.task-info{
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

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

.task-title-row input{
    width: 18px;
    min-width: 18px;
    height: 18px;
    min-height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
}

.task-title{
    font-size: 18px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

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

.meta-pill{
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 9px;
    color: #435760;
    background-color: #edf4f7;
    border: 1px solid #d9e5ea;
    border-radius: 999px;
    font-size: 13px;
}

.meta-pill.high,
.meta-pill.danger{
    color: #8d2424;
    background-color: #fdecec;
    border-color: #f3c2c2;
}

.meta-pill.medium{
    color: #7b4b08;
    background-color: #fff4df;
    border-color: #efd3a3;
}

.meta-pill.low{
    color: #27663f;
    background-color: #e9f7ee;
    border-color: #bfdfca;
}

.task-notes{
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.task-actions{
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 320px;
}

.secondary-action{
    color: #21445b;
    background-color: #dfeef3;
}

.danger-action,
#clear-all-btn{
    background-color: var(--danger);
}

#clear-completed-btn{
    background-color: var(--warning);
}

#print-btn{
    background-color: #657786;
}

#share-btn{
    background-color: var(--success);
}

.empty-state{
    margin: 18px 0 0;
    padding: 18px;
    color: var(--muted);
    text-align: center;
    background-color: var(--panel-soft);
    border: 1px dashed #b9cbd3;
    border-radius: 8px;
}

.empty-state[hidden]{
    display: none;
}

.list-actions{
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    justify-content: center;
}

@media print{
    body{
        background: #fff;
    }

    .input-area,
    .toolbar,
    .list-actions,
    .task-actions{
        display: none;
    }

    .app-shell{
        width: 100%;
        padding: 0;
    }

    .todo-container{
        padding: 0;
        border: none;
        box-shadow: none;
    }
}

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

    .input-area,
    .toolbar{
        grid-template-columns: 1fr;
    }

    .field-wide{
        grid-column: span 1;
    }

    .tool-controls{
        grid-template-columns: 1fr;
    }

    li{
        grid-template-columns: 1fr;
    }

    .task-actions{
        justify-content: flex-start;
        max-width: none;
    }
}

@media (max-width: 560px){
    .app-shell{
        width: min(100% - 24px, 1120px);
        padding: 18px 0;
    }

    .todo-container{
        padding: 18px;
    }

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

    .stats-grid{
        grid-template-columns: 1fr;
    }

    h1{
        font-size: 32px;
    }

    button,
    .calendar-link{
        width: 100%;
    }
}
