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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Flash messages */
.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.flash-error { background: #fee; border-left: 4px solid #c00; }
.flash-success { background: #efe; border-left: 4px solid #0a0; }
.flash-warning { background: #ffe; border-left: 4px solid #a80; }
.flash-info { background: #eef; border-left: 4px solid #06c; }

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    margin-bottom: 0.5rem;
    color: #2563eb;
}

.subtitle {
    color: #666;
    margin-bottom: 2rem;
}

.description {
    margin-bottom: 2rem;
    color: #555;
}

.notice {
    margin-top: 2rem;
    font-size: 0.875rem;
    color: #888;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-success {
    background: #059669;
    color: white;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}

/* Dashboard */
.dashboard {
    min-height: 100vh;
}

.header {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    color: #2563eb;
}

.user-email {
    color: #666;
    font-size: 0.875rem;
    margin-left: 1rem;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    color: #666;
    font-size: 0.875rem;
}

/* Email list */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.email-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.email-card.processed {
    background: #f0fdf4;
}

.email-card.marked-for-deletion {
    opacity: 0.5;
    background: #f3f4f6;
    border-left: 3px solid #9ca3af;
}

.email-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.email-date {
    font-size: 0.875rem;
    color: #666;
}

.badge {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.email-subject {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.email-from {
    color: #666;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.email-summary {
    font-size: 0.875rem;
    color: #059669;
    font-style: italic;
    margin-bottom: 0.5rem;
}

/* Patient info */
.patient-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.patient-label {
    font-weight: 600;
    color: #92400e;
}

.patient-name {
    font-weight: 600;
    color: #78350f;
}

.patient-dob {
    color: #92400e;
}

.patient-insurance {
    color: #a16207;
    font-family: monospace;
    font-size: 0.8125rem;
}

.email-snippet {
    color: #888;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.email-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-text {
    font-size: 0.875rem;
    color: #059669;
}

.status-text.error {
    color: #dc2626;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem;
    color: #666;
}

/* Settings */
.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.settings-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-card {
    padding: 1rem;
    background: #f9fafb;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-name {
    font-weight: 500;
}

.device-info {
    font-size: 0.875rem;
    color: #666;
    display: flex;
    gap: 1rem;
    flex: 1;
}

.device-meta {
    font-size: 0.75rem;
    color: #999;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Sections */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #374151;
}

/* Badge variants */
.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-muted {
    background: #e5e7eb;
    color: #6b7280;
}

/* Status messages */
.status-ok {
    color: #059669;
}

.status-warn {
    color: #d97706;
}

/* TOTP setup */
.totp-setup {
    margin: 2rem 0;
    text-align: center;
}

.totp-secret {
    background: #f3f4f6;
    padding: 1rem;
    border-radius: 8px;
    font-family: monospace;
    margin-bottom: 1rem;
    word-break: break-all;
}

.totp-qr {
    margin: 1rem 0;
}

/* Already processed emails */
.already-processed {
    opacity: 0.5;
}

/* Login form */
.login-form {
    text-align: left;
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* Status card */
.status-section {
    margin-bottom: 2rem;
}

.status-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-card.status-test {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.status-card.status-production {
    border-left: 4px solid #059669;
    background: #ecfdf5;
}

.status-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.status-label {
    font-weight: 500;
    color: #6b7280;
}

.status-value {
    font-weight: 600;
    color: #111827;
}

.status-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.status-times {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.status-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* Empty state hint */
.empty-state .hint {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

/* File download links */
.email-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.file-link {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #2563eb;
    text-decoration: none;
}

.file-link:hover {
    background: #e5e7eb;
    text-decoration: underline;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-checkbox {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Section header with bulk actions */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin: 0;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Email card with checkbox */
.email-card {
    display: flex;
    gap: 1rem;
}

.email-select {
    display: flex;
    align-items: flex-start;
    padding-top: 0.25rem;
}

.email-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.email-content {
    flex: 1;
}

/* Danger button */
.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger:disabled {
    background: #fca5a5;
    cursor: not-allowed;
}

/* Content rows - for email body and attachments */
.content-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    min-width: 0; /* Allow flex items to shrink below content size */
}

.email-body-row {
    border-left: 3px solid #2563eb;
}

.attachment-row {
    border-left: 3px solid #059669;
}

.row-label {
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.row-filename {
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-filename:hover {
    text-decoration: underline;
}

.row-summary {
    flex: 1;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8125rem;
    min-width: 0; /* Allow text to truncate */
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.btn-copy {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: #1d4ed8;
}

.btn-copy.copied {
    background: #059669;
}
