/* =====================================================================
   TeamHub – menu badges, tabs, team chat, notifications, announcements
   ===================================================================== */

/* ---------- Sidebar: badges, my teams ---------- */

.nav-badge {
    margin-left: auto;
    min-width: 1.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.3rem;
    text-align: center;
    color: #fff;
    background: var(--th-danger);
}

.nav-team {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.nav-team-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: 0.25rem;
    margin: -0.5rem 0 1.25rem;
    border-bottom: 1px solid var(--th-border);
    overflow-x: auto;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    font-weight: 600;
    color: var(--th-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab:hover {
    color: var(--th-text);
    text-decoration: none;
}

.tab.active {
    color: var(--th-primary);
    border-bottom-color: var(--th-primary);
}

/* ---------- Chat ---------- */

.chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 13rem);
    min-height: 26rem;
    border-radius: var(--th-radius);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    box-shadow: var(--th-shadow);
    overflow: hidden;
}

@media (max-width: 960px) {
    .chat {
        height: calc(100dvh - 12rem);
    }
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    font-size: 0.78rem;
    color: var(--th-muted);
    border-bottom: 1px solid var(--th-border);
    background: var(--th-surface-2);
}

.chat-status .dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--th-success);
}

.chat-status.warn {
    color: var(--th-warning);
    background: var(--th-warning-soft);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem 0.5rem;
    overscroll-behavior: contain;
}

.chat-empty {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--th-muted);
}

.chat-older {
    display: flex;
    justify-content: center;
    margin: 0.25rem 0 0.75rem;
}

.chat-day,
.chat-unread {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--th-muted);
}

.chat-day::before,
.chat-day::after,
.chat-unread::before,
.chat-unread::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--th-border);
}

.chat-unread {
    color: var(--th-danger);
}

.chat-unread::before,
.chat-unread::after {
    background: #fecdd3;
}

.chat-msg {
    position: relative;
    display: flex;
    gap: 0.7rem;
    padding: 0.35rem 0.75rem;
    border-radius: 10px;
}

.chat-msg:hover {
    background: var(--th-surface-2);
}

.chat-msg.compact {
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.chat-msg.mentioned {
    background: #fffbeb;
    box-shadow: inset 3px 0 0 #f59e0b;
}

.chat-avatar {
    flex: none;
    width: 36px;
}

.chat-body {
    min-width: 0;
    flex: 1;
}

.chat-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.chat-meta strong {
    font-size: 0.92rem;
}

.chat-meta time {
    font-size: 0.75rem;
    color: var(--th-muted);
}

.chat-text {
    font-size: 0.94rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.chat-text.deleted {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-style: italic;
    color: var(--th-muted);
}

.chat-text a {
    text-decoration: underline;
}

.chat-edited {
    margin-left: 0.3rem;
    font-size: 0.75rem;
    color: var(--th-muted);
}

.mention {
    padding: 0 0.2rem;
    border-radius: 5px;
    font-weight: 600;
    color: var(--th-primary);
    background: var(--th-primary-soft);
}

.mention.me,
.mention.all {
    color: #92400e;
    background: #fef3c7;
}

.chat-reply-ref {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    margin: 0.15rem 0 0.25rem;
    padding: 0.2rem 0.6rem;
    border-left: 3px solid #c7d2fe;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--th-muted);
    background: var(--th-surface-2);
}

.chat-reply-ref span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.chat-image img {
    display: block;
    max-width: min(320px, 100%);
    max-height: 240px;
    border-radius: 10px;
    border: 1px solid var(--th-border);
    object-fit: cover;
}

.chat-file {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 320px;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: var(--th-text);
    border: 1px solid var(--th-border);
    background: var(--th-surface-2);
}

.chat-file:hover {
    text-decoration: none;
    border-color: #c7d2fe;
}

.chat-file span {
    display: grid;
    min-width: 0;
}

.chat-file strong {
    overflow: hidden;
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-file small {
    color: var(--th-muted);
}

.chat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.chat-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font: inherit;
    font-size: 0.85rem;
    border: 1px solid var(--th-border);
    background: var(--th-surface);
    cursor: pointer;
}

.chat-reaction span {
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--th-muted);
}

.chat-reaction.mine {
    border-color: #c7d2fe;
    background: var(--th-primary-soft);
}

.chat-actions {
    position: absolute;
    top: -0.9rem;
    right: 0.75rem;
    display: none;
    gap: 0.1rem;
    padding: 0.15rem;
    border-radius: 10px;
    border: 1px solid var(--th-border);
    background: var(--th-surface);
    box-shadow: var(--th-shadow);
}

.chat-msg:hover .chat-actions,
.chat-msg:focus-within .chat-actions {
    display: flex;
}

@media (hover: none) {
    .chat-actions {
        position: static;
        display: flex;
        width: max-content;
        margin-top: 0.25rem;
        box-shadow: none;
    }
}

.chat-actions button {
    display: inline-grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 0;
    border-radius: 8px;
    color: var(--th-muted);
    background: transparent;
    cursor: pointer;
}

.chat-actions button:hover {
    color: var(--th-primary);
    background: var(--th-primary-soft);
}

.chat-actions button.danger:hover {
    color: var(--th-danger);
    background: var(--th-danger-soft);
}

.chat-picker {
    position: absolute;
    top: 2.2rem;
    right: 0;
    z-index: 5;
    display: flex;
    gap: 0.1rem;
    padding: 0.3rem;
    border-radius: 12px;
    border: 1px solid var(--th-border);
    background: var(--th-surface);
    box-shadow: var(--th-shadow-lg);
}

.chat-picker button {
    width: 2.1rem;
    height: 2.1rem;
    font-size: 1.15rem;
}

.chat-confirm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.88rem;
}

