:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #1c1e21;
    --border: #e4e6eb;
    --accent: #3868af;
    --accent-dark: #005dc2;
    --b-color: #2ecc71;
    --o-color: #f1c40f;
    --n-color: #e74c3c;
    --shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}


[data-theme="dark"] {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --border: #333;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    transition: background 0.3s ease;
}

#main-content {
    height: calc(100vh - 70px);
    width: 100%;
    position: relative;
}

.screen {
    position: absolute;
    inset: 0;
    background: var(--bg);
    display: none;
    flex-direction: column;
    z-index: 1;
    animation: fadeIn 0.25s ease-out;
}

.screen.active {
    display: flex;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* --- АНИМАЦИИ --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Анимация для модальных окон */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-card {
    background: var(--card);
    width: 60%;
    max-width: 280px;
    padding: 20px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.2);
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Анимация для карточек групп */
.group-card-wrapper {
    position: relative;
    animation: slideUp 0.3s ease-out forwards;
    opacity: 0;
    animation-delay: calc(0.05s * var(--i, 1));
}

.grid-list .group-card-wrapper:nth-child(1) {
    --i: 1;
}

.grid-list .group-card-wrapper:nth-child(2) {
    --i: 2;
}

.grid-list .group-card-wrapper:nth-child(3) {
    --i: 3;
}

.grid-list .group-card-wrapper:nth-child(4) {
    --i: 4;
}

.grid-list .group-card-wrapper:nth-child(5) {
    --i: 5;
}

.grid-list .group-card-wrapper:nth-child(6) {
    --i: 6;
}

header {
    padding: 45px 15px 15px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    position: relative;
}

.header-center-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.center-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0;
}

