:root {
    --accent: #0d6efd;
    --muted: #6c757d;
    --card-bg: #ffffff;
    --gap: 20px;
    --max-width: 1100px;
    --touch-size: 48px;
    --card-padding: 18px;
    --aside-width-desktop: 360px;
    --aside-width-tablet: 320px;
}

/* Base page styles */
body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    margin: 0;
    background: #f7f9fc;
    color: #111;
    -webkit-font-smoothing: antialiased;
    -webkit-font-feature-settings: "liga" 0; /* avoid odd rendering on some small screens */
}

.container-main {
    max-width: var(--max-width);
    margin: 28px auto;
    padding: 0 16px;
    box-sizing: border-box;
}

/* Hero / header */
.hero {
    background: linear-gradient(90deg, rgba(13,110,253,0.06), rgba(13,110,253,0.02));
    padding: 20px 0;
}

.hero > .container-main > .d-flex {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap; /* allow stacking on small screens */
}

/* Brand (logo + title) */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.logo-box {
    width: 64px;
    height: 64px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(16,24,40,0.04);
    flex-shrink: 0;
}

.logo-img {
    width: 48px;
    height: 48px;
    display: block;
}

#svgFallback {
    display: none;
    width: 48px;
    height: 48px;
}

.brand-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #0b5ed7;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-domain {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 2px;
}

/* Cards and layout */
.app-card {
    background: var(--card-bg);
    border: 1px solid #e9edf3;
    border-radius: 10px;
    padding: var(--card-padding);
    box-shadow: 0 6px 18px rgba(16,24,40,0.04);
    box-sizing: border-box;
    width: 100%;
}

.grid-row {
    display: grid;
    gap: var(--gap);
    align-items: start;
    grid-template-columns: 1fr var(--aside-width-desktop);
}

/* Previews / thumbs */
.preview {
    margin-top: 12px;
}

.multi-thumb {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.thumb {
    width: 120px;
    height: 98px;
    border: 1px solid #eef2f7;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.thumb img {
    max-width: 100%;
    max-height: 60px;
    object-fit: cover;
    display: block;
}

.thumb .t-info {
    font-size: 11px;
    color: #444;
    margin-top: 6px;
    text-align: center;
}

/* Form actions */
.form-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Small-screen adjustments */
@media (max-width: 575.98px) {
    :root {
        --card-padding: 14px;
        --gap: 14px;
    }

    .container-main {
        padding: 0 12px;
        margin: 16px auto;
    }

    .hero {
        padding: 12px 0;
    }

    .hero > .container-main > .d-flex {
        gap: 10px;
    }

    /* Stack brand text below logo on very small devices to conserve width */
    .brand {
        gap: 10px;
    }

    .brand-title {
        font-size: 1rem;
    }

    .grid-row {
        grid-template-columns: 1fr; /* single column */
    }

    .thumb {
        width: 96px;
        height: 78px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions .btn {
        width: 100%;
        min-height: var(--touch-size);
    }

    .ms-auto {
        margin-left: 0 !important;
    }

    /* make lead paragraph readable */
    .lead {
        font-size: 0.95rem;
    }
}

/* Tablet (landscape phone and tablets) */
@media (min-width: 576px) and (max-width: 991.98px) {
    :root {
        --aside-width-desktop: var(--aside-width-tablet);
    }

    .container-main {
        padding: 0 16px;
    }

    .grid-row {
        grid-template-columns: 1fr var(--aside-width-tablet);
    }

    .brand-title {
        font-size: 1.12rem;
    }

    .app-card {
        padding: 16px;
    }

    .form-actions .btn {
        min-height: var(--touch-size);
    }
}

/* Desktop and large screens */
@media (min-width: 992px) {
    .container-main {
        padding: 0 20px;
    }

    .grid-row {
        grid-template-columns: 1fr var(--aside-width-desktop);
    }

    .brand-title {
        font-size: 1.15rem;
    }

    .app-card {
        padding: 20px;
    }

    .lead {
        font-size: 1rem;
    }
}

/* Loading overlay */
#loadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1080;
}

#loadingOverlay .spinner-box {
    background: #fff;
    padding: 16px 18px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Buttons while working */
.btn-working {
    pointer-events: none;
    opacity: .7;
}

/* Footer */
footer {
    margin-top: 28px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    padding: 8px 0;
}

/* Modal: ensure QR scales nicely on small screens */
.modal-body img {
    max-width: 100%;
    height: auto;
    width: auto;
    max-height: 60vh;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Accessibility & targets */
.form-control, .btn, .form-actions .btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* Minor visual tweaks */
.muted-note {
    font-size: .9rem;
    color: var(--muted);
    margin-top: 6px;
}

/* Keep fallback svg hidden unless logo fails (same behavior as inline script) */
#svgFallback {
    display: none;
}   