:root {
    --bg: #F6F5F1;
    --surface: #FFFFFF;
    --border: #E4E1D9;
    --text: #24291F;
    --text-muted: #6E7364;
    --accent: #3D5A45;
    --accent-soft: #E8EDE5;

    --status-assigned: #6E7364;
    --status-inprogress: #B0762A;
    --status-blocked: #B5432E;
    --status-pending-review: #6B5FA8;
    --status-completed: #3D5A45;

    --priority-p1: #B5432E;
    --priority-p2: #B0762A;
    --priority-p3: #6E7364;

    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

/* --- Top bar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}
.brand span { color: var(--accent); font-weight: 600; }
.topbar nav a {
    margin-left: 24px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.92rem;
}
.topbar nav a:hover { color: var(--text); }

/* --- Page layout --- */
.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
h1 { font-size: 1.5rem; margin: 4px 0 2px; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; margin: 0 0 12px; color: var(--text); }
.subtitle { color: var(--text-muted); margin: 0; font-size: 0.94rem; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--text-muted); font-size: 0.88rem; }
.back-link:hover { color: var(--text); }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.88rem;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #32492f; }
.btn-secondary { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); }

/* --- Filter bar --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.filter-bar select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.88rem;
    color: var(--text);
}

/* --- Board / Kanban --- */
.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}
.board-column {
    background: transparent;
}
.board-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 10px;
}
.board-column-header .count {
    background: var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 0.75rem;
}
.board-column-header.col-assigned { color: var(--status-assigned); }
.board-column-header.col-in_progress { color: var(--status-inprogress); }
.board-column-header.col-blocked { color: var(--status-blocked); }
.board-column-header.col-pending_review { color: var(--status-pending-review); }
.board-column-header.col-completed { color: var(--status-completed); }

.board-column-body { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

.task-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.task-card:hover { box-shadow: 0 2px 10px rgba(36, 41, 31, 0.08); transform: translateY(-1px); }
.task-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.task-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.task-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
.deadline { font-size: 0.75rem; color: var(--text-muted); }

.empty-hint { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

/* --- Badges & pills --- */
.priority-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    color: white;
}
.priority-p1 { background: var(--priority-p1); }
.priority-p2 { background: var(--priority-p2); }
.priority-p3 { background: var(--priority-p3); }

.status-pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 6px;
}
.status-pill.status-assigned { background: var(--accent-soft); color: var(--status-assigned); }
.status-pill.status-in_progress { background: #FBF0DD; color: var(--status-inprogress); }
.status-pill.status-blocked { background: #F8E2DD; color: var(--status-blocked); }
.status-pill.status-completed { background: var(--accent-soft); color: var(--status-completed); }
.status-pill.status-pending_review { background: #EAE7F5; color: var(--status-pending-review); }

/* --- Progress bar --- */
.progress-track {
    background: var(--border);
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
}
.progress-track.large { height: 10px; }
.progress-fill { background: var(--accent); height: 100%; border-radius: 20px; }
.progress-label { font-size: 0.82rem; color: var(--text-muted); margin: 6px 0 0; }

/* --- Cards & forms --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.form .optional { font-weight: 400; color: var(--text-muted); }
.form input, .form select, .form textarea {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* --- Task detail layout --- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 0.88rem; margin: 0; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; font-weight: 500; }

/* --- Timeline --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline li:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    bottom: 0;
    width: 1px;
    background: var(--border);
}
.timeline-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 5px;
    flex-shrink: 0;
}
.timeline-meta { display: flex; gap: 8px; align-items: baseline; font-size: 0.82rem; margin-bottom: 2px; }
.timeline-meta span { color: var(--text-muted); }
.timeline-content p { margin: 0 0 4px; font-size: 0.9rem; }
.pct-tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 1px 8px;
    border-radius: 10px;
}

/* --- Table (employees) --- */
.simple-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.simple-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 8px 6px;
}
.simple-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.simple-table tr:last-child td { border-bottom: none; }

/* --- Login page --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
}
.login-brand { font-size: 1.3rem; margin: 0 0 4px; }
.login-brand span { color: var(--accent); }
.btn-full { width: 100%; text-align: center; border: none; }
.form-error {
    background: #F8E2DD;
    color: var(--status-blocked);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* --- Nav extras --- */
.user-pill {
    margin-left: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--accent-soft);
    border-radius: 20px;
}
.inline-form { display: inline; margin-left: 16px; }
.inline-form-stack { display: flex; gap: 8px; margin-top: 8px; }
.link-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 0.85rem; font-family: inherit; padding: 0;
}
.link-btn:hover { color: var(--status-blocked); }
.link-btn-inline {
    background: none; border: none; cursor: pointer;
    color: var(--accent); font-size: 0.82rem; font-family: inherit; padding: 0;
    text-decoration: underline;
}

/* --- Buttons --- */
.btn-danger { background: transparent; color: var(--status-blocked); border-color: var(--status-blocked); }
.btn-danger:hover { background: #F8E2DD; }
.btn-small { padding: 5px 10px; font-size: 0.78rem; }

/* --- Review / extension cards --- */
.review-card { border-left: 3px solid var(--status-pending-review); }
.extension-card { border-left: 3px solid var(--status-inprogress); }
.review-actions { display: flex; gap: 10px; margin: 10px 0; }
.redo-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.extension-toggle summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.extension-toggle[open] summary { margin-bottom: 12px; }

/* --- Attachments --- */
.attachment-link {
    display: inline-block;
    font-size: 0.82rem;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 10px;
    border-radius: 8px;
    margin-top: 2px;
}

/* --- Timeline entry types --- */
.timeline-dot.dot-approval { background: var(--status-completed); }
.timeline-dot.dot-redo { background: var(--status-blocked); }
.timeline-dot.dot-extension { background: var(--status-inprogress); }

/* --- Admin table extras --- */
.row-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.banner-success { border-left: 3px solid var(--status-completed); background: var(--accent-soft); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }
.form-hint { font-size: 0.82rem; color: var(--text-muted); margin: -6px 0 0; }

/* --- Responsive --- */
@media (max-width: 1000px) {
    .board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
    .board { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .board { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .topbar { padding: 14px 16px; }
    .page { padding: 20px 14px 48px; }
}
