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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --border: #e5e7eb;
    --bg-light: #f9fafb;
    --text: #111827;
    --text-light: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: #fff;
}

header {
    background: var(--primary);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1rem;
    opacity: 0.9;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.file-input-area,
.search-area,
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

input[type="file"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
}

input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

button:hover:not(:disabled) {
    background: var(--primary-dark);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button#clearBtn {
    background: var(--danger);
}

button#clearBtn:hover:not(:disabled) {
    background: #dc2626;
}

button#clearSearch {
    background: var(--text-light);
}

button#clearSearch:hover:not(:disabled) {
    background: #4b5563;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed var(--border);
    border-radius: 8px;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--bg-light);
    transition: all 0.3s;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.drop-message svg {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.drop-message p {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.drop-message .hint {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Table */
.table-container {
    margin-top: 2rem;
}

.table-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-light);
}

#filterInfo {
    color: var(--primary);
    font-weight: 500;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--bg-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: relative;
}

th:hover {
    background: #e5e7eb;
}

th.sortable::after {
    content: '⇅';
    margin-left: 0.5rem;
    opacity: 0.3;
    font-size: 0.8rem;
}

th.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--primary);
}

th.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--primary);
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-light);
}

td[contenteditable="true"] {
    cursor: text;
    outline: none;
}

td[contenteditable="true"]:focus {
    background: #fef3c7;
    box-shadow: inset 0 0 0 2px #fbbf24;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    margin-top: 4rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
    }

    .file-input-area,
    .search-area,
    .action-buttons {
        width: 100%;
        flex-direction: column;
    }

    button,
    input[type="text"],
    input[type="file"] {
        width: 100%;
    }

    th, td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}