.chat-edit textarea {
    width: 100%;
    min-height: 4.5rem;
}

.chat-edit-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.chat-typing {
    min-height: 1.5rem;
    padding: 0 1.1rem;
    font-size: 0.8rem;
    color: var(--th-muted);
}

.chat-typing .dots {
    display: inline-flex;
    gap: 2px;
    margin-right: 0.25rem;
}

.chat-typing .dots i {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--th-muted);
    animation: typing 1.2s infinite ease-in-out;
}

.chat-typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing .dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.chat-composer {
    position: relative;
    padding: 0.6rem 0.75rem 0.75rem;
    border-top: 1px solid var(--th-border);
    background: var(--th-surface);
}

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-input .icon-btn {
    color: var(--th-muted);
}

.chat-input textarea {
    flex: 1;
    height: auto;
    min-height: 2.65rem;
    max-height: 200px;
    padding: 0.6rem 0.85rem;
    resize: none;
    line-height: 1.4;
}

.chat-input .btn {
    width: 2.65rem;
    height: 2.65rem;
    padding: 0;
}

.chat-replying,
.chat-pending {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    color: var(--th-muted);
}

.chat-replying span {
    overflow: hidden;
    max-width: 40ch;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-pending .chip .icon-btn {
    width: 1.4rem;
    height: 1.4rem;
}

.chat-suggest {
    position: absolute;
    bottom: calc(100% - 0.25rem);
    left: 3.5rem;
    z-index: 10;
    display: grid;
    min-width: 16rem;
    padding: 0.3rem;
    border-radius: 12px;
    border: 1px solid var(--th-border);
    background: var(--th-surface);
    box-shadow: var(--th-shadow-lg);
}

.chat-suggest button {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.55rem;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.chat-suggest button:hover {
    background: var(--th-primary-soft);
}

/* ---------- Notifications & announcements ---------- */

.notif-list {
    display: grid;
    gap: 0.5rem;
}

.notif {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    border-radius: var(--th-radius);
    color: var(--th-text);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
}

.notif:hover {
    text-decoration: none;
    border-color: #c7d2fe;
}

.notif.unread {
    border-color: #c7d2fe;
    background: #f8f9ff;
}

.notif-text {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.notif-body {
    overflow: hidden;
    font-size: 0.88rem;
    color: #475569;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-dot {
    width: 0.6rem;
    height: 0.6rem;
    margin-left: auto;
    flex: none;
    border-radius: 999px;
    background: var(--th-primary);
}

.announcements {
    display: grid;
    gap: 1rem;
}

.announcement {
    padding: 1.25rem 1.4rem;
    border-radius: var(--th-radius);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    box-shadow: var(--th-shadow);
}

.announcement.pinned {
    border-color: #fde68a;
    box-shadow: inset 4px 0 0 #f59e0b, var(--th-shadow);
}

.announcement header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.announcement-body {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.announcement footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.82rem;
}

.chat-msg.pending {
    opacity: 0.6;
}

.nav-empty {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    color: #64748b;
}

.nav-sub .nav-manage {
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ---------- Teams page: unread per team ---------- */

.team-card .team-card-text {
    min-width: 0;
}

.team-card .team-badge {
    margin-left: auto;
    font-size: 0.8rem;
    line-height: 1.5rem;
    min-width: 1.6rem;
}

.team-card .team-badge + .icon,
.team-card .team-badge[hidden] + .icon {
    margin-left: 0.5rem;
}

.team-card .team-badge[hidden] + .icon {
    margin-left: auto;
}

.team-card.has-unread {
    border-color: #fecdd3;
    box-shadow: inset 4px 0 0 var(--th-danger), var(--th-shadow);
}

/* ---------- Events ---------- */

.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.event-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--th-radius);
    color: var(--th-text);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    box-shadow: var(--th-shadow);
    transition: border-color 0.15s, transform 0.15s;
}

.event-card:hover {
    text-decoration: none;
    border-color: #c7d2fe;
    transform: translateY(-1px);
}

.event-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--th-primary), var(--th-primary-2));
}

.event-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-placeholder {
    display: grid;
    place-items: center;
    height: 100%;
    color: rgb(255 255 255 / 70%);
}

.event-date {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: grid;
    justify-items: center;
    min-width: 3.2rem;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--th-shadow);
    line-height: 1.1;
}

.event-date strong {
    font-size: 1.35rem;
    color: var(--th-text);
}

.event-date small {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--th-danger);
}

.event-body {
    display: grid;
    gap: 0.3rem;
    padding: 1rem 1.1rem 1.2rem;
}

.event-body h2 {
    font-size: 1.05rem;
}

.event-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.85rem;
    color: var(--th-muted);
}

.event-desc {
    margin: 0.25rem 0 0;
    font-size: 0.88rem;
    color: #475569;
}

.event-hero {
    display: block;
    width: 100%;
    max-height: 360px;
    margin-bottom: 1.25rem;
    border-radius: 12px;
    object-fit: cover;
}

/* ---------- Calendar ---------- */
.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.calendar-title {
    margin: 0 0.25rem;
    min-width: 11rem;
    text-align: center;
    font-size: 1.25rem;
    text-transform: capitalize;
}

