* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #09090b;
    --bg2: #111114;
    --bg3: #1a1a1f;
    --bg4: #222228;
    --border: #27272a;
    --text: #fafafa;
    --text2: #a1a1aa;
    --accent: #8b5cf6;
    --accent2: #6d28d9;
    --green: #22c55e;
    --red: #ef4444;
    --blue: #3b82f6;
    --yellow: #f5c542;
    --ton: #0098EA;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: 20px;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

.header-title { font-size: 20px; font-weight: 700; }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px 8px;
    position: sticky;
    top: 53px;
    background: var(--bg);
    z-index: 40;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--bg2);
    color: var(--text2);
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.tab.active { background: var(--accent); color: #fff; }
.tab:active { transform: scale(0.97); }

/* ===== Filter Buttons ===== */
.filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px;
}
.filters.hidden { display: none; }

.filters-row {
    display: flex;
    gap: 6px;
}

.filter-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
    min-height: 48px;
}
.filter-btn:active { transform: scale(0.97); }
.filter-btn .filter-btn-label {
    color: var(--text2);
    font-size: 11px;
    font-weight: 400;
}
.filter-btn .filter-btn-value {
    font-size: 13px;
    font-weight: 600;
}
.filter-btn-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.filter-btn .chevron {
    color: var(--text2);
    font-size: 10px;
    margin-left: 2px;
}

/* ===== Grid ===== */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 8px 16px;
}

/* ===== Card ===== */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cardIn 0.4s ease both;
}
.card:active { transform: scale(0.97); border-color: var(--accent); }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-img-wrap {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg3);
    flex-shrink: 0;
    position: relative;
}
.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Badges on image */
.card-badge {
    position: absolute;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
}
.card-badge-num { top: 8px; left: 8px; }
.card-badge-dur { bottom: 8px; left: 8px; font-size: 11px; font-weight: 600; }

/* Card info */
.card-info {
    padding: 10px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Price block */
.card-price-block {
    background: var(--bg3);
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}
.card-price-ton {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* TON SVG icon */
.ton-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: middle;
    display: inline-block;
    border-radius: 50%;
}

.per-day {
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
}

.card-price-rub {
    font-size: 11px;
    color: var(--text2);
    margin-top: 3px;
}

.card-discount {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(34, 197, 94, 0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
}

/* ===== Filter Modal (bottom sheet) ===== */
.filter-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.filter-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.filter-modal {
    background: var(--bg3);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.filter-modal-overlay.active .filter-modal {
    transform: translateY(0);
}

.filter-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 14px;
    flex-shrink: 0;
}
.filter-modal-head h3 {
    font-size: 18px;
    font-weight: 700;
}
.filter-modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.filter-search {
    margin: 0 20px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg4);
    border-radius: 12px;
    padding: 10px 14px;
    flex-shrink: 0;
}
.filter-search svg { color: var(--text2); flex-shrink: 0; }
.filter-search input {
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 100%;
}
.filter-search input::placeholder { color: var(--text2); }

.filter-list {
    overflow-y: auto;
    padding: 0 20px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}
.filter-item:last-child { border-bottom: none; }
.filter-item:active { opacity: 0.7; }

.filter-radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--text2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.filter-radio-inner {
    width: 0;
    height: 0;
    background: #fff;
    border-radius: 50%;
    transition: all 0.2s;
}
.filter-item.selected .filter-radio {
    border-color: var(--accent);
    background: var(--accent);
}
.filter-item.selected .filter-radio-inner {
    width: 8px;
    height: 8px;
}

/* Sort: selected item highlight */
.sort-item.selected {
    background: rgba(139, 92, 246, 0.15);
    margin: 0 -20px;
    padding: 14px 20px;
    border-radius: 12px;
}
.sort-item.selected .sort-label {
    color: var(--accent);
    font-weight: 700;
}

.filter-item-img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg4);
    object-fit: contain;
    flex-shrink: 0;
}
.filter-item-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent);
}

.filter-item-info {
    flex: 1;
    min-width: 0;
}
.filter-item-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sort-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.filter-apply {
    margin: 16px 20px 24px;
    padding: 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: all 0.2s;
}
.filter-apply:active { transform: scale(0.98); opacity: 0.9; }

/* ===== Loading ===== */
.loading {
    display: flex;
    justify-content: center;
    padding: 24px;
}
.loading.hidden { display: none; }

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text2);
    font-size: 14px;
}

/* ===== Detail Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--bg2);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    position: sticky;
    top: 0;
    background: var(--bg2);
}
.modal-title { font-size: 18px; font-weight: 700; flex: 1; padding-right: 12px; }

.modal-close {
    background: var(--bg3);
    border: none;
    color: var(--text2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-body {
    padding: 0 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 16px;
    margin: 0 auto;
    display: block;
    background: var(--bg3);
}

.modal-attrs { display: flex; flex-wrap: wrap; gap: 6px; }

.attr-tag {
    background: var(--bg3);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text2);
}
.attr-tag span { color: var(--text); font-weight: 500; }

.modal-pricing {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px;
}
.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}
.price-label { color: var(--text2); font-size: 13px; }
.price-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ton);
    display: flex;
    align-items: center;
    gap: 4px;
}
.price-value .ton-icon { width: 16px; height: 16px; }

.discount-badge {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 6px;
}

/* Duration picker */
.duration-picker { background: var(--bg); border-radius: 12px; padding: 14px; }
.duration-label { font-size: 13px; color: var(--text2); display: block; margin-bottom: 12px; }
.duration-label strong { color: var(--text); }

.duration-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg3);
    border-radius: 3px;
    outline: none;
}
.duration-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}
.duration-range {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text2);
    margin-top: 8px;
}

/* Total */
.total-section { background: var(--bg); border-radius: 12px; padding: 14px; }
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text2);
}
.total-prices { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.total-prices strong {
    font-size: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 5px;
}
.total-prices strong .ton-icon { width: 20px; height: 20px; }
.total-rub { font-size: 13px; color: var(--text2); }

/* Rent button */
.rent-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.rent-btn:active { transform: scale(0.98); }
.rent-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s;
    white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green); }
