:root {
    --bg: #111;
    --row-bg: #1a1a1a;
    --text: #eee;
    --accent: #0078d4;
    --danger: #3d1b1c;
    --border: #333;
    --input-bg: #252525;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    margin: 0;
    overflow-x: auto;
}

.app-container {
    min-width: max-content;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

header {
    margin: 5px;
    display: flex;
    align-items: center;
    gap: 20px;
}

header h1 {
    font-weight: 300;
    margin: 0;
    color: var(--accent);
    min-width: 150px;
    transform: translateY(-4px);
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1e1e1e;
    padding: 24px;
    border: 1px solid #333;
    border-radius: 8px;
    width: 420px;
    display: flex;
    flex-direction: column;
}

.modal-content h3 {
    margin: 0 0 20px;
    font-weight: 400;
    font-size: 16px;
}

/* Лейблы и поля настроек */
#settings-input {
    width: 100%;
    height: 80px;
    background: #111;
    color: #00ff00;
    border: 1px solid #444;
    font-family: monospace;
    font-size: 13px;
    padding: 8px 10px;
    box-sizing: border-box;
    resize: none;
    border-radius: 3px;
    outline: none;
}

#settings-input:focus {
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background: #333;
    color: white;
    font-size: 18px;
    padding: 4px 10px;
}

h1 {
    font-weight: 300;
    margin: 0;
}

/* Кнопки */
.btn {
    border: none;
    border-radius: 2px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

/* Строка события */
.event-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    min-height: 72px;
}

.event-row:last-child {
    border-bottom: none;
}

.event-row:hover {
    background: #121212;
}

/* Поле названия */
.name-container {
    width: 200px;
    min-width: 200px;
    flex-shrink: 0;
}

.event-name-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 6px;
    border-radius: 3px;
    outline: none;
    display: block;
    resize: none;
    overflow: hidden;
    /* Каждая строка не переносится — длинный текст обрезается за краем */
    white-space: pre;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.event-countdown {
    font-size: 10px;
    color: #888;
    padding-left: 2px;
    text-transform: lowercase;
    font-family: 'Segoe UI', sans-serif;
}

.event-name-input:focus {
    border-color: var(--accent);
}

/* Контейнер дат */
.dates-list {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.date-item {
    display: flex;
    flex-direction: column;
    width: 200px;
    min-width: 200px;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 6px;
    gap: 6px;
}

.date-top-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.date-top-row input {
    flex-grow: 1;
    width: 100%;
}

.date-top-row .btn-danger {
    flex-shrink: 0;
}

.date-item input {
    background: #2a2a2a;
    border: 1px solid #333;
    color: white;
    padding: 4px 6px;
    font-size: 13px;
    border-radius: 2px;
    outline: none;
}

.date-desc-input {
    width: calc(100% - 12px);
    font-size: 11px !important;
    color: #aaa !important;
}

.date-item input:focus {
    border-color: var(--accent);
}

.date-item:last-child {
    border-style: dashed;
    opacity: 0.2;
}

.date-item:last-child:hover {
    opacity: 0.6;
}

.date-item:last-child:focus-within {
    border-style: solid;
    opacity: 1;
}

.flatpickr-calendar {
    background: #1e1e1e !important;
    border: 1px solid #333 !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5) !important;
}

.row-controls {
    margin-left: auto;
    padding-left: 20px;
}

.status-bar {
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 20px;
    align-items: center;
    margin-left: auto;
    width: fit-content;
}

#sync-btn {
    background: #222;
    color: #888;
    border: 1px solid #333;
}

#sync-btn:hover {
    background: #2a2a2a;
    color: #aaa;
}

/* --- Метки --- */

.label-badges {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    display: flex;
    align-items: center;
    overflow: hidden;
    /* Прячем всё, что не влезает */
    flex-shrink: 0;
}

.label-badge {
    display: block;
    width: 100%;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.label-placeholder {
    font-size: 14px;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.label-btn-wrap {
    position: relative;
    flex-shrink: 0;
}

.label-btn {
    font-size: 13px;
    padding: 3px 7px;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.label-btn:hover {
    opacity: 1;
}

.label-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 1000;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 4px;
    min-width: 160px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    padding: 4px 0;
}

.label-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #ccc;
    user-select: none;
}

.label-dropdown-item:hover {
    background: #2a2a2a;
}

.label-dropdown-item--checked {
    color: #fff;
}

.label-dropdown-item--checked::after {
    content: '✓';
    margin-left: auto;
    color: #0078d4;
    font-size: 12px;
}

.label-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.label-dropdown-sep {
    height: 1px;
    background: #333;
    margin: 4px 0;
}

.label-dropdown-new {
    padding: 5px 8px;
}

.label-new-input {
    width: 100%;
    background: #111;
    border: 1px solid #444;
    color: #eee;
    font-size: 12px;
    padding: 4px 7px;
    border-radius: 3px;
    outline: none;
    box-sizing: border-box;
}

.label-new-input:focus {
    border-color: #0078d4;
}

.labels-mgmt-wrap {
    position: relative;
}

.labels-mgmt-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: -42px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    width: 250px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-mgmt-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-bottom: 1px solid #2a2a2a;
}

.label-mgmt-item:last-child {
    border-bottom: none;
}

/* Стилизация Color Picker */
.label-color-picker {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
}

.label-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.label-color-picker::-webkit-color-swatch {
    border: 1px solid #444;
    border-radius: 50%;
}

.label-mgmt-name {
    flex-grow: 1;
    background: transparent;
    border: 1px solid transparent;
    color: #eee;
    font-size: 13px;
    padding: 2px 4px;
    outline: none;
}

.label-mgmt-name:focus {
    border-color: var(--accent);
    background: #111;
}

.label-mgmt-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 4px;
    color: white;
}

.btn-icon:hover {
    opacity: 1;
}

.new-label-row {
    margin-top: 5px;
    padding-top: 10px;
    border-top: 1px solid #333;
    display: flex;
    gap: 5px;
}

.label-cell {
    width: 100px;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.label-cell:hover .label-placeholder {
    opacity: 1;
}

.cal-btn {
    font-size: 11px;
    padding: 2px 4px;
    opacity: 0.4;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: white;
}

.cal-btn:hover {
    opacity: 1;
}

/* --- Режим просмотра названия --- */

.event-name-view {
    width: 100%;
    box-sizing: border-box;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 6px;
    border-radius: 3px;
    cursor: text;
    min-height: calc(1.4em * 3 + 12px);
    /* 3 строки */
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.event-name-view:hover {
    border-color: #555;
}

.event-name-line {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-height: 1.4em;
}

.event-name-link {
    color: #4da3ff;
    text-decoration: none;
}

.event-name-link:hover {
    text-decoration: underline;
}