* {
    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, #34495d 0%, #178bf7 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    position: relative;
    color: white;
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
}

.header-text {
    flex: 1;
    text-align: center;
}

.logo-container {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    width: 60px;
    height: 60px;
}

.si-logo {
    height: 60px;
    width: auto;
    display: block;
}

.logo-placeholder {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 24px;
    color: white;
    position: absolute;
    top: 0;
    left: 0;
}

.logo-container img.loaded {
    position: relative;
    z-index: 1;
}

.logo-container img.loaded ~ .logo-placeholder {
    display: none;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.calculator-wrapper {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
    align-items: start;
}

/* Input Section */
.input-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.input-section h2 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.5em;
    flex-shrink: 0;
}

.input-group {
    margin-bottom: 25px;
}

.input-group h3 {
    color: #34495e;
    font-size: 1.1em;
    margin-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

label {
    display: flex;
    flex-direction: column;
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

input[type="number"] {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    margin-top: 5px;
    transition: border-color 0.3s;
}

input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-link {
    background-color: transparent;
    color: #3498db;
    text-decoration: underline;
    border: none;
    padding: 0;
    font-size: 0.9em;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.btn-link:hover {
    color: #2980b9;
}

/* Diagram Section */
.diagram-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.diagram-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Top Row: Entities and Flows */
.diagram-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 15px;
    position: relative;
    padding-top: 0;
    min-height: 150px;
}

.profit-label-above {
    grid-column: 3;
    grid-row: 1;
    justify-self: center;
    align-self: end;
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    margin-bottom: 2px;
    text-align: center;
}

.entity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    grid-row: 3;
    align-self: center;
}

.person-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    border: 3px solid;
}

.seller-icon {
    background-color: #fff5e6;
    border-color: #ff9800;
    color: #ff9800;
}

.investor-icon {
    background-color: #e8f5e9;
    border-color: #4caf50;
    color: #4caf50;
}

.ofb-icon {
    background-color: #e3f2fd;
    border-color: #2196f3;
    color: #2196f3;
}

.entity-label-container {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.entity-label {
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
}

.info-icon {
    width: 14px;
    height: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.info-icon:hover {
    opacity: 1;
}

.profit-amount {
    grid-column: 3;
    grid-row: 2;
    justify-self: center;
    font-size: 1.3em;
    font-weight: bold;
    color: #4caf50;
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    white-space: nowrap;
    z-index: 10;
    margin-bottom: 10px;
}

/* Flow Arrows */
.flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    grid-row: 3;
    align-self: center;
}

.arrow-line {
    width: 100%;
    height: 3px;
    background-color: #34495e;
    position: relative;
}

.left-arrow .arrow-line::after {
    content: '';
    position: absolute;
    left: 0;
    top: -5px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 10px solid #34495e;
}

.right-arrow .arrow-line::after {
    content: '';
    position: absolute;
    left: 0;
    top: -5px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 10px solid #34495e;
}

.flow-label {
    margin-top: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95em;
    text-align: center;
}

/* Bottom Row: Calculation Summary */
.diagram-bottom {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.calculation-summary {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
}

.profit-breakdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.profit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.profit-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.profit-info-icon {
    width: 14px;
    height: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.profit-info-icon:hover {
    opacity: 1;
}

.profit-item span {
    font-size: 1.2em;
    font-weight: bold;
    color: #2c3e50;
}

.plus {
    font-size: 1.5em;
    font-weight: bold;
    color: #666;
}

.lifetime-value-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    margin-top: 15px;
    margin-bottom: 4px;
    text-align: center;
}

.total-profit {
    font-size: 1.8em;
    font-weight: bold;
    color: #4caf50;
    margin-top: 0;
}

/* Quality Indicators */
.quality-indicators {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.quality-indicators h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
}

.indicator-label {
    flex: 1;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
}

.indicator-info-icon {
    width: 14px;
    height: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.indicator-info-icon:hover {
    opacity: 1;
}

.indicator-value {
    font-weight: bold;
    color: #2c3e50;
    min-width: 100px;
    text-align: right;
}

.indicator-status {
    font-size: 1.2em;
    min-width: 30px;
    text-align: center;
}

.indicator-status.good {
    color: #4caf50;
}

.indicator-status.warning {
    color: #ff9800;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-content h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.modal-content p {
    color: #555;
    margin-bottom: 15px;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    margin-bottom: 20px;
}

.modal-content input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.load-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.load-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.load-item-info {
    flex: 1;
}

.load-item-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.load-item-date {
    font-size: 0.85em;
    color: #666;
}

.load-item-actions {
    display: flex;
    gap: 10px;
}

.btn-load {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-load:hover {
    background-color: #2980b9;
}

.btn-delete {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

.btn-delete:hover {
    background-color: #c0392b;
}

.load-count-info {
    padding: 10px;
    background: #e8f5e9;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #2c3e50;
    text-align: center;
}

.instructions-content {
    max-width: 700px;
}

.instructions-body {
    margin-bottom: 20px;
}

.instructions-body h3 {
    color: #2c3e50;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.instructions-body ol,
.instructions-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
    color: #555;
    line-height: 1.6;
}

.instructions-body li {
    margin-bottom: 8px;
}

.instructions-body ul {
    list-style-type: disc;
}

.instructions-note {
    margin-top: 15px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 4px;
    color: #2c3e50;
    font-style: italic;
}

/* Info Modals */
.info-modal {
    display: none;
}

.info-modal-content {
    max-width: 500px;
}

.info-modal-content p {
    line-height: 1.6;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calculator-wrapper {
        grid-template-columns: 1fr;
    }
    
    .diagram-top {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .flow-arrow {
        transform: rotate(90deg);
        min-width: auto;
        min-height: 80px;
    }
    
    .diagram-middle {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
