:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --border-color: #e2e8f0;
    --error-color: #dc2626;
    --error-bg: #fee2e2;
    --success-color: #16a34a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    padding: 20px;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

main {
    display: grid;
    gap: 2rem;
}

section {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button, .file-label {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.primary-btn:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.secondary-btn {
    background-color: var(--bg-white);
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: var(--bg-light);
    color: var(--secondary-hover);
}

.file-label {
    display: inline-block;
}

#fileInput {
    display: none;
}

.drop-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: var(--bg-light);
}

textarea {
    width: 100%;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    border: none;
    border-radius: 6px;
    resize: vertical;
    background-color: transparent;
    color: var(--text-primary);
}

textarea:focus {
    outline: none;
}

.drop-zone textarea {
    border: none;
}

#csvOutput {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--error-bg);
    color: var(--error-color);
    border-radius: 6px;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
}

.output-section {
    display: none;
}

.output-section.show {
    display: block;
}

.preview-container {
    margin-bottom: 1.5rem;
}

.preview-container:last-child {
    margin-bottom: 0;
}

.table-preview {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.table-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-preview th,
.table-preview td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-preview th {
    background-color: var(--bg-light);
    font-weight: 600;
    color: var(--text-primary);
}

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

.table-preview tr:hover {
    background-color: var(--bg-light);
}

footer {
    margin-top: 3rem;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

footer p {
    margin-bottom: 0.5rem;
}

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

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

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .button-group {
        width: 100%;
    }

    button, .file-label {
        flex: 1;
        text-align: center;
    }
}
