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

:root {
    --primary-color: #ff6b6b;
    --primary-hover: #ee5a52;
    --secondary-color: #f06595;
    --accent-color: #fd7e14;
    --success-color: #20c997;
    --error-color: #fa5252;
    --warning-color: #fcc419;
    --info-color: #4dabf7;
    --bg-primary: #fff5f5;
    --bg-secondary: #ffffff;
    --bg-card: #fef2f2;
    --border-color: #ffc9c9;
    --border-light: #ffe3e3;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --shadow-sm: 0 2px 4px rgba(255, 107, 107, 0.1);
    --shadow-md: 0 4px 12px rgba(255, 107, 107, 0.15);
    --shadow-lg: 0 10px 30px rgba(255, 107, 107, 0.2);
    --shadow-xl: 0 20px 40px rgba(255, 107, 107, 0.25);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #ff6b6b 0%, #f06595 50%, #fd7e14 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.header {
    background: linear-gradient(135deg, #ff6b6b 0%, #f06595 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.header__title {
    font-size: 2.75rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

.header__icon {
    font-size: 3.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.navigation {
    background: var(--bg-primary);
    padding: 1.5rem 2rem;
    border-bottom: 3px solid var(--border-color);
}

.navigation__primary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.navigation__secondary {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding-top: 1.25rem;
    border-top: 2px solid var(--border-light);
    flex-wrap: wrap;
}

.sort-label {
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 0.5rem;
    font-size: 1rem;
}

.nav-btn,
.sort-btn {
    padding: 0.875rem 1.75rem;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.nav-btn {
    background: white;
    color: var(--text-primary);
    border-color: var(--border-color);
    font-size: 1.05rem;
    box-shadow: var(--shadow-sm);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.nav-btn--active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

.sort-btn {
    background: white;
    color: var(--text-secondary);
    padding: 0.625rem 1.25rem;
    font-size: 0.95rem;
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.sort-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.sort-btn--active {
    background: linear-gradient(135deg, var(--success-color), #12b886);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

.main-content {
    padding: 2.5rem;
    min-height: 450px;
    background: var(--bg-secondary);
}

.page-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--border-light);
}

.page-title {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 500;
}

.alert {
    padding: 1.25rem 1.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    border-left: 5px solid;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.alert--success {
    background: linear-gradient(135deg, #d3f9d8 0%, #b2f2bb 100%);
    border-color: var(--success-color);
    color: #087f5b;
}

.alert--error {
    background: linear-gradient(135deg, #ffe3e3 0%, #ffc9c9 100%);
    border-color: var(--error-color);
    color: #c92a2a;
}

.alert--info {
    background: linear-gradient(135deg, #d0ebff 0%, #a5d8ff 100%);
    border-color: var(--info-color);
    color: #1864ab;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 2px solid var(--border-light);
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.contacts-table thead {
    background: linear-gradient(135deg, #ff6b6b 0%, #f06595 100%);
    color: white;
}

.contacts-table th {
    padding: 1.25rem 1rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.contacts-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s ease;
}

.contact-row:hover {
    background: var(--bg-card);
}

.contact-row:last-child td {
    border-bottom: none;
}

.contact-name {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.comment-cell {
    max-width: 250px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pagination {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

.pagination__link {
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 48px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.pagination__link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pagination__link--active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.contact-form {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-light);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.75rem;
    margin-bottom: 1.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.form-group--error .form-input,
.form-group--error .form-select,
.form-group--error .form-textarea {
    border-color: var(--error-color);
    background: #fff5f5;
}

.form-label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

.required {
    color: var(--error-color);
    font-weight: 700;
}

.form-input,
.form-select,
.form-textarea {
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.1);
    transform: translateY(-1px);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-error {
    color: var(--error-color);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1.25rem;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 1rem 2.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn--primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.05);
}

.btn--secondary {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn--secondary:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.contacts-selector {
    margin-bottom: 2.5rem;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-light);
}

.selector-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.contact-card {
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.contact-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.contact-card--active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #ffe3e3 0%, #ffc9c9 50%);
    box-shadow: var(--shadow-md);
}

.contact-card__name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.contact-card__badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--success-color), #12b886);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edit-divider {
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color), var(--accent-color));
    margin: 3rem 0;
    border-radius: var(--radius-sm);
}

.delete-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.delete-item {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    padding: 1.75rem;
    background: white;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.delete-item:hover {
    border-color: var(--error-color);
    background: linear-gradient(135deg, #fff5f5 0%, #ffe3e3 100%);
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
}

.delete-item__icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.delete-item__content {
    flex: 1;
}

.delete-item__name {
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.delete-item__action {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.delete-item:hover .delete-item__action {
    color: var(--error-color);
    font-weight: 600;
}

.footer {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #fff0f0 100%);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 3px solid var(--border-color);
    font-size: 0.95rem;
    font-weight: 500;
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
    }

    .header__title {
        font-size: 2rem;
    }

    .header__icon {
        font-size: 2.5rem;
    }

    .navigation {
        padding: 1rem;
    }

    .main-content {
        padding: 1.5rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

    .contact-form {
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .contacts-grid {
        grid-template-columns: 1fr;
    }

    .contacts-table {
        font-size: 0.85rem;
    }

    .contacts-table th,
    .contacts-table td {
        padding: 0.75rem 0.5rem;
    }

    .btn {
        padding: 0.875rem 1.75rem;
        font-size: 0.95rem;
    }
}

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

.contact-row,
.contact-card,
.delete-item {
    animation: slideIn 0.3s ease-out;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}
