:root {
    --bg: #f3f4fb;
    --bg-accent: radial-gradient(circle at 15% 0%, rgba(91,71,224,0.08), transparent 40%),
                 radial-gradient(circle at 85% 20%, rgba(0,200,117,0.07), transparent 35%);
    --card-bg: #ffffff;
    --card-bg-hover: #fbfbff;
    --text: #1c1f2e;
    --text-muted: #6b7086;
    --border: #e7e8f2;
    --border-strong: #d7d9ea;
    --primary: #5b47e0;
    --primary-dark: #4634c4;
    --primary-soft: #efecfe;
    --urgent: #e2445c;
    --urgent-soft: #fde7ea;
    --medium: #e08b1d;
    --medium-soft: #fdf1de;
    --low: #00a389;
    --low-soft: #dff7f2;
    --new: #3a7bf0;
    --new-soft: #e7f0fe;
    --progress: #e08b1d;
    --progress-soft: #fdf1de;
    --done: #00a389;
    --done-soft: #dff7f2;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(23, 27, 55, 0.06);
    --shadow-md: 0 8px 24px rgba(23, 27, 55, 0.08);
    --shadow-lg: 0 20px 50px rgba(23, 27, 55, 0.18);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14151f;
        --bg-accent: radial-gradient(circle at 15% 0%, rgba(123,104,238,0.14), transparent 40%),
                     radial-gradient(circle at 85% 20%, rgba(0,200,117,0.08), transparent 35%);
        --card-bg: #1c1e2b;
        --card-bg-hover: #21232f;
        --text: #eef0fa;
        --text-muted: #9298b0;
        --border: #2b2e40;
        --border-strong: #383c53;
        --primary: #8672f2;
        --primary-dark: #9a89f5;
        --primary-soft: #2a2350;
        --urgent-soft: #3a1f2a;
        --medium-soft: #3a2c15;
        --low-soft: #113a33;
        --new-soft: #182a44;
        --progress-soft: #3a2c15;
        --done-soft: #113a33;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
        --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
        --shadow-lg: 0 20px 50px rgba(0,0,0,0.55);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    background-image: var(--bg-accent);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5b47e0 0%, #7b68ee 55%, #00c875 100%);
}

.login-card {
    background: var(--card-bg);
    padding: 40px 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    animation: pop-in 0.35s ease;
}

.login-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 15px;
    margin-bottom: 18px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-block { width: 100%; justify-content: center; }

.alert {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--urgent-soft);
    color: var(--urgent);
}

/* ---------- Layout ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7b68ee);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.topbar h1 {
    font-size: 18px;
    margin: 0;
    letter-spacing: -0.01em;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px 28px 0;
    max-width: 1100px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 24px;
    border: 1px solid var(--border);
}

.tab {
    padding: 7px 16px;
    border-radius: 20px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab-active, .tab-active:hover {
    background: var(--primary);
    color: #fff;
}

.tab-count {
    font-size: 11px;
    font-weight: 700;
    background: rgba(127,127,127,0.18);
    padding: 1px 7px;
    border-radius: 10px;
}

.tab-active .tab-count { background: rgba(255,255,255,0.25); }

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-muted);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-box input[type="text"] {
    border: none;
    background: transparent;
    padding: 9px 0;
    font-size: 14px;
    min-width: 220px;
    color: var(--text);
}

.search-box input[type="text"]:focus { outline: none; }

.task-list {
    padding: 18px 28px 60px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 70px 20px;
    font-size: 15px;
    background: var(--card-bg);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}

/* ---------- Task card ---------- */
.task-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
    animation: fade-up 0.25s ease;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.task-card.priority-urgent { border-left-color: var(--urgent); }
.task-card.priority-medium { border-left-color: var(--medium); }
.task-card.priority-low { border-left-color: var(--low); }

.task-main {
    flex: 1;
    min-width: 240px;
}

