:root {
    --bg: #07111f;
    --bg-soft: #0d1728;
    --panel: rgba(12, 20, 34, 0.94);
    --panel-strong: #101c31;
    --panel-border: rgba(148, 163, 184, 0.14);
    --text: #e5eefb;
    --muted: #94a3b8;
    --muted-2: #cbd5e1;
    --accent: #60a5fa;
    --accent-2: #5eead4;
    --danger: #fb7185;
    --success: #34d399;
    --shadow: 0 24px 60px rgba(2, 6, 23, 0.35);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    margin: 0;
    max-width: 100vw;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, 0.22), transparent 36%),
        radial-gradient(circle at 85% 10%, rgba(94, 234, 212, 0.16), transparent 28%),
        linear-gradient(180deg, #030712 0%, #08101d 46%, #040a13 100%);
}

body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

body.auth-page .auth-shell {
    min-height: auto;
}

a {
    color: inherit;
}

code,
pre,
textarea {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 420px);
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    align-items: stretch;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: linear-gradient(180deg, rgba(16, 28, 49, 0.96), rgba(11, 19, 34, 0.98));
    box-shadow: var(--shadow);
}

.auth-aside {
    padding: 40px;
    background:
        radial-gradient(circle at top right, rgba(94, 234, 212, 0.16), transparent 28%),
        linear-gradient(180deg, rgba(8, 15, 28, 0.96), rgba(7, 12, 22, 0.96));
    border-right: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.22), rgba(94, 234, 212, 0.28));
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #dbeafe;
    font-size: 1.3rem;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.3);
}

.eyebrow {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.title {
    font-size: clamp(1.8rem, 3vw, 3rem);
    line-height: 1.06;
    letter-spacing: -0.04em;
    margin: 0;
}

.copy {
    color: var(--muted-2);
    line-height: 1.7;
    max-width: 52ch;
}

.points {
    display: grid;
    gap: 10px;
    margin-top: auto;
}

.point {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted-2);
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.point i {
    color: #8ec5ff;
}

.auth-panel {
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    width: 100%;
    max-width: 100%;
}

.card h1,
.card h2 {
    margin: 0 0 10px;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 22px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted-2);
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 15px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(7, 12, 22, 0.65);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: rgba(96, 165, 250, 0.38);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
    background: rgba(7, 12, 22, 0.82);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 14px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.18s ease, filter 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.btn-primary {
    width: 100%;
    padding: 13px 16px;
    background: linear-gradient(135deg, #5eead4, #60a5fa);
    color: #08101d;
    box-shadow: 0 14px 30px rgba(96, 165, 250, 0.22);
}

.btn-secondary {
    padding: 13px 16px;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #dbeafe;
}

.btn-ghost {
    padding: 13px 16px;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #dbeafe;
}

.message,
.error {
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    line-height: 1.55;
}

.message {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.18);
    color: #bbf7d0;
}

.error {
    background: rgba(251, 113, 133, 0.12);
    border-color: rgba(251, 113, 133, 0.18);
    color: #fecdd3;
}

.login-footer,
.form-actions,
.script-actions,
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.login-footer {
    flex-direction: column;
    align-items: stretch;
    margin-top: 8px;
}

.note {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
    font-size: 0.92rem;
    color: var(--muted-2);
}

.dashboard-shell {
    min-height: 100vh;
    max-width: 100%;
}

.side {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    overflow-y: auto;
    padding: 28px 22px;
    border-right: 1px solid var(--panel-border);
    background: linear-gradient(180deg, rgba(8, 15, 28, 0.98) 0%, rgba(7, 12, 22, 0.94) 100%);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 100;
}

.side-nav {
    display: grid;
    gap: 8px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--muted-2);
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid transparent;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.side-nav a:hover,
.side-nav a.active {
    transform: translateX(3px);
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.22);
    color: #fff;
}

.side-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.main {
    min-width: 0;
    padding: 26px;
    margin-left: 300px;
    overflow-x: hidden;
}

.surface {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    gap: 22px;
    overflow: hidden;
}

.hero,
.panel,
.metric-card,
.info-card,
.script-card {
    background: linear-gradient(180deg, rgba(16, 28, 49, 0.95), rgba(11, 19, 34, 0.96));
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    max-width: 100%;
    min-width: 0;
}

.hero {
    border-radius: var(--radius-xl);
    padding: 28px;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
    gap: 22px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: -1px;
    background:
        radial-gradient(circle at top right, rgba(94, 234, 212, 0.18), transparent 22%),
        radial-gradient(circle at bottom left, rgba(96, 165, 250, 0.14), transparent 26%);
    pointer-events: none;
}

.hero-content,
.hero-side {
    position: relative;
    z-index: 1;
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.12);
    color: #dbeafe;
    border: 1px solid rgba(96, 165, 250, 0.2);
    font-size: 0.86rem;
}

.hero-title {
    font-size: clamp(1.8rem, 2.4vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}

.hero-text {
    max-width: 62ch;
    color: var(--muted-2);
    line-height: 1.7;
    font-size: 1rem;
}

.hero-meta {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--muted-2);
    font-size: 0.88rem;
}

.hero-side {
    display: grid;
    gap: 12px;
    align-content: start;
}

.hero-side-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.hero-side-card.accent {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
}

.hero-side-card .label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.hero-side-card .value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.hero-side-card .hint {
    display: block;
    margin-top: 8px;
    color: var(--muted-2);
    font-size: 0.88rem;
    line-height: 1.5;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    border-radius: var(--radius-lg);
    padding: 18px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
}

.metric-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.metric-label {
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 10px;
}

