* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.filters-row {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.manager-filter {
    display: flex;
    align-items: center;
    gap: 12px;
}

.manager-filter label {
    font-size: 1rem;
    font-weight: 500;
}

.manager-filter select {
    padding: 10px 16px;
    font-size: 1rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    min-width: 180px;
}

.manager-filter select:hover,
.manager-filter select:focus {
    background: white;
    outline: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.okr-wrapper {
    position: relative;
    margin-bottom: 30px;
}

.level-section {
    margin-bottom: 60px;
}

.level-title {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.okr-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    position: relative;
    min-height: 200px;
}

.chief-row {
    margin-bottom: 40px;
}

.manager-row {
    margin-top: 40px;
}

.staff-row {
    margin-top: 40px;
}

.connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: rgba(255, 255, 255, 0.4);
    stroke-width: 2;
    fill: none;
    transition: opacity 0.3s ease;
}

.connection-line.highlighted {
    stroke: #4ade80;
    stroke-width: 3;
    filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.6));
}

.connection-line.faded {
    opacity: 0.2;
}

.okr-card {
    background: var(--owner-bg, white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: visible;
    border: 3px solid transparent;
    z-index: 2;
    min-width: 300px;
    flex: 0 1 auto;
}

.okr-card.faded {
    opacity: 0.25;
    pointer-events: none;
}

.okr-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--owner-accent, #667eea);
    transition: width 0.3s ease;
}

/* Level-based fallback when --owner-accent not set (e.g. missing owner) */
.okr-card.chief::before {
    background: linear-gradient(180deg, #f093fb 0%, #f5576c 100%);
}

.okr-card.manager::before {
    background: linear-gradient(180deg, #4facfe 0%, #00f2fe 100%);
}

.okr-card.staff::before {
    background: linear-gradient(180deg, #43e97b 0%, #38f9d7 100%);
}

.okr-card[style*="--owner-accent"]::before {
    background: var(--owner-accent);
}

.okr-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.okr-card:hover::before {
    width: 8px;
}

.okr-card.selected {
    border-color: #ffd700;
    box-shadow: 0 15px 40px rgba(255, 215, 0, 0.5);
    transform: scale(1.02);
}

.okr-card.selected::before {
    width: 8px;
    background: linear-gradient(180deg, #ffd700 0%, #ffed4e 100%);
}

.okr-card.linked {
    border-color: #4ade80;
    box-shadow: 0 15px 40px rgba(74, 222, 128, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

.okr-card.linked::before {
    width: 8px;
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 15px 40px rgba(74, 222, 128, 0.4);
    }
    50% {
        box-shadow: 0 15px 40px rgba(74, 222, 128, 0.7);
    }
}

.okr-level {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.okr-owner {
    font-size: 1rem;
    font-weight: 600;
    color: var(--owner-accent, #667eea);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: color-mix(in srgb, var(--owner-accent, #667eea) 12%, white);
    border-radius: 8px;
    display: inline-block;
}

.okr-level.chief {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.okr-level.manager {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.okr-level.staff {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #1f2937;
}

.okr-objective {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1f2937;
    line-height: 1.3;
}

.okr-key-result {
    font-size: 1rem;
    color: #6b7280;
    line-height: 1.5;
    padding-left: 16px;
    border-left: 3px solid #e5e7eb;
    margin-top: 8px;
}

.okr-link-info {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px dashed #e5e7eb;
    font-size: 0.9rem;
    color: #9ca3af;
}

.okr-link-info strong {
    color: #667eea;
}

.legend {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

.legend-color.chief {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.legend-color.manager {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.legend-color.staff {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.legend-color.selected {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.legend-color.linked {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
}

/* Tablet and down */
@media (max-width: 768px) {
    body {
        padding: 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    
    header {
        margin-bottom: 24px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .filters-row {
        margin-top: 16px;
        gap: 12px;
    }
    
    .manager-filter {
        flex: 1 1 auto;
        min-width: 0;
    }
    
    .manager-filter select {
        min-width: 0;
        width: 100%;
        padding: 8px 12px;
        font-size: 0.95rem;
    }
    
    .level-section {
        margin-bottom: 32px;
    }
    
    .level-title {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }
    
    .okr-row {
        display: grid;
        /* ~180px min allows 2 columns on iPhone Pro Max portrait (~430px) and similar phones */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        min-height: 120px;
    }
    
    .okr-card {
        min-width: 0;
        padding: 16px;
    }
    
    .okr-level {
        font-size: 0.75rem;
        padding: 4px 10px;
        margin-bottom: 8px;
    }
    
    .okr-owner {
        font-size: 0.9rem;
        padding: 6px 10px;
        margin-bottom: 10px;
    }
    
    .okr-objective {
        font-size: 1.15rem;
        margin-bottom: 8px;
    }
    
    .okr-key-result {
        font-size: 0.9rem;
        padding-left: 12px;
    }
    
    .okr-link-info {
        font-size: 0.8rem;
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .chief-row,
    .manager-row,
    .staff-row {
        margin-top: 24px;
        margin-bottom: 0;
    }
    
    .legend {
        padding: 14px;
        gap: 14px;
    }
    
    .legend-item {
        font-size: 0.85rem;
    }
    
    .legend-color {
        width: 20px;
        height: 20px;
    }
}

/* Narrow phones: single column, extra compact */
@media (max-width: 380px) {
    .okr-row {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
}