/* === GENERAL === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: #333;
    background: #fff;
}

/* === LOADING === */
.loading {
    text-align: center;
    padding: 60px 20px;
    font-size: 15px;
    color: #999;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === HEADER BAR === */
.header-bar {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    line-height: 1.6;
}
.header-point {
    font-weight: 700;
    font-size: 16px;
    color: #1976d2;
}
.header-responsible {
    color: #666;
    font-size: 13px;
}
.header-period {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    margin-top: 4px;
}

/* === NAV BAR === */
.nav-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    flex-wrap: wrap;
}
.nav-bar .title {
    font-size: 18px;
    font-weight: 700;
}
.nav-btn {
    padding: 6px 14px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.nav-btn:hover {
    background: #f0f0f0;
}
.btn-export {
    padding: 6px 16px;
    background: #d32f2f;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-export:hover {
    background: #b71c1c;
}

/* === CALENDAR TITLE ROW === */
.calendar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 4px;
    font-size: 15px;
    font-weight: 700;
    color: #333;
}
.sync-inline {
    font-size: 12px;
    color: #999;
    font-weight: 400;
}

/* === STATS === */
.header-stats {
    padding: 4px 16px 8px;
    font-size: 12px;
}
.stat-done { color: #2e7d32; font-weight: 600; }
.stat-work { color: #e65100; font-weight: 600; }
.stat-new { color: #1565c0; font-weight: 600; }
.stat-percent { color: #333; font-weight: 700; }

/* === CALENDAR GRID === */
.calendar-grid {
    display: grid;
    grid-template-columns: 40px repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
    border: 1px solid #e0e0e0;
}

/* === WEEK NUMBER === */
.week-number-header {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #bbb;
    font-weight: 600;
    padding: 8px 4px;
}
.week-number-cell {
    background: #f5f5f5;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    font-size: 11px;
    color: #aaa;
    font-weight: 600;
    min-height: 120px;
}

/* === WEEKDAY HEADER === */
.weekday-header {
    background: #f5f5f5;
    padding: 10px 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

/* === DAY CELLS === */
.day-cell {
    background: #fff;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.day-cell.other-month {
    background: #fafafa;
}
.day-cell.other-month .day-number {
    color: #ccc;
}
.day-cell.day-today {
    box-shadow: inset 0 0 0 2px #42a5f5;
}
.day-cell.day-today .day-header {
    background: #e3f2fd;
}
.day-cell.day-past {
    background: #fcfcfc;
}

/* === DAY HEADER === */
.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    min-height: 28px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}
.day-number {
    font-size: 14px;
    font-weight: 700;
    color: #333;
}
.day-weekday {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
}
.btn-add-row {
    width: 22px;
    height: 22px;
    border: none;
    background: #eee;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.btn-add-row:hover {
    background: #1976d2;
    color: #fff;
}

/* === DAY ROWS === */
.day-rows {
    padding: 3px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

/* === RECORD ROW === */
.record-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    min-height: 28px;
    border-left: 3px solid transparent;
}
.row-icon {
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* === ROW CONTENT (двухстрочная карточка) === */
.row-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.row-title {
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.row-hint {
    font-size: 10px;
    color: #888;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === STRIKE BUTTON === */
.btn-strike {
    font-size: 14px;
    color: rgba(0,0,0,0.3);
    cursor: pointer;
    display: none;
    flex-shrink: 0;
    background: none;
    border: none;
    margin-top: 2px;
}
.record-row:hover .btn-strike {
    display: block;
}
.btn-strike:hover {
    color: #d32f2f;
}

/* === STATUS COLORS === */
.row-blue {
    background: #e3f2fd;
    color: #1565c0;
    border-left-color: #42a5f5;
}
.row-yellow {
    background: #fff3e0;
    color: #e65100;
    border-left-color: #ff9800;
}
.row-green {
    background: #e8f5e9;
    color: #2e7d32;
    border-left-color: #4caf50;
}
.row-gray-striked {
    background: #f5f5f5;
    color: #999;
    opacity: 0.7;
    border-left-color: #ccc;
}
.row-gray-striked .row-title {
    text-decoration: line-through;
}

/* === MORE RECORDS === */
.more-records {
    font-size: 11px;
    color: #1565c0;
    padding: 2px 6px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
}
.more-records:hover {
    text-decoration: underline;
}

/* === TEMPLATE DROPDOWN === */
.template-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2147483647;
    min-width: 260px;
    max-width: 360px;
    border-radius: 6px;
    /* max-height и overflow-y намеренно убраны:
       они давали второй скроллбар и прыгающий layout.
       Список шаблонов и так помещается на экран. */
}
.tpl-group-name {
    padding: 6px 12px;
    background: #f5f5f5;
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
}
.tpl-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid #f5f5f5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tpl-item:hover {
    background: #e3f2fd;
}

/* === TOOLTIP (тёмный) === */
.record-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 280px;
    white-space: normal;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2000;
    pointer-events: none;
}

/* === TEMPLATE HINT === */
.template-hint {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 2000;
    max-width: 200px;
}

/* === EDITOR MODAL === */
.editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.editor-modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    width: 420px;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}
.editor-title {
    font-size: 12px;
    color: #999;
    font-weight: 400;
}
.editor-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}
.editor-close:hover {
    color: #333;
}
.editor-field-title {
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
}
.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.editor-toolbar button {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}
.editor-toolbar button:hover {
    background: #e3f2fd;
    border-color: #42a5f5;
}
.editor-textarea {
    padding: 12px 16px;
    min-height: 180px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    outline: none;
    border: 2px solid #e3f2fd;
    margin: 12px 16px;
    border-radius: 8px;
}
.editor-textarea:focus {
    border-color: #42a5f5;
}
.editor-textarea:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
}
.editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
}
.editor-btn-save {
    padding: 8px 20px;
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.editor-btn-save:hover {
    background: #1565c0;
}
.editor-btn-cancel {
    padding: 8px 20px;
    background: #fff;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.editor-btn-cancel:hover {
    background: #f5f5f5;
}

/* === КНОПКА СОЗДАНИЯ ЗАДАЧИ === */
.btn-create-task {
    background: none;
    border: 1px solid #4CAF50;
    color: #4CAF50;
    cursor: pointer;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    line-height: 1;
    flex-shrink: 0;
    display: none;
    margin-top: 2px;
}
.record-row:hover .btn-create-task {
    display: inline-block;
}
.btn-create-task:hover {
    background: #4CAF50;
    color: #fff;
}
.btn-create-task:disabled {
    opacity: 0.5;
    cursor: wait;
    display: inline-block;
}

/* === КНОПКА ОТКРЫТЬ ЗАДАЧУ === */
.btn-open-task {
    background: none;
    border: 1px solid #1976d2;
    color: #1976d2;
    cursor: pointer;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    line-height: 1;
    flex-shrink: 0;
    display: none;
    margin-top: 2px;
}
.record-row:hover .btn-open-task {
    display: inline-block;
}
.btn-open-task:hover {
    background: #1976d2;
    color: #fff;
}

/* === КНОПКА ВЫБОРА ИСПОЛНИТЕЛЯ === */
.btn-assign-user {
    background: none;
    border: 1px solid #ff9800;
    color: #ff9800;
    cursor: pointer;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    line-height: 1;
    flex-shrink: 0;
    display: none;
    margin-top: 2px;
}
.record-row:hover .btn-assign-user {
    display: inline-block;
}
.btn-assign-user:hover {
    background: #ff9800;
    color: #fff;
}

/* === ДРОПДАУН СОТРУДНИКОВ === */
.user-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 220px;
    max-width: 300px;
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
}
.user-dropdown-title {
    padding: 8px 12px;
    background: #f5f5f5;
    font-size: 11px;
    font-weight: 700;
    color: #999;
    border-bottom: 1px solid #eee;
}
.user-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid #f5f5f5;
}
.user-item:hover {
    background: #e3f2fd;
}
.user-item-default {
    font-weight: 600;
    color: #1976d2;
}
