:root {
    --bg: #0c1033;
    --card: #ffffff;
    --accent: #0bb489;
    --muted: #6b7280;
    --border: #e5e7eb;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: #f6f8fb;
    color: #0f172a;
}

.auth-body {
    background: var(--agent-bg, #040925);
    min-height: 100vh;
}

.agent-body {
    background: var(--agent-bg, #040925);
    min-height: 100vh;
}

.auth-card {
    max-width: 360px;
    margin: 6rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.15);
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-card input,
.auth-card button,
form input,
form select,
form textarea {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

button,
.link-button.primary,
form button,
a.primary {
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

button:hover,
a.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(11, 180, 137, 0.3);
}

.auth-toggle {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.auth-toggle a {
    text-align: center;
    padding: 0.5rem 0;
    text-decoration: none;
    color: #0f172a;
}

.auth-toggle a.active {
    background: var(--accent);
    color: #fff;
}

.admin-nav,
.agent-nav {
    background: #0c1033;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 3vw;
}

.agent-nav {
    position: relative;
    min-height: 78px;
}

.agent-header-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    z-index: 2;
}

.agent-header-logo img {
    height: 42px;
    width: auto;
    display: block;
}

.agent-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 700;
    color: #e2e8ff;
    font-size: 1.25rem;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

.agent-nav-links {
    margin-left: auto;
    z-index: 2;
}

.agent-nav--public .agent-nav-public-spacer {
    margin-left: auto;
    width: 120px;
}

.admin-nav ul,
.agent-nav ul {
    list-style: none;
    display: flex;
    gap: 1rem;
    margin: 0;
    padding: 0;
}

.admin-nav a,
.agent-nav a {
    color: #cbd5f5;
    text-decoration: none;
    font-weight: 500;
}

.page,
.agent-page {
    padding: 2rem 3vw 4rem;
}

.card {
    background: var(--card);
    border-radius: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

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

.grid.two-columns {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header a {
    font-size: 0.9rem;
    color: var(--accent);
    text-decoration: none;
}

.alert {
    background: #fef3c7;
    color: #92400e;
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1.25rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions form {
    display: inline;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.table-responsive {
    overflow-x: auto;
}

th,
td {
    padding: 0.75rem;
    border-bottom: 1px solid #eef2ff;
    text-align: left;
    vertical-align: top;
}

.dealer-details {
    max-width: 360px;
}

.dealer-details .dealer-name {
    font-weight: 700;
    color: #0f172a;
}

.dealer-details .muted {
    color: #64748b;
    font-size: 0.9rem;
}

.dealer-details .dealer-note {
    margin-top: 0.25rem;
    color: #334155;
    font-size: 0.9rem;
}

.dealer-details .dealer-label {
    font-weight: 700;
    color: #334155;
}

.catalog-thumb {
    width: 76px;
    height: 44px;
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    display: block;
}

.catalog-add-form {
    margin-bottom: 1rem;
}

.catalog-row-form {
    display: grid;
    gap: 0.4rem;
    min-width: 220px;
}

.badge {
    display: inline-flex;
    padding: 0.15rem 0.75rem;
    border-radius: 999px;
    background: #e0e7ff;
    font-size: 0.8rem;
}

.form-grid {
    display: grid;
    gap: 0.75rem;
}

.field-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #1f2937;
}

.field-help {
    display: block;
    margin-top: 0.35rem;
    color: #64748b;
    font-size: 0.82rem;
}

.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.upload-thumb {
    position: relative;
    width: 88px;
    height: 66px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #dbe3f3;
    background: #fff;
}

.upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-thumb button {
    position: absolute;
    top: 2px;
    right: 2px;
    border: none;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.theme-preview {
    border-radius: 1.2rem;
    overflow: hidden;
    background: #040925;
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.theme-preview-nav {
    background: rgba(12, 16, 51, 0.95);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    min-height: 70px;
    position: relative;
}

.theme-preview-left img {
    display: block;
    width: auto;
}

.theme-preview-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 700;
    white-space: nowrap;
}

.theme-preview-right {
    color: #cbd5f5;
    font-weight: 500;
    font-size: 0.95em;
}

.theme-preview-body {
    padding: 1.2rem;
}

.theme-preview-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1rem;
    padding: 1rem;
    max-width: 420px;
}

.theme-preview-card-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.theme-preview-card-text {
    color: rgba(226, 232, 255, 0.85);
    font-size: 0.95em;
}

.theme-preview-footer {
    padding: 1rem 1.2rem;
    text-align: center;
    color: rgba(226, 232, 255, 0.8);
    background: rgba(12, 16, 51, 0.7);
    font-size: 0.9em;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.import-progress {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.import-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.import-progress-stats {
    margin: 0.5rem 0;
    color: #334155;
    font-size: 0.95rem;
}

.progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.2s ease;
}

.import-progress-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.inventory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.inventory-filters {
    margin-bottom: 1rem;
}

.bulk-delete-form {
    margin: 0;
}

button.danger {
    background: #ef4444;
    box-shadow: none;
}

button.danger:hover {
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.25);
}

button.danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.filters input,
.filters select {
    flex: 1 1 200px;
}

.brand-grid .brands {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.brand-card {
    background: #eef2ff;
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    text-decoration: none;
    color: #0f172a;
    transition: transform 0.15s ease;
}

.brand-card:hover {
    transform: translateY(-3px);
}

.brand-logo {
    width: 48px;
    height: 48px;
    background: #fff;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.car-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.car-card {
    border-radius: 1.5rem;
    background: #fff;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.car-card .car-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 1;
    filter: contrast(1.04) saturate(1.08) brightness(0.96);
}

.image-filter-wrap {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.image-filter-layer {
    display: block;
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(135deg, rgba(7, 14, 46, 0.3), rgba(5, 12, 38, 0.08) 45%, rgba(0, 0, 0, 0) 75%),
        url('../Filter/Filter.png');
    background-position: center, center;
    background-size: cover, cover;
    background-repeat: no-repeat, no-repeat;
    pointer-events: none;
    opacity: 1;
    z-index: 2;
}

.car-body {
    padding: 1rem 1.25rem 1.5rem;
}

.car-body .price {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0.25rem 0;
}

.car-body .meta {
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.car-body .primary {
    display: inline-flex;
    justify-content: center;
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 999px;
}

.car-detail {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.gallery .hero {
    width: 100%;
    border-radius: 1rem;
    object-fit: cover;
}

.gallery .thumbs {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.5rem;
}

.gallery .thumbs .car-image {
    width: 100%;
    border-radius: 0.65rem;
    height: 70px;
    object-fit: cover;
}

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

.specs span {
    background: #f8fafc;
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
}

.feature-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.feature-tags span {
    background: #edf2f7;
    border-radius: 0.75rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.app-footer {
    text-align: center;
    padding: 2rem 1rem 3rem;
    color: #94a3b8;
}

.link-button {
    background: transparent;
    color: #0ea5e9;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pagination a {
    padding: 0.45rem 0.8rem;
    border-radius: 0.65rem;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: #0f172a;
}

.pagination a.active {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.agent-browse-page .browse-card {
    background: #e9edf7;
    border-radius: 1.4rem;
}

.brand-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.8rem;
}

.brand-tile {
    text-decoration: none;
    color: #0f172a;
    background: #f8faff;
    border-radius: 0.85rem;
    border: 1px solid #c9d3f0;
    min-height: 145px;
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.brand-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(12, 16, 51, 0.16);
}

.brand-logo-wrap {
    width: 86px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-bottom: 0.5rem;
}

.brand-logo-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.brand-logo-fallback {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #eef2ff;
    display: none;
    place-items: center;
    font-weight: 700;
}

.brand-name {
    font-weight: 700;
    margin: 0.1rem 0 0.2rem;
    text-align: center;
    line-height: 1.2;
}

.brand-tile small {
    color: #5b6782;
}

.type-logo-wrap {
    width: 96px;
    height: 54px;
}

.brand-list-page .brand-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.brand-list-page .brand-filters select {
    flex: 1 1 220px;
}

.listing-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.listing-grid .car-card .car-image {
    height: 150px;
}

.detail-hero-wrap {
    border-radius: 1rem;
}

.detail-thumb-wrap {
    border-radius: 0.65rem;
}

.empty-state {
    color: #64748b;
    padding: 0.8rem 0.2rem;
}

@media (max-width: 640px) {
    .filters {
        flex-direction: column;
    }
    /* In column flex, existing flex-basis was making inputs/selects extremely tall. */
    .filters input,
    .filters select,
    .filters button,
    .filters a {
        flex: 0 0 auto;
        width: 100%;
    }
    .card {
        padding: 1.25rem;
    }
    .brand-list-page .brand-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .agent-header-logo img {
        height: 34px;
    }
    .agent-header-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .agent-header-title {
        display: none;
    }
}
