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

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #0d1b2a, #1b2a4a, #2d5f8a);
    color: white;
    padding: 20px;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.logo-img {
    height: 70px;
    filter: brightness(1.1);
}

.logo-fallback {
    background: rgba(255,255,255,0.1);
    padding: 10px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.2);
}

.logo-text-fallback {
    font-size: 2rem;
    font-weight: 900;
}

.branch-name {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 3px;
    text-shadow: 0 3px 6px rgba(0,0,0,0.3);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.85rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.stats span {
    background: rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Tabs */
.group-tabs {
    display: flex;
    overflow-x: auto;
    background: white;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.tab.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
}

.tab-a.active { border-bottom-color: #e53935; color: #e53935; }
.tab-b.active { border-bottom-color: #f57c00; color: #f57c00; }
.tab-c.active { border-bottom-color: #1976d2; color: #1976d2; }
.tab-d.active { border-bottom-color: #f9a825; color: #f9a825; }

/* Main content */
main {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.group-section {
    margin-bottom: 24px;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    position: relative;
    overflow: hidden;
}

.group-header::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

.group-header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    right: 10px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.group-header .level {
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    margin-right: auto;
}

.group-header .count {
    font-size: 0.8rem;
    opacity: 0.9;
}

.group-header.group-a {
    background: linear-gradient(135deg, #b71c1c, #e53935, #ff5252);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.3);
}
.group-header.group-b {
    background: linear-gradient(135deg, #e65100, #f57c00, #ffb74d);
    box-shadow: 0 4px 15px rgba(245, 124, 0, 0.3);
}
.group-header.group-c {
    background: linear-gradient(135deg, #0d47a1, #1976d2, #42a5f5);
    box-shadow: 0 4px 15px rgba(25, 118, 210, 0.3);
}
.group-header.group-d {
    background: linear-gradient(135deg, #f57f17, #f9a825, #ffee58);
    box-shadow: 0 4px 15px rgba(249, 168, 37, 0.3);
}

.group-desc {
    background: white;
    padding: 8px 16px;
    font-size: 0.8rem;
    color: #666;
    border-bottom: 1px solid #eee;
}

/* Trainee cards */
.trainee-card {
    background: white;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.trainee-card:last-child {
    border-radius: 0 0 12px 12px;
    border-bottom: none;
}

.trainee-card:hover {
    background: #f8f9fa;
}

.trainee-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.avatar-a { background: linear-gradient(135deg, #e53935, #ff5252); }
.avatar-b { background: linear-gradient(135deg, #f57c00, #ffb74d); }
.avatar-c { background: linear-gradient(135deg, #1976d2, #42a5f5); }
.avatar-d { background: linear-gradient(135deg, #f9a825, #ffee58); }

.trainee-info {
    flex: 1;
    min-width: 0;
}

.trainee-name {
    font-weight: 600;
    font-size: 1rem;
}

.trainee-meta {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.trainee-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e8f5e9;
    color: #2e7d32;
    white-space: nowrap;
}

.badge.warn {
    background: #fff3e0;
    color: #e65100;
}

.badge.info {
    background: #e3f2fd;
    color: #1565c0;
}

.trainee-arrow {
    color: #ccc;
    font-size: 1.2rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: flex-end;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #f0f0f0;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.modal .group-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: white;
    margin-bottom: 16px;
}

.modal .group-tag.tag-a { background: #e53935; }
.modal .group-tag.tag-b { background: #f57c00; }
.modal .group-tag.tag-c { background: #1976d2; }
.modal .group-tag.tag-d { background: #f9a825; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
}

.detail-item .label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
}

.detail-item .value {
    font-size: 1rem;
    font-weight: 600;
}

.training-section {
    margin-top: 20px;
}

.training-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #333;
}

.training-option {
    background: #f0f7ff;
    border: 1px solid #d0e3f7;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.training-option .type {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.training-option .desc {
    font-size: 0.8rem;
    color: #555;
}

.goal-section {
    margin-top: 20px;
    background: #f0faf0;
    border: 1px solid #c8e6c9;
    border-radius: 10px;
    padding: 16px;
}

.goal-section h3 {
    color: #2e7d32;
    margin-bottom: 8px;
}

.goal-section p {
    font-size: 0.9rem;
    color: #555;
}

.notes-section {
    margin-top: 16px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 10px;
    padding: 16px;
}

.notes-section h3 {
    color: #f57f17;
    margin-bottom: 8px;
}

.notes-section p {
    font-size: 0.9rem;
    color: #555;
}

/* Trainee goal preview on card */
.trainee-goal-preview {
    font-size: 0.75rem;
    color: #2e7d32;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Current goal display */
.current-goal {
    background: white;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    border-right: 4px solid #4caf50;
}

/* Goal type selector */
.goal-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.goal-type-btn {
    flex: 1;
    padding: 10px 8px;
    border: 2px solid #c8e6c9;
    border-radius: 12px;
    background: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.goal-type-btn:hover {
    border-color: #4caf50;
    background: #e8f5e9;
}

.goal-type-btn.selected {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.goal-options {
    margin-bottom: 12px;
}

.goal-date-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.goal-date-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2e7d32;
    white-space: nowrap;
}

.goal-date-field input {
    padding: 8px 10px;
    border: 2px solid #c8e6c9;
    border-radius: 8px;
    font-size: 0.9rem;
}

.goal-date {
    font-size: 0.8rem;
    color: #666;
    margin-right: 8px;
}

/* Goal presets */
.goal-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.goal-preset-btn {
    background: white;
    border: 2px solid #c8e6c9;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
}

.goal-preset-btn:hover {
    border-color: #4caf50;
    background: #e8f5e9;
}

.goal-preset-btn.selected {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.goal-custom {
    display: flex;
    gap: 8px;
}

.goal-custom input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 0.9rem;
    direction: rtl;
}

.goal-custom input:focus {
    outline: none;
    border-color: #4caf50;
}

/* Save buttons */
.btn-save {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover {
    background: #388e3c;
}

.btn-save:active {
    transform: scale(0.97);
}

.btn-save-data {
    width: 100%;
    margin-top: 12px;
    background: #1976d2;
}

.btn-save-data:hover {
    background: #1565c0;
}

.btn-add-log {
    width: 100%;
    margin-top: 12px;
    background: #f57c00;
}

.btn-add-log:hover {
    background: #e65100;
}

/* Data section */
.data-section {
    margin-top: 20px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 10px;
    padding: 16px;
}

.data-section h3 {
    color: #1565c0;
    margin-bottom: 12px;
}

.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.data-field {
    display: flex;
    flex-direction: column;
}

.data-field.full-width {
    grid-column: 1 / -1;
}

.data-field label {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 4px;
    font-weight: 600;
}

.data-field input,
.data-field textarea,
.data-field select {
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    direction: rtl;
    font-family: inherit;
}

.data-field input:focus,
.data-field textarea:focus,
.data-field select:focus {
    outline: none;
    border-color: #1976d2;
}

/* Log section */
.log-section {
    margin-top: 20px;
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    border-radius: 10px;
    padding: 16px;
}

.log-section h3 {
    color: #e65100;
    margin-bottom: 12px;
}

.log-entries {
    margin-top: 16px;
}

.log-entries h4 {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
}

.log-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    align-items: center;
}

.log-date {
    font-weight: 700;
    color: #333;
}

.log-type {
    background: #fff3e0;
    padding: 2px 8px;
    border-radius: 6px;
    color: #e65100;
}

.log-km, .log-time {
    color: #555;
}

.log-notes {
    color: #888;
    font-style: italic;
    width: 100%;
}

.no-logs {
    text-align: center;
    color: #999;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Toast notification */
#toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: bottom 0.3s ease;
    z-index: 200;
}

#toast.show {
    bottom: 30px;
}

/* Responsive */
@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }
    .modal {
        border-radius: 20px;
        max-height: 80vh;
    }
}

@media (max-width: 400px) {
    .data-grid {
        grid-template-columns: 1fr;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .stats {
        flex-wrap: wrap;
        gap: 8px;
    }
}
