/* Dashboard + login */
body > .dash { flex: 1; }
.dash { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; width: 100%; }
.mobile-bar { display: none; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 32px;
    padding: 26px 16px 20px;
    background: linear-gradient(180deg, rgba(10, 20, 46, .85), rgba(5, 10, 26, .9));
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
}
.side-logo { padding: 0 10px; }
.side-nav { display: grid; gap: 6px; }

/* Active item: a glowing gradient underlay rising from beneath the label */
.side-link {
    position: relative;
    isolation: isolate;
    display: block;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    overflow: hidden;
    transition: color .2s, transform .2s;
}
.side-link::before {
    content: "";
    position: absolute; inset: 0; z-index: -1;
    border-radius: inherit;
    background:
        radial-gradient(120% 140% at 50% 130%, rgba(127, 219, 255, .38), rgba(77, 163, 255, .12) 55%, transparent 80%);
    opacity: 0;
    transform: translateY(40%);
    transition: opacity .3s, transform .3s;
}
.side-link::after {
    content: "";
    position: absolute; left: 16px; right: 16px; bottom: 0; height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--baby-blue), transparent);
    opacity: 0;
    transition: opacity .3s;
}
.side-link:hover { color: var(--white); transform: translateX(2px); }
.side-link:hover::before { opacity: .55; transform: none; }
.side-link.active { color: var(--white); font-weight: 600; transform: none; }
.side-link.active::before { opacity: 1; transform: none; }
.side-link.active::after { opacity: 1; }

.side-user {
    margin-top: auto;
    display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--baby-blue), var(--blue)); color: #05122b; font-weight: 800; }
