@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

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

:root {
    --brand-primary: #2CABE3;
    --brand-secondary: #FFFFFF;
    --brand-tertiary: #000000;
    --border-color: #E5E5E5;
    --hint-color: #666666;
    --bg-muted: #F8FCFE;
    --error: #E74C3C;
    --success: #27AE60;
    --telegram-color: #2AABEE;
    --telegram-hover: #229ED9;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--brand-secondary);
    color: var(--brand-tertiary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px 4px;
    margin: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-wrapper {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.card {
    background: var(--brand-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.telegram-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--telegram-color), var(--telegram-hover));
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(42, 171, 238, 0.2);
    font-size: 13px;
    font-weight: 600;
}

.telegram-banner svg {
    flex-shrink: 0;
}

.notification-group {
    margin-bottom: 8px;
    border: none;
    padding: 0;
}

.notification-group legend {
    margin: 0;
    padding: 0;
}

.notification-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.notification-option {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    background: var(--bg-muted);
    flex: 1 1 auto;
    justify-content: center;
}

.notification-option:hover {
    background: #EBF5FA;
    border-color: var(--brand-primary);
}

.notification-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--brand-primary);
    flex-shrink: 0;
}

.notification-option svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--brand-primary);
    opacity: 0.9;
}

.filter-option {
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    cursor: text;
}

.filter-option:focus-within {
    border-color: var(--brand-primary);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(44, 171, 227, 0.1);
}

.inline-number-input {
    width: 24px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-weight: 700;
    color: var(--brand-primary);
    text-align: center;
    padding: 0;
    font-size: 12px;
    appearance: textfield;
    -moz-appearance: textfield;
}

.inline-number-input::-webkit-outer-spin-button,
.inline-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.inline-number-input:focus {
    outline: none;
}

.inline-number-input::placeholder {
    color: #A0A0A0;
    font-weight: 400;
}

.unit {
    color: var(--hint-color);
    font-size: 12px;
    font-weight: 600;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 2px;
}

.subtitle {
    color: var(--hint-color);
    font-size: 14px;
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 8px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

input[type="email"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #D1D1D1;
    border-radius: 8px;
    font-size: 15px;
    direction: ltr;
    transition: border-color 0.2s ease;
}

input[type="email"]:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    padding: 2px;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--brand-secondary);
}

.category-item:hover {
    border-color: var(--brand-primary);
    background: var(--bg-muted);
}

.category-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-left: 12px;
    cursor: pointer;
    accent-color: var(--brand-primary);
}

.category-label {
    flex: 1;
    font-size: 13px;
}

.primary-btn {
    width: 100%;
    padding: 10px;
    background: var(--brand-primary);
    color: var(--brand-secondary);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.primary-btn:hover {
    background: #1F9DD1;
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

form button,
.form-action {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #2CABE3, #1F9DD1);
    color: var(--brand-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
    box-shadow: 0 10px 25px rgba(44, 171, 227, 0.25);
}

form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(30, 150, 201, 0.3);
}

form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-telegram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--telegram-color);
    color: white;
    text-decoration: none;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 10px;
    transition: all 0.2s ease;
    margin-top: 16px;
    width: 100%;
    box-shadow: 0 4px 12px rgba(42, 171, 238, 0.2);
}

.btn-telegram:hover {
    background: var(--telegram-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(42, 171, 238, 0.3);
    text-decoration: none;
}

.message {
    margin: 20px 0;
    padding: 14px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
}

.message.success {
    background: #e6f7f0;
    color: #12804d;
    border: 1px solid rgba(18, 128, 77, 0.2);
}

.message.error {
    background: #fdeceb;
    color: #b3201f;
    border: 1px solid rgba(179, 32, 31, 0.2);
}

.categories::-webkit-scrollbar {
    width: 6px;
}

.categories::-webkit-scrollbar-thumb {
    background: #DADADA;
    border-radius: 999px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.alert.success {
    background: #E8F8F0;
    color: var(--success);
}

.alert.error {
    background: #FDEDEC;
    color: var(--error);
}

.alert.show {
    display: block;
}

.input-hint {
    font-size: 12px;
    margin-top: 3px;
}

.helper-text {
    color: var(--hint-color);
}

.error-text {
    color: var(--error);
    display: none;
}

.error-text.show {
    display: block;
}

.loading {
    text-align: center;
    color: var(--hint-color);
    padding: 30px 0;
}

/* Status pages */
.status-wrapper {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.site-footer {
    margin-top: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    color: var(--hint-color);
    font-size: 13px;
    padding: 8px 0 2px;
}

.site-footer a {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.status-icon {
    font-size: 56px;
    margin-bottom: 16px;
    color: var(--brand-primary);
}

.preferences-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.preferences-header h1 {
    margin: 0;
}

.status-badge {
    display: none;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.show {
    display: inline-block;
}

.unsubscribe-btn {
    margin-top: 12px;
}

.status-badge.active {
    background: #E8F8F0;
    color: var(--success);
}

.status-badge.inactive {
    background: #FDEDEC;
    color: var(--error);
}

.danger-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.danger-btn:hover {
    background: var(--error);
    color: white;
}

.danger-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.back-link {
    margin-top: 10px;
    text-align: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-content p {
    margin: 0 0 20px 0;
    color: var(--hint-color);
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn-cancel,
.modal-btn-confirm {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.modal-btn-cancel {
    background: transparent;
    color: var(--hint-color);
    border: 1px solid var(--border-color);
}

.modal-btn-cancel:hover {
    background: var(--bg-muted);
}

.modal-btn-confirm {
    background: var(--error);
    color: white;
}

.modal-btn-confirm:hover {
    background: #c0392b;
}

.status-title {
    font-size: 24px;
    margin-bottom: 12px;
}

.status-message {
    color: var(--hint-color);
    font-size: 15px;
    margin-bottom: 24px;
}

@media (max-width: 520px) {
    .card {
        padding: 28px 22px;
    }

    h1 {
        font-size: 24px;
    }

    .categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}
