:root {
    --navy: #1c2b3a;
    --navy-light: #2a3f54;
    --accent: #b8894f;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1c2b3a;
    --muted: #6b7686;
    --border: #e2e5ea;
    --danger: #c0392b;
    --success: #2f8f4e;
    --warn: #c07d1a;
}
* { 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);
}

/* ---------- Auth screens ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
}
.auth-card {
    background: var(--card);
    padding: 40px;
    border-radius: 10px;
    width: 340px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.auth-error { background: #fdecea; color: var(--danger); padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.auth-card input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.auth-card button { width: 100%; margin-top: 20px; padding: 10px; background: var(--navy); color: #fff; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; }
.auth-card button:hover { background: var(--navy-light); }

/* ---------- App shell ---------- */
.topbar {
    height: 56px;
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}
.brand { font-weight: 600; font-size: 16px; }
.brand span { font-weight: 400; color: #cbd3dc; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.me { color: #cbd3dc; margin-right: 6px; }

.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
    width: 210px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
}
.filter-group { margin-top: 22px; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; padding-left: 4px; }
.filter-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 2px;
}
.filter-btn:hover { background: var(--bg); }
.filter-btn.active { background: #eef1f5; font-weight: 600; color: var(--navy); }

.content { flex: 1; padding: 20px 26px; overflow-x: auto; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.content-header h2 { margin: 0; font-size: 19px; }
#searchBox { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; width: 240px; font-size: 13.5px; }

.task-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.task-table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); border-bottom: 1px solid var(--border); padding: 10px 14px; background: #fafbfc;
}
.task-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.task-table tr:last-child td { border-bottom: none; }
.task-title-cell { cursor: pointer; font-weight: 500; color: var(--navy); }
.task-title-cell:hover { text-decoration: underline; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

.col-expand { width: 30px; }
.expand-toggle {
    background: none; border: none; cursor: pointer; color: var(--muted);
    font-size: 11px; width: 22px; height: 22px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .12s ease;
}
.expand-toggle:hover { background: var(--bg); color: var(--navy); }
.expand-toggle.open { transform: rotate(90deg); color: var(--navy); }
.subtask-detail-row td { background: #fafbfc; padding: 4px 14px 14px 44px; border-bottom: 1px solid var(--border); }
.subtask-detail-row.hidden { display: none; }
.inline-subtask-list { max-width: 640px; }
.inline-subtask-empty { color: var(--muted); font-size: 12.5px; padding: 4px 0; }
.inline-add-row { display: flex; gap: 8px; margin-top: 8px; max-width: 480px; }
.inline-add-row input { flex: 1; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }
.inline-add-row button { padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 12.5px; cursor: pointer; }
.inline-add-row button:hover { background: var(--bg); }
.subtask-count-cell { cursor: pointer; }
.subtask-count-cell:hover { text-decoration: underline; }

.subtask-mini-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.subtask-mini-row:last-child { border-bottom: none; }
.subtask-mini-title { flex: 1 1 140px; min-width: 120px; font-size: 13px; }
.subtask-mini-row.done .subtask-mini-title { text-decoration: line-through; color: var(--muted); }
.subtask-mini-select { padding: 4px 5px; border: 1px solid var(--border); border-radius: 5px; font-size: 11.5px; background: #fff; max-width: 110px; }
.subtask-mini-date { padding: 4px 5px; border: 1px solid var(--border); border-radius: 5px; font-size: 11.5px; width: 118px; }
.subtask-remove-mini { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 2px; }
.subtask-remove-mini:hover { color: var(--danger); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-Not-Started { background: #eceff1; color: #546e7a; }
.badge-In-Progress { background: #e3f0fd; color: #1565c0; }
.badge-In-Review { background: #fff3e0; color: var(--warn); }
.badge-Completed { background: #e6f4ea; color: var(--success); }

.priority-High { color: var(--danger); font-weight: 600; }
.priority-Medium { color: var(--warn); font-weight: 500; }
.priority-Low { color: var(--muted); }

.deadline-overdue { color: var(--danger); font-weight: 600; }

.status-select { border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12.5px; background: #fff; }

/* ---------- Buttons ---------- */
.btn-primary { background: var(--navy); color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-size: 13.5px; cursor: pointer; }
.btn-primary:hover { background: var(--navy-light); }
.btn-ghost { background: none; border: 1px solid rgba(255,255,255,0.35); color: #fff; padding: 7px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; text-decoration: none; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.modal .btn-ghost { border-color: var(--border); color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); padding: 8px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; margin-left: 8px; }
.btn-danger:hover { background: #fdecea; }
#newTaskBtn { width: 100%; margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(20,25,35,0.45); align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; width: 480px; max-width: 92vw; max-height: 88vh; overflow-y: auto; border-radius: 10px; box-shadow: 0 25px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px 24px; }
.modal-body label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.modal-body input[type=text], .modal-body input[type=date], .modal-body input[type=password], .modal-body select, .modal-body textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; font-family: inherit;
}
.form-row { display: flex; gap: 14px; }
.form-row > div { flex: 1; }
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.modal-body h4 { margin: 0 0 10px; font-size: 13.5px; }

.team-member-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13.5px; }
.subtask-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row input { flex: 1; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

.comment-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.comment-item:last-child { border-bottom: none; }
.comment-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }

.team-member-row { justify-content: space-between; border-bottom: 1px solid var(--border); }
.team-member-role { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.team-note { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.team-self-badge { font-size: 10.5px; background: #eef1f5; color: var(--navy); padding: 2px 7px; border-radius: 10px; margin-left: 6px; text-transform: uppercase; letter-spacing: .03em; }

.team-edit-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.team-edit-row:last-child { border-bottom: none; }
.team-edit-line1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.team-name-input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; }
.team-username { font-size: 12px; color: var(--muted); white-space: nowrap; }
.team-edit-line2 { display: flex; align-items: center; gap: 8px; }
.team-role-select { padding: 6px 7px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }
.team-password-input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; }
.team-save-btn { white-space: nowrap; padding: 6px 12px; }

@media (max-width: 720px) {
    .sidebar { display: none; }
    #searchBox { width: 140px; }
}
