* {
    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, #1a5f2a 0%, #2d8f4a 50%, #45a049 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

h1 {
    text-align: center;
    color: #1a5f2a;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

h2 {
    color: #1a5f2a;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

h3 {
    color: #2d8f4a;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

h4 {
    color: #45a049;
    margin-bottom: 10px;
    font-size: 1rem;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: #f0f0f0;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: #1a5f2a;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Upload Section */
.upload-section {
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed #2d8f4a;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: #f8fff8;
}

.upload-area:hover {
    border-color: #1a5f2a;
    background: rgba(45, 143, 74, 0.05);
}

.upload-area.dragover {
    border-color: #1a5f2a;
    background: rgba(45, 143, 74, 0.1);
}

#fileInput, #batchFileInput, #generalFileInput {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

/* Disable file input pointer events during drag so the parent div
   receives the drop event instead of the native file input handler. */
.upload-area.dragover input[type="file"] {
    pointer-events: none;
}

.upload-text {
    color: #2d8f4a;
    font-size: 1.1rem;
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.preview, .batch-preview {
    margin-top: 20px;
}

.preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.batch-file-item {
    display: inline-block;
    background: #e8f5e9;
    padding: 5px 12px;
    margin: 5px;
    border-radius: 15px;
    font-size: 0.9rem;
    color: #1a5f2a;
}

.batch-info {
    margin-top: 15px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 5px;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #1a5f2a;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #155522;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 95, 42, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
    transform: translateY(-2px);
}

.btn-ast {
    background: #2d8f4a;
    color: white;
}

.btn-ast:hover:not(:disabled) {
    background: #1a5f2a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 143, 74, 0.4);
}

.btn-sm {
    padding: 6px 15px;
    font-size: 0.85rem;
}

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

.action-buttons {
    margin-top: 20px;
}

/* Forms */
.form-section {
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #2d8f4a;
    box-shadow: 0 0 0 3px rgba(45, 143, 74, 0.1);
}

.raw-text-section {
    margin-bottom: 40px;
}

/* AST Section */
.ast-section {
    margin-bottom: 40px;
    border: 2px solid #2d8f4a;
    border-radius: 10px;
    padding: 30px;
    background: #fafff8;
}

.ast-organism {
    padding: 20px;
    background: #e8f5e9;
    border-radius: 8px;
    margin-bottom: 25px;
    border-left: 5px solid #2d8f4a;
}

.ast-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #1a5f2a;
    margin-top: 10px;
}

.ast-value.warning {
    color: #ff9800;
}

.ast-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.legend-item {
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.legend-s {
    background: #c8e6c9;
    color: #1b5e20;
}

.legend-i {
    background: #fff3e0;
    color: #e65100;
}

.legend-r {
    background: #ffcdd2;
    color: #b71c1c;
}

.ast-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ast-table th {
    background: #1a5f2a;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.ast-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.ast-table tr:hover {
    background: #f5f5f5;
}

.ast-table tbody tr:last-child td {
    border-bottom: none;
}

.interp-s {
    background: #c8e6c9;
    color: #1b5e20;
    font-weight: bold;
    text-align: center;
    border-radius: 4px;
}

.interp-i {
    background: #fff3e0;
    color: #e65100;
    font-weight: bold;
    text-align: center;
    border-radius: 4px;
}

.interp-r {
    background: #ffcdd2;
    color: #b71c1c;
    font-weight: bold;
    text-align: center;
    border-radius: 4px;
}

.ast-stats {
    margin-top: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
}

.stats-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.stat-item {
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-s {
    background: #c8e6c9;
    color: #1b5e20;
}

.stat-i {
    background: #fff3e0;
    color: #e65100;
}

.stat-r {
    background: #ffcdd2;
    color: #b71c1c;
}

.stat-empty {
    background: #e0e0e0;
    color: #666;
}

.stat-total {
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
}

.ast-actions {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.ast-actions select {
    padding: 10px 15px;
    border: 2px solid #2d8f4a;
    border-radius: 5px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    min-width: 100px;
}

/* Extraction Logs */
.extraction-logs {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.log-item {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.log-success {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
}

.log-error {
    background: #ffebee;
    border-left: 4px solid #f44336;
}

.log-warning {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
}

.log-item pre {
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.8rem;
    overflow-x: auto;
}

/* Batch Results */
.batch-results-section {
    margin-top: 30px;
    padding: 20px;
    background: #fafafa;
    border-radius: 10px;
}

.batch-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.badge-success {
    background: #c8e6c9;
    color: #1b5e20;
}

.badge-error {
    background: #ffcdd2;
    color: #b71c1c;
}

.batch-result-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #4caf50;
}

.batch-result-card.error {
    border-left-color: #f44336;
}

.batch-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.batch-result-body {
    color: #666;
}

.batch-result-body p {
    margin-bottom: 5px;
}

.batch-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2d8f4a;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #1a5f2a;
    font-size: 1.2rem;
}

/* Age Input Row */
.age-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 12px 16px;
    background: #f0f7ff;
    border-radius: 8px;
    border: 1px solid #cce0ff;
}

.age-input-row label {
    font-weight: 600;
    color: #1a4a8a;
    white-space: nowrap;
}

.age-input {
    width: 130px;
    padding: 8px 12px;
    border: 2px solid #4a90d9;
    border-radius: 5px;
    font-size: 1rem;
    text-align: center;
}

.age-input:focus {
    outline: none;
    border-color: #1a4a8a;
}

.age-hint {
    color: #888;
    font-size: 0.85rem;
}

/* Recommend Button */
.btn-recommend {
    background: #1a4a8a;
    color: white;
}

.btn-recommend:hover:not(:disabled) {
    background: #0d3366;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 74, 138, 0.4);
}

/* Retry Button */
.btn-retry {
    background: #f59e0b;
    color: #fff;
}

.btn-retry:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Best antibiotic callout */
.rec-best {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 20px 0 10px;
    padding: 18px 22px;
    border-radius: 10px;
    font-size: 0.97rem;
    line-height: 1.5;
}

.rec-best-ok {
    background: #f0fdf4;
    border: 2px solid #22c55e;
    color: #166534;
}

.rec-best-none {
    background: #fff7ed;
    border: 2px solid #f59e0b;
    color: #92400e;
}

.rec-best-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    line-height: 1.2;
}

.rec-best p {
    margin: 4px 0 0;
    opacity: 0.85;
    font-size: 0.88rem;
}

/* Bottom reset bar */
.bottom-reset {
    display: flex;
    justify-content: center;
    margin: 30px 0 10px;
}

/* Recommendation Section */
.recommend-section {
    margin-bottom: 40px;
    border: 2px solid #1a4a8a;
    border-radius: 10px;
    padding: 30px;
    background: #f7faff;
}

.recommend-section h2 {
    color: #1a4a8a;
    margin-bottom: 20px;
}

.rec-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #e8f0fb;
    border-radius: 8px;
    border-left: 5px solid #1a4a8a;
}

.rec-meta-item {
    font-size: 0.95rem;
    color: #333;
}

/* Flag Banners */
.flag-esbl {
    margin-bottom: 8px;
    padding: 10px 16px;
    background: #fff3e0;
    border-left: 5px solid #ff9800;
    border-radius: 4px;
    font-weight: 600;
    color: #e65100;
}

.flag-info {
    margin-bottom: 8px;
    padding: 10px 16px;
    background: #e3f2fd;
    border-left: 5px solid #2196f3;
    border-radius: 4px;
    font-weight: 600;
    color: #0d47a1;
}

.rec-warning {
    margin-bottom: 6px;
    padding: 9px 14px;
    background: #fffde7;
    border-left: 4px solid #fbc02d;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #5d4037;
}

.rec-error {
    margin-bottom: 6px;
    padding: 9px 14px;
    background: #ffebee;
    border-left: 4px solid #f44336;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #b71c1c;
    font-weight: 500;
}

/* Recommendation Table */
.rec-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rec-table th {
    background: #1a4a8a;
    color: white;
    padding: 14px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.rec-table td {
    padding: 11px 15px;
    border-bottom: 1px solid #e8eef7;
    font-size: 0.9rem;
    vertical-align: middle;
}

.rec-table tbody tr:last-child td {
    border-bottom: none;
}

/* Row color coding by status */
.rec-recommended {
    background: #f0fff4;
}

.rec-recommended:hover {
    background: #e0f7ea;
}

.rec-skip_resistant {
    background: #fff5f5;
    opacity: 0.75;
}

.rec-contraindicated {
    background: #fff0f3;
    opacity: 0.75;
}

.rec-not_tested {
    background: #fafafa;
}

.rec-rationale {
    color: #555;
    font-size: 0.85rem;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-ok {
    background: #c8e6c9;
    color: #1b5e20;
}

.status-r {
    background: #ffcdd2;
    color: #b71c1c;
}

.status-nt {
    background: #e0e0e0;
    color: #424242;
}

.status-ci {
    background: #fce4ec;
    color: #880e4f;
}

/* Interpretation Badge */
.interp-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    min-width: 32px;
}

.interp-s {
    background: #c8e6c9;
    color: #1b5e20;
}

.interp-i {
    background: #fff3e0;
    color: #e65100;
}

.interp-r {
    background: #ffcdd2;
    color: #b71c1c;
}

.interp-none {
    background: #eeeeee;
    color: #9e9e9e;
}

/* Disclaimer */
.rec-disclaimer {
    margin-top: 20px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #666;
    border-left: 4px solid #bdbdbd;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .btn {
        width: 100%;
        margin-bottom: 10px;
    }

    .tab-nav {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 100px;
    }

    .ast-actions {
        flex-direction: column;
    }

    .ast-legend {
        flex-direction: column;
    }

    .stats-row {
        flex-direction: column;
    }
}