.metric-value {
    font-size: clamp(1.6rem, 2vw, 2.15rem);
    letter-spacing: -0.04em;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.16), rgba(94, 234, 212, 0.16));
    color: #eaf2ff;
    flex: 0 0 auto;
}

.metric-meta {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-subtitle,
.metric-trend {
    color: var(--muted-2);
    font-size: 0.88rem;
}

.metric-trend {
    color: #a7f3d0;
}

.panel {
    border-radius: var(--radius-xl);
    padding: 22px;
}

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

.panel-head h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.06rem;
    letter-spacing: -0.02em;
}

.panel-note {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: right;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-card {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
    min-width: 0;
}

.info-card .label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.info-card .value {
    color: #fff;
    word-break: break-word;
    line-height: 1.5;
}

.script-card {
    border-radius: var(--radius-xl);
    padding: 22px;
}

.script-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.script-toolbar h2 {
    font-size: 1.06rem;
    letter-spacing: -0.02em;
}

.script-toolbar p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.script-box {
    display: grid;
    gap: 12px;
}

.code-block {
    width: 100%;
    min-height: 86px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
    color: #dbeafe;
    resize: none;
}

.copy-btn {
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #5eead4, #60a5fa);
    color: #08101d;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(7, 12, 22, 0.35);
}

thead th {
    position: sticky;
    top: 0;
    background: rgba(12, 20, 34, 0.98);
    color: #dbeafe;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 15px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    white-space: nowrap;
}

tbody td {
    padding: 15px 16px;
    color: var(--muted-2);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(96, 165, 250, 0.06);
}

tbody tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.84rem;
    background: rgba(52, 211, 153, 0.12);
    color: #bbf7d0;
    border: 1px solid rgba(52, 211, 153, 0.18);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 32px 20px;
    border-radius: 18px;
    border: 1px dashed rgba(148, 163, 184, 0.18);
    background: rgba(148, 163, 184, 0.04);
}

.clicks-list {
    display: grid;
    gap: 10px;
}

.click-item {
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(94, 234, 212, 0.16));
    display: grid;
    gap: 8px;
}

.click-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.click-label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 600;
}

.click-value {
    color: #fff;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
}

.click-value.tiny {
    font-size: 0.8rem;
    color: var(--muted-2);
}

.tiny {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Top navbar (mobile only) */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: 56px;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    background: rgba(8, 15, 28, 0.95);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--panel-border);
}

.topbar-title {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--muted-2);
}

.topbar-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(148, 163, 184, 0.06);
    color: #dbeafe;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.18s ease;
}

.topbar-btn:hover {
    background: rgba(96, 165, 250, 0.12);
}

/* Profile modal */
.profile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(2, 6, 23, 0.5);
    backdrop-filter: blur(4px);
}

.profile-overlay.open {
    display: block;
}

.profile-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2001;
    width: min(360px, calc(100% - 32px));
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(16, 28, 49, 0.98), rgba(11, 19, 34, 0.99));
    border: 1px solid var(--panel-border);
    box-shadow: 0 32px 80px rgba(2, 6, 23, 0.5);
    overflow: hidden;
}

.profile-modal.open {
    display: block;
}

.profile-modal-head {
    padding: 28px 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.profile-avatar {
    font-size: 2.8rem;
    color: var(--accent);
    margin-bottom: 10px;
}

.profile-modal-head h3 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.profile-modal-email {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0;
}

.profile-modal-body {
    padding: 16px 24px;
}

.profile-modal-item {
    padding: 10px 0;
}

.profile-modal-label {
    display: block;
    font-size: 0.74rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    margin-bottom: 3px;
}

.profile-modal-value {
    color: #fff;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
}

.profile-modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 16px;
    border-radius: 14px;
    background: rgba(251, 113, 133, 0.1);
    border: 1px solid rgba(251, 113, 133, 0.2);
    color: var(--danger);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background-color 0.18s ease;
}

.btn-logout:hover {
    background: rgba(251, 113, 133, 0.18);
}

.side-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(4px);
}

.side-overlay.open {
    display: block;
}

@media (max-width: 1200px) {
    .topbar {
        display: flex;
    }

    .dashboard-shell {
        grid-template-columns: 1fr;
    }

    [id] {
        scroll-margin-top: 72px;
    }

    .side {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1200;
        height: 100vh;
        width: 300px;
        border-right: 1px solid var(--panel-border);
        border-bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .side.open {
        transform: translateX(0);
    }

    .main {
        padding: 16px;
        padding-top: 72px;
        margin-left: 0;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .auth-shell {
        grid-template-columns: 1fr;
        width: min(720px, calc(100% - 24px));
        min-height: auto;
    }

    .auth-aside {
        border-right: 0;
        border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    }

    .auth-panel {
        padding: 28px;
    }
}

@media (max-width: 760px) {
    body {
        padding: 0;
    }

    .main {
        padding: 16px;
        padding-top: 72px;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 18px;
        border-radius: var(--radius-lg);
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-text {
        font-size: 0.92rem;
    }

    .hero-meta {
        flex-direction: column;
        gap: 8px;
    }

    .meta-chip {
        font-size: 0.82rem;
        padding: 8px 10px;
    }

    .hero-side-card .value {
        font-size: 1.4rem;
    }

    .metrics-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        border-radius: var(--radius-md);
        padding: 14px;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    .panel {
        padding: 14px;
        border-radius: var(--radius-lg);
    }

    .panel-head,
    .script-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-note {
        text-align: left;
    }

    .script-card {
        padding: 14px;
        border-radius: var(--radius-lg);
    }

    .surface {
        gap: 16px;
    }

    table {
        font-size: 0.82rem;
    }

    thead th,
    tbody td {
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    tbody td {
        word-break: break-word;
    }

    .hero-kicker {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .copy-btn {
        width: 100%;
    }
}
