/* ─────────────────────────────────────────────────────────
   GarageSaleMap — Design System
   ───────────────────────────────────────────────────────── */

:root {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #dbeafe;
    --primary-faint:  #eff6ff;
    --accent:         #f59e0b;
    --accent-dark:    #d97706;
    --success:        #10b981;
    --success-bg:     #d1fae5;
    --danger:         #ef4444;
    --danger-bg:      #fee2e2;
    --info:           #06b6d4;
    --info-bg:        #cffafe;

    --dark:           #111827;
    --text:           #1f2937;
    --text-muted:     #6b7280;
    --text-subtle:    #717784; /* ≥4.5:1 on white — WCAG AA for small text */
    --border:         #e5e7eb;
    --border-strong:  #d1d5db;
    --bg:             #f9fafb;
    --bg-card:        #ffffff;
    --white:          #ffffff;

    --radius-sm:  .375rem;
    --radius:     .625rem;
    --radius-lg:  1rem;
    --radius-xl:  1.5rem;

    --shadow-xs:  0 1px 2px 0 rgb(0 0 0 / .05);
    --shadow-sm:  0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .05);
    --shadow:     0 4px 6px -1px rgb(0 0 0 / .08), 0 2px 4px -2px rgb(0 0 0 / .05);
    --shadow-md:  0 10px 15px -3px rgb(0 0 0 / .07), 0 4px 6px -4px rgb(0 0 0 / .05);
    --shadow-lg:  0 20px 25px -5px rgb(0 0 0 / .07), 0 8px 10px -6px rgb(0 0 0 / .05);

    --nav-h:    60px;
    --sidebar-w: 340px;

    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Consolas, 'Liberation Mono', monospace;

    --transition: 150ms cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ─────────────────────────────────────────── */
.gsm-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--nav-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.gsm-nav-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 0 1.25rem;
    max-width: 100%;
}

.gsm-nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: -.02em;
}
.gsm-nav-brand:hover { color: var(--primary); text-decoration: none; }
.gsm-nav-brand .brand-icon {
    width: 22px; height: 22px;
    color: var(--primary);
    flex-shrink: 0;
}

.gsm-nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}

.gsm-nav-link {
    padding: .375rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color var(--transition), background var(--transition);
    text-decoration: none;
}
.gsm-nav-link:hover    { color: var(--text); background: var(--bg); text-decoration: none; }
.gsm-nav-link.active   { color: var(--primary); background: var(--primary-faint); }

.gsm-nav-divider {
    width: 1px; height: 20px;
    background: var(--border);
    margin: 0 .25rem;
}

.gsm-nav-admin {
    display: inline-flex !important;
    align-items: center;
    gap: .3rem;
    font-size: .78rem !important;
    font-weight: 600;
    color: var(--primary) !important;
    border: 1.5px solid var(--primary-faint);
    border-radius: var(--radius-sm);
    padding: .28rem .6rem !important;
}
.gsm-nav-admin:hover { background: var(--primary-faint) !important; }

.gsm-nav-user {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
    padding: .375rem .5rem;
}
.gsm-nav-user svg { width: 14px; height: 14px; }

/* Bell icon (mobile only — between brand and hamburger) */
.gsm-nav-bell {
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    margin-left: auto;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.gsm-nav-bell-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 9px; height: 9px;
    background: var(--danger, #dc2626);
    border: 2px solid var(--white, #fff);
    border-radius: 50%;
}

/* Hamburger toggle (mobile only) */
.gsm-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px; height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.gsm-nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}
.gsm-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.gsm-nav-toggle.open span:nth-child(2) { opacity: 0; }
.gsm-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Buttons ─────────────────────────────────────────────── */
.gsm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.gsm-btn:hover { text-decoration: none; }
.gsm-btn:active { transform: scale(.97); }

.gsm-btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}
.gsm-btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--white); }

.gsm-btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}
.gsm-btn-outline:hover { background: var(--bg); color: var(--text); }

.gsm-btn-danger {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}
.gsm-btn-danger:hover { background: var(--danger); color: var(--white); }