.task-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-priority-urgent { background: var(--urgent-soft); color: var(--urgent); }
.badge-priority-medium { background: var(--medium-soft); color: var(--medium); }
.badge-priority-low { background: var(--low-soft); color: var(--low); }

.assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-title {
    font-weight: 700;
    font-size: 15.5px;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.task-desc {
    font-size: 13.5px;
    color: var(--text-muted);
    white-space: pre-line;
    margin-bottom: 10px;
    line-height: 1.5;
}

.task-desc-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 5px 12px;
    border-radius: 20px;
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-link-chip:hover { text-decoration: underline; }

.task-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.view-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0 14px;
}

.view-links:empty { margin: 0; }

.links-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.link-row input { flex: 1; }

.link-row-remove {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
    padding: 6px 11px;
}

.btn-add-link {
    font-size: 12.5px;
    padding: 6px 12px;
}

.task-thumb-link { display: inline-block; }

.task-thumb {
    max-width: 160px;
    max-height: 110px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
    object-fit: cover;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.task-thumb-link:hover .task-thumb {
    transform: scale(1.03);
    box-shadow: var(--shadow-md);
}

.task-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 150px;
}

.status-select {
    font-weight: 700;
    font-size: 12px;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 6px 30px 6px 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    transition: box-shadow 0.15s;
}

.status-select:focus { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

.status-select.status-new { background-color: var(--new-soft); color: var(--new); }
.status-select.status-progress { background-color: var(--progress-soft); color: var(--progress); }
.status-select.status-done { background-color: var(--done-soft); color: var(--done); }

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

.task-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    color: var(--text);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

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

.btn-ghost {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--card-bg-hover); border-color: var(--border-strong); }

.btn-icon-only {
    padding: 7px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-icon-only:hover { background: var(--card-bg-hover); color: var(--text); }

.btn-view {
    padding: 7px 12px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 12.5px;
}

.btn-view:hover { background: var(--card-bg-hover); color: var(--text); }

.btn-danger { color: var(--urgent); }
.btn-danger:hover { background: var(--urgent-soft); border-color: var(--urgent-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 35, 0.55);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
    animation: fade-in 0.15s ease;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 26px 28px 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.modal label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text-muted);
}

.modal input[type="text"],
.modal input[type="file"],
.modal textarea,
.modal select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.modal input[type="text"]:focus,
.modal textarea:focus,
.modal select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

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

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 20px;
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    background: var(--bg);
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dropzone-active {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    pointer-events: none;
}

.dropzone-empty p {
    margin: 0;
    font-size: 13.5px;
}

.dropzone-empty small {
    font-size: 11px;
}

.dropzone-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
}

.dropzone-preview {
    position: relative;
    display: flex;
    max-width: 100%;
}

.dropzone-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--radius-sm);
    display: block;
    object-fit: cover;
}

.dropzone-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

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

/* ---------- View modal ---------- */
.status-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

.status-badge.status-new { background: var(--new-soft); color: var(--new); }
.status-badge.status-progress { background: var(--progress-soft); color: var(--progress); }
.status-badge.status-done { background: var(--done-soft); color: var(--done); }

.view-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0 14px;
}

.view-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-line;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    max-height: 40vh;
    overflow-y: auto;
}

.view-image-wrap { margin-top: 14px; }

.view-image-wrap img {
    max-width: 100%;
    max-height: 260px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
    transition: transform 0.18s ease;
}

.view-image-wrap a:hover img { transform: scale(1.02); }

.view-meta { margin-top: 14px; }

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    .topbar { padding: 12px 16px; }
    .topbar h1 { display: none; }
    .toolbar { padding: 16px 16px 0; }
    .task-list { padding: 14px 16px 60px; }
    .task-card { flex-direction: column; }
    .task-side { align-items: flex-start; width: 100%; flex-direction: row; flex-wrap: wrap; }
    .task-actions { order: 2; }
    .task-meta { order: 3; }
    .form-row { grid-template-columns: 1fr; }
    .search-box input[type="text"] { min-width: 0; flex: 1; }
    .btn span.btn-label { display: none; }
}
