:root {
    --bg0: #0b1220;
    --bg1: #111b2e;
    --card: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #e8eefc;
    --muted: #9fb0d0;
    --accent: #2dd4bf;
    --accent2: #22c55e;
    --danger: #f87171;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    --radius: 16px;
    --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--text);
    background: radial-gradient(1200px 800px at 10% -10%, #1a2b45 0%, transparent 55%),
        radial-gradient(900px 600px at 100% 0%, #0f766e 0%, transparent 45%),
        linear-gradient(165deg, var(--bg0), var(--bg1));
}

body {
    line-height: 1.5;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
    pointer-events: none;
    z-index: 0;
}

.app-wrap {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    box-shadow: 0 8px 24px rgba(45, 212, 191, 0.35);
}

.brand strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--muted);
}

.auth-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-pill {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: var(--card);
}

.main {
    flex: 1;
}

.hero h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.muted strong {
    color: #cbd5f5;
}

.small {
    font-size: 0.85rem;
}

.inline {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--card-border);
}

.panel {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.panel-login {
    max-width: 420px;
    margin: 2rem auto;
}

.panel-head h1 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.25rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field span {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    border-color: rgba(45, 212, 191, 0.55);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

.lookup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.lookup-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1.1rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--card-border);
}

.filter-hint {
    margin: 0.65rem 0 0;
}

.optional {
    font-weight: 400;
    color: var(--muted);
    font-size: 0.78em;
}

.field input[type="date"] {
    color-scheme: dark;
    min-height: 44px;
}

.grow {
    flex: 1 1 220px;
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 12px;
    padding: 0.7rem 1.25rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.15s ease;
    min-height: 44px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    color: #042f2e;
    background: linear-gradient(135deg, #5eead4, var(--accent));
    box-shadow: 0 12px 32px rgba(45, 212, 191, 0.35);
}

.btn-ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #042f2e;
    animation: spin 0.7s linear infinite;
}

.btn-primary .btn-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #042f2e;
}

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

.msg {
    font-size: 0.9rem;
    margin: 0;
}

.msg-error {
    color: #fecaca;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.2);
}

.stat-card.accent {
    border-color: rgba(45, 212, 191, 0.45);
    background: linear-gradient(145deg, rgba(45, 212, 191, 0.12), rgba(0, 0, 0, 0.2));
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-hint {
    display: block;
    margin-top: 0.35rem;
    font-weight: 400;
    line-height: 1.35;
}

.referrer-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(59, 130, 246, 0.1);
}

.pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.25);
    color: #bfdbfe;
    margin-bottom: 0.35rem;
}

.referrer-name {
    margin: 0;
    font-weight: 600;
    font-size: 1.05rem;
}

.table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.2);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 720px;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.25);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    border: 1px dashed var(--card-border);
    border-radius: var(--radius);
}

.footer {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    padding-top: 1rem;
}

@media (max-width: 520px) {
    .lookup-row .btn {
        width: 100%;
    }
}
