:root {
    --bg-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-main: #0a0a0a;
    --text-muted: #737373;
    --border-color: #e5e5e5;
    --primary-color: #000000;
    --primary-hover: #262626;
    --secondary-color: #f5f5f5;
    --secondary-hover: #e5e5e5;
    --success-bg: #f0fdf4;
    --success-text: #166534;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(#d4d4d4 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 900px; margin: 0 auto; padding: 4rem 1.5rem; }

header { margin-bottom: 3.5rem; text-align: center; }
header h1 { font-weight: 500; font-size: 2rem; letter-spacing: -0.04em; color: var(--text-main); }
header h1 span { color: var(--text-muted); font-weight: 300; }

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.03);
    transition: all 0.3s ease;
}
.card:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,0.06);
}

.card h2 { font-weight: 500; font-size: 1.1rem; letter-spacing: -0.02em; margin-bottom: 1.5rem; color: var(--text-main); display: flex; justify-content: space-between; align-items: center; }

.input-group { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.input-group input {
    flex: 1 1 200px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    background: transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus { border-color: var(--text-main); box-shadow: 0 0 0 1px var(--text-main); }
.input-group input::placeholder { color: #a3a3a3; }

.btn {
    padding: 0.75rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.btn.primary { background: var(--primary-color); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.btn.secondary { background: var(--secondary-color); color: var(--text-main); border-color: var(--border-color); }
.btn.secondary:hover { background: var(--secondary-hover); }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.icon-btn { background: transparent; color: var(--text-muted); padding: 0.5rem; font-size: 0.9rem; border: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-weight: 400;}
.icon-btn:hover { color: var(--text-main); }

/* Auth Modal styling */
.auth-modal { position: fixed; inset: 0; background: rgba(255,255,255,0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; justify-content: center; align-items: center; z-index: 1000; transition: opacity 0.3s; }
.auth-modal.hidden { display: none; opacity: 0; }
.auth-card { background: var(--card-bg); padding: 3rem 2.5rem; border-radius: 16px; border: 1px solid var(--border-color); width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.05); }
.auth-card h2 { font-weight: 500; font-size: 1.25rem; text-align: center; margin-bottom: 2rem; color: var(--text-main); }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form input { padding: 0.85rem 1.25rem; border: 1px solid var(--border-color); border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 1rem; outline: none; background: transparent; transition: 0.2s;}
.auth-form input:focus { border-color: var(--text-main); box-shadow: 0 0 0 1px var(--text-main); }
.auth-form input.hidden { display: none; }
.auth-links { margin-top: 1.5rem; display: flex; justify-content: space-between; font-size: 0.85rem; }
.auth-links a { color: var(--text-muted); text-decoration: none; transition: 0.2s; }
.auth-links a:hover { color: var(--text-main); }

/* UTM Builder styling */
.utm-builder {
    margin-top: 1.5rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(250, 250, 250, 0.5);
}
.utm-builder.hidden { display: none; }
.utm-header h3 { font-weight: 500; font-size: 0.95rem; margin-bottom: 1.5rem; color: var(--text-main); display: flex; align-items: center; justify-content: space-between; }
.utm-form { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.utm-field { display: flex; align-items: center; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; overflow: hidden; }
.utm-field label { background: transparent; color: var(--text-muted); padding: 0.75rem 1rem; width: 120px; font-weight: 400; font-size: 0.85rem; border-right: 1px solid var(--border-color); }
.utm-field input { flex: 1; border: none; padding: 0.75rem 1rem; font-size: 0.95rem; outline: none; background: transparent; color: var(--text-main); }
.utm-field input::placeholder { color: #d4d4d4; }
.utm-preview { margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-muted); padding-top: 1rem; border-top: 1px solid var(--border-color); word-break: break-all; }

/* Result Box */
.result-box { margin-top: 1.5rem; padding: 1.25rem 1.5rem; background: var(--secondary-color); border: 1px solid var(--border-color); border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.result-box.hidden { display: none; }
#shortLinkResult { font-size: 1rem; font-weight: 500; color: var(--text-main); }

/* Analytics Table */
.table-container { overflow-x: auto; margin-top: 0.5rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 1.25rem 0.5rem; border-bottom: 1px solid var(--border-color); }
th { background: transparent; color: var(--text-muted); font-weight: 400; font-size: 0.85rem; letter-spacing: 0.02em; }
td { font-size: 0.95rem; color: var(--text-main); }
tr:last-child td { border-bottom: none; }
td a { color: var(--text-muted); text-decoration: none; border-bottom: 1px dotted var(--text-muted); transition: color 0.2s;}
td a:hover { color: var(--text-main); border-bottom-style: solid; }

.trend-up { color: var(--success-text); font-weight: 500; font-size: 0.85rem; background: var(--success-bg); padding: 0.25rem 0.5rem; border-radius: 6px; }
.trend-down { color: var(--danger-text); font-weight: 500; font-size: 0.85rem; background: var(--danger-bg); padding: 0.25rem 0.5rem; border-radius: 6px; }
.trend-neutral { color: var(--text-muted); font-size: 0.85rem; background: var(--secondary-color); padding: 0.25rem 0.5rem; border-radius: 6px; }

/* ── Global utility ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Modal overlay (auth modal + pair modal) ─────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.hidden { display: none !important; }

/* ── Modal card ──────────────────────────────────────────────────────────── */
.modal-card {
    background: #ffffff;
    padding: 3rem 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 48px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.modal-card h2 {
    font-weight: 500;
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 1.75rem;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

/* ── Logo wrapper ────────────────────────────────────────────────────────── */
.logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

/* ── Auth error ──────────────────────────────────────────────────────────── */
.auth-error {
    margin-top: 1rem;
    font-size: 0.85rem;
    text-align: center;
    min-height: 1.25em;
    color: var(--danger-text);
}

/* ── Header layout (overrides the text-align:center from above) ──────────── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    text-align: left;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Card header (title row with inline action button) ───────────────────── */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.card-header h2 { margin-bottom: 0; }

/* ── Outline button ──────────────────────────────────────────────────────── */
.btn.outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.btn.outline:hover {
    background: var(--secondary-color);
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* ── UTM grid ────────────────────────────────────────────────────────────── */
.utm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(250, 250, 250, 0.6);
}
.utm-grid input {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    outline: none;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.2s;
}
.utm-grid input:focus { border-color: var(--text-main); box-shadow: 0 0 0 1px var(--text-main); }
.utm-grid input::placeholder { color: #c4c4c4; }
.utm-grid.hidden { display: none !important; }

/* ── Destination preview box ─────────────────────────────────────────────── */
.preview-box {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.5;
    word-break: break-all;
}
.preview-label { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.preview-url { color: var(--text-main); }
