:root {
    --bg: #0f1115;
    --panel: #151923;
    --panel-2: #1b2130;
    --text: #e7ecf3;
    --muted: #bcc6d6;
    --brand: #6ee7f0;
    --accent: #7c5cff;
    --ok: #22c55e;
    --warn: #f59e0b;
    --err: #ef4444;
    --border: #20283a;
    --bar: #2a3245;
    --bar-fill: #6ee7f0;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    --radius: 14px;
    --header-h: 64px;
    --min-card: 300px;
    --max-card: 450px;
}

* {
    box-sizing: border-box;
}
body,
html {
    min-height: 100%;
}
body {
    margin: 0;
    background: linear-gradient(180deg, #0d1016 0%, #0f1219 100%);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px clamp(16px, 4vw, 32px);
    background: rgba(13,16,22,.7);
    backdrop-filter:saturate(120%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand i {
    color: var(--brand);
    font-size: 22px;
}
.brand h1 {
    font-size: 20px;
    margin: 0;
}
.muted {
    color: var(--muted);
}
.small {
    font-size: 12px;
}
#wheelsGrid,
main {
    overflow: visible;
}

/* Controls */
.sr-only {
    position: absolute!important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

:root {
    --ctl-h: 44px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px clamp(16px, 4vw, 32px);
    border-bottom: 1px solid var(--border);
}
.toolbar__left {
    flex: 1 1 420px;
    min-width: 240px;
}
.toolbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.searchbox {
    position: relative;
    width: 100%;
}
.searchbox i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.searchbox input {
    height: var(--ctl-h);
    width: 100%;
    padding: 0 12px 0 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    outline: none;
}
.searchbox input:focus {
    border-color: var(--accent);
}

.field {
    position: relative;
}
.field__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: var(--ctl-h);
    padding: 0 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    outline: none;
    min-width: 180px;
    cursor: pointer;
}
.select:focus {
    border-color: var(--accent);
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--ctl-h);
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
}
.switch input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.switch span {
    color: var(--text);
    font-size: 14px;
}

.btn {
    height: var(--ctl-h);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 720px) {
    .toolbar {
        flex-wrap: wrap;
    }
    .toolbar__left {
        flex: 1 1 100%;
    }
    .toolbar__right {
        flex: 1 1 100%;
        justify-content: flex-start;
    }
}

.btn {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
}
.btn--ghost:hover {
    border-color: var(--accent);
}
.btn--primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
}
.btn--primary:hover {
    filter:brightness(1.05)
}

/* Grid & Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--min-card), var(--max-card)));
    gap: 16px;
    padding: 0 clamp(16px, 4vw, 32px) 48px;
    justify-content: center;
    align-content: start;
}
.card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 18px 18px 10px;
}
.card__title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.card__title h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.2px;
}
.card__meta {
    display: flex;
    gap: 12px;
    align-items: center;
}
.wheel-subline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--ok);
    box-shadow: 0 0 0 2px rgba(34,197,94,.15);
}
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

@media (max-width: 768px){
  .grid{
    grid-template-columns: 1fr;
    justify-content: start;
    gap: 12px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .card{
    width: 100%;
    max-width: none;
  }
}

/* Entries – clean */
.entries {
    padding: 12px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.entry {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.entry__row {
    display: grid;
    grid-template-columns: 1fr max-content;
    gap: 12px;
    align-items: center;
}
.entry__left {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}
.entry__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entry__slots {
    opacity: 0.75;
}
.entry__right {
    text-align: right;
}
.entry__bar {
    height: 8px;
    width: 100%;
    background: var(--bar);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.entry__bar__fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--bar-fill), #7aa6ff);
    transition: width 0.5s ease;
}

/* Footer small */
.card__footer {
    padding: 8px 14px 14px;
    display: flex;
    justify-content: flex-end;
}

/* Error Box */
.error-box {
    margin: 16px clamp(16px, 4vw, 32px);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(239,68,68,.12);
    color: #ffd9d9;
    border: 1px solid #9b1c1c66;
    padding: 14px 16px;
    border-radius: 12px;
}
.error-box.is-hidden {
    display: none;
}

/* App footer */
.app-footer {
    padding: 20px clamp(16px, 4vw, 32px);
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
}

@media (max-width: 768px) {
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: rgba(13,16,22,0.95);
    }

    body {
        padding-top: var(--header-h);
    }
}
