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

[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 28px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a2e;
}

header h2 {
    font-size: 0.95rem;
    font-weight: 400;
    color: #666;
    margin-top: 2px;
}

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

.upload-area {
    border: 2px dashed #c0c4cc;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #4a6cf7;
    background: #f5f7ff;
}

.upload-icon {
    color: #8c8fa3;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.upload-subtext {
    font-size: 0.85rem;
    color: #999;
}

/* Summary Bar */
.summary-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.summary-count {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-weight: 600;
}

.summary-item.total .summary-count { color: #333; }
.summary-item.approved .summary-count { color: #28a745; }
.summary-item.denied .summary-count { color: #dc3545; }
.summary-item.pending .summary-count { color: #ffc107; }

.btn-add {
    margin-left: auto;
    padding: 8px 16px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-add:hover {
    background: #3a5ce5;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Result Card */
.req-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.req-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.req-card-status {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.req-card.status-approved .req-card-status { background: #d4edda; }
.req-card.status-denied .req-card-status { background: #f8d7da; }
.req-card.status-pending .req-card-status { background: #fff3cd; }
.req-card.status-loading .req-card-status { background: #e8eaf0; }

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.req-card.status-approved .status-badge {
    background: #28a745;
    color: #fff;
}

.req-card.status-denied .status-badge {
    background: #dc3545;
    color: #fff;
}

.req-card.status-pending .status-badge {
    background: #ffc107;
    color: #333;
}

.req-card.status-loading .status-badge {
    background: #adb5bd;
    color: #fff;
}

.status-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.req-card.status-approved .status-label { color: #155724; }
.req-card.status-denied .status-label { color: #721c24; }
.req-card.status-pending .status-label { color: #856404; }

.req-card-body {
    padding: 14px 16px;
}

.req-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.req-card-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.req-card-detail {
    font-size: 0.8rem;
    color: #777;
    display: flex;
    gap: 6px;
}

.req-card-detail strong {
    color: #555;
    min-width: 65px;
}

.req-card-rules {
    padding: 10px 16px 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.rule-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.rule-chip.pass {
    background: #d4edda;
    color: #155724;
}

.rule-chip.fail {
    background: #f8d7da;
    color: #721c24;
}

.rule-chip.warn {
    background: #fff3cd;
    color: #856404;
}

.rule-chip-icon {
    font-size: 0.65rem;
}

/* Loading card */
.req-card.status-loading .req-card-body {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #4a6cf7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* Modal content */
.modal-result-banner {
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.modal-result-banner.approved {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 2px solid #28a745;
}

.modal-result-banner.denied {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border: 2px solid #dc3545;
}

.modal-result-banner.pending {
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 2px solid #ffc107;
}

.modal-result-icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.modal-result-text {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-result-banner.approved .modal-result-text { color: #155724; }
.modal-result-banner.denied .modal-result-text { color: #721c24; }
.modal-result-banner.pending .modal-result-text { color: #856404; }

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

.modal-data-item label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 2px;
}

.modal-data-item span {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.modal-rules {
    margin-top: 4px;
}

.modal-rules h4 {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 12px;
}

.modal-rule-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.modal-rule-item:last-child {
    border-bottom: none;
}

.modal-rule-status {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.modal-rule-status.pass { background: #28a745; }
.modal-rule-status.fail { background: #dc3545; }
.modal-rule-status.warn { background: #ffc107; color: #333; }

.modal-rule-content { flex: 1; }

.modal-rule-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 2px;
}

.modal-rule-item.fail .modal-rule-name { color: #dc3545; }

.modal-rule-desc {
    font-size: 0.8rem;
    color: #777;
    line-height: 1.4;
}

.modal-pdf-text {
    margin-top: 16px;
}

.modal-pdf-text summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #4a6cf7;
    font-weight: 600;
}

.modal-pdf-text pre {
    margin-top: 8px;
    background: #f7f8fa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.75rem;
    color: #555;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
}

/* Responsive */
@media (max-width: 600px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    .summary-bar {
        gap: 10px;
    }
    .modal-data-grid {
        grid-template-columns: 1fr;
    }
}