.btn-icon {
    padding: 0.45rem;
    line-height: 0;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    overflow: hidden;
    background: var(--th-border);
    gap: 1px;
    box-shadow: var(--th-shadow);
}

.calendar-dayname {
    padding: 0.5rem;
    background: var(--th-surface);
    color: var(--th-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
}

.calendar-day {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 7rem;
    padding: 0.35rem;
    background: var(--th-surface);
    min-width: 0;
}

.calendar-day.other-month {
    background: var(--th-bg);
}

.calendar-day.other-month .calendar-day-number {
    color: var(--th-muted);
    opacity: 0.6;
}

.calendar-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calendar-day-number {
    display: inline-grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.calendar-day.today .calendar-day-number {
    background: var(--th-primary);
    color: #fff;
}

.calendar-add {
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 6px;
    color: var(--th-muted);
    opacity: 0;
    transition: opacity 0.15s;
}

.calendar-day:hover .calendar-add,
.calendar-add:focus-visible {
    opacity: 1;
}

.calendar-add:hover {
    background: var(--th-primary-soft);
    color: var(--th-primary);
}

.calendar-chip {
    display: flex;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    background: var(--th-primary-soft);
    color: var(--th-primary);
    font-size: 0.78rem;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.calendar-chip:hover {
    background: var(--th-primary);
    color: #fff;
}

.calendar-chip.past {
    opacity: 0.6;
}

.calendar-chip-time {
    font-weight: 700;
    flex: none;
}

.calendar-chip-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-agenda {
    display: none;
    gap: 0.5rem;
}

.calendar-agenda-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    background: var(--th-surface);
    color: var(--th-text);
    text-decoration: none;
}

.calendar-agenda-item .event-date {
    position: static;
    box-shadow: none;
    background: var(--th-primary-soft);
}

.calendar-agenda-item.today {
    border-color: var(--th-primary);
}

.calendar-agenda-item.past {
    opacity: 0.6;
}

.calendar-agenda-item > span:last-child {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.calendar-agenda-item small {
    color: var(--th-muted);
}

.calendar-feed {
    margin-top: 1.5rem;
}

.calendar-feed h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
    font-size: 1.1rem;
}

.copy-field {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.copy-field input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.82rem;
}

.calendar-feed-help {
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    color: var(--th-muted);
    line-height: 1.7;
}

@media (max-width: 720px) {
    .calendar {
        display: none;
    }

    .calendar-agenda {
        display: grid;
    }

    .calendar-title {
        min-width: 0;
        flex: 1;
    }

    .copy-field {
        flex-direction: column;
    }
}

/* ---------- Menu: unread team chats under "Moje týmy" ---------- */
.nav-unread {
    display: grid;
    gap: 0.1rem;
    margin: 0.1rem 0 0.25rem 1.6rem;
    padding-left: 0.6rem;
    border-left: 1px solid rgb(255 255 255 / 10%);
}

.nav-unread:empty {
    display: none;
}

.nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    color: #fff;
}

.nav-subitem:hover,
.nav-subitem.active {
    background: rgb(255 255 255 / 8%);
    text-decoration: none;
}

.nav-subitem-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Event team & attendance ---------- */
.team-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--th-primary-soft);
    color: var(--th-primary);
    font-size: 0.78rem;
    font-weight: 650;
}

.event-attendance {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    font-weight: 650;
}

.event-attendance > span {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.going { color: var(--th-success); }
.maybe { color: var(--th-warning); }
.not-going { color: var(--th-danger); }

.event-attendance .my-answer {
    margin-left: auto;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--th-bg);
    color: var(--th-muted);
}

.event-attendance .my-answer.missing {
    background: var(--th-warning-soft);
    color: var(--th-warning);
}

.attendance {
    margin-top: 1rem;
}

.attendance h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
    font-size: 1.1rem;
}

.attendance-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.attendance-question {
    font-weight: 650;
    margin-right: 0.25rem;
}

.attendance-btn {
    border: 1.5px solid var(--th-border);
    background: var(--th-surface);
}

.attendance-btn.going.selected { background: var(--th-success); border-color: var(--th-success); color: #fff; }
.attendance-btn.maybe.selected { background: var(--th-warning); border-color: var(--th-warning); color: #fff; }
.attendance-btn.not-going.selected { background: var(--th-danger); border-color: var(--th-danger); color: #fff; }
.attendance-btn.going:not(.selected):hover { border-color: var(--th-success); color: var(--th-success); }
.attendance-btn.maybe:not(.selected):hover { border-color: var(--th-warning); color: var(--th-warning); }
.attendance-btn.not-going:not(.selected):hover { border-color: var(--th-danger); color: var(--th-danger); }

.attendance-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.attendance-group {
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--th-border);
    border-top-width: 3px;
}

.attendance-group.going { border-top-color: var(--th-success); }
.attendance-group.maybe { border-top-color: var(--th-warning); }
.attendance-group.not-going { border-top-color: var(--th-danger); }

.attendance-group h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 0.4rem;
    font-size: 0.92rem;
}

.attendance-count {
    font-size: 1.1rem;
}

.attendance-group ul {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--th-text);
    line-height: 1.7;
    font-size: 0.9rem;
}

.attendance-group .muted {
    margin: 0;
    color: var(--th-muted);
    font-size: 0.88rem;
}

.attendance-pending {
    margin-top: 0.9rem;
    color: var(--th-muted);
}