.gsm-btn-warning {
    background: #ffedd5;
    border-color: #fb923c;
    color: #9a3412;
}
.gsm-btn-warning:hover { background: #fb923c; color: var(--white); }

.gsm-btn-success {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}
.gsm-btn-success:hover { background: #0d9668; border-color: #0d9668; color: var(--white); }

.gsm-btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.gsm-btn-lg { padding: .7rem 1.4rem; font-size: 1rem; }
.gsm-btn-full { width: 100%; }

/* ── Form elements ────────────────────────────────────── */
.gsm-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .35rem;
    letter-spacing: .01em;
}

.gsm-input {
    width: 100%;
    padding: .55rem .8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.gsm-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / .12);
}
.gsm-input::placeholder { color: var(--text-subtle); }
.gsm-input:disabled {
    background: #f1f5f9;
    color: var(--text-subtle);
    cursor: not-allowed;
    opacity: .75;
}
.gsm-btn:disabled,
.gsm-btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.gsm-input-group {
    display: flex;
    align-items: stretch;
}
.gsm-input-group .gsm-input {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
}
.gsm-input-group .gsm-btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}

.gsm-select {
    width: 100%;
    padding: .55rem .8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right .8rem center;
    appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}
.gsm-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(37 99 235 / .12); }

.gsm-textarea {
    width: 100%;
    padding: .55rem .8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}
.gsm-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(37 99 235 / .12); }

.gsm-checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .875rem;
}
.gsm-checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.gsm-field { margin-bottom: 1rem; }
.gsm-hint  { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }

/* ── Cards ────────────────────────────────────────────── */
.gsm-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.gsm-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    color: var(--dark);
}

