:root {
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --border: #dde1e6;
    --text: #1f2430;
    --muted: #6b7280;
    --accent: #2563eb;
    --locked-bg: #ecfdf5;
    --locked-border: #34d399;
    --pending-bg: #fafafa;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.user-info { display: flex; gap: 14px; align-items: center; font-size: 0.9rem; color: var(--muted); }
.user-info a { color: var(--accent); text-decoration: none; }

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

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }

.inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-form input[type="text"], .inline-form input[type="date"] {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
}
button {
    background: var(--accent); color: white; border: none; border-radius: 6px;
    padding: 8px 14px; cursor: pointer; font-size: 0.9rem;
}
button:hover { opacity: 0.9; }

.instance-table, .checklist-grid { width: 100%; border-collapse: collapse; }
.instance-table th, .instance-table td {
    text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border);
}

.badge { padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: #dbeafe; color: #1e40af; }
.badge-complete { background: #dcfce7; color: #166534; }

.back-link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.muted { color: var(--muted); }

.notification-banner { background: #fff7ed; border-color: #fdba74; }
.warning-banner { background: #fef2f2; border-color: #fca5a5; }

.phase-section h2 { border-left: 4px solid var(--accent); padding-left: 10px; }
.phase-heading {
    display: flex; align-items: center; cursor: pointer; user-select: none;
}
.phase-chevron {
    margin-left: auto; font-size: 0.8rem; color: var(--muted);
    transition: transform 0.2s ease;
}
.phase-section.collapsed .phase-chevron { transform: rotate(-90deg); }
.phase-section.collapsed .phase-body { display: none; }
.due-hint { font-size: 0.75rem; font-weight: 400; color: var(--muted); margin-left: 10px; }
.due-hint.overdue { color: #b91c1c; font-weight: 600; }
.phase-overdue { border-color: #fca5a5; }
.grid-scroll { overflow-x: auto; }
.checklist-grid thead th {
    background: #eef2ff; padding: 10px; font-size: 0.85rem;
    border: 1px solid var(--border); white-space: nowrap;
}
.checklist-grid td.lane {
    vertical-align: top; border: 1px solid var(--border); padding: 8px;
    min-width: 190px; background: #fcfcfd;
}

.task {
    background: var(--pending-bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 8px; margin-bottom: 8px; font-size: 0.85rem;
}
.task.locked { background: var(--locked-bg); border-color: var(--locked-border); }
.task.custom { border-style: dashed; }
.task-desc { margin-bottom: 6px; display: flex; align-items: flex-start; gap: 3px; }
.task-desc-text { flex: 1; }
.task-meta { font-size: 0.75rem; color: var(--muted); }
.tag {
    font-size: 0.65rem; background: #ede9fe; color: #5b21b6;
    padding: 1px 6px; border-radius: 99px; margin-left: 4px;
}
.complete-btn { font-size: 0.75rem; padding: 4px 8px; }

.add-task { margin-top: 6px; font-size: 0.8rem; }
.add-task summary { cursor: pointer; color: var(--accent); }
.add-task form { display: flex; gap: 6px; margin-top: 6px; }
.add-task input[type="text"] {
    flex: 1; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.8rem;
}

/* Note icon button in team column headers */
.note-icon-btn {
    background: none; border: none; padding: 2px 3px; margin-left: 5px;
    cursor: pointer; color: var(--muted); vertical-align: middle;
    border-radius: 4px; line-height: 0;
}
.note-icon-btn svg { width: 11px; height: 11px; display: block; }
.note-icon-btn:hover { color: var(--accent); background: #eef2ff; }
.note-icon-btn.has-note { color: var(--accent); }
.note-icon-btn.has-note svg { stroke-width: 3; }

/* Notes dialog */
.note-dialog {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 0; width: 480px; max-width: 95vw;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.note-dialog::backdrop { background: rgba(0,0,0,0.3); }
.note-dialog-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 0;
}
.note-dialog-header h3 { margin: 0; font-size: 1rem; }
.note-dialog-close {
    background: none; border: none; font-size: 1rem; color: var(--muted);
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.note-dialog-close:hover { background: var(--bg); color: var(--text); }
.note-meta { margin: 6px 20px 0; font-size: 0.8rem; }
.note-body-display {
    margin: 8px 20px 0; font-size: 0.9rem; white-space: pre-wrap;
    min-height: 20px; color: var(--text);
}
.note-form { display: none; flex-direction: column; gap: 10px; padding: 12px 20px 20px; }
.note-textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.9rem; font-family: inherit; resize: vertical;
}
.note-form-actions { display: flex; gap: 8px; }
.btn-secondary {
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.manager-fields {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.manager-field { display: flex; align-items: center; gap: 6px; }
.manager-label { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.manager-input {
    padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.85rem; width: 220px;
}
.manager-save { font-size: 0.85rem; padding: 5px 12px; }
.manager-readonly { margin-top: -8px; }

.filter-btn {
    background: var(--bg); color: var(--muted); border: 1px solid var(--border);
    padding: 5px 12px; border-radius: 6px; font-size: 0.85rem; cursor: pointer;
}
.filter-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Instructions icon button */
.info-icon-btn {
    background: none; border: none; padding: 2px 3px;
    cursor: pointer; color: var(--muted); opacity: 0.4; line-height: 0;
    border-radius: 4px; flex-shrink: 0; transition: opacity 0.1s;
}
.info-icon-btn svg { width: 11px; height: 11px; display: block; }
.info-icon-btn:hover { background: #eef2ff; color: var(--accent); opacity: 1; }
.info-icon-btn.has-instructions { color: var(--accent); opacity: 1; }

/* Instructions dialog */
.instructions-dialog { width: 440px; }
.instructions-body {
    margin: 10px 20px 4px; font-size: 0.9rem; white-space: pre-wrap;
    color: var(--text); line-height: 1.5;
}
.instructions-link-row { padding: 4px 20px 10px; }
.instructions-link {
    display: inline-block; font-size: 0.875rem; color: var(--accent);
    text-decoration: none; font-weight: 500;
}
.instructions-link:hover { text-decoration: underline; }
.instructions-view-actions { display: flex; gap: 8px; padding: 10px 20px 20px; }
.instructions-form { display: none; flex-direction: column; gap: 8px; padding: 10px 20px 20px; }
.instr-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.instructions-url-input {
    width: 100%; padding: 7px 10px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.instr-scope-note { font-size: 0.75rem; margin: 0; }

/* Cross-team sign-off badge */
.cross-team-badge {
    display: inline-block; font-size: 0.65rem; font-weight: 600;
    background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
    padding: 1px 5px; border-radius: 99px; margin-left: 4px;
    vertical-align: middle;
}

/* Danger button (remove/delete) */
.btn-danger {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
}
.btn-danger:hover { background: #fecaca; opacity: 1; }

/* Confirm sign-off dialog */
.confirm-dialog { width: 380px; }
.confirm-desc {
    margin: 12px 20px 4px; font-size: 0.95rem;
    font-weight: 600; color: var(--text);
}
.confirm-warning { margin: 0 20px 16px; font-size: 0.85rem; color: #b91c1c; }
.confirm-actions { display: flex; gap: 8px; padding: 0 20px 20px; }
.confirm-btn { background: #16a34a; }
.confirm-btn:hover { background: #15803d; }
