:root {
    --bg: #1a1029;
    --bg-card: #241740;
    --bg-card-hover: #2d1d4e;
    --border: rgba(255,255,255,0.06);
    --text: #f0edf5;
    --text-dim: #9b8fb5;
    --accent: #a855f7;
    --accent-soft: rgba(168,85,247,0.15);
    --green: #22c55e;
    --green-soft: rgba(34,197,94,0.12);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.45;
    min-height: 100vh;
    overflow-x: hidden;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 14px 80px;
}

/* ── Header ── */
.header {
    padding: 8px 0 12px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #c084fc, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.live-dot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.live-dot span {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green);
    animation: blink 1.5s infinite;
}

.header-sub {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ── Filters ── */
.filters {
    display: flex;
    gap: 8px;
    margin: 12px 0 16px;
}

.filter-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.filter-chip:focus {
    border-color: var(--accent);
}

/* ── Loading ── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 0;
    color: var(--text-dim);
    font-size: 0.82rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid rgba(255,255,255,0.06);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.hidden { display: none !important; }

/* ── Rates list ── */
.rates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Rate Card ── */
.rate-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    transition: background 0.15s, border-color 0.15s;
    animation: fadeUp 0.35s ease both;
}

.rate-card:active {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.1);
}

/* Price row */
.rate-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.rate-price {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

.rate-price .currency {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-left: 4px;
}

.rate-price-label {
    font-size: 0.68rem;
    color: var(--text-dim);
}

.buy-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.buy-btn:active { opacity: 0.7; }

/* Seller row */
.rate-seller {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.seller-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.seller-name {
    font-size: 0.82rem;
    font-weight: 600;
}

.seller-stats {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-left: auto;
}

/* Info rows */
.rate-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rate-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.rate-info-row .label {
    color: var(--text-dim);
}

.rate-info-row .value {
    color: var(--text);
    font-weight: 500;
}

/* Payment badges */
.payment-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.pm-badge {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.68rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* Verified badge */
.verified {
    color: var(--accent);
    font-size: 0.7rem;
    margin-left: 2px;
}

/* Flash badge for very cheap */
.flash-badge {
    background: var(--green-soft);
    color: var(--green);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ── Footer ── */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 12px;
    font-size: 0.7rem;
    color: var(--text-dim);
    background: linear-gradient(transparent, var(--bg) 40%);
    pointer-events: none;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* ── Animations ── */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

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

/* ── Settings Panel ── */
.settings-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}

.settings-header:active {
    background: var(--bg-card-hover);
}

.settings-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.settings-icon {
    font-size: 1rem;
}

.chevron {
    font-size: 0.65rem;
    color: var(--text-dim);
    transition: transform 0.2s;
}

.settings-form {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 14px;
    transition: max-height 0.3s ease-out, opacity 0.2s;
}

.settings-form.collapsed {
    display: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 48px 10px 12px;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.input-suffix {
    position: absolute;
    right: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
}

.input-hint {
    font-size: 0.68rem;
    color: var(--text-dim);
    opacity: 0.8;
}

.form-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
}

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 38px;
    height: 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    transition: background-color 0.2s;
    border: 1px solid var(--border);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-container input:checked + .toggle-slider {
    background: var(--green);
    border-color: transparent;
}

.toggle-container input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

/* Save button */
.save-btn {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: white;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.save-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Status message */
.status-msg {
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    padding: 6px;
    border-radius: 6px;
    margin-top: 4px;
}

.status-msg.success {
    background: var(--green-soft);
    color: var(--green);
}

.status-msg.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