.gsm-card-body  { padding: 1.25rem; }
.gsm-card-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ── Badges ───────────────────────────────────────────── */
.gsm-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 9999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.gsm-badge-green   { background: var(--success-bg);  color: #065f46; }
.gsm-badge-amber   { background: #fef3c7; color: #92400e; }
.gsm-badge-orange  { background: #ffedd5; color: #9a3412; }
.gsm-badge-blue    { background: var(--primary-light); color: var(--primary-dark); }
.gsm-badge-gray    { background: #f3f4f6; color: #4b5563; }
.gsm-badge-teal    { background: #ccfbf1; color: #0f766e; }
.gsm-badge-red     { background: var(--danger-bg); color: #991b1b; }
.gsm-badge-dot::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: .15rem;
}

/* ── Alerts ───────────────────────────────────────────── */
.gsm-alert {
    padding: .875rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    display: flex;
    gap: .5rem;
    align-items: flex-start;
}
.gsm-alert-danger  { background: var(--danger-bg);  border-color: #fca5a5; color: #991b1b; }
.gsm-alert-success { background: var(--success-bg); border-color: #6ee7b7; color: #065f46; }
.gsm-alert-info    { background: var(--info-bg);    border-color: #67e8f9; color: #0e7490; }

/* ── Page layout ──────────────────────────────────────── */
.gsm-page { padding: 2rem 1.25rem; }
.gsm-container { max-width: 900px; margin: 0 auto; }
.gsm-container-sm { max-width: 480px; margin: 0 auto; }

/* ── Auth pages ───────────────────────────────────────── */
.auth-page {
    min-height: calc(100vh - var(--nav-h));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 .25rem;
    letter-spacing: -.02em;
}

.auth-sub {
    font-size: .875rem;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
}

/* ── Map layout ───────────────────────────────────────── */
#app-container {
    display: flex;
    height: calc(100vh - var(--nav-h));
    overflow: hidden;
}

#map { flex: 1; height: 100%; }

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    order: -1; /* sidebar left of map on desktop */
}

/* Mobile drag handle — hidden on desktop */
#sidebar-handle { display: none; }

.sidebar-section {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-section-title {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    margin: 0 0 .6rem;
}

#sale-list { flex: 1; overflow-y: auto; }

.sale-card {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.sale-card:hover          { background: var(--bg); }
.sale-card.selected       { background: var(--primary-faint); }
.sale-card.sale-card-closed { opacity: .7; }
.sale-card.selected::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.sale-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .3rem;
}

.sale-card-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.3;
}

.sale-card-meta {
    font-size: .75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.sale-check {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
    margin-top: 1px;
}

/* ── Filters toggle panel ────────────────────────────── */
#filters-body { overflow: hidden; }
#filters-toggle:hover { color: var(--primary); }
#filters-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ── Search & filter bar ─────────────────────────────── */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .4rem .6rem;
    transition: border-color var(--transition);
}
.sidebar-search:focus-within { border-color: var(--primary); background: var(--white); }
.sidebar-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: .825rem;
    font-family: var(--font);
    color: var(--text);
    width: 100%;
}
.sidebar-search input::placeholder { color: var(--text-subtle); }
.sidebar-search svg { color: var(--text-subtle); flex-shrink: 0; width: 15px; height: 15px; }

.filter-pills {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}

.filter-pill {
    padding: .3rem .65rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.filter-pill:hover  { border-color: var(--primary); color: var(--primary); background: var(--primary-faint); }
.filter-pill.active { border-color: var(--primary); color: #fff; background: var(--primary); }

.sort-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .5rem;
}
.sort-row label { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.sort-row select {
    flex: 1;
    font-size: .75rem;
    padding: .25rem .5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text);
    outline: none;
    cursor: pointer;
}

/* ── Route panel ──────────────────────────────────────── */
#route-panel {
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-bottom: 1px solid var(--border);
}

.route-title {
    font-size: .8rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: .35rem;
}

.route-stops {
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .5rem;
    max-height: 220px;
    overflow-y: auto;
}

.route-stop-row {
    display: flex;
    align-items: flex-start;
    gap: .4rem;
    padding: .3rem .1rem;
    border-bottom: 1px solid var(--border);
}
.route-stop-row:last-child { border-bottom: none; }

.route-stop-num {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: .65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: .1rem;
}

.route-stop-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.route-stop-addr {
    font-size: .68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.route-stop-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-subtle);
    font-size: .75rem;
    padding: .1rem .2rem;
    line-height: 1;
    border-radius: 3px;
    margin-top: .1rem;
}
.route-stop-remove:hover { color: var(--danger); background: var(--bg); }

/* ── Map ──────────────────────────────────────────────── */
#map { flex: 1; height: 100%; }

/* ── Map popup ────────────────────────────────────────── */
.map-popup { min-width: 210px; font-family: var(--font); }
.map-popup .popup-title { font-size: .95rem; font-weight: 700; margin-bottom: .3rem; color: var(--dark); }
.map-popup .popup-actions { display: flex; gap: .4rem; margin-top: .6rem; }

/* ── Sale detail ──────────────────────────────────────── */
.sale-hero {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border-strong); }

.sale-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.sale-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    margin-top: .75rem;
}

.sale-meta-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .875rem;
    color: var(--text-muted);
}
.sale-meta-item svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Item cards ───────────────────────────────────────── */
.item-img { height: 170px; width: 100%; object-fit: cover; }
.item-img-placeholder {
    height: 170px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    color: var(--text-subtle);
}

/* ── Communities page ─────────────────────────────────── */
.comm-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.comm-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.comm-card.has-active { border-color: var(--success); }
.comm-card.has-active:hover { border-color: #0d9668; }

.comm-card-body { padding: 1.25rem; flex: 1; }
.comm-card-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

#community-map { height: 380px; border-radius: var(--radius); }

/* ── Community member list (manage modal) ──────────────── */
.comm-member-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.comm-member-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .6rem;
    border-radius: 6px;
    background: var(--bg);
    font-size: .875rem;
}
.comm-member-name { flex: 1; font-weight: 500; }

/* ── Tables ───────────────────────────────────────────── */
.gsm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.gsm-table th {
    padding: .75rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.gsm-table td {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.gsm-table tbody tr:hover { background: var(--bg); }
.gsm-table tbody tr:last-child td { border-bottom: none; }

/* ── Misc utilities ───────────────────────────────────── */
.text-muted    { color: var(--text-muted) !important; }
.text-subtle   { color: var(--text-subtle) !important; }
.fw-semibold   { font-weight: 600; }
.fw-bold       { font-weight: 700; }
.text-sm       { font-size: .875rem; }
.text-xs       { font-size: .75rem; }
.mt-0          { margin-top: 0; }
.price-tag     { font-size: 1.05rem; font-weight: 700; color: var(--success); }

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: .5rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; color: var(--dark); margin: 0; }
.page-header p  { font-size: .875rem; color: var(--text-muted); margin: .25rem 0 0; }

/* ── Auth modal tabs ──────────────────────────────────── */
.auth-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: -1px; /* overlap modal header border */
}

.auth-tab {
    padding: .6rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.auth-tab:hover  { color: var(--text); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Modal (vanilla) ──────────────────────────────────── */
.gsm-modal-backdrop {
    position: fixed; inset: 0;
    background: rgb(0 0 0 / .45);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.gsm-modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.gsm-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.gsm-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; color: var(--dark); }
.gsm-modal-close {
    width: 28px; height: 28px;
    border: none; background: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.gsm-modal-close:hover { background: var(--bg); color: var(--text); }
.gsm-modal-body   { padding: 1.5rem; }
.gsm-modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

/* ── Sale detail bottom sheet ─────────────────────────── */
#sheet-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgb(0 0 0 / .4);
    z-index: 600;
}

#sale-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 700;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px rgb(0 0 0 / .18);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    /* Flex column: handle + chrome (nav bar) + track (slides) */
    display: flex;
    flex-direction: column;
    height: 85vh;
    max-height: 85vh;
    padding-bottom: env(safe-area-inset-bottom, 1.5rem);
}
#sale-sheet.open { transform: translateY(0); }

.sale-sheet-handle {
    width: 48px; height: 5px;
    background: var(--border-strong);
    border-radius: 3px;
    margin: .6rem auto .4rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* Chrome: nav bar (Prev / N of M / Next) lives outside the sliding track */
#sheet-chrome {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
#sheet-chrome .sheet-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .75rem;
}
#sheet-chrome .sheet-nav button {
    background: none; border: none; cursor: pointer;
    padding: .35rem .5rem; color: var(--text-muted);
    font-size: .78rem; display: flex; align-items: center; gap: .25rem;
    min-height: 36px;
}
#sheet-chrome .sheet-nav button:active { color: var(--primary); }
#sheet-chrome .sheet-close {
    position: absolute; top: .75rem; right: .75rem;
    background: none; border: none; cursor: pointer;
    font-size: 1.6rem; line-height: 1; color: var(--text-muted);
    min-width: 44px; min-height: 44px; display: flex;
    align-items: center; justify-content: center;
    z-index: 2;
}

