:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --border: #e2e8f0;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin: 0 0 6px 0;
    font-size: 1.6rem;
}

.subtitle {
    margin: 0 0 22px 0;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-form label {
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-form input {
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.auth-form input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.25);
    border-color: var(--primary);
}

.auth-form button {
    margin-top: 6px;
    height: 46px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-form button:hover {
    background: var(--primary-dark);
}

.alert {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.dashboard-page {
    min-height: 100vh;
}

.topbar {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.topbar-wide {
    width: 100%;
}

.brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    color: var(--muted);
    font-size: 0.95rem;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 7px 11px;
}

.logout-btn {
    text-decoration: none;
    background: #0f172a;
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.dashboard-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
}

.dashboard-intro h1 {
    margin: 0;
    font-size: 1.75rem;
}

.dashboard-intro p {
    margin: 8px 0 0 0;
    color: var(--muted);
}

.dashboard-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.calc-card {
    cursor: pointer;
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    color: inherit;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    min-height: 168px;
}

.calc-card h2 {
    margin: 0 0 10px 0;
    font-size: 1.25rem;
}

.calc-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.card-arrow {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 600;
    align-self: flex-start;
}

.calc-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.1);
    border-color: #c7d2fe;
}

.viewer-page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.viewer-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.viewer-left {
    justify-self: start;
}

.viewer-right {
    justify-self: end;
}

.viewer-title {
    font-weight: 600;
    text-align: center;
    color: var(--text);
}

.back-btn {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: #eff6ff;
}

.viewer-shell {
    height: calc(100vh - 65px);
}

.viewer-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

@media (max-width: 768px) {
    .topbar {
        padding: 16px;
    }

    .dashboard-shell {
        padding: 16px;
    }

    .dashboard-intro h1 {
        font-size: 1.4rem;
    }

    .viewer-topbar {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }

    .viewer-left,
    .viewer-right {
        justify-self: center;
    }

    .viewer-shell {
        height: calc(100vh - 122px);
    }
}
