/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-page: #f8f8f8;
    --text: #1a1a1a;
    --text-muted: #666;
    --border: rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-card: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --blue: #2563eb;
    --blue-bg: #dbeafe;
    --amber: #d97706;
    --amber-bg: #fef3c7;
    --gray: #6b7280;
    --gray-bg: #f3f4f6;
    --teal: #0d9488;
    --teal-bg: #ccfbf1;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1e1e1e;
        --bg-page: #121212;
        --text: #e4e4e4;
        --text-muted: #999;
        --border: rgba(255,255,255,0.1);
        --green-bg: #052e16;
        --blue-bg: #172554;
        --amber-bg: #451a03;
        --gray-bg: #27272a;
        --teal-bg: #042f2e;
        --red-bg: #450a0a;
    }
}

html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Navigation ─── */
.nav {
    background: var(--bg);
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
}
.nav-brand {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.nav-links a.active { color: var(--text); border-bottom-color: var(--primary); }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-logout { color: var(--red) !important; }

/* ─── Container ─── */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ─── Page Header ─── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 500;
}

/* ─── Cards ─── */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-card);
    padding: 16px 20px;
    display: block;
}
.card-link { transition: border-color 0.15s; }
.card-link:hover { border-color: var(--primary); text-decoration: none; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.card-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
}
.card-category {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-desc {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 13px;
}

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }

/* ─── Sections ─── */
.section { margin-bottom: 2rem; }
.section h2 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 1rem;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-header h2 { margin-bottom: 0; }

/* ─── Task List ─── */
.task-list {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--border);
    gap: 1rem;
}
.task-item:last-child { border-bottom: none; }
.task-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.task-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.task-title { font-size: 14px; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.task-project {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--gray-bg);
    padding: 2px 8px;
    border-radius: var(--radius);
}
.task-due { font-size: 12px; color: var(--text-muted); }
.task-due.overdue { color: var(--red); font-weight: 500; }
.task-notes {
    padding: 0 16px 12px 52px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ─── Links ─── */
.link-list {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.link-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--border);
    gap: 1rem;
}
.link-item:last-child { border-bottom: none; }
.link-item a { font-weight: 500; flex: 1; }
.link-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--gray-bg);
    padding: 2px 8px;
    border-radius: var(--radius);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: 0.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--gray-bg); text-decoration: none; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-small { padding: 4px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}
.btn-icon:hover { background: var(--gray-bg); }
.btn-delete:hover { color: var(--red); }

/* ─── Forms ─── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* ─── Modal ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg);
    border-radius: var(--radius-card);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.modal-header h2 { font-size: 18px; font-weight: 500; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}

/* ─── Login ─── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}
.login-card {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-card);
    padding: 32px;
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* ─── Alerts ─── */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 14px;
}
.alert-error { background: var(--red-bg); color: var(--red); }

/* ─── Project Detail ─── */
.project-desc {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ─── Empty State ─── */
.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    padding: 1rem 0;
}

/* ─── Responsive ─── */
@media (max-width: 639px) {
    .task-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .task-meta { flex-wrap: wrap; }
    .nav-links { gap: 1rem; font-size: 13px; }
}