/* ── Image lightbox ─────────────────────────────────────── */
#img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, .93);
    display: none;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
#img-lightbox.open { display: flex; }
#lightbox-close {
    position: absolute;
    top: .85rem; right: .85rem;
    z-index: 2;
    background: rgba(255, 255, 255, .18);
    border: none;
    color: #fff;
    font-size: 1.35rem;
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#lightbox-close:active { background: rgba(255,255,255,.3); }
#lightbox-img-wrap {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
#lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    transform-origin: center center;
    will-change: transform;
    pointer-events: none;
}
.lightbox-hint {
    position: absolute;
    bottom: 1.5rem; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,.5);
    color: rgba(255,255,255,.8);
    font-size: .72rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity .4s;
}

/* Track: clips the 3 slides */
#sheet-track {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 200px;
}

/* Slides: absolutely positioned inside track, each 100% wide */
.sheet-slide {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
    /* Pan vertically freely; JS handles horizontal intercept */
    touch-action: pan-y;
}

/* Sticky action bar — always visible at bottom of sheet */
#sheet-actions {
    flex-shrink: 0;
    padding: .65rem 1.1rem;
    border-top: 1px solid var(--border);
    background: var(--white);
    padding-bottom: max(.65rem, env(safe-area-inset-bottom));
}
#sheet-actions:empty { display: none; }

.sheet-title    { font-size: 1.2rem; font-weight: 800; color: var(--dark); margin: 0 0 .4rem; letter-spacing: -.02em; }
.sheet-meta     { font-size: .875rem; color: var(--text-muted); display: flex; flex-direction: column; gap: .3rem; margin: .75rem 0; }
.sheet-meta-row { display: flex; align-items: center; gap: .4rem; }
.sheet-actions  { display: flex; gap: .5rem; margin-top: 1rem; }

