:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #192235;
    --muted: #68738a;
    --line: #e3e9f1;
    --primary: #2f6f62;
    --primary-dark: #24584e;
    --primary-soft: #e5f2ee;
    --accent: #e1a94b;
    --danger: #c44e52;
    --shadow: 0 20px 60px rgba(25, 34, 53, 0.12);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at 10% 10%, rgba(47, 111, 98, 0.12), transparent 30%),
        radial-gradient(circle at 90% 80%, rgba(225, 169, 75, 0.12), transparent 32%),
        var(--bg);
}

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

button {
    cursor: pointer;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--primary), #4e8f82);
    box-shadow: 0 10px 24px rgba(47, 111, 98, 0.28);
}

.brand div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand strong {
    font-size: 20px;
    letter-spacing: -0.02em;
}

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

.auth-layout {
    display: grid;
    min-height: 100vh;
    padding: 32px 20px;
    place-items: center;
}

.auth-card {
    width: min(100%, 470px);
    padding: 38px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.auth-copy {
    margin: 42px 0 28px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.auth-copy h1,
.welcome-panel h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.auth-copy p:last-child,
.welcome-panel > div > p:last-child {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    margin-bottom: 22px;
    border-radius: 14px;
    background: var(--surface-muted);
}

.auth-tab {
    padding: 10px;
    color: var(--muted);
    border: 0;
    border-radius: 10px;
    background: transparent;
}

.auth-tab.is-active {
    color: var(--text);
    font-weight: 700;
    background: var(--surface);
    box-shadow: 0 5px 16px rgba(25, 34, 53, 0.08);
}

.auth-form,
#task-form {
    display: grid;
    gap: 18px;
}

label {
    display: grid;
    gap: 8px;
    color: #39445a;
    font-size: 13px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: none;
    background: var(--surface);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(47, 111, 98, 0.12);
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    min-height: 42px;
    padding: 10px 16px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
}

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

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

.button-ghost {
    color: var(--text);
    border-color: var(--line);
    background: var(--surface);
}

.button-danger {
    color: var(--danger);
    border-color: rgba(196, 78, 82, 0.2);
    background: rgba(196, 78, 82, 0.06);
}

.button-block {
    width: 100%;
}

.form-error {
    margin: 0;
    padding: 10px 12px;
    color: #9d3035;
    font-size: 13px;
    border-radius: 10px;
    background: #fff0f0;
}

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

.app-header {
    display: flex;
    padding: 18px clamp(20px, 5vw, 64px);
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(227, 233, 241, 0.8);
    background: rgba(243, 246, 251, 0.8);
    backdrop-filter: blur(16px);
}

.brand-compact .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
    border-radius: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    padding: 7px 12px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--primary-soft);
}

.main-content {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

.welcome-panel {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
}

.summary-card {
    display: grid;
    min-width: 190px;
    padding: 22px 24px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 14px 36px rgba(25, 34, 53, 0.08);
}

.summary-card span {
    color: var(--muted);
    font-size: 12px;
}

.summary-card strong {
    margin: 4px 0;
    color: var(--primary);
    font-size: 38px;
    line-height: 1;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
    gap: 12px;
    margin: 38px 0 24px;
}

.search-field input,
.select-field select {
    height: 48px;
    background-color: rgba(255, 255, 255, 0.86);
}

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

.task-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    padding: 20px;
    align-items: start;
    border: 1px solid rgba(227, 233, 241, 0.9);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 30px rgba(25, 34, 53, 0.05);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 38px rgba(25, 34, 53, 0.08);
}

.task-check {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    color: var(--primary);
    border: 2px solid #bfd4ce;
    border-radius: 50%;
    background: transparent;
}

.task-card.is-done .task-check {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.task-body h3 {
    margin: 2px 0 6px;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.task-body p {
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    color: #8b95a8;
    font-size: 12px;
}

.task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0 0 12px;
}

.tag-chip {
    padding: 4px 8px;
    color: #536276;
    font-size: 11px;
    font-weight: 700;
    border-radius: 7px;
    background: #eef2f7;
}

.status-pill {
    padding: 4px 8px;
    color: #91631a;
    font-weight: 700;
    border-radius: 999px;
    background: #fff4db;
}

.priority-pill {
    padding: 4px 8px;
    font-weight: 750;
    border-radius: 999px;
}

.priority-pill.is-high {
    color: #9d3035;
    background: #ffe9e9;
}

.priority-pill.is-medium {
    color: #91631a;
    background: #fff4db;
}

.priority-pill.is-low {
    color: #41637d;
    background: #eaf3fb;
}

.due-date.is-overdue {
    color: var(--danger);
    font-weight: 700;
}

.status-pill.is-done {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.task-card.is-done h3 {
    color: #8b95a8;
    text-decoration: line-through;
}

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

.icon-button {
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.icon-button:hover {
    color: var(--text);
    border-color: #ccd5e2;
}

.icon-button.danger:hover {
    color: var(--danger);
    border-color: rgba(196, 78, 82, 0.3);
}

.loading-state,
.empty-state {
    display: grid;
    padding: 64px 20px;
    place-items: center;
    text-align: center;
    border: 1px dashed #cdd7e4;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.55);
}

.loading-state {
    grid-auto-flow: column;
    gap: 12px;
    color: var(--muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ccd8d5;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state h2 {
    margin: 14px 0 6px;
    font-size: 21px;
}

.empty-state p {
    margin: 0 0 20px;
    color: var(--muted);
}

.empty-icon {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    color: var(--primary);
    font-size: 28px;
    border-radius: 18px;
    background: var(--primary-soft);
}

.pagination {
    display: flex;
    margin-top: 24px;
    align-items: center;
    justify-content: center;
    gap: 20px;
    color: var(--muted);
    font-size: 13px;
}

.modal {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    padding: 24px;
    place-items: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 27, 42, 0.48);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    max-height: calc(100vh - 48px);
    padding: 28px;
    overflow-y: auto;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.modal-card-small {
    width: min(100%, 440px);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 25px;
    letter-spacing: -0.03em;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

.toast-container {
    position: fixed;
    z-index: 70;
    right: 20px;
    bottom: 20px;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 240px;
    max-width: 380px;
    padding: 13px 16px;
    color: #fff;
    border-radius: 12px;
    background: #26384d;
    box-shadow: 0 12px 30px rgba(25, 34, 53, 0.2);
}

.toast.is-error {
    background: #9d3035;
}

.admin-view {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

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

.admin-header h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 44px);
    letter-spacing: -0.045em;
}

.admin-header p:last-child {
    margin: 12px 0 0;
    color: var(--muted);
}

.admin-user-list {
    display: grid;
    gap: 12px;
}

.admin-user-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 20px;
    padding: 20px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.92);
}

.admin-user-card h3 {
    margin: 0 0 5px;
    font-size: 17px;
}

.admin-user-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

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

.role-field span {
    color: var(--muted);
    font-size: 11px;
}

.role-field .button {
    margin-top: 4px;
}

@media (max-width: 760px) {
    .auth-card {
        padding: 28px 22px;
        border-radius: 24px;
    }

    .app-header {
        padding: 14px 18px;
    }

    .brand-compact span,
    .user-badge {
        display: none;
    }

    .main-content {
        width: min(100% - 28px, 1120px);
        padding-top: 36px;
    }

    .admin-view {
        width: min(100% - 28px, 1120px);
        padding-top: 36px;
    }

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

    .admin-user-card {
        grid-template-columns: 1fr;
    }

    .welcome-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-card {
        min-width: 0;
    }

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

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

    .task-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .task-actions {
        grid-column: 2;
        justify-content: flex-end;
    }
}
