* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e2e2e2;
    --text: #1a1a1a;
    --text-secondary: #6b6b6b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --priority: #dc2626;
    --greyed: #9ca3af;
    --success: #16a34a;
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
}

.nav-links a:hover {
    color: var(--text);
}

.nav-user {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Auth pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.auth-card h1 {
    font-size: 20px;
    margin-bottom: 24px;
    text-align: center;
}

.error {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

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

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.form-section h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-page h1 {
    font-size: 20px;
    margin-bottom: 24px;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

/* Dashboard header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.dashboard-header h1 {
    font-size: 20px;
    font-weight: 600;
}

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

#search-input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    width: 240px;
    outline: none;
}

#search-input:focus {
    border-color: var(--primary);
}

/* Projects grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.project-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.project-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.project-card-title:hover {
    color: var(--primary);
}

.project-number {
    font-size: 12px;
    color: var(--text-secondary);
}

.project-card-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Progress bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.progress-container.large {
    margin-bottom: 20px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 40px;
    text-align: right;
}

.progress-label.large {
    font-size: 13px;
    font-weight: 500;
}

/* Priority section */
.priority-section {
    margin-bottom: 12px;
}

.btn-toggle-priority {
    background: none;
    border: none;
    color: var(--priority);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    font-weight: 500;
}

.btn-toggle-priority:hover {
    text-decoration: underline;
}

.priority-list {
    margin-top: 6px;
    padding-left: 12px;
}

.priority-item {
    font-size: 12px;
    color: var(--priority);
    padding: 2px 0;
}

.priority-task-name {
    font-weight: 500;
}

.priority-empty {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Project card footer */
.project-card-footer {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.inline-form {
    display: inline;
}

/* Project detail */
.project-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.back-link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
}

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

.project-detail-header h1 {
    font-size: 22px;
    font-weight: 600;
}

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

/* Meta grid */
.project-meta {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}

.meta-item {
    font-size: 13px;
}

.meta-item strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Task sections */
.task-sections {
    margin-top: 24px;
}

.task-section {
    margin-bottom: 24px;
}

.task-section h2 {
    font-size: 15px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.task-group {
    margin-bottom: 2px;
}

.task-subgroup {
    margin-left: 20px;
    margin-bottom: 2px;
}

.task-sub-subgroup {
    margin-left: 20px;
    margin-bottom: 2px;
}

/* Task item */
.task-item {
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 4px 8px;
}

.task-item:hover {
    border-color: var(--border);
}

.task-item.task-greyed {
    opacity: 0.5;
}

.task-item.task-priority .task-name {
    color: var(--priority);
    font-weight: 600;
}

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

.task-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.task-label {
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    min-width: 20px;
    text-align: center;
}

.task-name {
    flex: 1;
    font-size: 13px;
}

.task-grey-toggle {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.task-grey-toggle input {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.task-date-input {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    width: 130px;
    outline: none;
}

.task-date-input:focus {
    border-color: var(--primary);
}

.task-not-initialized {
    opacity: 0.4;
}

.task-not-initialized-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 15px;
}

/* HTMX indicators */
.htmx-indicator {
    color: var(--text-secondary);
    font-size: 12px;
}

.htmx-request .htmx-indicator {
    display: inline;
}

/* Responsive */
@media (max-width: 640px) {
    .navbar {
        padding: 0 12px;
    }
    
    .container {
        padding: 16px 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .project-detail-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .meta-grid {
        grid-template-columns: 1fr;
    }
}
