* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #1e293b;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    overflow-x: auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    height: 60px;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 10px;
}

header .date {
    font-size: 1.1rem;
    color: #64748b;
    font-weight: 500;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
}

.tab {
    padding: 12px 32px;
    border: none;
    background: white;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.tab:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.tab.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Organization Chart */
.org-chart {
    display: none;
    animation: fadeIn 0.3s ease;
}

.org-chart.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.org-chart h2 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 40px;
    color: #1e293b;
}

/* Tree Wrapper for zoom */
.tree-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding: 10px 0;
}

/* Tree Structure */
.tree {
    display: flex;
    justify-content: center;
    padding: 20px;
    transform-origin: top center;
    transition: transform 0.2s ease;
    will-change: transform;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 8px 0 8px;
    transition: all 0.5s;
}

/* Connector Lines */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #cbd5e1;
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #cbd5e1;
}

.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

.tree li:only-child {
    padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

.tree li:last-child::before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Vertical line from parent */
.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #cbd5e1;
    width: 0;
    height: 20px;
}

/* Person Card */
.person {
    background: white;
    border-radius: 12px;
    padding: 15px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    max-width: 260px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
    text-align: left;
}

.person:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* CEO Style */
.person.ceo {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-left: 5px solid #f97316;
    color: #1e293b;
    min-width: 240px;
    padding: 18px;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.18);
}

.person.ceo .info h3 {
    color: #1e293b;
}

.person.ceo .info p {
    color: #78716c;
}

/* Director Style */
.person.director {
    border-left: 4px solid #6366f1;
}

.person.director.new {
    border-left: 4px solid #f59e0b;
}

.person.director.matrix {
    border-left: 4px dashed #ec4899;
}

/* Manager Style */
.person.manager {
    border-left: 4px solid #10b981;
    min-width: 180px;
}

/* Staff Style */
.person.staff {
    border-left: 4px solid #64748b;
    min-width: 160px;
    padding: 12px;
}

/* Avatar */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.person.staff .avatar {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
}

.avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #e2e8f0;
}

.person.staff .avatar-img {
    width: 40px;
    height: 40px;
}

/* Info */
.info {
    flex: 1;
    min-width: 0;
}

.info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info p {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.3;
}

.person.staff .info h3 {
    font-size: 0.8rem;
}

.person.staff .info p {
    font-size: 0.7rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    background: #fef3c7;
    color: #d97706;
    margin-top: 4px;
}

.badge.matrix {
    background: #fce7f3;
    color: #db2777;
}

/* Note */
.note {
    margin-top: 40px;
    text-align: center;
    padding: 20px;
    background: #fffbeb;
    border-radius: 12px;
    border: 1px solid #fcd34d;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.note p {
    font-size: 0.9rem;
    color: #92400e;
}

/* Footer */
footer {
    margin-top: 60px;
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1400px) {
    .person {
        min-width: 160px;
        max-width: 200px;
        padding: 12px;
    }

    .person.ceo {
        min-width: 200px;
    }

    .avatar, .avatar-img {
        width: 40px;
        height: 40px;
    }

    .info h3 {
        font-size: 0.8rem;
    }

    .info p {
        font-size: 0.7rem;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .tabs {
        flex-direction: column;
        align-items: center;
    }

    .tab {
        width: 100%;
        max-width: 300px;
    }

    .tree {
        padding: 10px;
    }

    .tree li {
        padding: 15px 5px 0 5px;
    }

    .person {
        min-width: 140px;
        max-width: 160px;
        padding: 10px;
        flex-direction: column;
        text-align: center;
    }

    .info {
        text-align: center;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .tabs {
        display: none;
    }

    .org-chart {
        display: block !important;
        page-break-after: always;
    }

    .person {
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }

    .person:hover {
        transform: none;
    }
}

/* Breadcrumb navigation */
.breadcrumb {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding: 10px 20px;
    background: white;
    border-radius: 50px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.breadcrumb.visible {
    display: flex;
}

.back-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6366f1;
    padding: 4px 10px;
    border-radius: 20px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.back-btn:hover {
    background: #f1f5f9;
    transform: translateX(-2px);
}

.breadcrumb-sep {
    color: #cbd5e1;
    font-size: 1.1rem;
}

.breadcrumb-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

/* Clickable director cards in top view */
.person.drillable {
    cursor: pointer;
}

.person.drillable::after {
    content: '›';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: #6366f1;
    opacity: 0;
    transition: opacity 0.2s, right 0.2s;
}

.person.drillable:hover::after {
    opacity: 1;
    right: 6px;
}

/* Dark mode - breadcrumb */
body.dark .breadcrumb {
    background: #1e293b;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark .back-btn {
    color: #818cf8;
}

body.dark .back-btn:hover {
    background: #334155;
}

body.dark .breadcrumb-name {
    color: #f1f5f9;
}

/* Dark Mode Toggle Button */
.dark-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.dark-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 18px rgba(0,0,0,0.2);
}

/* Dark Mode */
body.dark {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f1f5f9;
}

body.dark .dark-toggle {
    background: #334155;
}

body.dark header h1 {
    color: #f1f5f9;
}

body.dark header .date {
    color: #94a3b8;
}

body.dark .org-chart h2 {
    color: #f1f5f9;
}

body.dark .person {
    background: #1e293b;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

body.dark .person:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

body.dark .person.ceo {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    border-left-color: #f97316;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

body.dark .person.ceo .info h3 {
    color: #f1f5f9;
}

body.dark .person.ceo .info p {
    color: #94a3b8;
}

body.dark .info h3 {
    color: #f1f5f9;
}

body.dark .info p {
    color: #94a3b8;
}

body.dark .tree li::before,
body.dark .tree li::after,
body.dark .tree li:last-child::before,
body.dark .tree li:first-child::after,
body.dark .tree ul ul::before {
    border-color: #475569;
}

body.dark .note {
    background: #1c1917;
    border-color: #78350f;
}

body.dark .note p {
    color: #fbbf24;
}

body.dark footer {
    color: #94a3b8;
}

body.dark .zoom-btn {
    background: #334155;
    color: #f1f5f9;
}

body.dark .zoom-btn:hover {
    background: #475569;
}

body.dark .avatar-img {
    border-color: #475569;
}

/* Zoom controls */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    background: white;
    padding: 8px 12px;
    border-radius: 30px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #1e293b;
    font-weight: 600;
}

.zoom-btn:hover {
    background: #f1f5f9;
    transform: scale(1.1);
}

#zoomLevel {
    font-size: 0.8rem;
    color: #64748b;
    min-width: 38px;
    text-align: center;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

body.dark .zoom-controls {
    background: #334155;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body.dark .zoom-btn {
    color: #f1f5f9;
}

body.dark .zoom-btn:hover {
    background: #475569;
}

body.dark #zoomLevel {
    color: #94a3b8;
}
