* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0e27;
    color: #ffffff;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* StartupTN Theme Colors */
:root {
    --startuptn-blue: #29388B;
    --startuptn-orange: #FF6B35;
    --startuptn-yellow: #FFB800;
    --startuptn-green: #00A651;
    --dark-bg: #0a0e27;
    --dark-bg-secondary: #1a1f3a;
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

/* Left Sidebar - Project List */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    flex-shrink: 0;
    position: relative;
}

.sidebar-header h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
}

.btn-load-data {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    width: 100%;
    transition: all 0.3s;
}

.btn-load-data:hover {
    background: rgba(255, 255, 255, 0.3);
}

.project-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    background: #1e293b;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.project-item {
    padding: 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: #ffffff;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-color: rgba(41, 56, 139, 0.3);
}

.project-item.active {
    background: linear-gradient(135deg, #29388B 0%, #FF6B35 100%);
    color: white;
    border-color: #29388B;
    box-shadow: 0 4px 12px rgba(41, 56, 139, 0.4);
}

.project-item-name {
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: 5px;
}

.project-item-meta {
    font-size: 0.85em;
    color: #ffffff;
    opacity: 0.8;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

/* Top Header Line */
.top-header-line {
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.top-header-line .header-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.top-header-line .logo {
    height: 35px;
    width: auto;
    object-fit: contain;
    max-width: 160px;
    display: block;
}

.top-header-line .separator {
    color: #FF6B35;
    font-size: 1.1em;
    margin: 0 8px;
    font-weight: 300;
}

.top-header-line .agent-name {
    font-size: 1.2em;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

/* Header right area with agent selector */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-selector-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-selector-label {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    white-space: nowrap;
}

.agent-selector {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 7px 30px 7px 12px;
    font-size: 0.85em;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 180px;
}

.agent-selector:hover {
    border-color: rgba(41, 56, 139, 0.6);
    background-color: rgba(255, 255, 255, 0.12);
}

.agent-selector:focus {
    border-color: rgba(41, 56, 139, 0.8);
    box-shadow: 0 0 0 2px rgba(41, 56, 139, 0.2);
}

.agent-selector option {
    background: #1a1a2e;
    color: #ffffff;
    padding: 8px;
}

/* Top: KPI Cards Section */
.kpi-cards-top-section {
    background: #1e293b;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px 10px;
    height: auto;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1;
}

.kpi-cards-header {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    flex-shrink: 0;
    gap: 15px;
}

.kpi-cards-header h2 {
    font-size: 1.1em;
    color: #ffffff;
    font-weight: 600;
    margin: 0;
}


.kpi-cards-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    padding-bottom: 6px;
}

.kpi-cards-container.showing-all-projects {
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;
    align-items: stretch;
}

.kpi-cards-container::-webkit-scrollbar {
    height: 6px;
}

.kpi-cards-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.kpi-cards-container::-webkit-scrollbar-thumb {
    background: rgba(255, 184, 0, 0.5);
    border-radius: 3px;
}

.kpi-card {
    min-width: 200px;
    max-width: 240px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    position: relative;
    overflow: visible;
    flex-shrink: 0;
    height: auto;
    min-height: 0;
}

/* Compact card for split-KPI mode (4+ individual cards) */
.kpi-card-compact {
    min-width: 185px;
    max-width: 205px;
    padding: 10px 12px 10px;
    border-radius: 10px;
    justify-content: flex-start;
}

.kpi-card-compact .kpi-compact-title {
    font-size: 0.73em;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
    line-height: 1.3;
    margin-bottom: 7px;
    min-height: 2.6em;
    display: flex;
    align-items: flex-start;
}

.kpi-card-compact .kpi-compact-mid {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 7px;
}

.kpi-card-compact .kpi-compact-chart {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
}

.kpi-card-compact .kpi-compact-pct {
    font-size: 1.35em;
    font-weight: 700;
    line-height: 1;
}

.kpi-card-compact .kpi-compact-label {
    font-size: 0.65em;
    color: rgba(255,255,255,0.45);
    margin-top: 3px;
    letter-spacing: 0.3px;
}

.kpi-card-compact .kpi-compact-rows {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 7px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-card-compact .kpi-compact-row {
    display: flex;
    gap: 5px;
    align-items: flex-start;
    font-size: 0.68em;
    line-height: 1.35;
}

.kpi-card-compact .kpi-compact-row-label {
    color: rgba(255,255,255,0.45);
    font-weight: 600;
    flex-shrink: 0;
    padding-top: 1px;
    min-width: 13px;
}

.kpi-card-compact .kpi-compact-row-val {
    color: rgba(255,255,255,0.9);
    word-break: break-word;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--startuptn-blue) 0%, var(--startuptn-orange) 100%);
}

.project-completion-card {
    margin-left: auto;
    border: 2px solid;
    position: relative;
}

.project-completion-card::before {
    background: currentColor;
    opacity: 0.8;
    height: 4px;
}

.overall-completion-card {
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-right: 0;
}

.all-projects-container {
    overflow-y: auto;
    height: calc(100vh - 200px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    background: transparent;
}

.project-status-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
}

.project-status-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 184, 0, 0.3);
    transform: translateY(-2px);
}

