/* ---------------------------------------------------------------------------
   AutoSOFT Stock - a single stylesheet, no framework, no build step.
   Kept deliberately plain: this has to be maintainable by whoever maintains
   the Xbase++, and a CSS build chain is one more thing to keep alive.
   --------------------------------------------------------------------------- */

:root {
    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --surface-2:    #fafbfc;
    --border:       #dfe3e8;
    --text:         #1c2430;
    --text-dim:     #5b6775;
    --text-faint:   #8a949f;
    --accent:       #1f5fa9;
    --accent-dark:  #184a84;
    --accent-soft:  #eaf1fa;

    --ok-bg:        #e6f4ea;
    --ok-fg:        #1e6b36;
    --warn-bg:      #fdf3e2;
    --warn-fg:      #8a5a12;
    --info-bg:      #e8eefb;
    --info-fg:      #2b4b8f;
    --mute-bg:      #eef0f3;
    --mute-fg:      #5b6775;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:          #14181d;
        --surface:     #1c2229;
        --surface-2:   #222932;
        --border:      #2f3843;
        --text:        #e6eaef;
        --text-dim:    #a3aeba;
        --text-faint:  #78838f;
        --accent:      #5d9bdf;
        --accent-dark: #7cb0e8;
        --accent-soft: #1e2b3a;

        --ok-bg:   #16301f; --ok-fg:   #7fd196;
        --warn-bg: #332714; --warn-fg: #e0b269;
        --info-bg: #1b2740; --info-fg: #8fb4ef;
        --mute-bg: #262d36; --mute-fg: #9aa5b1;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

/* -- top bar --------------------------------------------------------------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    width: 32px; height: 32px;
    flex: 0 0 32px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .01em; }
.brand-text small {
    color: var(--text-dim);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--text-dim); font-size: 13px; }
.inline { display: inline; margin: 0; }

/* -- page shell ------------------------------------------------------------ */

.page {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.foot {
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
    padding: 14px 16px;
}

.banner {
    padding: 10px 16px;
    text-align: center;
    font-size: 14px;
}
.banner-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* -- headings -------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.page-head h1 { font-size: 20px; margin: 0; }
.count { color: var(--text-dim); font-size: 14px; }

/* -- controls -------------------------------------------------------------- */

.btn {
    display: inline-block;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-quiet { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
input:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 4px; }

/* -- filter bar ------------------------------------------------------------ */

.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.filter-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    align-items: end;
}
.filter-grid .wide { grid-column: span 2; }

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

@media (max-width: 640px) {
    .filter-grid .wide { grid-column: span 1; }
}

/* -- stock cards ----------------------------------------------------------- */

.cards {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    transition: transform .08s ease, box-shadow .08s ease;
}
.card:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 24, 40, .10);
}

.card-photo {
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-photo .nophoto { color: var(--text-faint); font-size: 13px; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.card-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.card-sub { color: var(--text-dim); font-size: 13px; }

.card-price {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.price { font-size: 17px; font-weight: 700; }
.price-none { color: var(--text-faint); font-weight: 400; font-size: 14px; }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
}

/* -- badges ---------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge-available { background: var(--ok-bg);   color: var(--ok-fg); }
.badge-otp       { background: var(--info-bg); color: var(--info-fg); }
.badge-proforma  { background: var(--warn-bg); color: var(--warn-fg); }
.badge-sold      { background: var(--mute-bg); color: var(--mute-fg); }
.badge-cost      { background: var(--accent-soft); color: var(--accent-dark); }

/* -- paging ---------------------------------------------------------------- */

.paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.paging .pos { color: var(--text-dim); font-size: 14px; }

/* -- empty / messages ------------------------------------------------------ */

.empty {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
}

.alert {
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    margin-bottom: 14px;
}
.alert-error { background: var(--warn-bg); color: var(--warn-fg); }

/* -- login ----------------------------------------------------------------- */

.login-wrap {
    max-width: 380px;
    margin: 8vh auto 0;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 24px;
}
.login-head { text-align: center; margin-bottom: 20px; }
.login-head .brand-mark { margin: 0 auto 10px; width: 44px; height: 44px; font-size: 20px; }
.login-head h1 { font-size: 19px; margin: 0 0 4px; }
.login-head p { margin: 0; color: var(--text-dim); font-size: 13px; }
.field { margin-bottom: 14px; }
.login-card .btn { width: 100%; }

/* -- vehicle detail -------------------------------------------------------- */

.detail-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 860px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.panel-body { padding: 14px 16px; }
.panel + .panel { margin-top: 18px; }

.gallery-main {
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; }

.thumbs { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; }
.thumbs a { display: block; width: 72px; height: 54px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs a.current { outline: 2px solid var(--accent); outline-offset: 1px; }

dl.spec { margin: 0; display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; }
dl.spec dt { color: var(--text-dim); font-size: 13px; }
dl.spec dd { margin: 0; font-size: 14px; word-break: break-word; }

.price-big { font-size: 26px; font-weight: 700; }

.money { font-variant-numeric: tabular-nums; }
.num   { font-variant-numeric: tabular-nums; }

.backlink { display: inline-block; margin-bottom: 12px; font-size: 14px; }

.costline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.costline:last-child { border-bottom: 0; }
.costline .lbl { color: var(--text-dim); }
.costline.total { font-weight: 700; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 8px; }
.pos { color: var(--ok-fg); }
.neg { color: #b3261e; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .neg { color: #f2857c; }
}

/* -- section tabs (Stock / Sales) ------------------------------------------ */

.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.tabs a {
    padding: 5px 14px;
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.current { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 640px) {
    .who, .brand-text strong { display: none; }
}

/* -- sales ----------------------------------------------------------------- */

.tiles {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 18px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tile-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tile-value { font-size: 22px; font-weight: 700; }

.salelist { list-style: none; margin: 0; padding: 0; }
.salelist li + li { border-top: 1px solid var(--border); }
.salelist a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: inherit;
}
.salelist a:hover { background: var(--surface-2); text-decoration: none; }
.sale-main { display: flex; flex-direction: column; min-width: 0; }
.sale-amt  { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; font-weight: 600; }
