:root {
    --primary: #008080;
    --primary-dark: #006666;
    --primary-light: #00a0a0;
    --accent: #f0e68c;
    --accent-dark: #daa520;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.25rem;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: 0.3s;
}

nav {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
    max-width: 1200px;
    margin: 0 auto;
}

nav.open {
    display: flex;
}

nav a {
    color: var(--accent);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background 0.2s;
}

nav a:hover {
    background: rgba(255,255,255,0.1);
}

@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }
    
    nav {
        display: flex;
        flex-direction: row;
        padding: 0.5rem 0;
    }
}

main {
    flex: 1;
    padding: 1.5rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

footer {
    background: var(--primary-dark);
    color: var(--accent);
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

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

.hero h1 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.hero p {
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-actions h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.action-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.action-icon {
    font-size: 1.5rem;
}

.action-text {
    font-weight: 600;
    color: var(--primary);
}

.action-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
}

.page-header p {
    color: var(--text-muted);
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-block {
    width: 100%;
}

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

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid {
    display: flex;
    flex-direction: column;
}

.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.upload-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.upload-area:hover,
.upload-area.has-file {
    border-color: var(--primary);
    background: rgba(0, 128, 128, 0.05);
}

.upload-area input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-text {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin: 1rem 0;
}

.file-preview.hidden {
    display: none;
}

.file-name {
    font-weight: 500;
    word-break: break-all;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-weight: 600;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.info-card h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.info-card li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.file-card:hover {
    transform: translateX(4px);
}

.file-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-info .file-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-arrow {
    color: var(--primary);
    font-size: 1.25rem;
}

.section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.section-card h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.file-detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detail-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 500;
}

.extracted-text {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.labs-table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 640px) {
    .data-table thead {
        display: none;
    }
    
    .data-table tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        background: var(--bg);
        border-radius: var(--radius-sm);
    }
    
    .data-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }
    
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
    }
}

.vitals-list {
    display: grid;
    gap: 0.75rem;
}

.vital-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.vital-type {
    font-weight: 500;
}

.vital-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.vital-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.insights-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-stat {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.insight-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.insight-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.insight-section {
    margin-bottom: 1rem;
}

.insight-text {
    font-size: 1rem;
    line-height: 1.7;
}

.insight-list {
    list-style: none;
    padding: 0;
}

.insight-list li {
    padding: 0.75rem;
    padding-left: 2rem;
    position: relative;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.insight-list li::before {
    content: "→";
    position: absolute;
    left: 0.75rem;
    color: var(--primary);
}

.insight-list.alerts li {
    background: #fef3c7;
    color: #92400e;
}

.insight-list.alerts li::before {
    content: "⚠";
    color: var(--warning);
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-container {
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

@media (max-width: 480px) {
    .action-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .vital-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
