:root {
    --primary-color: #7248B9;
    --primary-light: #8a5fd1;
    --primary-dark: #5d3b94;
    --success-color: #28a745;
    --info-color: #7248B9;
    --text-color: #2c3e50;
    --text-light: #6c757d;
    --bg-color: #f8f9fa;
    --white: #ffffff;
    --border-color: #e9ecef;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --fs-xs: clamp(0.75rem, 1.8vw + 0.5rem, 0.85rem);
    --fs-sm: clamp(0.85rem, 2vw + 0.5rem, 0.95rem);
    --fs-base: clamp(0.9rem, 2.2vw + 0.5rem, 1rem);
    --fs-md: clamp(1rem, 2.2vw + 0.5rem, 1.1rem);
    --fs-lg: clamp(1.05rem, 2.5vw + 0.5rem, 1.2rem);
    --fs-xl: clamp(1.2rem, 3vw + 0.5rem, 1.5rem);
    --fs-2xl: clamp(1.35rem, 3.5vw + 0.5rem, 2rem);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: clamp(15px, 2.2vw + 10px, 18px);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: var(--fs-base);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-width: 0;
}

/* Заголовок страницы / хлебные крошки */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.page-title {
    margin: 0 0 4px;
    font-size: var(--fs-2xl);
    color: var(--primary-color);
    font-weight: 700;
}
.page-subtitle {
    margin: 0;
    font-size: var(--fs-base);
    color: var(--text-light);
}

/* Кнопки: основная и вторичная */
.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}
.btn-primary:disabled,
.btn-primary.btn-submit-loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
.btn-secondary {
    background: var(--white);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-secondary:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Блок быстрого добавления расхода */
.quick-add-block {
    background: linear-gradient(135deg, #f8f6fc 0%, #f0ecf9 100%);
    border-radius: 14px;
    padding: 20px 24px;
    margin: 24px 0;
    border: 1px solid #e0d8f0;
}
.quick-add-title {
    margin: 0 0 16px;
    font-size: 1.15rem;
    color: var(--primary-color);
}
.quick-add-desc {
    margin: 0 0 14px;
    color: var(--text-light);
    font-size: 0.9rem;
}
.quick-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.quick-add-label {
    flex: 1;
    min-width: 120px;
}
.quick-add-label-sum { flex: 1; }
.quick-add-label-select { flex: 2; min-width: 180px; }
.field-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-light);
}
.quick-add-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.quick-add-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}
.quick-add-message {
    margin-top: 12px;
    font-size: 0.9rem;
    display: none;
}
.quick-add-message[style*="block"] {
    display: block;
}
.quick-add-income {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #a5d6a7;
}
.quick-add-income .quick-add-title { color: #2e7d32; }
.income-value { color: #1b5e20; font-weight: 600; }
.balance-value { font-weight: 700; }
.summary-item .balance-value.positive { color: #2e7d32; }
.summary-item .balance-value.negative { color: #c62828; }
tr.record-income td { background: rgba(232, 245, 233, 0.4); }
tr.record-expense td { background: transparent; }

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: var(--primary-color);
    font-size: var(--fs-2xl);
    margin-bottom: 10px;
}

.header p {
    color: var(--text-light);
    font-size: var(--fs-md);
}

.filters {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.filters .filter-group {
    flex: 1 1 180px;
    min-width: 120px;
}
.filters .filter-group label {
    display: block;
    margin-bottom: 4px;
    font-size: var(--fs-sm);
    color: var(--text-color);
    cursor: pointer;
}

.filters button[type="submit"], .filters button[type="button"] {
    margin: 0 8px 0 0;
    min-width: 140px;
    flex: 0 0 auto;
}

.filters input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--fs-base);
    transition: all 0.3s ease;
}

.filters input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}

.filters button {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    grid-column: 1 / -1;
    max-width: 300px;
    margin: 0 auto;
}

.filters button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.filters button[type="button"] {
    background: var(--white);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.filters button[type="button"]:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.summary {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.summary-main {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-item {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.summary-item h3 {
    color: var(--text-light);
    font-size: var(--fs-base);
    margin-bottom: 10px;
}

.summary-item .value {
    font-size: var(--fs-xl);
    font-weight: 700;
}

.summary-item .value.sum {
    color: var(--success-color);
}

.summary-item .value.count {
    color: var(--info-color);
}

.summary-categories {
    margin-top: 30px;
}

.summary-categories h3 {
    color: var(--primary-color);
    font-size: var(--fs-lg);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}
.stats-extra .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.stats-extra .category-item {
    cursor: default;
}
.stats-extra .category-item:hover {
    transform: none;
}

.category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.summary-categories:not(.stats-extra) .category-list {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
    .summary-categories:not(.stats-extra) .category-list {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 520px) {
    .summary-categories:not(.stats-extra) .category-list {
        grid-template-columns: 1fr;
    }
}

/* Табличное отображение категорий и комментариев */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-soft, 0 8px 20px rgba(15, 23, 42, 0.04));
}
.stats-table tbody tr.stats-row-category {
    font-weight: 600;
    cursor: pointer;
}
.stats-table tbody tr.stats-row-comment {
    color: var(--text-light);
    display: none;
}
.stats-table tbody tr.stats-row-category:hover {
    background: rgba(124, 58, 237, 0.04);
}
.stats-table tbody tr.stats-row-comment:hover {
    background: rgba(148, 163, 184, 0.08);
}
.stats-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}
.stats-table .stats-col-name {
    text-align: left;
}
.stats-table .stats-col-sum {
    text-align: right;
    white-space: nowrap;
}
.stats-table tbody tr:last-child td {
    border-bottom: none;
}
.stats-row-comment .stats-col-name {
    padding-left: 28px;
    position: relative;
}
.stats-row-comment .stats-col-name::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary-color);
    transform: translateY(-50%);
    opacity: 0.6;
}

/* Адаптация таблицы категорий: одна строка, название и сумма в ряд */
.stats-table .stats-col-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0; /* заставляет ячейку сжиматься, вторая займёт контент */
}
.stats-table .stats-col-sum {
    white-space: nowrap;
    vertical-align: middle;
    width: 1%;
}

