@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    font-family: 'Open Sans','Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #fff8fa 0%, #fef7f7 50%, #f8fbff 100%);
    color: #2c2c2c;
    padding: 16px;
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 200px;
    height: 100px;
    background: rgba(255, 255, 255, .4);
    border-radius: 50px;
    z-index: -1;
    animation: float 6s ease-in-out infinite
}

body::before {
    top: 20px;
    left: -50px;
    animation-delay: 0s
}

body::after {
    top: 150px;
    right: -50px;
    animation-delay: 3s
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0) rotate(0)
    }
    50% {
        transform: translateY(-20px) rotate(5deg)
    }
}

.header {
    text-align: center;
    margin-bottom: 12px;
    padding: 20px;
    background: linear-gradient(135deg, #ffb6c1, #dda0dd);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(221, 160, 221, .3);
    position: relative;
    overflow: hidden
}

.header::before {
    content: ' ';
    position: absolute;
    top: -10px;
    left: 20px;
    font-size: 40px;
    animation: bounce 2s ease-in-out infinite
}

.header::after {
    content: ' ';
    position: absolute;
    top: -10px;
    right: 20px;
    font-size: 40px;
    animation: bounce 2s ease-in-out infinite 1s
}

@keyframes bounce {
    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0)
    }
    40% {
        transform: translateY(-10px)
    }
    60% {
        transform: translateY(-5px)
    }
}

.header h1 {
    font-size: 20px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, .3);
    font-weight: 700;
    text-transform: uppercase;
}

.header p {
    color: #fff;
    font-size: 16px;
    font-weight: 500
}

.add-agency-btn {
    background: linear-gradient(135deg, #ffb6c1, #dda0dd);
    color: #fff;
    border: none;
    padding: 16px 28px;
    border-radius: 25px;
    font-size: 18px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 24px;
    transition: all .3s ease;
    box-shadow: 0 6px 20px rgba(221, 160, 221, .4);
    font-weight: 600;
    position: relative;
    overflow: hidden
}

.add-agency-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent);
    transition: left .5s
}

.add-agency-btn:hover::before {
    left: 100%
}

.add-agency-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(221, 160, 221, .6)
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 182, 193, .8);
    backdrop-filter: blur(5px);
    z-index: 1000
}