.attendance-pending summary {
    cursor: pointer;
    font-weight: 600;
}

.calendar-chip.needs-answer {
    box-shadow: inset 3px 0 0 var(--th-warning);
}

/* ---------- Checkbox picker (modal) ---------- */
.picker-trigger {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.picker-summary,
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.picker-chip {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--th-primary-soft);
    color: var(--th-primary);
    font-size: 0.85rem;
    font-weight: 650;
}

.picker-empty {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--th-bg);
    color: var(--th-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.picker-dialog {
    width: min(34rem, calc(100vw - 2rem));
    max-height: min(42rem, calc(100vh - 2rem));
    padding: 0;
    border: 0;
    border-radius: var(--th-radius);
    background: var(--th-surface);
    color: var(--th-text);
    box-shadow: var(--th-shadow-lg);
}

.picker-dialog[open] {
    display: flex;
    flex-direction: column;
}

.picker-dialog::backdrop {
    background: rgb(15 23 42 / 45%);
}

.picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem 0.5rem;
}

.picker-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.picker-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 1.1rem 0.5rem;
    border-bottom: 1px solid var(--th-border);
}

.picker-count {
    color: var(--th-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.picker-search {
    margin: 0.6rem 1.1rem 0.2rem;
}

.picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem 0.6rem;
    min-height: 6rem;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    cursor: pointer;
}

.picker-item:hover {
    background: var(--th-bg);
}

.picker-item[hidden] {
    display: none;
}

.picker-item input {
    width: 1.1rem;
    height: 1.1rem;
    flex: none;
    accent-color: var(--th-primary);
}

.picker-item-label {
    flex: 1;
    font-weight: 550;
}

.picker-item small {
    color: var(--th-muted);
}

.picker-none {
    padding: 1rem 0.6rem;
}

.picker-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.1rem;
    border-top: 1px solid var(--th-border);
    justify-content: flex-end;
}

.picker-role {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.picker-foot .spacer {
    flex: 1;
}

.notified-info {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.25rem;
    color: var(--th-success);
    font-size: 0.85rem;
    font-weight: 600;
}

.team-events-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.team-events-head .tabs {
    margin: 0;
}

a.team-chip:hover {
    background: var(--th-primary);
    color: #fff;
    text-decoration: none;
}

.picker-role span {
    white-space: nowrap;
}

/* Picker: wide dialog, list in columns (fewer rows → usually no scrolling), never a horizontal scrollbar. */
.picker-dialog {
    width: min(72rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: hidden;
}

.picker-dialog *,
.picker-dialog *::before,
.picker-dialog *::after {
    box-sizing: border-box;
}

.picker-search {
    width: calc(100% - 2.2rem);
    max-width: 28rem;
}

.picker-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    align-content: start;
    gap: 0.1rem 0.5rem;
    overflow-x: hidden;
    padding: 0.5rem 0.8rem;
}

.picker-item {
    min-width: 0;
    padding: 0.4rem 0.5rem;
}

.picker-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-none {
    grid-column: 1 / -1;
}

/* Fewer, wider columns: long names (roles) stay readable instead of being cut. */
.picker-list.picker-list-wide {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
}

.picker-list-wide .picker-item-label {
    white-space: normal;
    overflow-wrap: anywhere;
}

.picker-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.3rem 1.1rem 0.6rem;
    color: var(--th-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.picker-pager[hidden] {
    display: none;
}

@media (max-width: 720px) {
    .picker-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .picker-list {
        grid-template-columns: 1fr;
    }
}

input.invalid {
    border-color: var(--th-danger) !important;
    box-shadow: 0 0 0 3px var(--th-danger-soft) !important;
}

/* ---------- Events administration ---------- */
.events-toolbar {
    flex-wrap: wrap;
}

.events-toolbar .input-icon {
    flex: 1 1 16rem;
}

.date-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--th-muted);
}

.date-filter input {
    width: auto;
}

.events-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.25rem 0 0.75rem;
}

.events-summary p {
    margin: 0;
}

.view-switch {
    display: inline-flex;
    gap: 0.25rem;
}

.events-table tr.past {
    opacity: 0.65;
}

.events-table .event-attendance {
    flex-wrap: nowrap;
}

.nowrap {
    white-space: nowrap;
}

.row-actions {
    display: inline-flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

/* ---------- Notification settings ---------- */
.prefs-table .center {
    text-align: center;
    width: 7rem;
}

.prefs-table input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--th-primary);
}

.pref-section {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.pref-section > svg {
    flex: none;
    margin-top: 0.15rem;
    color: var(--th-primary);
}

/* ---------- Team files ---------- */
.files-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-weight: 650;
}

.breadcrumbs a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.breadcrumbs .sep {
    color: var(--th-muted);
}

.files-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.folder-description {
    margin-top: 0;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.6rem;
    margin: 1rem 0;
}

.folder-card {
    display: grid;
    gap: 0.2rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--th-border);
    border-radius: 12px;
    background: var(--th-surface);
    color: var(--th-text);
    text-decoration: none;
    box-shadow: var(--th-shadow);
}

.folder-card svg {
    color: #f59e0b;
}

.folder-card:hover {
    border-color: var(--th-primary);
    text-decoration: none;
}

