:root {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --accent: #f43f5e;
    --bg-dark: #020617;
    --glass: rgba(15, 23, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-muted: #94a3b8;
    --emerald: #10b981;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Outfit", sans-serif;
    background: radial-gradient(circle at 10% 20%, #0f172a 0%, #020617 100%);
    color: #f8fafc;
    min-height: 100vh;
}

main {
    max-width: 980px;
    margin: 96px auto 24px;
    padding: 0 16px;
}

body.popup-flow {
    min-height: 100vh;
    overflow: hidden;
}

body.popup-flow main {
    max-width: 440px;
    margin: 18px auto;
    padding: 0 10px;
}

body.popup-flow #app-bar {
    display: none !important;
}

body.popup-flow .card {
    min-height: calc(100vh - 36px);
    border-radius: 18px;
}

body.popup-flow #auth-view,
body.popup-flow #activation-view,
body.popup-flow #home-view {
    display: none !important;
}

body.popup-flow #loading-view.hidden {
    display: block !important;
}

.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(12px);
}

.loading-shell {
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loading-orb {
    width: 68px;
    height: 68px;
    margin-bottom: 18px;
    border-radius: 50%;
    border: 3px solid rgba(99, 102, 241, 0.18);
    border-top-color: #818cf8;
    border-right-color: #f43f5e;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.18);
    animation: spin 0.9s linear infinite;
}

.hero-kicker {
    display: inline-block;
    margin-bottom: 12px;
    padding: 6px 10px;
    border: 1px solid rgba(129, 140, 248, 0.28);
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.12);
}

.hidden {
    display: none;
}

h1,
h2,
h3 {
    margin: 0 0 10px;
}

p {
    margin: 0 0 16px;
    color: var(--text-muted);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0 8px;
}

.info-item {
    padding: 16px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.32);
}

.info-item h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.info-item p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

label {
    display: block;
    font-size: 0.9rem;
    margin-top: 12px;
    margin-bottom: 6px;
}

input,
select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
}

.primary-btn {
    margin-top: 16px;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.primary-btn:hover {
    opacity: 0.95;
}

.status-note {
    margin-top: 12px;
    color: #cbd5e1;
}

.action-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-btn {
    margin-top: 0;
}

.result-box {
    margin-top: 18px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    background: rgba(2, 6, 23, 0.45);
}

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

.result-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.secondary-btn,
.ghost-btn {
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
}

.secondary-btn {
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.12);
    color: #e0e7ff;
}

.ghost-btn {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: #f8fafc;
}

.secondary-btn:disabled,
.ghost-btn:disabled,
.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.doc-pill {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #a7f3d0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.doc-type-copy {
    margin: 8px 0 0;
    font-size: 0.9rem;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    color: #cbd5e1;
}

/* Result Formatting Styles */
.result-section {
    margin-bottom: 24px;
}

.result-section h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 6px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.summary-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.result-table th,
.result-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.result-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
}

.result-table tr:last-child td {
    border-bottom: none;
}

.raw-json-section summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    user-select: none;
    padding: 8px 0;
}

.raw-json-pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
}

/* Standardized App Shell styles managed via shell.css */


.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
}

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

/* New Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.stream-container {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    font-family: "Fira Code", monospace;
    position: relative;
    overflow: hidden;
}

.stream-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--emerald), transparent);
    animation: scan 2s linear infinite;
    display: none;
}

.stream-container.scanning::after {
    display: block;
}

.stream-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stream-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
}

.scanning .stream-dot {
    background: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
    animation: pulse 1s infinite;
}

.stream-log {
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    opacity: 0.7;
    animation: slideIn 0.3s ease-out forwards;
}

.log-entry.success { color: var(--emerald); opacity: 1; }
.log-entry.info { color: var(--primary); }

footer {
    margin-top: 80px;
    padding: 40px 20px;
    border-top: 1px solid var(--glass-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.footer-divider { opacity: 0.3; }
.powered-by strong { color: #fff; font-weight: 700; }

@keyframes scan {
    0% { top: -5%; }
    100% { top: 105%; }
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 800px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .info-grid {
        grid-template-columns: 1fr;
    }

    .action-row,
    .result-header {
        flex-direction: column;
    }

    .result-actions {
        width: 100%;
    }

    .result-actions button {
        width: 100%;
    }
}
