:root {
    --bg: #0b0b0d;
    --surface: #151519;
    --border: #35353b;
    --text: #f1f1f2;
    --text-muted: #a4a4ac;
    --primary: #b10f1c;
    --success: #6ac46f;
    --danger: #ff4b4b;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background:
        radial-gradient(circle at 12% -10%, rgba(177, 15, 28, 0.22), transparent 34%),
        radial-gradient(circle at 88% 0%, rgba(255, 255, 255, 0.06), transparent 28%),
        var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

.navbar {
    background: var(--surface);
    border-bottom: 1px solid #4a4a52;
    padding: 0.75rem 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.nav-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.nav-brand-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    padding-bottom: 0.5rem;
}

.nav-brand-row .nav-profile {
    margin-left: auto;
    flex-shrink: 0;
}

.nav-main-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    gap: 0.5rem 1rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-main-row .nav-links,
.nav-main-row .nav-links-guest {
    flex: 1 1 auto;
    justify-content: flex-start;
    min-width: 0;
}

.rt-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
}

.rt-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    background: linear-gradient(145deg, #f0202f, #ad0e19);
    color: #fff;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.rt-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
    display: block;
}

.rt-brand-name {
    font-family: "Germania One", "Old English Text MT", "Times New Roman", serif;
    font-size: 2.35rem;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #f4f4f5;
}

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1 1 auto;
    justify-content: flex-start;
    min-width: 0;
}

.nav-profile {
    margin-left: 0;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.nav-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.nav-profile-link:hover,
.nav-profile-link.active {
    color: var(--primary);
    border-color: rgba(88,166,255,0.35);
}

.nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0b1016;
    display: inline-block;
}