.project-kpis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.projects-table-container {
    overflow-y: auto;
    width: 100%;
    background: transparent;
}

.projects-status-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
}

.table-header-btn {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95em;
    color: #ffffff;
    background: #FF6B35;
    border: none;
    border-radius: 6px;
    margin: 2px;
    cursor: default;
}

.projects-status-table thead tr {
    background: transparent;
}

.projects-status-table tbody {
    background: rgba(255, 255, 255, 0.02);
}

.table-cell-project-name,
.table-cell-kpi-target,
.table-cell-achieved,
.table-cell-progress {
    padding: 18px 20px;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.table-cell-project-name {
    font-weight: 500;
    font-size: 0.95em;
    vertical-align: top;
    padding-top: 18px;
}

.table-cell-kpi-target {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    line-height: 1.6;
    max-width: 300px;
    word-wrap: break-word;
    font-weight: 500;
}

.table-cell-achieved {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9em;
    line-height: 1.5;
    max-width: 200px;
    word-wrap: break-word;
}

.table-cell-progress {
    text-align: center;
}

.projects-status-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.projects-status-table tbody tr:last-child td {
    border-bottom: none;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 184, 0, 0.3);
}

.kpi-card-title {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
    flex-shrink: 0;
}

.kpi-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex: 0 0 auto;
}

.kpi-card-value {
    font-size: 1.6em;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
    flex: 1;
}

.kpi-card-chart-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    position: relative;
}

.kpi-card-chart-wrapper canvas {
    max-width: 100%;
    max-height: 100%;
}

.kpi-card-target {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.75);
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.4;
    word-wrap: break-word;
}

.kpi-card-achieved {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4px;
    word-wrap: break-word;
    line-height: 1.4;
}

.empty-kpi-cards {
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 40px 20px;
    font-size: 0.95em;
}

/* Chat Section - Takes remaining space */
.chat-section {
    flex: 1;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0a0e27 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 0;
    min-height: 0;
}

.chat-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: radial-gradient(circle at top left, rgba(41, 56, 139, 0.3) 0%, transparent 70%);
    pointer-events: none;
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    position: relative;
    z-index: 1;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    max-width: 180px;
    display: block;
}

.separator {
    color: #FF6B35;
    font-size: 1.2em;
    margin: 0 8px;
    font-weight: 300;
}

.agent-name {
    font-size: 1.3em;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.btn-clear {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s;
    opacity: 0.9;
}

.btn-clear:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 30px;
    background: transparent;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    justify-content: flex-start;
    align-items: stretch;
}

.chat-messages.has-welcome {
    justify-content: center;
    align-items: center;
}