@media (max-width: 640px) {
    .stats-table {
        border-radius: 12px;
        box-shadow: var(--shadow);
    }
    .stats-table td {
        padding: 8px 10px;
        font-size: 0.875rem;
    }
    .stats-table .stats-col-name {
        font-size: 0.875rem;
    }
    .stats-table .stats-col-sum {
        font-size: 0.875rem;
        font-weight: 600;
    }
    .stats-row-comment .stats-col-name {
        padding-left: 24px;
    }
}
.stats-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}
.stats-link:hover {
    color: var(--primary-dark);
}

.stats-toggle {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--text-color);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}
.stats-toggle::after {
    content: '▾';
    margin-left: 6px;
    font-size: 0.8em;
}
.stats-row-category.open .stats-toggle::after {
    content: '▴';
}

.data-table {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.data-table th, .data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--fs-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.data-table tr:hover {
    background: var(--bg-color);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination a {
    padding: 8px 16px;
    background: var(--white);
    color: var(--primary-color);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: var(--fs-sm);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--primary-color);
    color: var(--white);
}

.pagination a.active {
    background: var(--primary-color);
    color: var(--white);
}

.pagination .dots {
    padding: 8px 16px;
    color: var(--text-light);
}

.category-item, .user-item {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.category-item::after, .user-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-item:hover::after, .user-item:hover::after {
    opacity: 0.1;
}

.category-item:active, .user-item:active {
    transform: scale(0.98);
}

.user-stats {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.user-stats h3 {
    color: var(--primary-color);
    font-size: var(--fs-lg);
    margin-bottom: 20px;
}

.user-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.user-item {
    background: var(--bg-color);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.user-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.user-item .name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: var(--fs-md);
}

.user-item .stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item .sum {
    color: var(--success-color);
    font-weight: 600;
    font-size: var(--fs-md);
}

.user-item .count {
    color: var(--info-color);
    font-size: var(--fs-sm);
}

.calendar-section {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-top: 30px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-title {
    color: var(--primary-color);
    font-size: var(--fs-lg);
    font-weight: 600;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-nav button {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calendar-nav button:hover {
    background: var(--primary-dark);
}

.summary-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.calendar-weekday {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
    padding: 10px;
    font-size: var(--fs-sm);
}

.calendar-day {
    aspect-ratio: 1;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.calendar-day:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.calendar-day.empty {
    background: none;
    cursor: default;
}

.calendar-day .date {
    font-size: var(--fs-md);
    font-weight: 600;
    margin-bottom: 5px;
}

.calendar-day .sum {
    font-size: var(--fs-xs);
    color: var(--success-color);
}

.calendar-day.today {
    background: var(--primary-color);
    color: var(--white);
}

.calendar-day.today .sum {
    color: var(--white);
}

/* Карточки с графиками (analytics.php) */
.chart-card {
    margin-top: 20px;
    height: 320px;
    max-height: 320px;
    overflow: hidden;
}
.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 768px) {
    .container > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .data-table, .calendar-section {
        width: 100%;
        max-width: 100vw;
        min-width: 0;
        margin: 0 auto;
        box-sizing: border-box;
        padding: 6px 0;
        overflow-x: auto;
        display: block;
    }
    .data-table table {
        min-width: 320px;
        width: 100%;
        margin: 0 auto;
    }
    .data-table th, .data-table td {
        padding: 6px 4px;
        font-size: var(--fs-xs);
    }
    .calendar-section {
        padding: 6px 0;
    }
    .calendar-grid {
        min-width: 240px;
        width: 100%;
        margin: 0 auto;
        gap: 4px;
    }
    .calendar-day, .calendar-weekday {
        padding: 4px 0;
        min-width: 28px;
        min-height: 28px;
        font-size: var(--fs-xs);
    }
    .filters form {
        justify-content: center;
    }
    #toggle-password-change-btn, #toggle-table-btn, #toggle-table-btn-admin, a[href*="logout"] {
        white-space: normal !important;
        word-wrap: break-word;
        min-height: 48px !important;
    }
}
.data-table, .calendar-section {
    margin-left: auto;
    margin-right: auto;
}

/* Страница входа: блок-описание и сетка */
.page-intro {
    max-width: 900px;
    margin: 0 auto 30px;
    background: linear-gradient(135deg, #f8f6fc 0%, #f0ecf9 100%);
    border-radius: 14px;
    padding: 28px;
    border: 1px solid #e0d8f0;
}
.page-intro-title {
    margin: 0 0 16px;
    color: var(--primary-color);
    font-size: 1.5rem;
    text-align: center;
}
.page-intro-text {
    margin: 0;
    color: var(--text-light);
    line-height: 1.6;
    text-align: center;
    font-size: 1rem;
}

.auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
}
@media (max-width: 700px) {
    .auth-grid {
        grid-template-columns: 1fr;
    }
}

.auth-form {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.auth-form-standalone {
    margin: 0;
    max-width: none;
}
.auth-form-title,
.auth-form h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    margin-top: 0;
    text-align: center;
    font-size: var(--fs-xl);
}
.yes-message {
    color: var(--success-color);
    margin-top: 10px;
    font-size: 0.9rem;
    display: none;
}
.yes-message-visible {
    display: block;
    background: #e8f5e9;
    padding: 10px;
    border-radius: 6px;
}

.register-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px;
}
.register-card-title {
    margin-top: 0;
    color: var(--primary-color);
    font-size: var(--fs-xl);
}
.register-card-text {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.register-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s;
}
.register-btn:hover {
    background: var(--primary-dark);
}
.register-card-hint {
    margin-top: 16px;
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
}

/* Блок «Мой дневной лимит» и форма смены пароля */
.my-limit-card {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 8px;
}
.my-limit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.my-limit-label {
    color: var(--text-light);
    font-size: 0.9em;
    margin-bottom: 5px;
}
.my-limit-value {
    font-size: 1.3rem;
    font-weight: 600;
}
.my-limit-value-primary { color: var(--primary-color); }
.my-limit-value-ok { color: var(--success-color); }
.my-limit-value-over { color: #dc3545; }
.my-limit-value-muted { color: var(--text-light); }
.my-limit-value-sm { font-size: 1.2rem; }
.my-limit-form {
    display: flex;
    gap: 10px;
    align-items: center;
    max-width: 400px;
    flex-wrap: wrap;
}
.my-limit-form label { flex: 1; min-width: 120px; }
.my-limit-form .limit-input { width: 100%; }
.form-block-desc {
    margin: 0 0 16px;
    color: var(--text-light);
    font-size: 0.95em;
}
.form-block-error {
    margin: 0 0 12px;
    color: #dc3545;
    font-size: 0.95em;
}
.form-block-form { width: 100%; max-width: 400px; }
.form-block label {
    display: block;
    margin-bottom: 12px;
}
.form-block label span {
    display: block;
    margin-bottom: 4px;
    color: var(--text-light);
    font-size: 0.9em;
}
.form-block .limit-input { width: 100%; }
.form-block button { margin-top: 4px; }
.my-limit-muted-hint { font-size: 0.85em; color: var(--text-light); margin-top: 5px; }
.my-limit-section { margin-top: 30px; }

.auth-form h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
    font-size: var(--fs-xl);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--fs-base);
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: var(--fs-base);
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-form button:hover {
    background: var(--primary-dark);
}

.auth-error {
    color: #dc3545;
    margin-bottom: 15px;
    text-align: center;
}

.logout-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: var(--fs-sm);
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--primary-dark);
}

.chat-config {
    margin-top: 30px;
    padding: 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.chat-config.admin-section {
    margin-top: 32px;
    border: 1px solid rgba(114, 72, 185, 0.2);
    background: linear-gradient(180deg, #fdfbff 0%, var(--white) 100%);
}
.chat-config.admin-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-config.admin-section h3::before {
    content: '';
    width: 4px;
    height: 1.2em;
    background: var(--primary-color);
    border-radius: 2px;
}
.users-limits-table {
    width: 100%;
    border-collapse: collapse;
}
.users-limits-table th,
.users-limits-table td {
    padding: 12px 10px;
    border: 1px solid var(--border-color);
    text-align: left;
    font-size: var(--fs-sm);
}
.users-limits-table thead tr {
    background: #f3f0fa;
    color: var(--primary-color);
    font-weight: 700;
}
.users-limits-table tbody tr:hover {
    background: var(--bg-color);
}
.users-limits-table .name { font-weight: 600; }
.users-limits-table .id { color: var(--text-light); font-size: 0.9em; }
.users-limits-table .limit-ok { color: var(--success-color); font-weight: 600; }
.users-limits-table .limit-over { color: #dc3545; font-weight: 600; }
.users-limits-table .limit-na { color: var(--text-light); }

/* Кнопка OK и поля в таблице лимитов (админка) */
.chat-config.admin-section .users-limits-table .btn-ok,
.users-limits-table .btn-ok {
    padding: 8px 14px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.1s;
}
.chat-config.admin-section .users-limits-table .btn-ok:hover,
.users-limits-table .btn-ok:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}
.chat-config.admin-section .users-limits-table .form-inline .limit-input,
.users-limits-table .form-inline .limit-input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--fs-sm);
    background: var(--white);
}
.chat-config.admin-section .users-limits-table .access-select,
.users-limits-table .access-select {
    min-width: 140px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--fs-sm);
    background: var(--white);
    color: var(--text-color);
}
.chat-config.admin-section .users-limits-table .delete-btn,
.users-limits-table .delete-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.chat-config.admin-section .users-limits-table .delete-btn:hover,
.users-limits-table .delete-btn:hover {
    background: #c82333;
}

.form-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.form-inline .limit-input { width: 100px; }

#dynamic-blocks-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

#password-change-block,
#table-container,
#table-container-admin {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#table-container .data-table,
#table-container-admin .data-table {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#password-change-block form {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-config h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: var(--fs-lg);
}