.nav-avatar-placeholder {
    background: #0b1016;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.02rem;
    font-weight: 700;
    display: inline-block;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(177, 15, 28, 0.35);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

main.container h1 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Full-bleed sections inside centered container */
.full-bleed {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border-radius: 0;
}

/* Treasurer payments matrix: fit screen without horizontal scroll */
.payments-matrix {
    padding-left: 1rem;
    padding-right: 1rem;
}
.payments-matrix .matrix-wrap {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
}
.payments-matrix .matrix-table {
    table-layout: fixed;
}
.payments-matrix .matrix-table th,
.payments-matrix .matrix-table td {
    padding: 0.35rem 0.4rem;
}
.payments-matrix .matrix-sticky {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 2;
}
.payments-matrix td.matrix-sticky {
    z-index: 1;
}
.payments-matrix .matrix-name {
    width: 280px;
}
.payments-matrix .matrix-month,
.payments-matrix .matrix-cell {
    width: calc((100% - 280px) / 12);
    text-align: center;
    white-space: nowrap;
}
.payments-matrix .matrix-name {
    white-space: normal;
}
.payments-matrix input.pay-toggle {
    transform: scale(1.25);
    transform-origin: center;
}
.payments-matrix .partial-btn {
    padding: 0.25rem 0.45rem;
    font-size: 0.9rem;
    max-width: none;
}

@media (max-width: 900px) {
    .payments-matrix .matrix-name { width: 210px; }
    .payments-matrix .matrix-month,
    .payments-matrix .matrix-cell { width: calc((100% - 210px) / 12); }
    .payments-matrix .matrix-table th,
    .payments-matrix .matrix-table td { padding: 0.3rem 0.35rem; }
}

@media (max-width: 700px) {
    .payments-matrix .matrix-name { width: 170px; }
    .payments-matrix .matrix-month,
    .payments-matrix .matrix-cell { width: calc((100% - 170px) / 12); }
    .payments-matrix .matrix-table th { font-size: 0.75rem; }
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success { background: rgba(63, 185, 80, 0.2); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: rgba(248, 81, 73, 0.2); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background: rgba(210, 180, 50, 0.2); color: #d4b832; border: 1px solid #d4b832; }
.alert-info { background: rgba(88, 166, 255, 0.2); color: var(--primary); border: 1px solid var(--primary); }

.auth-box {
    max-width: 360px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.auth-box::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.auth-box h1 {
    margin-top: 0;
    font-size: 1.5rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.rt-login-brand {
    text-align: center;
    margin-bottom: 0.9rem;
}

.rt-login-large-logo {
    width: min(100%, 340px);
    margin: 0 auto 0.35rem;
}

.rt-login-large-logo img {
    display: block;
    width: 100%;
    height: auto;
}

.rt-login-mark {
    display: inline-grid;
    place-items: center;
    width: 70px;
    height: 70px;
    margin: 0 auto 0.45rem;
    border-radius: 14px;
    border: 2px solid rgba(255,255,255,0.78);
    background: linear-gradient(160deg, #f21e2f, #9e0d18);
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 2px 0 rgba(0,0,0,0.45);
    box-shadow: 0 8px 20px rgba(177, 15, 28, 0.32);
}

.rt-login-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.rt-login-name {
    font-family: Georgia, "Times New Roman", serif;
    text-transform: uppercase;
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #f2f2f3;
}

.rt-login-sub {
    margin-top: 0.12rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.auth-form label {
    display: block;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form input[type="text"],
.auth-form input[type="tel"],
.auth-form input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.password-field-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-top: 0.25rem;
}

.password-field-row .password-input {
    flex: 1;
    min-width: 0;
    margin-top: 0;
}

.password-field-row .btn-toggle-password {
    flex-shrink: 0;
    align-self: center;
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated, #1a1d24);
    color: var(--text);
}

.password-field-row .btn-toggle-password:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.profile-pw-sms-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.profile-pw-sms-wrap .auth-sending-overlay {
    border-radius: 8px;
}

.profile-pw-sms-wrap.is-sending .auth-sending-overlay {
    display: flex;
}

.profile-pw-sms-wrap.is-sending #profilePwSmsBtn {
    pointer-events: none;
    opacity: 0.55;
}

.auth-form-wrap {
    position: relative;
}

.auth-sending-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(11, 11, 13, 0.78);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
}

.auth-form-wrap.is-sending .auth-sending-overlay {
    display: flex;
}

.auth-form-wrap.is-sending .auth-form {
    pointer-events: none;
    opacity: 0.45;
}

.rt-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rt-spin 0.65s linear infinite;
}

@keyframes rt-spin {
    to {
        transform: rotate(360deg);
    }
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    width: auto;
    max-width: 260px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 6px 16px rgba(177,15,28,0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    max-width: none;
}

/* --- Стена (лента) --- */
.wall-compose-title {
    font-size: 1.1rem;
    margin-top: 0;
}

.wall-form .wall-label {
    display: block;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.wall-form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    resize: vertical;
    min-height: 5rem;
}

.wall-form input[type="file"] {
    display: block;
    margin-top: 0.35rem;
    max-width: 100%;
}

.wall-hint {
    font-size: 0.82rem;
    margin: -0.5rem 0 0.75rem;
}

.wall-feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.25rem;
}

.wall-post-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.wall-post-author {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.wall-post-author-meta {
    min-width: 0;
}

.wall-post-author-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
}

.wall-post-author-link:hover .wall-post-name-text,
.wall-post-author-link:focus-visible .wall-post-name-text {
    text-decoration: underline;
}

.wall-post-author-link:focus {
    outline: none;
}

.wall-post-author-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.wall-post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.wall-post-avatar-ph {
    display: inline-block;
    background: #0b1016;
}

.wall-post-name,
.wall-post-name-link,
.wall-post-name-text {
    font-weight: 700;
    font-size: 1rem;
}

.wall-post-date {
    font-size: 0.82rem;
    margin-top: 0.1rem;
}

.wall-delete-form {
    flex-shrink: 0;
}

.wall-post-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    margin-bottom: 0.75rem;
}

.wall-votes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.65rem;
    margin-top: 0.15rem;
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
}

.wall-vote-form {
    display: inline;
    margin: 0;
}

.wall-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    line-height: 1.2;
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.wall-vote-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
}

.wall-vote-btn:focus {
    outline: none;
}

.wall-vote-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.wall-vote-btn:disabled {
    opacity: 0.55;
    cursor: wait;
    pointer-events: none;
}

.wall-vote-btn--like.is-active {
    color: var(--success);
    border-color: rgba(106, 196, 111, 0.45);
    background: rgba(106, 196, 111, 0.12);
}

.wall-vote-btn--dislike.is-active {
    color: var(--danger);
    border-color: rgba(255, 75, 75, 0.45);
    background: rgba(255, 75, 75, 0.1);
}

.wall-vote-icon {
    flex-shrink: 0;
    opacity: 0.9;
}

.wall-vote-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 1ch;
}

