:root {
    --primary-color: #007bff;
    --primary-hover-color: #0056b3;
    --background-color: #f4f7f9;
    --card-background-color: #ffffff;
    --text-color: #333;
    --border-color: #dee2e6;
    --danger-color: #dc3545;
    --danger-hover-color: #c82333;
    --secondary-button-bg: #6c757d;
}

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

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* --- General Components --- */

.card {
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
    margin: 0;
}
input, select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.button-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
}
.button-primary:hover {
    background-color: var(--primary-hover-color);
}
.button-secondary {
    background-color: var(--secondary-button-bg);
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}



/* --- Tabs --- */

.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.tab-button {
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: var(--card-background-color);
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}
.tab-button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.tab-button:not(.active):hover {
    background-color: #e9ecef;
}
.tab-content { display: none; }
.tab-content.active { display: block; }


/* --- Page B: Rate Configuration --- */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

#roles-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.role-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.role-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 1rem 0;
    margin: 0;
}
.role-name-input {
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 5px;
    width: 70%;
}
.role-name-input:focus {
    border-bottom: 2px solid var(--primary-color);
}
.delete-role-btn, .delete-row-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.delete-role-btn:hover, .delete-row-btn:hover {
    background-color: var(--danger-hover-color);
}
.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.rate-item label {
    font-size: 0.9rem;
    color: #555;
}
.rate-input {
    width: 80px;
    text-align: right;
}


/* --- Page A: Project Budget --- */

/* New Summary Panel Layout */
.summary-panel .card-header {
    text-align: center;
}
.summary-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 1rem;
}
.summary-grid .summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 0.5rem;
    min-width: 150px;
}
.summary-grid .summary-item span {
    font-size: 0.9rem;
    color: #555;
}
.summary-grid .summary-item strong {
    font-size: 1.5rem;
}
.summary-grid .total-budget strong {
    color: var(--primary-color);
}
.summary-item-details {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Template Form */
.template-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.5rem 1.5rem;
}
.template-form select {
    flex-grow: 1;
}

/* Project Info Form */
.project-info-form {
    padding: 1rem 1.5rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.project-info-form .form-group {
    display: flex;
    flex-direction: column;
}
.project-info-form label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}
.project-info-form input {
    width: 100%;
    box-sizing: border-box;
}

/* WBS Table */
.wbs-table-container {
    overflow-x: auto; /* Add horizontal scroll if table is too wide */
    padding: 0 1.5rem 1rem;
}
.wbs-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* Ensure table has a minimum width */
}
.wbs-table th, .wbs-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: nowrap; /* Prevent text wrapping in cells */
}
.wbs-table th {
    background-color: #f8f9fa;
    font-size: 0.9rem;
}
.wbs-table tbody tr:hover {
    background-color: #f1f3f5;
}
/* Re-balanced column widths */
.wbs-table .col-work-item { width: 45%; white-space: normal; } /* Increased */
.wbs-table .col-role { width: 15%; } /* Decreased */
.wbs-table .col-difficulty { width: 8%; } /* Decreased */
.wbs-table .col-rate { width: 8%; } /* Decreased */
.wbs-table .col-hours { width: 7%; } /* Decreased */
.wbs-table .col-budget { width: 10%; }
.wbs-table .col-actions { width: 7%; }


.phase-row td {
    background-color: #e9ecef;
    font-weight: bold;
}
.phase-row td button {
    margin-left: 1rem;
    font-size: 0.8rem;
    padding: 3px 8px;
}

.task-indent { margin-left: 20px; }
.calculated-value { font-weight: bold; }
.wbs-table .task-title-input {
    width: 100%;
    box-sizing: border-box;
}
.wbs-table .task-hours-input {
    width: 70px;
}
.role-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.role-cell select {
    flex-grow: 1;
}

.info-icon {
    font-family: serif;
    font-weight: bold;
    cursor: pointer;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    user-select: none;
    flex-shrink: 0;
}

#add-phase-btn {
    margin: 1rem 1.5rem 1.5rem;
    width: auto;
}

/* Tooltip for Role Responsibilities */
.role-tooltip {
    position: absolute;
    display: none; /* Initially hidden */
    background-color: #333;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    width: 300px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
}
.role-tooltip.active {
    display: block;
    opacity: 1;
}
.role-tooltip h5 {
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #666;
    font-size: 1rem;
}
.role-tooltip ul {
    margin: 0;
    padding-left: 1.2rem;
}
.role-tooltip li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}