.welcome-message {
    text-align: center;
    max-width: 600px;
}

.welcome-message h3 {
    font-size: 2.8em;
    font-weight: 300;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.welcome-message p {
    margin-top: 20px;
    color: #ffffff;
    font-size: 0.95em;
    font-weight: 300;
    opacity: 0.8;
}

.message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
}

.message-content {
    padding: 16px 20px;
    border-radius: 12px;
    line-height: 1.7;
    font-size: 0.95em;
}

.user-message .message-content {
    background: rgba(41, 56, 139, 0.3);
    color: #ffffff;
    border: 1px solid rgba(41, 56, 139, 0.5);
    margin-left: auto;
    text-align: right;
    max-width: 70%;
}

.bot-message .message-content {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 85%;
}

.bot-message .message-content strong {
    color: #ffffff;
    font-weight: 600;
}

/* Markdown styling for AI responses */
.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3,
.bot-message .message-content h4,
.bot-message .message-content h5,
.bot-message .message-content h6 {
    color: #ffffff;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.bot-message .message-content h1 {
    font-size: 1.5em;
    border-bottom: 2px solid rgba(255, 184, 0, 0.3);
    padding-bottom: 0.3em;
}

.bot-message .message-content h2 {
    font-size: 1.3em;
    border-bottom: 1px solid rgba(255, 184, 0, 0.2);
    padding-bottom: 0.3em;
}

.bot-message .message-content h3 {
    font-size: 1.1em;
}

.bot-message .message-content p {
    margin: 0.8em 0;
    line-height: 1.7;
}

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

.bot-message .message-content li {
    margin: 0.4em 0;
    line-height: 1.6;
}

.bot-message .message-content ul li {
    list-style-type: disc;
}

.bot-message .message-content ol li {
    list-style-type: decimal;
}

.bot-message .message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #FFB800;
}

.bot-message .message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
    border: 1px solid rgba(255, 184, 0, 0.2);
}

.bot-message .message-content pre code {
    background: transparent;
    padding: 0;
    color: #ffffff;
    font-size: 0.85em;
}

.bot-message .message-content blockquote {
    border-left: 4px solid rgba(255, 184, 0, 0.5);
    padding-left: 1em;
    margin: 1em 0;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.bot-message .message-content hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 1.5em 0;
}

.bot-message .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.bot-message .message-content table th,
.bot-message .message-content table td {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    text-align: left;
}

.bot-message .message-content table th {
    background: rgba(255, 184, 0, 0.2);
    font-weight: 600;
    color: #FFB800;
}

.bot-message .message-content table td {
    background: rgba(255, 255, 255, 0.05);
}

.bot-message .message-content a {
    color: #FFB800;
    text-decoration: underline;
    transition: color 0.3s;
}

.bot-message .message-content a:hover {
    color: #ffd966;
}

.chat-input-wrapper {
    padding: 20px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    position: relative;
    z-index: 1;
}

.chat-input-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 4px;
    transition: all 0.3s;
}

.chat-input-container:focus-within {
    border-color: rgba(41, 56, 139, 0.5);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(41, 56, 139, 0.1);
}

.chat-input {
    flex: 1;
    padding: 16px 20px;
    border: none;
    background: transparent;
    border-radius: 12px;
    font-size: 1em;
    color: #ffffff;
    outline: none;
}

.chat-input::placeholder {
    color: #ffffff;
    opacity: 0.9;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-right: 12px;
}

.tools-link {
    color: #ffffff;
    font-size: 0.9em;
    cursor: pointer;
    transition: color 0.3s;
    opacity: 0.8;
}

.tools-link:hover {
    color: #ffffff;
    opacity: 1;
}

.tools-dropdown-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-hint {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    padding: 2px 8px;
    background: rgba(41, 56, 139, 0.4);
    border-radius: 6px;
}