.month-picker {
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: bold;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.back-btn-icon {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.6rem;
    cursor: pointer;
    position: absolute;
    left: 10px;
    z-index: 50;
    transition: var(--transition);
}

.back-btn-icon:active {
    transform: scale(0.9);
    color: var(--accent-dark);
}

.grid-list {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    overflow-y: auto;
}

.group-card {
    background: var(--card);
    padding: 30px 10px;
    border-radius: 18px;
    text-align: center;
    border: 1px solid var(--border);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
}

.group-card:active {
    transform: scale(0.97);
    background: var(--border);
}

.btn-del {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--n-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.btn-del:active {
    transform: scale(0.9);
    background: #c0392b;
}

.table-container {
    overflow: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

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

th,
td {
    border: 1px solid var(--border);
    padding: 0;
    min-width: 50px;
    height: 45px;
    text-align: center;
    font-size: 0.9rem;
    position: relative;
    transition: background 0.2s ease;
}

th.today-mark {
    background-color: var(--accent) !important;
    color: white !important;
}

.sticky-col {
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 5;
    min-width: 140px;
    text-align: left;
    padding-left: 10px;
    display: flex;
    align-items: center;
}

.btn-del-row {
    color: var(--n-color);
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    margin-right: 5px;
    transition: var(--transition);
}

.btn-del-row:active {
    transform: scale(0.8);
}

/* Значки отработки */
.duty-status-mark {
    position: absolute;
    top: 1px;
    left: 1px;
    font-size: 25px;
    width: 23px;
    height: 23px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: black;
    z-index: 6;
    cursor: pointer;
    transition: var(--transition);
}

.duty-status-mark:active {
    transform: scale(0.8);
}

.mark-unsolved {
    color: var(--n-color);
    font-weight: 900;
}

.mark-solved {
    color: var(--b-color);
    font-weight: 900;
}

td:not(.cell-О) .duty-status-mark {
    display: none;
}

[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: gray;
    opacity: 0.5;
    font-style: italic;
    pointer-events: none;
}

.edit-name {
    outline: none;
    display: inline-block;
    min-width: 20px;
    padding: 4px 2px;
    border-radius: 4px;
    transition: background 0.2s;
}

.edit-name:focus {
    background: rgba(0, 123, 255, 0.1);
}

/* --- ЯЧЕЙКИ С ОЦЕНКАМИ --- */
td.cell-Б {
    background: var(--b-color) !important;
}

td.cell-О {
    background: var(--o-color) !important;
}

td.cell-Н {
    background: var(--n-color) !important;
}

/* --- СЕЛЕКТ В ЯЧЕЙКАХ --- */
.status-select {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-weight: bold;
    text-align-last: center;
    appearance: none;
    outline: none;
    cursor: pointer;
}

/* Цвет текста по умолчанию (пустые ячейки) */
td .status-select {
    color: var(--text) !important;
}

/* Цвет текста в цветных ячейках — ВСЕГДА одинаковый, независимо от темы */
td.cell-Б .status-select {
    color: #ffffff !important;
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

td.cell-О .status-select {
    color: #1a1a1a !important;
    font-weight: 900;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

td.cell-Н .status-select {
    color: #ffffff !important;
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Для тёмной темы — пустые ячейки используют var(--text) */
[data-theme="dark"] td:not(.cell-Б):not(.cell-О):not(.cell-Н) .status-select {
    color: var(--text) !important;
}

/* Фиксированные цвета для цветных ячеек в тёмной теме */
[data-theme="dark"] td.cell-Б .status-select,
[data-theme="dark"] td.cell-Н .status-select {
    color: #1a1a1a !important;
}

[data-theme="dark"] td.cell-О .status-select {
    color: #1a1a1a !important;
}

/* --- НИЖНЯЯ ПАНЕЛЬ --- */
.dockbar {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 70px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.dock-side {
    flex: 1;
    display: flex;
    justify-content: center;
}

.dock-center {
    flex: 0 0 80px;
    position: relative;
    display: flex;
    justify-content: center;
}

.circle-add-btn {
    width: 65px;
    height: 65px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 35px;
    position: absolute;
    top: -35px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle-add-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.4);
}

.clean-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text);
    transition: var(--transition);
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clean-btn:active {
    background: var(--border);
    transform: scale(0.9);
}

/* --- КНОПКИ UI --- */
.ui-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 12px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ui-btn:active {
    transform: scale(0.97);
    filter: brightness(0.9);
}

.ui-btn i {
    font-size: 1.1em;
}

.secondary {
    background: #6c757d;
}

/* --- ДЕЖУРНЫЕ --- */
.duty-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
    margin: 5px 0;
    border-bottom: 2px solid var(--border);
    display: inline-block;
    padding: 0 10px;
    animation: fadeIn 0.3s ease;
}

/* --- ИНФОРМАЦИЯ ОБ АВТОРАХ --- */
.authors-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.authors-info h4 {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.6;
    gap: 5px;
}

.authors-info p {
    margin: 5px 0 10px;
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text);
}

/* --- СОЦСЕТИ --- */
.social-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.soc-btn {
    text-decoration: none;
    color: white;
    padding: 8px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: bold;
    text-align: center;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.soc-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.tg {
    background: #0088cc;
}

.gh {
    background: #333;
}

.don {
    background: #e7bd33;
}

.export {
    background: #1e58af;
}

.import {
    background: #35b460;
}

/* --- КАСТОМНЫЕ ДИАЛОГИ --- */
.prompt-input-field {
    width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    margin: 10px 0 5px;
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}

.prompt-input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.prompt-error {
    color: var(--n-color);
    font-size: 0.8rem;
    min-height: 20px;
    margin-bottom: 5px;
    font-weight: 500;
    animation: shake 0.3s ease;
}

#custom-confirm-modal #custom-alert-modal .modal-card {
    text-align: center;
}

#confirm-message {
    line-height: 1.5;
}

.prompt-error:not(:empty) {
    animation: fadeIn 0.2s ease;
}

#btn-force-update:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.update-success {
    background: #28a745;
    color: white;
}

.update-error {
    background: #dc3545;
    color: white;
}
