body {
    min-height: 100dvh;
}

/* ============================================================
   Login Screen
   ============================================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
}

.login-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--ds-glass-saturate));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--ds-glass-saturate));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md), var(--ds-glass-inset-shadow);
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    margin-bottom: 16px;
    outline: none;
    transition: border-color .2s;
}
.login-input:focus { border-color: var(--blue); }

.login-btn {
    width: 100%;
    min-height: var(--touch-target);
    padding: 14px 16px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s var(--ease-standard), transform .2s var(--ease-standard);
}
.login-btn:hover { opacity: .85; }
.login-btn:active { transform: scale(0.985); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }

.login-error {
    color: var(--red);
    font-size: 14px;
    margin-top: 12px;
    display: none;
}

.login-footer {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================================
   Dashboard Layout
   ============================================================ */
.dashboard { display: none; }
.dashboard.active { display: block; }
.login-screen.hidden { display: none; }

.dash-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
    backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
}

.dash-nav-inner {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-nav-logo {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.dash-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
}
.dash-logout:hover { background: var(--surface); }

.dash-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.dash-header {
    margin-bottom: 32px;
}

.dash-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.dash-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ============================================================
   Period Selector
   ============================================================ */
.period-selector {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 4px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    width: fit-content;
}

.period-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    transition:
        background-color .2s var(--ease-standard),
        color .2s var(--ease-standard),
        transform .2s var(--ease-standard);
}
.period-btn.active {
    background: var(--blue);
    color: white;
}
.period-btn:active { transform: scale(0.985); }

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-change {
    font-size: 13px;
    margin-top: 4px;
}
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ============================================================
   Charts
   ============================================================ */
.chart-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

@media (max-width: 768px) {
    .chart-section { grid-template-columns: 1fr; }
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-spaced {
    margin-bottom: 32px;
}

.card-subsection {
    margin-top: 20px;
}

.card-title-compact {
    font-size: 14px;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   Funnel
   ============================================================ */
.funnel-stage {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.funnel-stage:last-child { border-bottom: none; }

.funnel-bar-wrap {
    flex: 1;
    min-width: 0;
}

.funnel-label {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.funnel-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.funnel-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--blue);
    transition: width .6s var(--ease-emphasized);
}

.funnel-count {
    font-size: 20px;
    font-weight: 700;
    min-width: 60px;
    text-align: right;
}

.funnel-rate {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

/* ============================================================
   Origins Table
   ============================================================ */
.origins-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 32px;
}

.origins-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}

.origins-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

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

.origin-domain {
    font-weight: 500;
    font-family: var(--mono);
    font-size: 13px;
}

/* ============================================================
   API Key & Domains
   ============================================================ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 14px;
    word-break: break-all;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    font-family: var(--font);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}
.copy-btn:hover { background: rgba(0,122,255,.1); }

.domain-list {
    list-style: none;
}

.domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.domain-item:last-child { border-bottom: none; }

.domain-name {
    font-family: var(--mono);
    font-size: 13px;
}

.domain-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.domain-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.domain-status.verified { background: rgba(52,199,89,.15); color: var(--green); }
.domain-status.pending { background: rgba(255,149,0,.15); color: var(--orange); }

.domain-remove {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    font-family: var(--font);
}

.add-domain-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.add-domain-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    outline: none;
}
.add-domain-input:focus { border-color: var(--blue); }

.add-domain-btn {
    padding: 10px 16px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    white-space: nowrap;
}
.add-domain-btn:hover { opacity: .85; }

/* ============================================================
   Snippet
   ============================================================ */
.snippet-block {
    background: #1a1a2e;
    border-radius: var(--radius-sm);
    padding: 20px;
    color: #e0e0e0;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    overflow-x: auto;
    position: relative;
}

.snippet-copy {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,.1);
    border: none;
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
}
.snippet-copy:hover { background: rgba(255,255,255,.2); }

/* ============================================================
   Loading
   ============================================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
    font-size: 15px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-right: 12px;
}

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