.modal-content {
    background: linear-gradient(135deg, #fff, #f8f9ff);
    margin: 20px;
    padding: 24px;
    border-radius: 20px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(221, 160, 221, .3);
    border: 2px solid rgba(221, 160, 221, .2)
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(221, 160, 221, .2)
}

.modal-header h2 {
    color: #8b008b;
    font-size: 24px;
    font-weight: 700
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #dda0dd;
    transition: all .3s ease
}

.close-btn:hover {
    color: #c71585;
    transform: scale(1.1)
}

.form-group {
    margin-bottom: 20px
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a4a4a;
    font-size: 16px
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid rgba(221, 160, 221, .3);
    border-radius: 15px;
    font-size: 16px;
    background: #fff;
    color: #2c2c2c;
    transition: all .3s ease
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #dda0dd;
    box-shadow: 0 0 15px rgba(221, 160, 221, .3);
    background: #fff
}

.form-group textarea {
    resize: vertical;
    min-height: 100px
}

.submit-btn {
    background: linear-gradient(135deg, #ffb6c1, #dda0dd);
    color: #fff;
    border: none;
    padding: 16px 28px;
    border-radius: 25px;
    font-size: 18px;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    transition: all .3s ease;
    box-shadow: 0 6px 20px rgba(221, 160, 221, .4)
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(221, 160, 221, .6)
}

.agency-card {
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "title price rating" "meta price rating";
    gap: 4px 10px;
    align-items: center;
    z-index: 1;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-radius: 20px;
}
.

.agency-title {
    grid-area: title;
    display: flex;
    flex-direction: column;
    gap: 2px
}

.agency-name {
    font-size: 16px;
    font-weight: 600;
    color: #8b008b;
    margin: 0
}

.agency-username-inline {
    color: #8b008b;
    font-weight: 600;
    font-size: 12px;
    background: #f5f3fb;
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-block;
    width: max-content
}

.agency-meta {
    grid-area: meta;
    color: #4a4a4a;
    font-size: 12px;
    font-weight: 600
}

.price-pill {
    grid-area: price;
    justify-self: end;
    color: #8b008b;
    font-weight: 600;
    font-size: 13px;
    background: #f6eafa;
    padding: 6px 10px;
    border-radius: 999px;
    align-self: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.rating-wrap {
    grid-area: rating;
    justify-self: end;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    grid-row: 1 / span 3;
    align-self: start
}

.rate-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #faf7fc;
    border: 1px solid rgba(221, 160, 221, .35);
    color: #8b008b;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
    white-space: nowrap
}

.rate-pill:hover {
    box-shadow: 0 6px 14px rgba(221, 160, 221, .18)
}

.delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffebee;
    border: 1px solid rgba(244, 67, 54, .35);
    color: #d32f2f;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: all .3s ease
}

.delete-btn:hover {
    background: #ffcdd2;
    box-shadow: 0 6px 14px rgba(244, 67, 54, .18);
    transform: scale(1.05)
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: #8b008b;
    font-size: 18px;
    font-weight: 600
}

.error {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    color: #c62828;
    padding: 16px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 2px solid #ef9a9a;
    text-align: center
}

.success {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    color: #2e7d32;
    padding: 16px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 2px solid #a5d6a7;
    text-align: center
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #8b008b
}

.empty-state h3 {
    margin-bottom: 16px;
    color: #8b008b;
    font-size: 24px;
    font-weight: 700
}

.empty-state p {
    font-size: 16px;
    color: #4a4a4a
}

.cloud {
    position: fixed;
    background: rgba(255, 255, 255, .5);
    border-radius: 50px;
    z-index: -1;
    animation: float 8s ease-in-out infinite
}

.cloud1 {
    width: 120px;
    height: 60px;
    top: 80px;
    left: 10%;
    animation-delay: 2s
}

.cloud2 {
    width: 80px;
    height: 40px;
    top: 200px;
    right: 15%;
    animation-delay: 4s
}

.cloud3 {
    width: 100px;
    height: 50px;
    bottom: 100px;
    left: 20%;
    animation-delay: 6s
}

.agency-name,
.agency-username-inline,
.agency-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.agency-conditions {
    grid-column: 1 / -1;
    margin-top: 6px;
    font-size: 12px;
    color: #5a5a5a;
    background: #faf7fc;
    border: 1px solid rgba(221, 160, 221, .25);
    border-radius: 10px;
    padding: 8px 10px;
    white-space: pre-wrap;
    word-break: break-word
}

.filters-row{display:flex;gap:12px;margin-bottom:12px;justify-content:space-between;align-items:center;flex-wrap:nowrap}
.sort-btn{background:linear-gradient(135deg,#ff6b9d,#ff8fab);border:none;color:#ffffff;padding:12px 24px;border-radius:25px;font-size:14px;font-weight:600;cursor:pointer;transition:all .3s ease;box-shadow:0 4px 15px rgba(255,107,157,.3);display:flex;align-items:center;gap:8px;min-width:140px;justify-content:center}
.sort-btn:hover{transform:translateY(-2px);box-shadow:0 6px 20px rgba(255,107,157,.4);background:linear-gradient(135deg,#ff5a8a,#ff7ba7)}
.sort-btn:active{transform:translateY(0);box-shadow:0 2px 10px rgba(255,107,157,.3)}

/* Выровнять кнопки в один ряд и по высоте */
.filters-row > div{display:flex;gap:10px;align-items:center}
.filters-row .add-agency-btn{width:auto;margin-bottom:0;padding:12px 18px;border-radius:25px;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.filters-row .sort-btn{padding:12px 24px}

/* Иконка-кнопка сортировки */
.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;border-radius:50%;border:none;background:linear-gradient(135deg,#ff6b9d,#ff8fab);box-shadow:0 4px 15px rgba(255,107,157,.3);cursor:pointer;margin:0}
.icon-btn img{width:22px;height:22px;filter:brightness(0) invert(1);opacity:1}
.icon-btn:hover{transform:translateY(-2px);box-shadow:0 6px 20px rgba(255,107,157,.4)}
.icon-btn:active{transform:translateY(0)}

@media (max-width: 480px) {
    .filters-row{flex-wrap:nowrap}
    .add-agency-btn{font-size:13px;padding:10px 12px}
    .icon-btn{width:44px;height:44px;margin:0}
    .icon-btn img{width:20px;height:20px}
}

/* Стили модального окна сортировки */
.sort-modal{display:none;position:fixed;bottom:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);z-index:2000;align-items:flex-end;justify-content:center}
.sort-modal-content{background:#fff;border-radius:16px 16px 0 0;width:100%;max-width:420px;box-shadow:0 -10px 30px rgba(0,0,0,.3);transform:translateY(100%);transition:transform .3s ease;animation:slideUp .3s ease forwards;max-height:90vh;overflow-y:auto;-webkit-overflow-scrolling:touch;margin:0 16px}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.sort-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #eee;position:sticky;top:0;background:#fff;z-index:1;min-height:56px}
.sort-header h3{font-size:18px;font-weight:700;color:#333;margin:0}
.sort-close-btn{background:none;border:none;font-size:22px;cursor:pointer;color:#999;padding:0;width:28px;height:28px;display:flex;align-items:center;justify-content:center}
.sort-close-btn:hover{color:#666}
.sort-options{padding:8px 0}
.sort-option{display:flex;align-items:center;padding:12px 20px;cursor:pointer;transition:background .2s ease}
.sort-option:hover{background:#f8f9fa}
.sort-option input[type=radio]{margin:0 12px 0 0;width:18px;height:18px;accent-color:#ffb6c1}
.sort-option-text{font-size:16px;color:#333;font-weight:500}
.sort-actions{display:flex;gap:10px;padding:12px 16px 40px;justify-content:stretch}
.sort-modal #addAgencyForm{padding:12px 20px 20px}
.apply-sort-btn{flex:1;background:linear-gradient(135deg,#ffb6c1,#dda0dd);color:#fff;border:none;padding:10px 16px;border-radius:12px;font-weight:700;cursor:pointer;font-size:15px}
.cancel-sort-btn{flex:1;background:#f5f5f5;color:#666;border:none;padding:10px 16px;border-radius:12px;font-weight:600;cursor:pointer;font-size:15px}
.cancel-sort-btn:hover{background:#eee}

.price-group{grid-column:1 / -1}
.price-slider{display:flex;align-items:center;gap:10px;width:100%}
.price-slider input[type=range]{flex:1;height:4px;border-radius:4px;background:#eee;outline:none;-webkit-appearance:none;appearance:none}
.price-slider input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; appearance:none; width:14px;height:14px;border-radius:50%;background:#fff;border:1px solid #cfcfcf;box-shadow:0 1px 3px rgba(0,0,0,.08);cursor:pointer}
.price-slider input[type=range]::-moz-range-thumb{ width:14px;height:14px;border-radius:50%;background:#fff;border:1px solid #cfcfcf;box-shadow:0 1px 3px rgba(0,0,0,.08);cursor:pointer}
.price-slider input[type=range]:hover::-webkit-slider-thumb{box-shadow:0 2px 6px rgba(0,0,0,.12)}
.price-slider input[type=range]:focus::-webkit-slider-thumb{border-color:#dda0dd}
.price-value{min-width:80px;text-align:right;color:#6a6a6a;font-weight:600;font-size:13px}
@media (max-width:700px){.price-value{min-width:68px;font-size:12px}}

@media (max-width:420px) {
    .add-agency-btn {
        padding: 12px 16px;
        font-size: 16px
    }
    .agency-card {
        padding: 10px 12px;
        gap: 4px 8px;
        grid-template-columns: 1fr auto auto;
        grid-template-areas: "title price rating" "username price rating" "meta price rating"
    }
    .agency-name {
        font-size: 16px
    }
    .agency-username-inline {
        font-size: 11px;
        padding: 2px 6px
    }
    .agency-meta {
        font-size: 11px
    }
    .price-pill {
        font-size: 12px;
        padding: 4px 8px;
        justify-self: end;
        align-self: start
    }
    .rating-wrap {
        gap: 4px;
        align-items: flex-end;
        grid-row: 1 / span 3;
        align-self: start
    }
    .rate-pill {
        font-size: 11px;
        padding: 4px 8px
    }
}