* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Constrain tab content to reasonable width and center */
.tab-content {
    display: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tab-content.active {
    display: block !important;
    animation: fadeIn 0.3s;
}

.tab-content > article.card {
    max-width: 1350px;
    margin-left: auto;
    margin-right: auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.3s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    width: 100%;
    max-width: 1350px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Constrain card content to match input width */
.card > * {
    max-width: 100%;
    box-sizing: border-box;
}

.card h2 {
    margin-bottom: 20px;
    color: var(--text);
    font-size: 1.75rem;
}

/* Input Groups */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-group {
    max-width: 100%;
    width: 100%;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    max-width: 100%;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

#image-input {
    display: none;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.upload-icon {
    font-size: 3rem;
}

.upload-hint {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Preview Container */
.preview-container {
    margin-bottom: 20px;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Results Container */
.results-container {
    margin-top: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.result-item {
    background: var(--bg);
    border-left: 4px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.result-item.success {
    border-left-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.result-item.warning {
    border-left-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.result-item.error {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.result-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.result-content {
    flex: 1;
}

.result-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.result-details {
    color: var(--text-light);
    font-size: 0.9rem;
}

.result-value {
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
}

/* BIMI Preview */
.bimi-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.preview-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.preview-card h4 {
    margin-bottom: 15px;
    color: var(--text);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.email-preview {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 15px;
    min-height: 100px;
}

.email-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.bimi-logo {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.email-from {
    flex: 1;
}

.email-from-name {
    font-weight: 600;
    color: var(--text);
}

.email-from-address {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Info Content */
.info-content {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.info-content section {
    margin-bottom: 40px;
}

.info-content h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.info-content p {
    margin-bottom: 15px;
    color: var(--text);
    line-height: 1.8;
}

.info-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.info-content li {
    margin-bottom: 8px;
    color: var(--text);
}

.info-text {
    color: var(--text-light);
    margin-bottom: 20px;
}

.cert-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.cert-option {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.cert-option h4 {
    color: var(--primary);
    margin-bottom: 12px;
}

.deliverability-tips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure all content inside cards respects container width */
.card h2,
.card h3,
.card h4,
.card p,
.card ul,
.card ol,
.card div,
.card section {
    max-width: 100%;
    box-sizing: border-box;
}

/* Prevent any element from overflowing */
.card * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure grids don't exceed container */
.services-grid,
.cert-options,
.deliverability-tips,
.platform-features {
    max-width: 100%;
    overflow-x: hidden;
}

/* Constrain service cards */
.service-card {
    min-width: 0; /* Allow flex items to shrink */
    overflow-wrap: break-word;
}

.tip {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tip h4 {
    margin-bottom: 10px;
    color: var(--text);
}

.tip p {
    color: var(--text-light);
    font-size: 0.95rem;
}

pre {
    background: var(--bg);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    word-break: break-all;
}

code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Download Button */
.btn-download {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.3s;
}

.btn-download:hover {
    background: #059669;
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Footer styles */
footer {
    background: var(--bg);
}

footer nav ul {
    font-size: 0.9rem;
}

footer nav a:hover {
    text-decoration: underline;
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 30px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.service-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.service-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.service-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    text-align: center;
}

.service-card h3 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.service-card p {
    color: var(--text);
    margin-bottom: 15px;
    line-height: 1.6;
}

.service-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.service-features li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text);
    font-size: 0.95rem;
}

.service-features li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

.platform-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.platform-feature {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.platform-feature strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.platform-feature p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
    line-height: 1.5;
}

.checking-status {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .tabs {
        flex-direction: column;
    }

    .input-group {
        flex-direction: column;
    }

    .bimi-preview {
        grid-template-columns: 1fr;
    }
}

