/* CampusCart UI */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --accent: #0891b2;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e5e9f0;
    --surface: #ffffff;
    --canvas: #f7f8fc;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px rgba(15, 23, 42, .07);
    --shadow-lg: 0 18px 44px rgba(15, 23, 42, .12);
    --ring: 0 0 0 4px rgba(79, 70, 229, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--primary-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: 8px;
}
::selection { background: #dbe4ff; color: var(--ink); }
h1, h2, h3, h4 { margin: 0 0 .55rem; line-height: 1.22; letter-spacing: -.025em; font-weight: 750; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.14rem; }
p { margin: 0 0 1rem; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}
.nav-shell {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 72px;
    padding: 0 26px;
    display: flex;
    align-items: center;
    gap: 26px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.22rem;
    letter-spacing: -.05em;
    color: var(--ink);
    white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(140deg, #6366f1, #4f46e5 55%, #0891b2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 5px 14px rgba(79, 70, 229, .28);
}
.brand-mark svg { width: 20px; height: 20px; }
.main-nav { display: flex; align-items: center; gap: 20px; flex: 1; }
.main-nav a {
    position: relative;
    color: var(--muted);
    font-weight: 600;
    font-size: .91rem;
    padding: 6px 0;
    white-space: nowrap;
}
.main-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 100%;
    bottom: -2px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    transition: right .18s ease;
}
.main-nav a:hover { color: var(--primary); }
.main-nav a:hover::after, .main-nav a.active::after { right: 0; }
.main-nav a.active { color: var(--primary); font-weight: 700; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-weight: 650;
    font-size: .91rem;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    transition: background .15s ease;
}
.nav-user:hover { color: var(--ink); background: #f1f5f9; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #e0e7ff, #cffafe);
    color: var(--primary-dark);
    font-weight: 800;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
    flex: none;
}
.avatar.lg { width: 82px; height: 82px; font-size: 2rem; box-shadow: 0 8px 22px rgba(79,70,229,.16); }
.inline-form { display: inline; margin: 0; }

/* Buttons */
.btn, .btn-primary, .btn-ghost, .btn-outline, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font: inherit;
    font-weight: 650;
    font-size: .92rem;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover, .btn-primary:hover, .btn-ghost:hover, .btn-outline:hover, .btn-danger:hover { transform: translateY(-1px); }
.btn:active, .btn-primary:active, .btn-ghost:active, .btn-outline:active, .btn-danger:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, #5b54ec, var(--primary)); color: #fff; box-shadow: 0 5px 16px rgba(79, 70, 229, .26); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 8px 22px rgba(79, 70, 229, .32); }
.btn-outline { background: #fff; color: var(--primary); border-color: #c9d2fe; box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: var(--primary-soft); border-color: #a5b4fc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn-danger { background: #fff1f2; color: var(--danger); border-color: #fecdd3; }
.btn-danger:hover { background: #ffe4e6; }
.btn-primary.small, .btn-outline.small, .btn-danger.small, .btn-ghost.small {
    padding: 8px 14px;
    font-size: .85rem;
    border-radius: 9px;
}
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* Layout */
main { min-height: calc(100vh - 230px); }
.container { max-width: 1200px; margin: 0 auto; padding: 44px 26px 76px; }
.container.narrow { max-width: 840px; }
.container.compact { max-width: 480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); margin-bottom: 6px; }
.page-head p { margin: 0; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 42px 0 20px; gap: 16px; }
.section-head h2 { position: relative; padding-bottom: 10px; }
.section-head h2::after { content:""; position:absolute; left:0; bottom:0; width:42px; height:3px; border-radius:3px; background:linear-gradient(90deg,var(--primary),var(--accent)); }
.section-head p { margin: 0; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); background: #fff; }
.footer-inner {
    max-width: 1200px; margin: 0 auto; padding: 30px 26px;
    display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    color: var(--muted); font-size: .87rem;
}
.footer-inner a { color: var(--ink-soft); font-weight: 600; }

/* Hero */
.hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(900px 420px at 88% -12%, rgba(8, 145, 178, .17), transparent 70%),
        radial-gradient(700px 360px at 6% 110%, rgba(99, 102, 241, .13), transparent 70%),
        linear-gradient(135deg, #f5f7ff 0%, #f9fafc 55%, #ecfeff 100%);
    border-bottom: 1px solid var(--line);
}
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(79,70,229,.12) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: linear-gradient(90deg, transparent, #000 60%, transparent);
    opacity: .5;
    pointer-events: none;
}
.hero-inner {
    position: relative;
    max-width: 1200px; margin: 0 auto; padding: 80px 26px 84px;
    display: grid; grid-template-columns: 1.08fr .92fr; gap: 56px; align-items: center;
}
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.9); border: 1px solid #c9d2fe; color: var(--primary);
    padding: 7px 13px; border-radius: 999px; font-weight: 750; font-size: .76rem;
    letter-spacing: .06em; text-transform: uppercase;
    box-shadow: var(--shadow-sm);
}
.hero h1 { margin: 22px 0 16px; font-size: clamp(2.4rem, 4.6vw, 3.5rem); line-height: 1.08; }
.hero h1 span { background: linear-gradient(100deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 1.12rem; color: #475569; max-width: 580px; }
.hero-actions { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.stats { display: flex; gap: 0; margin-top: 34px; flex-wrap: wrap; }
.stat { padding-right: 30px; margin-right: 30px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat strong { display: block; font-size: 1.55rem; letter-spacing: -.04em; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.hero-art {
    position: relative;
    background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 22px;
    padding: 22px; box-shadow: var(--shadow-lg); transform: rotate(1deg);
}
.hero-art::before {
    content: "Trending on campus";
    display: block;
    font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
    color: var(--muted); padding: 0 6px 12px;
}
.hero-art .mini-row { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px dashed var(--line); }
.hero-art .mini-row:last-child { border-bottom: 0; padding-bottom: 4px; }
.hero-art .mini-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: linear-gradient(135deg, #eef2ff, #ecfeff); flex: none; }
.hero-art strong { display: block; font-size: .91rem; }
.hero-art small { display: block; font-size: .8rem; }

/* Cards and grids */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 28px;
}
.card + .card { margin-top: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 22px; }
.listing-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.listing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #c9d2fe; }
.listing-thumb {
    position: relative;
    height: 140px; display: grid; place-items: center;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe 60%, #ecfeff);
    border-bottom: 1px solid var(--line);
}
.listing-thumb::after {
    content: ""; position: absolute; inset: auto -20% -70% -20%; height: 100px;
    background: radial-gradient(closest-side, rgba(255,255,255,.75), transparent);
}
.thumb-icon {
    position: relative; z-index: 1;
    width: 68px; height: 68px; border-radius: 20px;
    display: grid; place-items: center; font-size: 2.3rem;
    background: rgba(255,255,255,.82);
    box-shadow: 0 8px 22px rgba(79,70,229,.12), inset 0 0 0 1px rgba(255,255,255,.9);
}
.listing-body { padding: 17px 19px 19px; flex: 1; display: flex; flex-direction: column; }
.listing-body h3 { font-size: 1.01rem; margin-bottom: 5px; }
.listing-body h3 a { color: var(--ink); }
.listing-body h3 a:hover { color: var(--primary); }
.listing-price { font-weight: 800; color: var(--primary); font-size: 1.1rem; margin: 10px 0 14px; letter-spacing: -.02em; }
.listing-meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .8rem; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--line); }
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 999px;
    background: #f1f5f9; color: #475569; font-size: .73rem; font-weight: 750;
    letter-spacing: .01em;
}
.badge.available { background: #ecfdf5; color: var(--success); }
.badge.sold { background: #fef2f2; color: var(--danger); }
.badge.open, .badge.placed, .badge.pending { background: #eff6ff; color: #2563eb; }
.badge.closed, .badge.delivered { background: #ecfdf5; color: var(--success); }
.badge.transit { background: #fffbeb; color: var(--warning); }
.category-bar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 26px; }
.chip {
    padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); font-weight: 650; font-size: .86rem;
    box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.chip:hover { border-color: #c9d2fe; color: var(--primary); transform: translateY(-1px); }
.chip.active { background: linear-gradient(135deg, var(--primary), #6366f1); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.25); }

/* Detail layouts */
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: start; }
.detail-hero {
    height: 220px; border-radius: 14px; display: grid; place-items: center; font-size: 4.4rem;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe 60%, #ecfeff);
    border: 1px solid var(--line); margin-bottom: 22px;
}
.price-large { font-size: 2.1rem; font-weight: 800; color: var(--primary); letter-spacing: -.045em; line-height: 1.2; }
.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.detail-list li:last-child { border-bottom: 0; }
.detail-list .label { color: var(--muted); }
.detail-list .value { font-weight: 650; text-align: right; word-break: break-word; }
.seller-card { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.seller-card .name { font-weight: 750; }
.profile-top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-top h1 { margin: 0; font-size: 1.9rem; }
.profile-stats { display: flex; gap: 30px; margin-top: 20px; flex-wrap: wrap; }
.referral {
    margin-top: 20px; padding: 15px 17px; border: 1px dashed #c9d2fe;
    background: linear-gradient(135deg, #f8faff, #f0f9ff); border-radius: 12px;
}
.referral code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .96rem; font-weight: 750; color: var(--primary); letter-spacing: .02em; }

/* Forms */
.field { margin-bottom: 19px; }
.field label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 8px; color: var(--ink-soft); }
.field input, .field textarea, .field select {
    width: 100%; padding: 12px 14px; border: 1px solid #d8dee9;
    border-radius: var(--radius-sm); background: #fff; color: var(--ink); font: inherit; font-size: .94rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .14s ease, box-shadow .14s ease;
}
.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 38px;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--primary); box-shadow: var(--ring);
}
.field input::placeholder, .field textarea::placeholder { color: #94a3b8; }
.field textarea { min-height: 116px; resize: vertical; }
.field-hint { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.code-input { letter-spacing: .55em; font-size: 1.4rem !important; text-align: center; font-weight: 750; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th, td { padding: 15px 17px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; white-space: nowrap; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: .8rem; display: block; margin-top: 2px; }
td form { white-space: nowrap; }

/* Alerts */
.flash-stack { max-width: 1200px; margin: 20px auto -12px; padding: 0 26px; }
.flash {
    padding: 13px 17px; border-radius: var(--radius-sm); font-weight: 650; font-size: .9rem;
    margin-bottom: 9px; box-shadow: var(--shadow-sm); border: 1px solid transparent;
    border-left-width: 4px;
    animation: flash-in .22s ease both;
}
.flash.success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; border-left-color: var(--success); }
.flash.error { background: #fef2f2; color: #b91c1c; border-color: #fecdd3; border-left-color: var(--danger); }
.flash.info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; border-left-color: #3b82f6; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Auth */
.auth-card { max-width: 470px; margin: 14px auto; }
.auth-card .card { padding: 32px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 1.2rem; border-radius: 14px; }
.auth-brand h1 { font-size: 1.7rem; margin-bottom: 4px; }
.auth-alt { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--ink-soft); cursor: pointer; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--primary); }

/* Conversations */
.thread-row {
    display: flex; align-items: center; gap: 14px; padding: 17px 20px;
    border-bottom: 1px solid var(--line); color: var(--ink);
    transition: background .14s ease;
}
.thread-row:last-child { border-bottom: 0; }
.thread-row:hover { background: #fafbff; color: var(--ink); }
.thread-row .thread-body { flex: 1; min-width: 0; }
.thread-row .thread-name { font-weight: 750; }
.thread-row .thread-sub { color: var(--muted); font-size: .82rem; }
.thread-row .thread-snippet { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-msg { margin-bottom: 16px; }
.chat-meta { color: var(--muted); font-size: .78rem; margin-bottom: 4px; }
.bubble {
    padding: 11px 15px; border-radius: 12px; background: #f1f5f9;
    color: var(--ink-soft); max-width: 90%;
}
.bubble.mine { margin-left: auto; background: linear-gradient(135deg, #eef2ff, #e0f2fe); color: var(--primary-dark); }

/* Empty state */
.empty {
    text-align: center; padding: 68px 24px;
    background: linear-gradient(180deg, #fff, #fbfcff);
    border: 1px dashed #ccd5e4; border-radius: var(--radius); color: var(--muted);
}
.empty .emoji {
    width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 20px;
    display: grid; place-items: center; font-size: 2.2rem;
    background: linear-gradient(135deg, #eef2ff, #ecfeff);
}
.empty h3 { color: var(--ink); }

/* Error page */
.error-page { text-align: center; padding: 100px 20px; }
.error-page .code { font-size: 5.6rem; font-weight: 850; color: #c7d2fe; line-height: 1; letter-spacing: -.06em; }

@media (max-width: 980px) {
    .nav-shell { flex-wrap: wrap; gap: 10px 18px; padding: 10px 20px 0; }
    .main-nav {
        order: 3; width: 100%; overflow-x: auto; gap: 18px;
        padding: 8px 0 10px; border-top: 1px solid var(--line);
        scrollbar-width: none;
    }
    .main-nav::-webkit-scrollbar { display: none; }
    .nav-actions { margin-left: auto; }
    .hero-inner, .detail-grid { grid-template-columns: 1fr; gap: 36px; }
    .hero-inner { padding: 58px 24px 64px; }
    .hero-art { display: none; }
    .stat { padding-right: 22px; margin-right: 22px; }
}

@media (max-width: 640px) {
    .container { padding: 32px 18px 56px; }
    .nav-shell { padding: 10px 16px 0; }
    .card { padding: 20px; }
    .auth-card .card { padding: 24px; }
    .inline-fields { grid-template-columns: 1fr; gap: 0; }
    .detail-list li { flex-direction: column; gap: 3px; }
    .detail-list .value { text-align: left; }
    .page-head { align-items: flex-start; }
    .stats { gap: 14px; }
    .stat { border: 0; padding: 0 14px 0 0; margin: 0; }
    .flash-stack { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