/* ── Mobile ───────────────────────────────────────────── */
/* Sale detail page layout */
.sale-detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 768px) {
    :root { --sidebar-w: 100%; }

    /* Sale detail: stack to single column, sidebar goes below content */
    .sale-detail-grid {
        grid-template-columns: 1fr;
    }
    .sale-detail-grid > *:last-child {
        position: static !important;
    }

    /* Sale page action buttons stack on mobile */
    .sale-title-row {
        flex-direction: column;
    }
    .sale-title-row > div:last-child {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }
    .sale-title-row > div:last-child .gsm-btn {
        flex: 1;
        text-align: center;
        min-width: 120px;
    }

    /* Nav */
    .gsm-nav-bell   { display: flex; }
    .gsm-nav-toggle { display: flex; margin-left: 0; }
    /* No bell in DOM (logged-out) → toggle handles its own right-alignment */
    .gsm-nav-inner:not(:has(.gsm-nav-bell)) .gsm-nav-toggle { margin-left: auto; }
    .gsm-nav-links {
        display: none;
        position: absolute;
        top: var(--nav-h);
        left: 0; right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: .75rem 1rem 1rem;
        gap: .25rem;
        box-shadow: var(--shadow);
    }
    .gsm-nav-links.open { display: flex; }
    .gsm-nav-divider { width: 100%; height: 1px; margin: .25rem 0; background: var(--border); }
    /* Keep nav sticky on mobile too so the dropdown overlay works */
    .gsm-nav { position: sticky; }

    /* Map fills the screen; sidebar slides up from the bottom */
    #app-container {
        flex-direction: column;
        height: calc(100vh - var(--nav-h));
        position: relative;
        overflow: hidden;
    }

    #map {
        position: absolute;
        inset: 0;
        height: 100%;
        width: 100%;
        z-index: 0;
    }

    /* Sidebar becomes a bottom drawer */
    #sidebar {
        position: absolute;
        bottom: 0; left: 0; right: 0;
        z-index: 100;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        box-shadow: 0 -4px 20px rgb(0 0 0 / .10);
        height: 82vh;
        /* Default: collapsed — only the handle bar visible */
        transform: translateY(calc(100% - 52px));
        transition: transform .3s cubic-bezier(.32, .72, 0, 1);
        overflow: hidden;
        order: 0;
    }
    #sidebar.drawer-open { transform: translateY(0); }
    /* Peek state: handle + community picker + ~2 sale cards visible */
    #sidebar.drawer-peek { transform: translateY(calc(100% - 240px)); }
    /* When filters are collapsed, allow the peek to show much more of the list */
    #sidebar.drawer-peek.filters-collapsed { transform: translateY(calc(100% - 62vh)); }

    /* Drag handle */
    #sidebar-handle {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: .6rem .75rem .5rem;
        cursor: pointer;
        user-select: none;
        flex-shrink: 0;
        background: var(--white);
        touch-action: none; /* let our touchmove handler run without browser scroll interference */
    }
    .handle-bar {
        width: 48px; height: 5px;
        background: var(--border-strong);
        border-radius: 3px;
        margin-bottom: .35rem;
    }
    #handle-label {
        font-size: .85rem;
        font-weight: 700;
        color: var(--primary);
        letter-spacing: .01em;
    }

    /* Collapse sidebar sections to save space when drawer is open */
    .sidebar-section { padding: .55rem .875rem; }
    .sidebar-section-title { margin-bottom: .4rem; }

    /* Sale list scrolls inside the drawer */
    #sale-list { overflow-y: auto; max-height: 45vh; }

    .auth-box   { padding: 1.75rem 1.25rem; }
    .gsm-page   { padding: 1.25rem 1rem; }

    /* ── Mobile touch-target improvements ─────────────────── */

    /* Nav dropdown — every link needs a 48px+ tap target */
    .gsm-nav-toggle { width: 44px; height: 44px; padding: 8px; }
    .gsm-nav-links {
        padding: .5rem .75rem 1rem;
        gap: .15rem;
    }
    .gsm-nav-links .gsm-nav-link {
        padding: .85rem 1rem;
        font-size: .95rem;
        border-radius: var(--radius-sm);
        min-height: 48px;
        display: flex;
        align-items: center;
        color: var(--text);
    }
    .gsm-nav-links .gsm-nav-link.active { color: var(--primary); }
    .gsm-nav-links .gsm-nav-admin {
        padding: .75rem 1rem !important;
        font-size: .9rem !important;
        min-height: 44px;
        border-radius: var(--radius-sm);
    }
    /* Register button in nav — full width on mobile */
    .gsm-nav-links .gsm-btn {
        width: 100%;
        justify-content: center;
        padding: .85rem 1rem;
        font-size: .95rem;
        margin-top: .25rem;
        min-height: 48px;
    }
    .gsm-nav-user { padding: .85rem 1rem; min-height: 48px; font-size: .9rem; }
    .gsm-nav-user svg { width: 16px; height: 16px; }

    /* Search — taller, bigger text */
    .sidebar-search {
        padding: .65rem .75rem;
    }
    .sidebar-search input { font-size: .9rem; }
    .sidebar-search svg { width: 17px; height: 17px; }

    /* Filters toggle — bigger touch target */
    #filters-toggle { min-height: 44px; font-size: .9rem; }

    /* Filter pills — enough padding for a confident tap */
    .filter-pill {
        padding: .55rem 1rem;
        font-size: .82rem;
        min-height: 38px;
        display: inline-flex;
        align-items: center;
    }
    /* Category pills — slightly smaller than main pills but still tappable */
    .cat-pill {
        padding: .45rem .8rem !important;
        font-size: .78rem !important;
        min-height: 34px;
        display: inline-flex !important;
        align-items: center;
    }

    /* Show-closed / show-upcoming rows — bigger everything */
    .toggle-check-label {
        font-size: .88rem !important;
        gap: .5rem !important;
        min-height: 36px;
    }
    .toggle-check-label input[type="checkbox"] {
        width: 19px !important;
        height: 19px !important;
    }

    /* Sort row — taller select, bigger near-me button */
    .sort-row select {
        height: 40px;
        font-size: .875rem;
        padding: .5rem .6rem;
    }
    .sort-row .gsm-btn { padding: .55rem .75rem; min-height: 40px; }

    /* Sale list cards — bigger tap area, easier to read */
    .sale-card { padding: .95rem 1rem; }
    .sale-card-title { font-size: .925rem; }
    .sale-card-meta { font-size: .78rem; line-height: 1.6; }
    /* Checkbox — much easier to tap */
    .sale-check { width: 22px; height: 22px; margin-top: 0; }

    /* Route planner — remove button needs a real touch target */
    .route-stop-remove {
        min-width: 32px;
        min-height: 32px;
        padding: .35rem .5rem;
        font-size: .9rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .route-stop-row { padding: .45rem .1rem; }
    .route-stop-num { width: 22px; height: 22px; font-size: .7rem; }

    /* Primary buttons on forms — larger on mobile */
    .gsm-btn-primary.gsm-btn-full,
    .gsm-btn.gsm-btn-full { min-height: 48px; font-size: .95rem; }

    /* Form inputs / selects — comfortable to type in */
    .gsm-input, .gsm-select, .gsm-textarea {
        font-size: 1rem;      /* prevents iOS auto-zoom on focus */
        padding: .65rem .875rem;
        min-height: 46px;
    }
    .gsm-checkbox input { width: 19px; height: 19px; }
    .gsm-checkbox { font-size: .9rem; min-height: 36px; }
}