.tools-dropdown {
    display: none;
    position: absolute;
    left: 0;
    bottom: 100%;
    margin-bottom: 6px;
    background: #1a1a2e;
    border: 1px solid rgba(41, 56, 139, 0.5);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 140px;
    z-index: 100;
}

.tools-dropdown.open {
    display: block;
}

.tools-dropdown-option {
    padding: 10px 14px;
    color: #ffffff;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
    border-radius: 6px;
    margin: 4px;
}

.tools-dropdown-option:hover {
    background: rgba(41, 56, 139, 0.4);
}

.btn-send-icon {
    background: rgba(41, 56, 139, 0.3);
    border: 1px solid rgba(41, 56, 139, 0.5);
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    padding: 0;
}

.btn-send-icon:hover {
    background: rgba(41, 56, 139, 0.5);
    border-color: rgba(41, 56, 139, 0.7);
    transform: scale(1.05);
}

.btn-primary {
    padding: 12px 24px;
    background: #29388B;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #1e2a6b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(41, 56, 139, 0.4);
}

/* Bottom: Project Details with Overall Progress */
.project-details-section {
    height: 200px;
    min-height: 200px;
    max-height: 250px;
    background: #1e293b;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.details-header {
    padding: 15px 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.details-header h2 {
    font-size: 1.3em;
    color: #ffffff;
}

.details-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 15px;
    gap: 15px;
    background: #1e293b;
    min-height: 0;
    flex-direction: row;
}

.kpi-status-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    min-width: 0;
}

.kpi-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.status-section {
    display: none;
}

.kpi-section h3 {
    font-size: 1em;
    margin-bottom: 12px;
    color: #FFB800;
    flex-shrink: 0;
}

.kpi-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 5px;
}

.kpi-list::-webkit-scrollbar {
    width: 4px;
}

.kpi-list::-webkit-scrollbar-thumb {
    background: rgba(255, 184, 0, 0.3);
    border-radius: 2px;
}

.kpi-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 184, 0, 0.5);
}

.kpi-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #29388B;
    color: #ffffff;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 70px;
    flex-shrink: 0;
}

.kpi-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding-right: 2px;
}

.kpi-chart-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    position: relative;
    align-self: center;
    margin-left: 2px;
}

.kpi-chart-wrapper canvas {
    max-width: 100%;
    max-height: 100%;
}

.kpi-title {
    font-weight: 600;
    font-size: 0.85em;
    margin-bottom: 4px;
    color: #ffffff;
    line-height: 1.2;
}

.kpi-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: capitalize;
    margin-top: 5px;
    max-width: 90px;
    width: fit-content;
    text-align: center;
}