.chat-list {
    display: grid;
    gap: 10px;
}

.chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
}

.chat-item .id {
    font-family: monospace;
    color: var(--text-light);
}

.chat-item .name {
    font-weight: 500;
}

.chat-config form.add-chat {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.chat-config input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-config input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}
.chat-config input[type="number"] {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-config input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}
.chat-config input[type="password"] {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-config input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}
.chat-config .limit-form input[type="number"] {
    padding: 8px 12px;
    width: 110px;
}
.chat-config select,
.chat-config .access-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    min-width: 140px;
    max-width: 100%;
    appearance: auto;
}
.chat-config select:focus,
.chat-config .access-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 72, 185, 0.1);
}
.chat-config button.add-btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}
.chat-config button.add-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}
.chat-item {
    position: relative;
}
.chat-item .delete-btn {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 16px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}
.chat-item .delete-btn:hover {
    color: #a71d2a;
}
.chat-config .delete-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-config .delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Универсальное модальное окно в стилистике сайта */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 62, 80, 0.4);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.modal-overlay.is-open {
    display: flex;
}
.modal-box {
    background: var(--white);
    padding: 28px 32px 24px;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(114, 72, 185, 0.08);
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: modalAppear 0.2s ease-out;
}
@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.modal-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
}
.modal-msg {
    color: var(--text-light);
    font-size: var(--fs-base);
    line-height: 1.5;
    margin-bottom: 24px;
}
.modal-btns {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
}
.modal-btn:hover {
    transform: translateY(-1px);
}
.modal-btn-primary {
    background: var(--primary-color);
    color: var(--white);
}
.modal-btn-primary:hover {
    background: var(--primary-dark);
}
.modal-btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}
.modal-btn-secondary:hover {
    background: #dee2e6;
}
.modal-btn-danger {
    background: #dc3545;
    color: var(--white);
}
.modal-btn-danger:hover {
    background: #c82333;
}

.data-table th {
    background: #f3f0fa;
    color: #7248B9;
    font-weight: 700;
    border-bottom: 2px solid #d1c4e9;
    font-size: var(--fs-sm);
}

.toggle-table-btn {
    background: #7248B9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: var(--fs-md);
    font-weight: 600;
    padding: 14px 36px;
    margin: 20px 0 15px 0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(114,72,185,0.08);
    transition: background 0.2s, transform 0.1s;
    outline: none;
    display: inline-block;
}
.toggle-table-btn:hover, .toggle-table-btn:focus {
    background: #5d3b94;
    transform: translateY(-2px) scale(1.03);
}

/* Одинаковая высота для всех кнопок нижней панели */
#toggle-password-change-btn,
#toggle-table-btn,
#toggle-table-btn-admin,
a[href*="logout"] {
    min-height: 48px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    line-height: 1.4;
}

.delete-record-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.delete-record-btn:hover {
    background: #a71d2a;
}