/* ── Mobile FAB (floating action button) ────────────────── */
#mobile-fab { display: none; }

@media (max-width: 768px) {
    #mobile-fab {
        display: flex;
        align-items: center;
        gap: .5rem;
        position: fixed;
        right: 1rem;
        bottom: 256px; /* sits just above the peek drawer */
        z-index: 110;
        border-radius: 999px;
        padding: .75rem 1.35rem;
        font-size: .9rem;
        font-weight: 700;
        box-shadow: 0 4px 16px rgb(37 99 235 / .4), 0 1px 4px rgb(0 0 0 / .15);
        text-decoration: none;
        transition: box-shadow var(--transition), transform var(--transition), bottom var(--transition);
        white-space: nowrap;
    }
    #mobile-fab:hover { text-decoration: none; }
    #mobile-fab:active { transform: scale(.95); }
    /* When filters are collapsed, peek shows 62vh — move FAB above it */
    body:has(#sidebar.filters-collapsed:not(.drawer-open)) #mobile-fab {
        bottom: calc(62vh + .75rem);
    }
    /* Hide FAB when drawer is fully open (map is hidden anyway) */
    #sidebar.drawer-open ~ #mobile-fab,
    body.drawer-is-open #mobile-fab { display: none; }
}

/* ── My Sales cards ─────────────────────────────────────────── */
.ms-section-header {
    padding: .6rem 1rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ms-section-toggle { cursor: pointer; list-style: none; user-select: none; }
.ms-section-toggle::-webkit-details-marker { display: none; }
.ms-section-count {
    font-weight: 400;
    text-transform: none;
    font-size: .78rem;
    letter-spacing: 0;
    margin-left: .4rem;
}
.ms-card {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
}
.ms-card:last-child { border-bottom: none; }
.ms-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .3rem;
}
.ms-card-title {
    font-weight: 600;
    font-size: .95rem;
    color: var(--dark);
    text-decoration: none;
    line-height: 1.3;
}
.ms-card-title:hover { color: var(--primary); }
.ms-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem .4rem;
    font-size: .78rem;
    color: var(--text-muted);
    margin-bottom: .55rem;
}
.ms-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    flex-wrap: wrap;
}
.ms-card-btns {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
}
.ms-suspended-notice {
    margin: .4rem 0 .5rem;
    padding: .55rem .75rem;
    background: var(--danger-bg);
    border-left: 3px solid #dc2626;
    border-radius: 0 6px 6px 0;
    font-size: .8rem;
    color: #7f1d1d;
    line-height: 1.4;
}
.ms-suspended-notice a { color: #991b1b; }

/* ── Mobile bottom nav (non-feed pages, mobile only) ───────── */
#g2-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(62px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 300;
}
.g2-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: .62rem;
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem 0 .3rem;
    transition: color .13s;
    -webkit-tap-highlight-color: transparent;
}
.g2-tab.active { color: var(--primary); }
.g2-tab svg { flex-shrink: 0; }
@media (min-width: 769px) {
    #g2-bottom-nav  { display: none; }
    #g2-nav-spacer  { display: none; }
}