.wall-votes-readonly {
    font-size: 0.86rem;
}

.wall-vote-sep {
    margin: 0 0.2rem;
    opacity: 0.5;
}

.wall-vote-readonly-pair .wall-vote-icon-inline {
    margin-right: 0.15rem;
    font-weight: 700;
    opacity: 0.75;
}

.wall-comments-details {
    margin-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.wall-comments-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    user-select: none;
    border-radius: 6px;
    margin: 0 -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.wall-comments-summary::-webkit-details-marker {
    display: none;
}

.wall-comments-summary:hover {
    color: var(--primary);
}

.wall-comments-summary:focus {
    outline: none;
}

.wall-comments-summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.wall-comments-summary-chevron {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
    margin-top: -0.2em;
}

.wall-comments-details[open] > .wall-comments-summary .wall-comments-summary-chevron {
    transform: rotate(45deg);
    margin-top: 0.05em;
}

.wall-comments-summary-label {
    font-weight: 600;
}

.wall-comments-count {
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(88, 166, 255, 0.18);
    color: var(--primary);
    line-height: 1;
}

.wall-comments-load-wrap {
    margin: 0 0 0.65rem;
}

.wall-comments-load-more:disabled {
    opacity: 0.65;
    cursor: wait;
}

.wall-comment-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}

.wall-comment + .wall-comment {
    margin-top: 0.65rem;
}

.wall-comment-inner {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.wall-comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    display: block;
}

.wall-comment-avatar-ph {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0b1016;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.wall-comment-avatar-link {
    line-height: 0;
    border-radius: 50%;
}

.wall-comment-main {
    min-width: 0;
    flex: 1;
}

.wall-comment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.65rem;
    font-size: 0.88rem;
    margin-bottom: 0.2rem;
}

.wall-comment-author-name {
    font-weight: 600;
}

.wall-comment-date {
    font-size: 0.82rem;
}

.wall-comment-delete-form {
    display: inline;
    margin: 0;
}

.wall-comment-delete-btn {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    color: var(--danger);
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
}

.wall-comment-delete-btn:hover {
    color: #ff8a80;
}

.wall-comment-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-size: 0.95rem;
}

.wall-comment-body + .wall-comment-media {
    margin-top: 0.45rem;
}

.wall-comment-media {
    margin-top: 0.35rem;
    max-width: min(100%, 360px);
}

.wall-comment-media .wall-fs-trigger img,
.wall-comment-media .wall-fs-trigger video {
    max-height: 220px;
    width: 100%;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: middle;
}

.wall-comment-media .wall-fs-trigger--video video {
    background: #000;
}

.wall-comment-compose-hint {
    font-size: 0.8rem;
    margin: 0.25rem 0 0.35rem;
}

.wall-comment-media-label {
    display: block;
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
}

.wall-comment-media-label input[type="file"] {
    margin-top: 0.2rem;
    max-width: 100%;
}

.wall-comment-edit-details {
    display: inline-block;
    margin-right: 0.35rem;
}

.wall-comment-meta .wall-comment-edit-details[open] {
    flex: 1 0 100%;
    margin-right: 0;
}

.wall-comment-edit-summary {
    cursor: pointer;
    font-size: 0.82rem;
    list-style: none;
    user-select: none;
}

.wall-comment-edit-summary::-webkit-details-marker {
    display: none;
}

.wall-comment-edit-summary:hover {
    color: var(--primary);
}

.wall-comment-edit-form {
    margin-top: 0.5rem;
    padding: 0.5rem 0 0;
    border-top: 1px solid var(--border);
    max-width: 100%;
}

