:root {
    --background: hsl(0 0% 100%);
    --foreground: hsl(0 0% 9%);
    --card: hsl(0 0% 98%);
    --card-border: hsl(0 0% 90%);
    --sidebar: hsl(0 0% 96%);
    --sidebar-border: hsl(0 0% 92%);
    --primary: hsl(210 100% 45%);
    --primary-foreground: hsl(0 0% 98%);
    --secondary: hsl(0 0% 92%);
    --secondary-foreground: hsl(0 0% 9%);
    --muted: hsl(0 0% 94%);
    --muted-foreground: hsl(0 0% 35%);
    --border: hsl(0 0% 90%);
    --success: hsl(142 76% 36%);
    --radius: 0.5rem;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 256px;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 12px;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    padding: 0 8px;
}

.sidebar-nav {
    padding: 0 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    color: var(--foreground);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s;
}

.nav-item:hover {
    background: var(--secondary);
}

.nav-item.active {
    background: var(--secondary);
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    opacity: 0;
}

.nav-item.active .nav-chevron {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 256px;
    padding: 32px 40px;
    max-width: 1100px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-description {
    font-size: 14px;
    color: var(--muted-foreground);
}

/* Steps */
.step {
    display: none;
}

.step.active {
    display: block;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 600;
}

.card-content {
    padding: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

.btn-primary:hover {
    background: hsl(210 100% 40%);
}

.btn-secondary {
    background: var(--background);
    color: var(--foreground);
    border-color: var(--border);
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--muted);
    color: var(--muted-foreground);
}

.badge-success {
    background: hsl(142 76% 94%);
    color: var(--success);
}

/* Upload Section */
.upload-card {
    padding: 24px;
}

.upload-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.upload-box:hover {
    border-color: var(--primary);
    background: hsl(210 100% 98%);
}

.upload-icon {
    margin-bottom: 16px;
}

.upload-icon svg {
    width: 48px;
    height: 48px;
    color: var(--muted-foreground);
}

.upload-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 13px;
    color: var(--muted-foreground);
}

.uploaded-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.file-name {
    display: block;
    font-weight: 500;
    font-size: 14px;
}

.file-size {
    font-size: 12px;
    color: var(--muted-foreground);
}

.demo-hint {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hint-text {
    font-size: 13px;
    color: var(--muted-foreground);
}

/* Parsing Animation */
.parsing-card {
    padding: 48px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 32px;
}

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

.parsing-steps {
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
}

.parsing-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    color: var(--muted-foreground);
    font-size: 14px;
}

.step-check {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.step-check svg {
    width: 16px;
    height: 16px;
    color: var(--success);
}

.parsing-step.done {
    color: var(--foreground);
}

.parsing-step.done .step-check {
    opacity: 1;
}

/* Review Section */
.review-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.card-full {
    grid-column: 1 / -1;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    margin-bottom: 4px;
}

.info-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Visit List */
.visit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.visit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 14px;
}

.visit-num {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.visit-name {
    flex: 1;
    font-weight: 500;
}

.visit-window {
    font-size: 13px;
    color: var(--muted-foreground);
}

/* Form List */
.form-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-item {
    background: var(--background);
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
}

.form-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.form-icon {
    width: 20px;
    height: 20px;
    color: var(--muted-foreground);
}

.form-info {
    flex: 1;
}

.form-info strong {
    display: block;
    font-size: 14px;
    font-weight: 500;
}

.field-count {
    font-size: 12px;
    color: var(--muted-foreground);
}

.expand-icon {
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    transition: transform 0.2s;
}

.form-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.form-fields {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 12px;
}

.form-item.expanded .form-fields {
    display: block;
}

.field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.field code {
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    background: var(--muted);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--muted-foreground);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.action-bar-center {
    justify-content: center;
    gap: 12px;
}

/* Success */
.success-container {
    text-align: center;
    padding: 32px 0;
}

.success-icon {
    margin-bottom: 20px;
}

.success-icon svg {
    width: 64px;
    height: 64px;
    color: var(--success);
}

.success-container h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.success-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin: 32px 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--muted-foreground);
}

.created-card {
    max-width: 600px;
    margin: 24px auto;
    text-align: left;
}

.db-section {
    margin-bottom: 20px;
}

.db-section:last-child {
    margin-bottom: 0;
}

.db-section h3 {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    margin-bottom: 8px;
}

.db-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.db-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
}

.db-item code {
    font-family: 'Roboto Mono', monospace;
}

.db-meta {
    font-size: 11px;
    color: var(--muted-foreground);
}

/* Study Card */
.study-card {
    max-width: 500px;
    padding: 20px;
}

.study-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.study-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.study-desc {
    font-size: 14px;
    color: var(--muted-foreground);
}

.study-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
}

/* Page Header Row */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
    font-family: inherit;
}

.tab:hover {
    color: var(--foreground);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--muted);
}

.data-table code {
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
}

/* Form Detail List */
.form-detail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-detail-item {
    background: var(--background);
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
}

.form-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.form-detail-info {
    flex: 1;
}

.form-detail-info strong {
    display: block;
    font-size: 14px;
    font-weight: 500;
}

.form-detail-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.form-detail-body {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 16px;
}

.form-detail-item.expanded .form-detail-body {
    display: block;
}

.form-section {
    margin-bottom: 16px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h4 {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    margin-bottom: 8px;
}

/* Visit Mapping */
.visit-mapping {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mapped-visit {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: hsl(210 100% 95%);
    color: var(--primary);
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

/* Field Grid */
.field-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--muted);
    border-radius: var(--radius);
    font-size: 13px;
}

.field-item code {
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    background: var(--background);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--muted-foreground);
}