/* ── messages.php ─────────────────────────────────────── */
.msg-page { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.msg-conv-list { display: flex; flex-direction: column; gap: .5rem; }
.msg-conv-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .85rem 1rem; border-radius: var(--radius);
    background: var(--bg-card); border: 1.5px solid var(--border);
    cursor: pointer; text-decoration: none; color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.msg-conv-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.msg-conv-item.unread { border-color: var(--primary-faint); background: #eff6ff; }
.msg-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-faint); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.msg-conv-body { flex: 1; min-width: 0; }
.msg-conv-name { font-weight: 600; font-size: .9rem; color: var(--text); }
.msg-conv-sale { font-size: .73rem; color: var(--primary); margin: .1rem 0; }
.msg-conv-preview { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-meta { font-size: .7rem; color: var(--text-subtle); white-space: nowrap; flex-shrink: 0; text-align: right; }
.msg-unread-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary); margin-left: .3rem; vertical-align: middle;
}
.msg-thread { display: flex; flex-direction: column; gap: .75rem; margin: 1rem 0 1.5rem; }
.msg-bubble {
    max-width: 82%; padding: .65rem .9rem;
    border-radius: var(--radius-lg); font-size: .875rem; line-height: 1.5;
    word-wrap: break-word;
}
.msg-bubble.mine {
    align-self: flex-end;
    background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
    align-self: flex-start;
    background: var(--bg); border: 1.5px solid var(--border); color: var(--text);
    border-bottom-left-radius: 4px;
}
.msg-bubble-time { font-size: .65rem; opacity: .65; margin-top: .25rem; }
.msg-bubble.mine .msg-bubble-time { text-align: right; }
.msg-reply-box { display: flex; gap: .5rem; align-items: flex-end; }
.msg-reply-box textarea {
    flex: 1; font-family: var(--font); font-size: .875rem;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: .6rem .75rem; resize: vertical; min-height: 72px;
    outline: none; color: var(--text); background: var(--bg-card);
    transition: border-color .15s;
}
.msg-reply-box textarea:focus { border-color: var(--primary); }
@media (max-width: 600px) {
    .msg-bubble { max-width: 90%; }
}

/* ── add_sale.php ─────────────────────────────────────── */
.tag-pill-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-faint);
    color: var(--primary-dark);
    font-weight: 600;
}

/* ── Suspend modal (shared by classic + feed layouts) ──── */
.gsm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.gsm-modal-box {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.gsm-modal-title { margin: 0 0 .5rem; font-size: 1.1rem; }
.gsm-modal-desc  { margin: 0 0 1rem; font-size: .875rem; color: var(--text-muted); line-height: 1.5; }
.gsm-modal-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* ── Suspended listing indicators ─────────────────────── */
.sale-card-suspended { opacity: .72; border-left: 3px solid #dc2626; }
.gsm-suspended-mod-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .6rem;
    background: var(--danger-bg);
    border-radius: 6px;
    font-size: .8rem;
    color: #7f1d1d;
    margin-top: .25rem;
}

/* ── Touch ergonomics: bigger hit targets on touch devices ─────────────── */
@media (pointer: coarse) {
    .gsm-btn      { min-height: 44px; }
    .gsm-btn-sm   { min-height: 42px; padding: .5rem .9rem; }
    .gsm-nav-toggle { width: 44px; height: 44px; }
    a.gsm-badge   { padding: .3rem .7rem; }
}

/* ── Respect the user's reduced-motion preference ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