.folder-name {
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-cell {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.file-cell a {
    word-break: break-word;
}

.file-thumb,
.file-icon {
    flex: none;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 8px;
}

.file-thumb {
    object-fit: cover;
    background: var(--th-bg);
}

.file-icon {
    display: inline-grid;
    place-items: center;
    background: var(--th-primary-soft);
    color: var(--th-primary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.form-dialog {
    width: min(34rem, calc(100vw - 2rem));
    padding: 0;
    border: 0;
    border-radius: var(--th-radius);
    background: var(--th-surface);
    color: var(--th-text);
    box-shadow: var(--th-shadow-lg);
}

.form-dialog::backdrop {
    background: rgb(15 23 42 / 45%);
}

.form-dialog .form {
    gap: 0;
}

.dialog-body {
    display: grid;
    gap: 0.8rem;
    padding: 0.5rem 1.1rem 1rem;
}

@media (max-width: 720px) {
    .hide-sm {
        display: none;
    }
}

/* ---------- Team files: drag & drop, previews, folder tree ---------- */
.files-dropzone {
    position: relative;
    border-radius: var(--th-radius);
    outline: 2px dashed transparent;
    outline-offset: 6px;
    transition: outline-color 0.15s, background 0.15s;
}

.files-dropzone.files-over {
    outline-color: var(--th-primary);
    background: var(--th-primary-soft);
}

.drop-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    padding: 0.8rem;
    border-radius: 12px;
    background: var(--th-primary);
    color: #fff;
    font-weight: 650;
}

.files-dropzone.files-over .drop-hint {
    display: flex;
}

.folder-card.drop-over,
.breadcrumbs a.drop-over {
    border-color: var(--th-primary);
    background: var(--th-primary-soft);
    box-shadow: 0 0 0 3px var(--th-primary-soft), var(--th-shadow);
}

.breadcrumbs a.drop-over {
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
}

.folder-card[draggable="true"],
.files-table tr[draggable="true"] {
    cursor: grab;
}

.dragging {
    opacity: 0.45;
}

.busy {
    opacity: 0.6;
    pointer-events: none;
}

.files-dnd-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--th-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    word-break: break-word;
}

.link-btn:hover {
    text-decoration: underline;
}

.show-sm {
    display: none;
}

.file-icon.pdf { background: #fef2f2; color: #dc2626; }
.file-icon.docx { background: #eff6ff; color: #2563eb; }
.file-icon.sheet { background: #ecfdf5; color: #059669; }

.preview-dialog {
    width: min(70rem, calc(100vw - 2rem));
    height: calc(100vh - 2rem);
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: var(--th-radius);
    background: var(--th-surface);
    color: var(--th-text);
    box-shadow: var(--th-shadow-lg);
    overflow: hidden;
}

.preview-dialog[open] {
    display: flex;
    flex-direction: column;
}

.preview-dialog::backdrop {
    background: rgb(15 23 42 / 60%);
}

.preview-dialog .picker-head {
    border-bottom: 1px solid var(--th-border);
    padding-bottom: 0.75rem;
}

.preview-dialog .picker-head h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-body {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    background: var(--th-bg);
    overflow: auto;
}

.preview-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.form-dialog.wide {
    width: min(44rem, calc(100vw - 2rem));
}

.form-dialog {
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

.folder-tree {
    max-height: 18rem;
    overflow: auto;
    padding: 0.4rem;
    border: 1px solid var(--th-border);
    border-radius: 12px;
    background: var(--th-bg);
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem 0.35rem calc(0.5rem + (var(--depth, 0) + 1) * 1.1rem);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.tree-node.root {
    padding-left: 0.5rem;
    font-weight: 650;
}

.tree-node svg {
    flex: none;
    color: #f59e0b;
}

.tree-node[data-tree-target]:hover,
.tree-node.drop-over {
    background: var(--th-primary-soft);
}

.tree-node.selected {
    box-shadow: inset 0 0 0 2px var(--th-primary);
}

.tree-node.current {
    background: var(--th-primary);
    color: #fff;
    font-weight: 650;
    cursor: grab;
}

.tree-node.current svg {
    color: #fff;
}

.tree-node.in-branch:not(.current) {
    color: var(--th-muted);
    cursor: default;
}

.tree-badge {
    margin-left: auto;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: rgb(255 255 255 / 25%);
    font-size: 0.72rem;
    font-weight: 600;
}

@media (max-width: 720px) {
    .show-sm {
        display: block;
    }
}

/* ---------- Team files: selection, move dialog, preview messages ---------- */
.bulk-bar {
    position: sticky;
    top: 0.5rem;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: var(--th-primary-soft);
    border: 1px solid var(--th-primary);
    box-shadow: var(--th-shadow);
}

.bulk-bar[hidden] {
    display: none;
}

.cell-check {
    width: 2.2rem;
    text-align: center;
}

.cell-check input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--th-primary);
    cursor: pointer;
}

.files-table tr.selected td {
    background: var(--th-primary-soft);
}

.tree-node.here {
    font-style: italic;
}

.muted-badge {
    background: var(--th-border);
    color: var(--th-muted);
}

.tree-node.selected .muted-badge {
    background: rgb(255 255 255 / 60%);
}

.preview-message {
    display: grid;
    justify-items: center;
    gap: 0.8rem;
    max-width: 32rem;
    padding: 2rem;
    text-align: center;
    color: var(--th-muted);
}

.preview-message p {
    margin: 0;
}

.preview-text {
    align-self: stretch;
    justify-self: stretch;
    margin: 0;
    padding: 1rem 1.2rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--th-surface);
    font: 0.9rem/1.55 ui-monospace, Consolas, monospace;
}

/* The upload form is driven by the "Nahrát soubory" button (system file chooser) and by drag & drop. */
.upload-form {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Club logo next to the name (menu) ---------- */
.org-chip.with-logo {
    gap: 0.65rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.95rem;
}

.org-logo {
    flex: none;
    height: 2.5rem;
    width: auto;
    max-width: 5.5rem;
    object-fit: contain;
    padding: 2px;
    border-radius: 8px;
    background: #fff;
}

.sidebar-sample {
    max-width: 16rem;
    padding: 0.9rem;
    border-radius: 12px;
    background: var(--th-sidebar);
}

/* Preview rendered in the page itself (fallback when the isolated preview page does not start). */
.preview-doc {
    align-self: stretch;
    justify-self: stretch;
    overflow: auto;
    padding: 1rem;
    background: #f4f6fb;
    color: #0f172a;
}

.preview-doc .docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
}

.preview-sheet {
    overflow: auto;
    margin-bottom: 1rem;
    background: #fff;
    border-radius: 10px;
}

.preview-sheet table {
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-sheet td,
.preview-sheet th {
    border: 1px solid #e6e8ef;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
}

/* ---------- Preview: loading spinner ---------- */
.preview-body {
    position: relative;
}

.preview-loading {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    color: var(--th-muted);
    font-weight: 600;
}

.spinner {
    width: 2.6rem;
    height: 2.6rem;
    border: 4px solid var(--th-border);
    border-top-color: var(--th-primary);
    border-radius: 50%;
    animation: th-spin 0.8s linear infinite;
}

@keyframes th-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2.4s; }
}

/* The isolated preview page loads underneath the spinner and appears once it has drawn the document. */
.preview-frame.pending {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

/* ---------- Roles: search, section + permission filter, cards / table ---------- */
.roles-toolbar {
    flex-wrap: wrap;
}

.roles-toolbar .input-icon {
    flex: 1 1 16rem;
}

.segmented {
    display: inline-flex;
    padding: 0.2rem;
    border: 1px solid var(--th-border);
    border-radius: 10px;
    background: var(--th-surface);
}

.segmented label {
    position: relative;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--th-muted);
    white-space: nowrap;
}

.segmented label.active span,
.segmented input:checked + span {
    background: var(--th-primary);
    color: #fff;
}

.segmented input:focus-visible + span {
    outline: 2px solid var(--th-primary);
    outline-offset: 2px;
}

.perm-list li.highlight {
    border-radius: 6px;
    background: var(--th-primary-soft);
    font-weight: 650;
}

.roles-table .center {
    text-align: center;
}

.roles-table th.highlight,
.roles-table td.highlight {
    background: var(--th-primary-soft);
}

.role-desc-line {
    max-width: 28rem;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Users administration ---------- */
.users-toolbar {
    flex-wrap: wrap;
}

.users-toolbar .input-icon {
    flex: 1 1 18rem;
}

.users-toolbar .picker-summary {
    max-width: 22rem;
}

.users-summary {
    margin: 0.25rem 0 0.75rem;
}

.pending-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #fde68a;
    border-radius: 12px;
    background: var(--th-warning-soft);
    color: var(--th-warning);
}

.pending-banner:hover {
    text-decoration: none;
    border-color: var(--th-warning);
}

tr.pending-row td {
    background: var(--th-warning-soft);
}

.badge-match {
    background: var(--th-primary-soft);
    color: var(--th-primary);
    box-shadow: inset 0 0 0 1px var(--th-primary);
}

.picker-hint {
    margin: 0;
}

/* ---------- Trainings ---------- */
/* Type colors: text + soft background + strong accent (calendar border, swatch). */
.tt-indigo { --tt-fg: #4338ca; --tt-bg: #eef2ff; --tt-accent: #6366f1; }
.tt-green { --tt-fg: #047857; --tt-bg: #ecfdf5; --tt-accent: #10b981; }
.tt-orange { --tt-fg: #c2410c; --tt-bg: #fff7ed; --tt-accent: #f97316; }
.tt-red { --tt-fg: #b91c1c; --tt-bg: #fef2f2; --tt-accent: #ef4444; }
.tt-teal { --tt-fg: #0f766e; --tt-bg: #f0fdfa; --tt-accent: #14b8a6; }
.tt-pink { --tt-fg: #be185d; --tt-bg: #fdf2f8; --tt-accent: #ec4899; }
.tt-yellow { --tt-fg: #a16207; --tt-bg: #fefce8; --tt-accent: #eab308; }
.tt-gray { --tt-fg: #475569; --tt-bg: #f1f5f9; --tt-accent: #94a3b8; }

.tt-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--tt-bg);
    color: var(--tt-fg);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.tt-badge::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--tt-accent);
}

.calendar-chip.training {
    background: var(--tt-bg);
    color: var(--tt-fg);
    border-left: 3px solid var(--tt-accent);
}

.calendar-chip.training:hover {
    background: var(--tt-accent);
    color: #fff;
}

.calendar-agenda-item.training {
    border-left: 4px solid var(--tt-accent);
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin: 0.75rem 0 1.25rem;
    color: var(--th-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.calendar-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 3px;
    background: var(--tt-accent);
}

.legend-dot.event {
    background: var(--th-primary);
}

.trainings-toolbar select {
    max-width: 14rem;
}

.training-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1rem;
}

.training-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1.1rem 1.25rem;
    border-radius: var(--th-radius);
    color: var(--th-text);
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    box-shadow: var(--th-shadow);
    transition: border-color 0.15s, transform 0.15s;
}

a.training-card:hover {
    text-decoration: none;
    border-color: #c7d2fe;
    transform: translateY(-1px);
}

.training-card.ended {
    opacity: 0.7;
}

.training-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.training-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.training-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.training-slots li {
    padding: 0.2rem 0.55rem;
    border-radius: 8px;
    background: var(--th-bg);
    font-size: 0.85rem;
}

.training-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--th-muted);
    font-size: 0.85rem;
}

.training-meta span,
.training-next {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.training-next {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--th-border);
    font-size: 0.85rem;
    color: var(--th-muted);
}

.training-next strong {
    color: var(--th-text);
}

.training-detail {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.training-detail .card + .card {
    margin-top: 0;
}

.training-author {
    margin: 1rem 0 0;
    font-size: 0.85rem;
}

.training-upcoming h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.training-upcoming ul {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.training-upcoming li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.training-upcoming li > span:last-child,
.training-upcoming li > a {
    display: flex;
    flex-direction: column;
    color: var(--th-text);
}

.training-upcoming li small {
    color: var(--th-muted);
}

.team-upcoming {
    margin-bottom: 1rem;
}

.form-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0 0.75rem;
    font-size: 1.05rem;
}

.training-days {
    display: grid;
    gap: 0.4rem;
    margin: 1rem 0 0.35rem;
    max-width: 34rem;
}

.training-day {
    display: grid;
    grid-template-columns: 9rem auto auto auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--th-border);
    border-radius: 10px;
    background: var(--th-surface);
}

.training-day.on {
    border-color: #c7d2fe;
    background: var(--th-primary-soft);
}

.training-day:not(.on) .training-time input {
    opacity: 0.45;
}

.training-day-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 650;
    cursor: pointer;
}

.training-day-check input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--th-primary);
}

.training-time input {
    width: 7.5rem;
}

.training-dash {
    color: var(--th-muted);
}

.danger-zone {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--th-border);
}

.training-types-layout {
    display: grid;
    grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.training-type-form h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

.training-type-delete {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--th-border);
}

.color-field {
    margin: 0.75rem 0 0;
    padding: 0;
    border: 0;
}

.color-field legend {
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-swatch {
    position: relative;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--tt-accent);
    cursor: pointer;
}

.color-swatch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.color-swatch:has(input:checked) {
    box-shadow: 0 0 0 3px var(--th-surface), 0 0 0 5px var(--tt-accent);
}

.color-swatch:has(input:focus-visible) {
    outline: 2px solid var(--th-text);
    outline-offset: 4px;
}

.row-selected td {
    background: var(--th-primary-soft);
}

@media (max-width: 860px) {
    .training-detail,
    .training-types-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .training-day {
        grid-template-columns: 1fr auto auto auto;
    }

    .training-time input {
        width: 6.2rem;
    }
}

.training-upcoming .event-date {
    position: static;
    flex: none;
    box-shadow: none;
    background: var(--th-primary-soft);
}

/* ---------- Training attendance ---------- */
.training-sessions {
    margin-top: 1rem;
}

.training-sessions h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

.training-stats-title {
    margin: 1.5rem 0 0.75rem;
    font-size: 1rem;
}

.presence-count {
    display: inline-block;
    min-width: 2rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
}

.presence-count.present { color: #047857; background: #ecfdf5; }
.presence-count.absent { color: #b91c1c; background: #fef2f2; }
.presence-count.excused { color: #a16207; background: #fefce8; }

.presence-bar {
    width: 100%;
    max-width: 10rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--th-bg);
    overflow: hidden;
}

.presence-bar span {
    display: block;
    height: 100%;
    background: #10b981;
}

.attendance-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.attendance-tools .spacer {
    flex: 1;
}

.attendance-summary,
.attendance-recorded {
    color: var(--th-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.attendance-list {
    display: flex;
    flex-direction: column;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.attendance-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid var(--th-border);
}

.attendance-person {
    display: flex;
    flex-direction: column;
    min-width: 12rem;
}

.presence-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.presence-option {
    position: relative;
    cursor: pointer;
}

.presence-option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.presence-option span {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--th-border);
    border-radius: 999px;
    background: var(--th-surface);
    font-size: 0.85rem;
    font-weight: 650;
    color: var(--th-muted);
}

.presence-option input:focus-visible + span {
    outline: 2px solid var(--th-primary);
    outline-offset: 2px;
}

.presence-option.present input:checked + span { color: #fff; background: #10b981; border-color: #10b981; }
.presence-option.absent input:checked + span { color: #fff; background: #ef4444; border-color: #ef4444; }
.presence-option.excused input:checked + span { color: #fff; background: #eab308; border-color: #eab308; }
.presence-option.clear input:checked + span { color: var(--th-text); background: var(--th-bg); }

.attendance-form .form-actions {
    flex-wrap: wrap;
    align-items: center;
}

.sessions-toolbar .field-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--th-muted);
}

.sessions-toolbar input[type="date"] {
    width: auto;
}

.sessions-presets {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.training-stats-note {
    margin: -0.5rem 0 1rem;
    font-size: 0.85rem;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: inherit;
    white-space: nowrap;
}

.sort-link:hover {
    color: var(--th-primary);
    text-decoration: none;
}

.sort-link .sort-arrow {
    font-size: 0.7rem;
    opacity: 0.45;
}

.sort-link.active {
    color: var(--th-primary);
}

.sort-link.active .sort-arrow {
    opacity: 1;
}

/* More training type colors */
.tt-blue { --tt-fg: #1d4ed8; --tt-bg: #eff6ff; --tt-accent: #3b82f6; }
.tt-sky { --tt-fg: #0369a1; --tt-bg: #f0f9ff; --tt-accent: #0ea5e9; }
.tt-cyan { --tt-fg: #0e7490; --tt-bg: #ecfeff; --tt-accent: #06b6d4; }
.tt-lime { --tt-fg: #4d7c0f; --tt-bg: #f7fee7; --tt-accent: #84cc16; }
.tt-amber { --tt-fg: #b45309; --tt-bg: #fffbeb; --tt-accent: #f59e0b; }
.tt-rose { --tt-fg: #be123c; --tt-bg: #fff1f2; --tt-accent: #f43f5e; }
.tt-fuchsia { --tt-fg: #a21caf; --tt-bg: #fdf4ff; --tt-accent: #d946ef; }
.tt-purple { --tt-fg: #7e22ce; --tt-bg: #faf5ff; --tt-accent: #a855f7; }
.tt-violet { --tt-fg: #6d28d9; --tt-bg: #f5f3ff; --tt-accent: #8b5cf6; }
.tt-brown { --tt-fg: #78350f; --tt-bg: #fdf8f3; --tt-accent: #a16207; }

/* Training detail: the info card full width, the next dates in one row below */
.training-detail {
    grid-template-columns: minmax(0, 1fr);
}

.training-next-row {
    margin-top: 1rem;
}

.training-next-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.training-next-head h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.05rem;
}

.training-next-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.training-next-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--th-border);
    border-radius: 10px;
}

.training-next-list li > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.training-next-list small {
    color: var(--th-muted);
}

.training-next-list .event-date {
    position: static;
    flex: none;
    box-shadow: none;
    background: var(--th-primary-soft);
}

.training-next-list li {
    padding: 0.45rem 0.5rem;
    gap: 0.45rem;
}

.training-next-list .event-date {
    min-width: 2.6rem;
    padding: 0.25rem 0.35rem;
}

.training-next-list li strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .training-next-list {
        grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    }
}

.sessions-presets {
    gap: 0.4rem;
}

/* Filter buttons (CheckboxPicker Filter mode): colored while the filter is applied */
.btn.filter-active {
    color: var(--th-primary);
    background: var(--th-primary-soft);
    border-color: #a5b4fc;
}

.btn.filter-active:hover {
    color: #fff;
    background: var(--th-primary);
}

.picker-tool-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.picker-extra {
    padding: 0.6rem 1.1rem 0;
}

.picker-option {
    margin: 0;
}

/* Team tab: the next two weeks in two columns */
.team-upcoming ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 1.5rem;
}

@media (max-width: 720px) {
    .team-upcoming ul {
        grid-template-columns: 1fr;
    }
}

/* Today's date of a training: in the color of its type */
.training-next-list li.today,
.team-upcoming li.today {
    background: var(--tt-bg);
    border: 1px solid var(--tt-accent);
    border-radius: 10px;
    box-shadow: inset 4px 0 0 var(--tt-accent);
}

.team-upcoming li.today {
    padding: 0.35rem 0.5rem;
}

.training-next-list li.today .event-date,
.team-upcoming li.today .event-date {
    background: var(--tt-accent);
}

.training-next-list li.today .event-date strong,
.training-next-list li.today .event-date small,
.team-upcoming li.today .event-date strong,
.team-upcoming li.today .event-date small {
    color: #fff;
}

.training-next-list li.today strong,
.team-upcoming li.today strong {
    color: var(--tt-fg);
}

.training-next.today {
    margin: auto -1.25rem -1.1rem;
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--tt-accent);
    border-radius: 0 0 var(--th-radius) var(--th-radius);
    background: var(--tt-bg);
    color: var(--tt-fg);
    font-weight: 600;
}

.training-next.today strong {
    color: var(--tt-fg);
}

/* Attendance filter row: all buttons the same size */
.sessions-presets {
    gap: 0.5rem;
}

.bulk-bar .spacer {
    flex: 1;
}

.bulk-bar .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Segmented control made of links (GET navigation without a form) */
.segmented a {
    display: block;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--th-muted);
    white-space: nowrap;
    text-decoration: none;
}

.segmented a.active {
    background: var(--th-primary);
    color: #fff;
}

/* Closed attendance */
.attendance-closed {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid #a7f3d0;
    border-radius: var(--th-radius);
    background: #ecfdf5;
    color: #047857;
}

.attendance-closed > span:not(.spacer) {
    display: flex;
    flex-direction: column;
}

.attendance-closed small {
    color: var(--th-muted);
}

.attendance-closed .spacer {
    flex: 1;
}

.attendance-form.closed .presence-option {
    cursor: default;
}

.attendance-form.closed .presence-option input:not(:checked) + span {
    opacity: 0.45;
}

/* Notification settings grouped by section */
.prefs-table .pref-group th {
    padding-top: 1rem;
    background: var(--th-bg);
    color: var(--th-text);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.prefs-table .pref-group th svg {
    vertical-align: -3px;
    margin-right: 0.3rem;
}

.pref-topic .muted {
    font-size: 0.85rem;
}

.pref-select {
    width: auto;
    min-width: 13rem;
    font-size: 0.85rem;
}