.side-user-info { display: grid; line-height: 1.2; min-width: 0; }
.side-user-info strong { color: var(--white); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-info span { color: var(--muted); font-size: .78rem; }
.side-user form { grid-column: 1 / -1; }
.icon-btn { width: 100%; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.icon-btn:hover { color: var(--white); border-color: var(--border-strong); background: var(--surface-strong); }

.content { padding: 44px clamp(20px, 4vw, 60px) 72px; max-width: 1140px; width: 100%; }
.page-head { margin-bottom: 32px; }
.page-head h1 { margin: 0 0 6px; font-size: clamp(1.8rem, 3vw, 2.3rem); letter-spacing: -.035em; color: var(--white); }
.page-head p { margin: 0; }
.small { font-size: .82rem; }

/* Button text must stay dark on the filled button, whatever element it is */
.content .btn:not(.btn-ghost):not(.btn-danger) { color: #05122b; }
.content .btn.btn-ghost { color: var(--white); }
.btn { background-image: linear-gradient(135deg, var(--baby-blue), #5cc3ff); }
.btn-ghost, .btn-danger { background-image: none; }

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 26px;
    margin-bottom: 22px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.panel h3 { margin: 0 0 16px; color: var(--white); font-size: 1.05rem; letter-spacing: -.01em; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-size: .92rem; border: 1px solid; }
.alert-success { background: rgba(31, 212, 123, .1); border-color: rgba(31, 212, 123, .4); color: #8ff0bd; }
.alert-error { background: rgba(255, 77, 77, .1); border-color: rgba(255, 77, 77, .45); color: #ff9c9c; }

/* Overview */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    display: grid; gap: 6px;
    padding: 22px;
    background: linear-gradient(160deg, rgba(127, 219, 255, .08), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: transform .2s, border-color .2s;
}
a.stat:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.stat-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; color: var(--white); }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat-sub { color: var(--muted); font-size: .85rem; }
.bar { height: 6px; background: rgba(255, 255, 255, .08); border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--blue), var(--baby-blue)); border-radius: 99px; }
.upsell { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-color: var(--border-strong); }
.upsell h3 { margin-bottom: 4px; }
.upsell p { margin: 0; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.input, .field input[type=email], .field input[type=password] {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(5, 12, 30, .7);
    color: var(--white);
    font: inherit;
}
.input:focus, .field input:focus { outline: none; border-color: var(--baby-blue); box-shadow: 0 0 0 3px rgba(127, 219, 255, .15); }
select.input option { background: #0b1530; }
input[type=color] { width: 100%; height: 42px; padding: 4px; border-radius: 10px; border: 1px solid var(--border); background: rgba(5, 12, 30, .7); cursor: pointer; }
.inline-form { display: flex; gap: 10px; }
.inline-form .input { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; color: var(--muted); font-size: .9rem; cursor: pointer; }
.check input { accent-color: var(--baby-blue); width: 16px; height: 16px; }
.btn-danger { background: transparent; color: #ff8a8a; border-color: rgba(255, 77, 77, .4); }
.btn-danger:hover { background: rgba(255, 77, 77, .12); box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* Links table */
.table { display: grid; }
.row {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr) 80px auto;
    gap: 14px; align-items: center;
    padding: 12px 4px;
    border-top: 1px solid var(--border);
}
.row.no-views, .row.head.no-views { grid-template-columns: 170px minmax(0, 1fr) auto; }
.row.head { border-top: 0; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; padding-top: 0; }
.row a { color: var(--baby-blue); text-decoration: none; font-weight: 600; }
.row a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.end { justify-self: end; }
.clip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.edit-form { grid-column: 1 / -1; }
.edit-form[hidden] { display: none; }

/* QR */
.qr-form { display: grid; grid-template-columns: 1fr 260px; gap: 32px; align-items: start; }
.seg { display: inline-flex; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: rgba(5, 12, 30, .6); margin-bottom: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 22px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg input:checked + span { background: var(--baby-blue); color: #05122b; }
.seg input:focus-visible + span { outline: 2px solid var(--white); }
.qr-side { display: grid; gap: 14px; justify-items: center; }
.qr-preview { background: #fff; border-radius: 16px; padding: 6px; min-height: 232px; min-width: 232px; display: grid; place-items: center; }
.qr-preview canvas, .qr-thumb canvas { max-width: 100%; height: auto !important; border-radius: 10px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.qr-card { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: rgba(5, 12, 30, .5); transition: transform .2s, border-color .2s; }
.qr-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.qr-thumb { justify-self: center; background: #fff; border-radius: 12px; line-height: 0; }
.qr-meta { display: grid; gap: 2px; min-width: 0; }
.qr-meta a { color: var(--baby-blue); text-decoration: none; font-weight: 600; }

/* Login */
.auth-card {
    width: 100%; max-width: 420px;
    padding: 36px 32px;
    background: linear-gradient(160deg, rgba(127, 219, 255, .07), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.7rem; letter-spacing: -.03em; color: var(--white); }
.auth-card > p { margin: 0 0 24px; }

@media (max-width: 860px) {
    .dash { grid-template-columns: 1fr; }

    .mobile-bar {
        position: sticky; top: 0; z-index: 60;
        display: flex; align-items: center; justify-content: space-between;
        height: 60px; padding: 0 18px;
        background: rgba(7, 14, 34, .85);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border);
    }
    .menu-toggle {
        position: relative; width: 42px; height: 42px;
        border: 1px solid var(--border); border-radius: 12px;
        background: var(--surface); cursor: pointer;
    }
    .menu-toggle span {
        position: absolute; left: 11px; right: 11px; height: 2px;
        background: var(--white); border-radius: 2px;
        transition: transform .3s, opacity .2s, top .3s;
    }
    .menu-toggle span:nth-child(1) { top: 14px; }
    .menu-toggle span:nth-child(2) { top: 20px; }
    .menu-toggle span:nth-child(3) { top: 26px; }
    .menu-open .menu-toggle span:nth-child(1) { top: 20px; transform: rotate(45deg); }
    .menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
    .menu-open .menu-toggle span:nth-child(3) { top: 20px; transform: rotate(-45deg); }

    /* Full-screen menu sitting beneath the top bar */
    .sidebar {
        position: fixed; inset: 60px 0 0 0; z-index: 50;
        height: auto;
        padding: 28px 22px 24px;
        gap: 24px;
        border-right: 0;
        background: linear-gradient(180deg, rgba(7, 14, 34, .97), rgba(5, 10, 26, .99));
        opacity: 0; visibility: hidden; transform: translateY(-12px);
        transition: opacity .25s, transform .25s, visibility 0s linear .25s;
        overflow-y: auto;
    }
    .menu-open .sidebar { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
    .menu-open { overflow: hidden; }
    .side-logo { display: none; }
    .side-link { font-size: 1.35rem; padding: 18px 20px; }

    .content { padding-top: 28px; }
    .qr-form { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .row, .row.no-views { grid-template-columns: 1fr; gap: 6px; }
    .row.head { display: none; }
    .end { justify-self: start; }
    .num { text-align: left; }
    .inline-form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .side-link, .side-link::before, .sidebar, .menu-toggle span { transition: none; }
}