.kpi-desc {
    font-size: 0.8em;
    color: #ffffff;
    margin-top: 3px;
    opacity: 0.9;
    line-height: 1.3;
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.status-label {
    font-weight: 600;
    color: #ffffff;
    opacity: 0.9;
}

.status-value {
    color: #ffffff;
}

.status-completed {
    color: #10b981;
}

.status-active {
    color: #29388B;
}

.status-planning {
    color: #f59e0b;
}

.chart-section {
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.chart-section h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #ffffff;
    width: 100%;
    text-align: left;
    flex-shrink: 0;
    font-weight: 600;
    opacity: 0.9;
}

.chart-container {
    width: 180px;
    height: 180px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.overall-chart-container {
    width: 220px;
    height: 140px;
    margin-bottom: 15px;
    flex-shrink: 0;
    position: relative;
}

.completion-percentage {
    text-align: center;
    margin-top: 10px;
}

.percentage-value {
    font-size: 2.5em;
    font-weight: 700;
    color: #FFB800;
    display: block;
    text-align: center;
}

.percentage-label {
    display: none;
}

/* Impacts section removed */

/* Badge Colors */
.badge-completed {
    background: #10b981;
    color: white;
}

.badge-in_progress {
    background: #29388B;
    color: white;
}

.badge-todo {
    background: #f59e0b;
    color: white;
    max-width: 90px;
    width: fit-content;
    min-width: 60px;
}

.badge-blocked {
    background: #ef4444;
    color: white;
}

/* Utility Classes */
.loading, .empty-state, .error {
    text-align: center;
    padding: 20px;
    color: #ffffff;
    font-style: italic;
    opacity: 0.8;
}

.error {
    color: #f87171;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.modal-content h3 {
    color: #ffffff;
    margin-bottom: 15px;
}

.modal-content p {
    color: #ffffff;
    opacity: 0.9;
}

.btn-import-action {
    background: linear-gradient(135deg, #29388B 0%, #FF6B35 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.btn-import-action:hover {
    background: linear-gradient(135deg, #1e2a6b 0%, #e55a2b 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(41, 56, 139, 0.4);
}

.btn-close {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
    opacity: 0.9;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    opacity: 1;
}

/* Scrollbar Styling */
.project-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.kpi-status-section::-webkit-scrollbar {
    width: 8px;
}

.project-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.kpi-status-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.project-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.kpi-status-section::-webkit-scrollbar-thumb {
    background: rgba(41, 56, 139, 0.5);
    border-radius: 4px;
}

.project-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.kpi-status-section::-webkit-scrollbar-thumb:hover {
    background: rgba(41, 56, 139, 0.7);
}

/* Mobile Menu Toggle Button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: rgba(41, 56, 139, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
    background: rgba(41, 56, 139, 1);
    transform: scale(1.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
    backdrop-filter: blur(4px);
}

/* ===== Tablet (769px – 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 240px; min-width: 240px; }
    .kpi-card { min-width: 200px; max-width: 220px; }
}

/* ===== Mobile (≤ 768px) ===== */
@media (max-width: 768px) {
    /* --- Sidebar --- */
    .sidebar-toggle { display: block; }
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
        z-index: 100; will-change: transform;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { width: 100%; }

    /* --- Top Header --- */
    .top-header-line {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .top-header-line .header-left {
        padding-left: 40px; /* space for hamburger */
    }
    .top-header-line .logo { height: 26px; max-width: 110px; }
    .top-header-line .agent-name { font-size: 0.95em; }
    .top-header-line .separator { margin: 0 5px; font-size: 0.9em; }
    .header-right { gap: 6px; }
    .agent-selector-label { display: none; }
    .agent-selector {
        min-width: 120px; font-size: 0.8em;
        padding: 5px 22px 5px 8px;
    }
    .btn-clear { padding: 6px 12px; font-size: 0.8em; }

    /* --- KPI Cards Header (project name + buttons) --- */
    .kpi-cards-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .kpi-cards-header h2 { font-size: 0.95em; }

    /* --- KPI Cards Section --- */
    .kpi-cards-top-section {
        max-height: 30vh;
        overflow-y: auto;
        padding: 10px 12px;
        flex-shrink: 1;
    }
    .kpi-cards-container {
        -webkit-overflow-scrolling: touch;
    }
    .kpi-card {
        min-width: 155px; max-width: 180px;
        padding: 10px; height: auto; min-height: 0;
    }
    .kpi-card-title { font-size: 0.75em; max-height: 36px; }
    .kpi-card-value { font-size: 1.5em; }
    .kpi-card-chart-wrapper { width: 50px; height: 50px; }
    .kpi-card-target, .kpi-card-achieved { font-size: 0.75em; }

    /* --- Overall Project Status Table --- */
    .table-header-btn {
        padding: 8px 10px; font-size: 0.8em;
    }
    .table-cell-project-name,
    .table-cell-kpi-target,
    .table-cell-achieved,
    .table-cell-progress {
        padding: 10px 8px; font-size: 0.8em;
    }
    .table-cell-kpi-target { max-width: 180px; }
    .table-cell-achieved { max-width: 120px; }
    .projects-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .projects-status-table {
        min-width: 600px; /* force horizontal scroll on narrow screens */
    }

    /* --- Chat Section --- */
    .chat-section {
        padding: 0;
        flex: 1;
        min-height: 40vh;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .chat-messages {
        padding: 15px 15px 10px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    .chat-input-wrapper {
        padding: 12px 12px;
        background: rgba(30, 41, 59, 0.8);
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }
    .chat-input-container {
        border-radius: 12px;
        border: 1px solid rgba(41, 56, 139, 0.6) !important;
        box-shadow: 0 0 12px rgba(41, 56, 139, 0.3);
    }
    .chat-input { padding: 14px 14px; font-size: 1em; }
    .input-actions { gap: 10px; padding-right: 8px; }
    .tools-link { font-size: 0.85em; }
    .btn-send-icon { width: 36px; height: 36px; }

    .message { max-width: 100%; }
    .message-content { padding: 12px 14px; font-size: 0.9em; line-height: 1.6; }
    .user-message .message-content { max-width: 85%; }
    .bot-message .message-content { max-width: 95%; }

    /* Bot message tables responsive */
    .bot-message .message-content table {
        display: block; overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.85em;
    }
    .bot-message .message-content table th,
    .bot-message .message-content table td {
        padding: 6px 8px; white-space: nowrap;
    }

    /* --- Welcome Message on mobile --- */
    .welcome-message { padding: 20px 10px; }
    .welcome-message h3 { font-size: 1.4em; }
    .welcome-message p { font-size: 0.8em; }

    /* --- Modal --- */
    .modal-content { width: 95%; padding: 20px; }
}

/* ===== Small phone (≤ 480px) ===== */
@media (max-width: 480px) {
    .sidebar { width: 100%; max-width: 300px; }

    .top-header-line { padding: 8px 10px; }
    .top-header-line .header-left { padding-left: 38px; }
    .top-header-line .logo { height: 22px; max-width: 90px; }
    .top-header-line .agent-name { font-size: 0.85em; }
    .top-header-line .separator { margin: 0 4px; }
    .agent-selector {
        min-width: 100px; font-size: 0.75em;
        padding: 4px 18px 4px 6px;
    }
    .btn-clear { padding: 5px 10px; font-size: 0.75em; }

    .kpi-cards-top-section {
        max-height: 25vh;
        overflow-y: auto;
        padding: 8px 10px;
    }
    .kpi-cards-header h2 { font-size: 0.85em; }
    .kpi-card {
        min-width: 140px; max-width: 165px;
        height: auto; min-height: 0;
        padding: 8px;
    }
    .kpi-card-title { font-size: 0.7em; }
    .kpi-card-value { font-size: 1.3em; }
    .kpi-card-chart-wrapper { width: 42px; height: 42px; }

    /* Table: smaller minimum */
    .projects-status-table { min-width: 550px; }
    .table-header-btn { padding: 6px 8px; font-size: 0.75em; }
    .table-cell-project-name,
    .table-cell-kpi-target,
    .table-cell-achieved,
    .table-cell-progress {
        padding: 8px 6px; font-size: 0.75em;
    }

    .chat-messages { padding: 15px 10px; }
    .chat-input-wrapper { padding: 8px 10px; }
    .chat-input { padding: 10px 12px; font-size: 0.9em; }
    .input-actions { gap: 8px; padding-right: 6px; }

    .message-content { padding: 10px 12px; font-size: 0.85em; }
    .welcome-message h3 { font-size: 1.4em; }

    .modal-content { width: 96%; padding: 16px; }
}

/* ===== Extra small (≤ 360px) ===== */
@media (max-width: 360px) {
    .top-header-line .logo { height: 20px; max-width: 80px; }
    .top-header-line .agent-name { font-size: 0.8em; }
    .agent-selector { min-width: 85px; font-size: 0.7em; }

    .kpi-cards-top-section { max-height: 22vh; overflow-y: auto; }
    .kpi-card {
        min-width: 125px; max-width: 145px;
        height: auto; min-height: 0;
    }
    .kpi-card-value { font-size: 1.1em; }
}