.wall-comment-edit-label {
    font-size: 0.88rem;
}

.wall-comments-panel {
    padding-top: 0.25rem;
    padding-bottom: 0.35rem;
}

.wall-comment-compose {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0;
    padding-top: 0;
}

.wall-comment-list + .wall-comment-compose {
    margin-top: 0.35rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.wall-comment-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.45;
    resize: vertical;
    min-height: 3.25rem;
    max-height: 14rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wall-comment-input::placeholder {
    color: var(--text-muted);
    opacity: 0.85;
}

.wall-comment-input:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

.wall-comment-input:focus {
    outline: none;
    border-color: rgba(88, 166, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.wall-comment-actions {
    display: flex;
    justify-content: flex-end;
}

.wall-comment-readonly-hint {
    font-size: 0.86rem;
    margin: 0.5rem 0 0;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.wall-feed-comment-hint {
    font-size: 0.9rem;
    margin: 1rem 0 0;
}

.wall-post-media {
    margin-top: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0b1016;
}

.wall-post-media .wall-fs-trigger--image img,
.wall-post-media .wall-fs-trigger--video video {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.wall-fs-trigger {
    display: block;
    width: 100%;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    color: inherit;
}

.wall-fs-trigger--image {
    cursor: zoom-in;
}

.wall-fs-trigger--video {
    position: relative;
    cursor: pointer;
}

.wall-fs-trigger:focus {
    outline: none;
}

.wall-fs-trigger:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.wall-fs-play-icon {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.wall-fs-play-icon::after {
    content: "";
    position: absolute;
    left: calc(50% + 3px);
    top: 50%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 0.65rem 0 0.65rem 1.1rem;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.95);
}

/* Fullscreen-style lightbox for wall media */
.wall-fs-viewer {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.wall-fs-viewer.open {
    display: flex;
}

.wall-fs-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    z-index: 0;
}

.wall-fs-viewer .gallery-viewer-close {
    z-index: 2;
}

.wall-fs-stage {
    position: relative;
    z-index: 1;
    max-width: 100%;
    max-height: 100%;
    padding: 3.25rem 0.75rem 0.75rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wall-fs-stage img,
.wall-fs-stage video {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

@media (max-width: 720px) {
    .wall-fs-stage {
        padding: 3rem 0.35rem 0.35rem;
    }

    .wall-fs-stage img,
    .wall-fs-stage video {
        max-width: 100vw;
        max-height: 100vh;
    }
}

.wall-post-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.5rem;
}

.wall-edit-details {
    text-align: right;
}

.wall-edit-details > summary {
    list-style: none;
    cursor: pointer;
}

.wall-edit-details > summary::-webkit-details-marker {
    display: none;
}

/* Иконки «Редактировать» / «Удалить» на стене: ~48×48 px для удобного тапа */
.wall-action-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    vertical-align: middle;
}

.wall-action-btn:hover {
    color: var(--primary);
    border-color: rgba(88, 166, 255, 0.45);
}

.wall-action-btn:focus {
    outline: none;
}

.wall-action-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.wall-action-btn--danger {
    color: var(--danger);
    border-color: rgba(248, 81, 73, 0.35);
}

.wall-action-btn--danger:hover {
    color: #ff8a80;
    border-color: rgba(248, 81, 73, 0.55);
}

.wall-action-btn__icon {
    width: 1.4rem;
    height: 1.4rem;
    flex-shrink: 0;
    pointer-events: none;
}

.wall-edit-form {
    margin-top: 0.75rem;
    text-align: left;
    max-width: 100%;
}

.wall-remove-media-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.wall-preview-wrap {
    margin: 0.5rem 0 0.75rem;
}

.wall-preview-label {
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

.wall-preview-box {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0b1016;
    max-width: 100%;
}

.wall-preview-box img,
.wall-preview-box video {
    display: block;
    max-width: 100%;
    max-height: 240px;
    width: auto;
    margin: 0 auto;
    object-fit: contain;
}

.wall-preview-clear {
    margin-top: 0.5rem;
}

.wall-pagination {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.wall-pagination-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.balance-other-debt-h3 {
    margin-top: 1rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.balance-other-debt-h3:first-child {
    margin-top: 0;
}

.balance-other-debt-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
}

.balance-other-debt-profile:hover .balance-other-debt-name,
.balance-other-debt-profile:focus-visible .balance-other-debt-name {
    text-decoration: underline;
}

.balance-other-debt-profile:focus {
    outline: none;
}

.balance-other-debt-profile:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.balance-other-debt-name {
    font-weight: 700;
    color: var(--primary);
}

.balance-other-debt-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.balance-other-debt-avatar-ph {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0b1016;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* In-app chat (fallback when Rocket.Chat не настроен) */
.chat-msg-row {
    display: flex;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-msg-main {
    min-width: 0;
    flex: 1;
}

.chat-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    display: block;
}

.chat-profile-avatar-ph {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-block;
    background: #0b1016;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

a.chat-profile-snippet {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
    border-radius: 8px;
}

a.chat-profile-snippet:hover .chat-profile-name,
a.chat-profile-snippet:focus-visible .chat-profile-name {
    text-decoration: underline;
}

a.chat-profile-snippet:focus {
    outline: none;
}

a.chat-profile-snippet:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.chat-profile-name {
    font-weight: 700;
}

a.chat-profile-name-link {
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
}

a.chat-profile-name-link:hover .chat-profile-name,
a.chat-profile-name-link:focus-visible .chat-profile-name {
    text-decoration: underline;
}

a.chat-profile-name-link:focus {
    outline: none;
}

a.chat-profile-name-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Таблица взносов: годы и названия месяцев */
.contrib-cal-table .contrib-cal-year,
.contrib-cal-table .contrib-cal-month {
    color: var(--primary);
}

.contrib-cal-table thead .contrib-cal-year,
.contrib-cal-table thead .contrib-cal-month {
    font-weight: 700;
}

.contrib-cal-table tbody .contrib-cal-year {
    font-weight: 700;
}

.auth-form .btn { margin-top: 0.5rem; }
.auth-link { margin-top: 1rem; text-align: center; }
.auth-link a { color: var(--primary); }

.auth-box .btn {
    width: 220px;
    max-width: 100%;
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.auth-register-btn {
    margin-top: 0.7rem;
}

@media (max-width: 480px) {
    .auth-box {
        max-width: 100%;
        margin: 0.75rem auto;
        padding: 1rem 0.875rem;
        border-radius: 10px;
    }

    .auth-box h1 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .auth-form label {
        margin-bottom: 0.75rem;
        font-size: 0.88rem;
    }

    .auth-form input[type="text"],
    .auth-form input[type="tel"],
    .auth-form input[type="password"] {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 0.625rem 0.75rem;
    }

    .auth-form .btn {
        width: 100%;
        max-width: none;
    }
    .auth-box .btn {
        width: 100%;
    }
}

.card {
    background: var(--surface);
    border: 1px solid #424249;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 12px 28px rgba(0,0,0,0.32);
}

.card h2 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.balance-summary p,
.balance-total {
    margin: 0.25rem 0;
    font-size: 1.1rem;
}

.balance-total { font-size: 1.25rem; }


.kazna-balance {
    margin-top: -0.35rem;
    margin-bottom: 0.7rem;
    color: #fff;
    font-size: 1.28rem;
    font-weight: 800;
}

/* Вкладки раздела «Казна» (Журнал / График / …) */
.kazna-tabs {
    display: flex;
    gap: 0.5rem 0.65rem;
    flex-wrap: wrap;
    margin: 0.75rem 0 1rem;
}

.kazna-tabs .btn {
    text-align: center;
}

/* --- Казна: без inline-стилей в шаблонах --- */
.clickable-summary {
    cursor: pointer;
}

.kazna-stack-top-sm {
    margin-top: 0.5rem;
}

.kazna-stack-top-md {
    margin-top: 0.75rem;
}

.table-cell-nowrap {
    white-space: nowrap;
}

.table-identity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.table-identity--compact {
    display: inline-flex;
    gap: 0.4rem;
}

.table-identity__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.table-identity__avatar--sm {
    width: 22px;
    height: 22px;
}

.table-identity__ph {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-block;
    background: #0b1016;
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.table-identity__ph--sm {
    width: 22px;
    height: 22px;
}

.table-identity__meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

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

.balance-chart-form {
    margin-bottom: 0.75rem;
}

.balance-chart-date-row {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.balance-chart-opening-note {
    margin-bottom: 0.5rem;
}

.balance-chart-panel {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.08);
    position: relative;
}

.balance-chart-canvas {
    display: block;
    width: 100%;
    height: 320px;
}

.balance-chart-tip.card {
    position: absolute;
    display: none;
    padding: 0.5rem 0.6rem;
    margin: 0;
    pointer-events: none;
    background: rgba(26, 35, 50, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

.balance-chart-tip-date {
    font-size: 0.85rem;
}

.balance-chart-tip-val {
    font-weight: 700;
}

.balance-other-debts-inactive-heading {
    margin-top: 1.25rem;
    font-size: 1rem;
    font-weight: 600;
}

.balance-other-debts-toggle {
    margin-top: 1rem;
}

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

.table th,
.table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.muted { color: var(--text-muted); }

/* Make clickable names look like plain text (no blue/visited purple) */
.plain-link,
.plain-link:visited {
    color: inherit;
    text-decoration: none;
}
.plain-link:hover {
    text-decoration: underline;
}

/* Ссылка как обычный текст, подчёркивание всегда (например ФИО в казне) */
.plain-link-underline,
.plain-link-underline:visited {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}
.plain-link-underline:hover {
    color: inherit;
    text-decoration: underline;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.form-inline label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-inline input,
.form-inline select {
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.badge-success { background: var(--success); color: var(--bg); }
.badge-danger { background: var(--danger); color: #fff; }

/* Subtle member status pills */
.status-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
    line-height: 1.2;
    border: 1px solid transparent;
}
.status-active {
    color: rgba(63, 185, 80, 0.95);
    background: rgba(63, 185, 80, 0.12);
    border-color: rgba(63, 185, 80, 0.22);
}
.status-left {
    color: rgba(248, 81, 73, 0.95);
    background: rgba(248, 81, 73, 0.12);
    border-color: rgba(248, 81, 73, 0.22);
}

.footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #3f3f46;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.rt-dashboard-hero {
    display: grid;
    place-items: center;
    padding: 0.15rem 0 0.35rem;
    margin-bottom: 1rem;
}

.rt-dashboard-hero img {
    width: min(100%, 420px);
    height: auto;
    display: block;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45));
}

.sbp-cta {
    text-align: center;
    padding: 1rem 1rem 0.85rem;
}

.sbp-pay-btn {
    width: min(100%, 340px);
    max-width: 100%;
    font-size: 1.08rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

.sbp-qr-wrap {
    margin-top: 0.8rem;
    display: grid;
    place-items: center;
}

.sbp-qr-wrap img {
    width: 220px;
    height: 220px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: #fff;
    padding: 8px;
}

.sbp-flow {
    max-width: 460px;
    margin: 1.2rem auto;
    text-align: center;
}

.sbp-status {
    margin: 0.6rem 0 0;
    min-height: 1.2em;
}

.sbp-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.sbp-modal-card {
    width: min(100%, 460px);
    background: var(--surface);
    border: 1px solid #484850;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}

.sbp-modal-card h3 {
    margin: 0 0 0.75rem;
}

/* --- Profile --- */
.profile-card {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.profile-album-card {
    margin-top: 1.25rem;
}

.profile-album-card-head {
    margin-bottom: 0.65rem;
}

.profile-album-card-title {
    margin: 0 0 0.15rem;
    font-size: 1.1rem;
}

.profile-album-card-meta {
    margin: 0;
    font-size: 0.88rem;
}

.profile-album-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.5rem 0 0.75rem;
}

.profile-album-thumb-link {
    display: block;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: border-color 0.12s ease, transform 0.12s ease;
}

.profile-album-thumb-link:hover {
    border-color: rgba(177, 15, 28, 0.55);
    transform: translateY(-1px);
}

.profile-album-thumb {
    display: block;
    width: 72px;
    height: 72px;
    background: #0b1016;
    position: relative;
    overflow: hidden;
}

.profile-album-thumb--img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-album-thumb--video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-album-thumb-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 16px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.92);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    pointer-events: none;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
}

.profile-album-thumb--text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    text-align: center;
    padding: 0.25rem;
}

.profile-album-empty {
    margin: 0.25rem 0 0.75rem;
    font-size: 0.9rem;
}

.profile-album-actions {
    margin-top: 0.25rem;
}

.profile-avatar {
    width: 160px;
    flex: 0 0 160px;
}

.profile-avatar-trigger {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: zoom-in;
    border-radius: 14px;
    display: block;
    line-height: 0;
}

.profile-avatar-trigger:focus-visible {
    outline: 2px solid rgba(110, 168, 254, 0.95);
    outline-offset: 2px;
}

.profile-avatar-img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    display: block;
    background: #0b1016;
    pointer-events: none;
}

.profile-avatar-placeholder {
    width: 160px;
    height: 160px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0b1016;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 2rem;
}

.profile-actions {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.btn-secondary {
    background: #1b1b1f;
    color: #fff;
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-secondary.active {
    background: #24242a;
    border-color: rgba(88,166,255,0.55);
    color: var(--primary);
}

/* Treasurer payments matrix */
input.pay-toggle {
    width: 18px;
    height: 18px;
    transform: scale(1.25);
    transform-origin: left center;
}

.partial-btn {
    padding: 0.1rem 0.35rem;
    font-size: 0.85rem;
    line-height: 1;
}

.profile-info {
    flex: 1 1 320px;
    min-width: 260px;
}

.profile-name {
    margin: 0 0 0.25rem 0;
    font-size: 1.35rem;
}

.profile-meta {
    margin: 0.25rem 0 0 0;
    color: var(--text-muted);
}

.profile-kv {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.35rem;
}

.profile-kv-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
    align-items: center;
}

.profile-kv-key { color: var(--text-muted); font-size: 0.9rem; }
.profile-kv-val {
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.profile-kv-val-text {
    min-width: 0;
    flex: 1 1 auto;
}

.profile-kv-edit-btn {
    flex-shrink: 0;
}

.profile-debts-card {
    margin-top: 1.25rem;
}

.album-page-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
}

.album-back-link {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.album-back-link:hover {
    color: var(--text);
    text-decoration: underline;
}

.album-page-sub-sep {
    opacity: 0.55;
    font-weight: 400;
}

.hidden { display: none !important; }

/* --- Members --- */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.member-card { padding: 1rem; }
.member-card { position: relative; cursor: pointer; }
.member-card details { cursor: default; }
.member-card details * { cursor: auto; }
.member-card:hover {
    border-color: rgba(88,166,255,0.35);
}

.member-head {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.member-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0b1016;
}

.member-avatar-placeholder {
    display: inline-block;
    background: #0b1016;
}

.member-title { min-width: 0; }
.member-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-sub { font-size: 0.9rem; }

.member-kv {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.35rem;
}

.member-kv-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.treasurer-top-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

/* --- Mobile responsiveness --- */
@media (max-width: 720px) {
    .container { padding: 1rem 0.75rem; }
    .nav-container { padding: 0 0.75rem; }
    .nav-links { gap: 0.75rem; flex-wrap: wrap; justify-content: flex-start; }
    .nav-main-row { gap: 0.65rem; }
    .rt-brand-mark { width: 32px; height: 32px; font-size: 0.9rem; }
    .rt-brand-name { font-size: 2rem; line-height: 1; }

    .card { padding: 1rem; }
    .btn { max-width: none; }

    .kazna-tabs .btn {
        flex: 1 1 auto;
        min-width: min(100%, 10.5rem);
    }

    /* Stack inline forms */
    .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline label { width: 100%; }
    .form-inline input,
    .form-inline select { width: 100%; }

    /* Tables: allow horizontal scroll when needed */
    .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table th, .table td { white-space: nowrap; }

    /* Календарь взносов на дашборде — компактнее при горизонтальном скролле */
    .contrib-cal-table th,
    .contrib-cal-table td {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.4rem 0.3rem;
    }

    /* Profile key/value */
    .profile-kv-row { grid-template-columns: 1fr; gap: 0.15rem; }
    .profile-kv-key { font-size: 0.85rem; }

    /* Members grid tighter */
    .members-grid { grid-template-columns: 1fr; }
    .member-avatar { width: 52px; height: 52px; }
    .member-kv-row { flex-direction: column; align-items: flex-start; }
    .rt-dashboard-hero img { width: min(100%, 320px); }
    .sbp-qr-wrap { display: none; }
    .treasurer-top-grid { grid-template-columns: 1fr; }

    /* Формы редактирования долгов в профиле (инпуты вне <label>) */
    .profile-debts-card .form-inline input:not([type="hidden"]),
    .profile-debts-card .form-inline select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}

@media (max-width: 720px) {
    /* Payments matrix: on small screens allow horizontal scroll (13 columns can't fit) */
    .payments-matrix .matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .payments-matrix .matrix-table { min-width: 980px; }
    .payments-matrix .matrix-name { width: 260px; }
    .payments-matrix .matrix-month,
    .payments-matrix .matrix-cell { width: auto; }
}

/* Узкие экраны: шапка поста на стене — автор и кнопки столбцом */
@media (max-width: 560px) {
    .wall-post-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .wall-post-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .nav-links a {
        font-size: 0.92rem;
        padding: 0.28rem 0.32rem;
    }

    .rt-brand-name {
        font-size: 1.65rem;
    }

    .kazna-balance {
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .kazna-tabs .btn {
        flex: 1 1 100%;
        min-width: 0;
    }

    .balance-chart-canvas {
        height: 240px;
    }

    /* iOS: не увеличивать страницу при фокусе в полях < 16px */
    .wall-form textarea,
    .wall-edit-form textarea,
    .wall-comment-input {
        font-size: 16px;
    }

    .rt-login-large-logo {
        width: 100%;
        border-radius: 12px;
    }
    .rt-login-mark {
        width: 60px;
        height: 60px;
        border-radius: 12px;
        font-size: 1.7rem;
    }
    .rt-login-name {
        font-size: 1.1rem;
    }
}

/* --- Gallery --- */
.gallery-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
    align-items: center;
}

.crumb {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: var(--text);
    border-radius: 6px;
    padding: 0.28rem 0.55rem;
    cursor: pointer;
}

.crumb.current {
    border-color: rgba(88,166,255,0.55);
    color: var(--primary);
}

.crumb-sep {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.8rem;
}

.gallery-tile {
    border: 1px solid #414149;
    border-radius: 10px;
    background: #19191d;
    color: var(--text);
    text-align: left;
    padding: 0.55rem;
    cursor: pointer;
}

.gallery-tile:hover {
    border-color: rgba(88,166,255,0.45);
}

.gallery-folder {
    display: grid;
    align-content: center;
    min-height: 140px;
}

.gallery-icon {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.45rem;
}

.gallery-photo img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    background: #0f1013;
}

.gallery-name {
    margin-top: 0.45rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.gallery-viewer {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.96);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gallery-viewer.open {
    display: flex;
}

.gallery-viewer img {
    max-width: 96vw;
    max-height: 92vh;
    object-fit: contain;
}

.gallery-viewer-close {
    position: fixed;
    top: 0.5rem;
    right: 0.65rem;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
}

.gallery-viewer-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: rgba(255,255,255,0.16);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.gallery-viewer-prev { left: 0.75rem; }
.gallery-viewer-next { right: 0.75rem; }

@media (max-width: 720px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .gallery-photo img {
        height: 115px;
    }

    .gallery-viewer {
        padding: 0.35rem;
    }

    .gallery-viewer img {
        max-width: 100vw;
        max-height: 100vh;
    }

    .gallery-viewer-nav {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
}
