/* --- Modals & Forms --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.6); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    backdrop-filter: blur(8px);
}
.modal-overlay.visible { opacity: 1; visibility: visible; }
.modal-content {
    background: var(--light-surface); padding: 0; border-radius: 20px;
    width: 90%; max-width: 500px; max-height: 90vh;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-content.wide { max-width: 700px; }
.modal-content.medium { max-width: 550px; }
#edit-parsed-event-modal .modal-content { z-index: 1010; }
.modal-view { display: flex; flex-direction: column; flex-grow: 1; min-height: 0; }
.modal-header {
    padding: 20px 25px 15px; display: grid;
    grid-template-columns: 1fr auto 1fr; align-items: center;
    border-bottom: 1px solid var(--light-border); flex-shrink: 0;
}
.modal-title { text-align: center; grid-column: 2; font-size: 1.25em; font-weight: 700; }
.modal-close { grid-column: 3; justify-self: end; }
.editor-back-btn { grid-column: 1; justify-self: start; }
.modal-close, .editor-back-btn {
    font-size: 2em; font-weight: 900; cursor: pointer; background: none;
    border: none; color: inherit; line-height: 1;
}
.modal-body { padding: 20px 25px; overflow-y: auto; flex-grow: 1; }
.modal-actions {
    padding: 15px 25px; display: flex; gap: 10px;
    justify-content: space-between; align-items: center;
    border-top: 1px solid var(--light-border);
    background: var(--light-surface); flex-shrink: 0;
}
.modal-actions-group { display: flex; gap: 10px; }
.modal-actions-left { display: flex; gap: 10px; }
.modal-actions-right { display: flex; gap: 10px; align-items: center; }

/* Modal Buttons */
.modal-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 10px; border-radius: 9999px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.8rem; line-height: 1;
  cursor: pointer; user-select: none; transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.modal-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.modal-btn:active { transform: translateY(0); box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.modal-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(129,140,248,.35); }
.modal-btn:disabled { opacity: .6; transform: none; box-shadow: none; cursor: not-allowed; }
.btn-icon { padding: 8px; width: 38px; height: 38px; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-save { background: var(--primary-color); color: #fff; }
.btn-add { background: var(--success-color); color: #fff; }
.btn-info { background: var(--info-color); color: #fff; }
.btn-delete { background: var(--danger-color); color: #fff; }
.btn-edit { background: var(--light-surface); border-color: var(--light-border); color: var(--light-text); }
.btn-cancel { 
    background: var(--light-bg); 
    border-color: var(--light-border); 
    color: var(--light-text); 
    transition: all 0.2s ease;
}
.btn-cancel:hover { 
    background: var(--danger-color); 
    border-color: var(--danger-color);
    color: #fff; 
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}
.btn-cancel:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35);
}

/* Warning button styling for backup "Go Back" button */
.btn-warning { 
    background: var(--warning-color-light, rgba(245, 158, 11, 0.1)); 
    color: var(--warning-color, #f59e0b); 
    border-color: var(--warning-color-light, rgba(245, 158, 11, 0.3)); 
    transition: all 0.2s ease;
}
.btn-warning:hover { 
    background: var(--warning-color-light, rgba(245, 158, 11, 0.2)); 
    color: var(--warning-color-dark, #d97706); 
    border-color: var(--warning-color, #f59e0b);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}
.btn-warning:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
}

/* Dark theme support for warning button */
html[data-theme="midnight"] .btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}
html[data-theme="midnight"] .btn-warning:hover {
    background: rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    border-color: #fbbf24;
}

/* Form & Input Styles */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 8px; }
.form-group input, .form-group textarea, .form-group select, .editor-input {
    width: 100%; padding: 12px; border-radius: 8px;
    border: 1px solid var(--light-border); font-size: 1em;
    background: var(--light-bg); color: var(--light-text); font-family: inherit;
}
.editor-input { padding: 8px 12px; height: 40px; font-size: 0.9rem; background: var(--light-surface); }
.editor-input.text-center { text-align: center; }

/* Enhanced Backup Confirmation Redesign */
.backup-confirmation-redesign {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Title section */
.backup-confirmation-title {
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--light-border);
}

.backup-confirmation-title h3 {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--light-text);
}

.backup-status {
    font-size: 0.8rem;
    color: var(--light-text-secondary);
    font-weight: 500;
}

/* Enhanced backup info header */
.backup-info-header {
    background: linear-gradient(135deg, var(--light-surface) 0%, var(--light-bg) 100%);
    border: 1px solid var(--light-border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.backup-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.backup-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.info-icon {
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color-alpha);
    border-radius: 8px;
    flex-shrink: 0;
}

.backup-info-item.current .info-icon {
    background: rgba(99, 102, 241, 0.1);
}

.backup-info-item.backup .info-icon {
    background: rgba(34, 197, 94, 0.1);
}

.backup-info-item.date .info-icon {
    background: rgba(59, 130, 246, 0.1);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--light-text-secondary);
    line-height: 1;
}

.info-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--light-text);
    line-height: 1.1;
}

/* Enhanced tabbed restoration interface */
.restore-mode-tabs {
    border: 1px solid var(--light-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--light-surface);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab-buttons {
    display: flex;
    background: var(--light-bg);
    border-bottom: 1px solid var(--light-border);
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    color: var(--light-text-secondary);
}

.mode-tab:not(:last-child) {
    border-right: 1px solid var(--light-border);
}

.mode-tab:hover {
    background: var(--primary-color-alpha);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.mode-tab.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.mode-tab.active .tab-icon {
    transform: scale(1.1);
}

.tab-icon {
    font-size: 1.2rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.tab-text {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.2;
}

/* Enhanced tab content area */
.tab-content {
    padding: 20px;
    background: white;
}

.mode-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.mode-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mode-explanation {
    margin-bottom: 16px;
    text-align: center;
}

.mode-explanation strong {
    display: block;
    font-size: 1rem;
    color: var(--light-text);
    margin-bottom: 6px;
    font-weight: 600;
}

.mode-explanation p {
    font-size: 0.85rem;
    color: var(--light-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Enhanced preview section */
.mode-preview {
    background: linear-gradient(135deg, var(--primary-color-alpha) 0%, rgba(129, 140, 248, 0.05) 100%);
    border: 1px solid var(--primary-color, rgba(129, 140, 248, 0.3));
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
    font-size: 0.85rem;
    color: var(--light-text);
    min-height: 32px;
    position: relative;
}

.mode-preview::before {
    content: '📊';
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 1rem;
}

.mode-preview .preview-summary {
    font-weight: 600;
    margin-left: 24px;
    line-height: 1.4;
}

.preview-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Enhanced contextual warnings */
.mode-warning {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.mode-warning.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.mode-warning.safe {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #16a34a;
}

.mode-warning.info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #2563eb;
}

/* Mobile responsiveness for backup confirmation */
@media (max-width: 768px) {
    .backup-confirmation-redesign {
        gap: 12px;
    }
    
    .backup-info-header {
        padding: 10px 12px;
    }
    
    .backup-info-grid {
        gap: 12px;
    }
    
    .info-label {
        font-size: 0.7rem;
    }
    
    .info-value {
        font-size: 1rem;
    }
    
    .tab-content {
        padding: 12px;
    }
    
    .mode-tab {
        padding: 10px 6px;
        gap: 3px;
    }
    
    .tab-icon {
        font-size: 1rem;
    }
    
    .tab-text {
        font-size: 0.75rem;
    }
    
    .mode-preview {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    .mode-warning {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .backup-info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .backup-info-item:nth-child(3) {
        grid-column: 1 / -1;
        justify-self: center;
        margin-top: 6px;
    }
    
    .mode-tab {
        padding: 10px 2px;
        gap: 2px;
        min-width: 0;
        flex: 1;
    }
    
    .tab-text {
        font-size: 0.65rem;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .tab-content {
        padding: 12px;
    }
}

@media (max-width: 360px) {
    .tab-text {
        display: none;
    }
    
    .mode-tab {
        padding: 12px 4px;
        justify-content: center;
    }
    
    .tab-icon {
        font-size: 1.4rem;
    }
}

/* Search controls layout */
.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.search-container {
    position: relative;
    flex: 1;
}
.search-input {
    width: 100%; padding: 10px 35px 10px 12px; border-radius: 8px;
    border: 1px solid var(--light-border); font-size: 0.9rem;
    background: var(--light-bg); color: var(--light-text); font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

/* Search clear button */
.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--light-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.search-clear-btn:hover {
    background-color: var(--light-border);
    color: var(--light-text);
}

/* Sort dropdown */
.sort-dropdown {
    padding: 10px 35px 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--light-border);
    font-size: 0.9rem;
    background: var(--light-bg);
    color: var(--light-text);
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23666'%3E%3Cpath d='M8 10.5l-3.5-3.5h7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    background-size: 16px 16px;
}
.sort-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

/* Category usage count styles */
.category-usage-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color-alpha);
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    min-width: 24px;
    height: 20px;
}

/* Date buttons layout */
.date-buttons-wrapper {
    margin-top: 15px;
}
.date-buttons-main {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.modal-btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid;
    background: transparent;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 24px;
    white-space: nowrap;
    flex: 0 0 auto;
}
.modal-btn-small.btn-green {
    border-color: var(--green-color, #10b981);
    color: var(--green-color, #10b981);
}
.modal-btn-small.btn-green:hover {
    background-color: var(--green-color, #10b981);
    color: white;
    border-color: var(--green-color, #10b981);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}
.modal-btn-small.btn-blue {
    border-color: var(--blue-color, #3b82f6);
    color: var(--blue-color, #3b82f6);
}
.modal-btn-small.btn-blue:hover {
    background-color: var(--blue-color, #3b82f6);
    color: white;
    border-color: var(--blue-color, #3b82f6);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}
.modal-btn-small.btn-gray {
    border-color: var(--light-border);
    color: var(--light-text-secondary);
}
.modal-btn-small.btn-gray:hover {
    background-color: var(--light-border);
    color: var(--light-text);
    transform: translateY(-1px);
}

/* Date buttons expansion */
.date-buttons-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-buttons-main {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.date-buttons-expanded {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--light-border);
    margin-top: 4px;
    animation: expandIn 0.2s ease-out;
}

@keyframes expandIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 100px;
    }
}

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(129, 140, 248, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    opacity: 0.9;
}

.scroll-to-top:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(129, 140, 248, 0.6);
}

.scroll-to-top:active {
    transform: translateY(0);
}

/* Modal overlay scroll lock */
body.modal-open {
    overflow: hidden;
}

/* Help Modal Specific Styles */
.help-modal-content {
    max-width: 800px;
    max-height: 90vh;
}

.help-modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 5px;
}

.help-section {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--light-bg);
    border-radius: 12px;
    border: 1px solid var(--light-border);
}

.help-section h3 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
    font-weight: 600;
}

.help-item {
    margin-bottom: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    line-height: 1.5;
}

.help-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.help-item strong {
    color: var(--secondary-color);
    font-weight: 600;
}

.help-tips {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.1), rgba(244, 114, 182, 0.1));
    border-radius: 12px;
    border: 1px solid var(--primary-color);
}

.help-tips h3 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.1em;
    font-weight: 600;
}

.help-tips ul {
    margin: 0;
    padding-left: 20px;
}

.help-tips li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--light-text);
}

.help-tips li:last-child {
    margin-bottom: 0;
}

/* Dark theme support for help modal */
html[data-theme="midnight"] .help-section {
    background: var(--midnight-bg);
    border-color: var(--midnight-border);
}

html[data-theme="midnight"] .help-item {
    border-bottom-color: rgba(255,255,255,0.1);
}

html[data-theme="midnight"] .help-tips {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.15), rgba(244, 114, 182, 0.15));
    border-color: var(--primary-color);
}

html[data-theme="midnight"] .help-tips li {
    color: var(--midnight-text);
}


/* Fieldset legend with inline clear button */
fieldset legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

fieldset legend span {
    flex: 1;
}

.clear-all-dates-btn {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    opacity: 0.8;
}

.clear-all-dates-btn:hover {
    opacity: 1;
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.clear-all-dates-btn svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}

/* --- Editor & Import Specific Styles --- */
.editor-form fieldset {
    padding: 10px 12px; background: var(--light-bg); border-radius: 12px;
    border: 1px solid var(--light-border); margin-bottom: 10px;
}
.editor-form legend { padding: 0 8px; font-weight: 600; color: var(--light-text-secondary); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor-grid-item { display: flex; flex-direction: column; gap: 8px; }

.color-input-container {
    position: relative; display: flex; align-items: center; height: 40px;
    background-color: var(--light-surface); border: 1px solid var(--light-border);
    border-radius: 8px; cursor: pointer; justify-content: flex-start; padding: 0 8px;
}
.color-input-container input[type="color"] {
    position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.color-input-container .color-preview-swatch {
    width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--light-border);
    pointer-events: none;
}
.color-input-container span { margin-left: 10px; font-weight: 500; color: var(--light-text-secondary); font-size: 0.9rem; }

.segmented-control-wrapper {
    display: flex; align-items: center; justify-content: center; height: 40px;
    background-color: var(--light-bg); border: 1px solid var(--light-border);
    border-radius: 8px; padding: 4px;
}
.segmented-control { width: 100%; display: flex; gap: 4px; }
.segmented-control button {
    width: 100%; padding: 4px 10px; border-radius: 6px; border: 1px solid transparent;
    background: transparent; font-size: 0.9rem; font-weight: 600;
    color: var(--light-text-secondary); cursor: pointer; transition: all 0.2s ease;
}
.segmented-control button.active {
    background-color: var(--light-surface); color: var(--primary-color);
    font-weight: 700; border-color: var(--light-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.toggle-wrapper {
    display: flex; align-items: center; justify-content: flex-start; height: 40px;
    background-color: var(--light-surface); border: 1px solid var(--light-border);
    border-radius: 8px; padding: 0 8px;
}
.toggle-wrapper label { margin: 0 10px; font-size: 0.9rem; white-space: nowrap; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.toggle-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .toggle-slider { background-color: var(--info-color); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

/* Enhanced visual feedback for checked exclude holidays toggle */
.toggle-switch input:checked ~ label,
.toggle-switch input:checked + .toggle-slider + label {
    color: var(--info-color);
    font-weight: 600;
}

.toggle-wrapper:has(input:checked) {
    background-color: var(--info-color-light, rgba(59, 130, 246, 0.1));
    border-color: var(--info-color);
}

.date-entry-container { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.date-entry-container:not(:empty) { border: 1px solid var(--light-border); border-radius: 8px; padding: 6px; background: var(--light-bg); }
.date-entry-item { display: grid; align-items: center; gap: 6px; grid-template-columns: 1fr auto 1fr auto; }
.date-entry-item.single { grid-template-columns: 1fr auto; }
.date-entry-item > span { text-align: center; color: var(--light-text-secondary); }
.remove-date-btn {
    background: var(--danger-color); color: white; border: none; border-radius: 50%;
    width: 24px; height: 24px; cursor: pointer; font-weight: bold; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
    line-height: 1; padding: 0;
    transition: all 0.2s ease;
}
.remove-date-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Pill Reference Styles - Scoped pill styles for specific modal buttons only */
.btn{display:inline-flex;align-items:center;gap:8px;padding:10px 20px;border-radius:999px;border:1.5px solid;font-weight:600;cursor:pointer;transition:.2s;line-height:1}
.btn svg{width:20px;height:20px}
.btn-outline{background:transparent}
.btn-blue{color:var(--blue-600);border-color:var(--blue-600)}
.btn-blue:hover{background:var(--blue-600);color:#fff}
.btn-green{color:var(--emerald-600);border-color:var(--emerald-600)}
.btn-green:hover{background:var(--emerald-600);color:#fff}
.btn-indigo{color:var(--indigo-500);border-color:var(--indigo-500)}
.btn-indigo:hover{background:var(--indigo-500);color:#fff}
.btn-fill{border-color:transparent;color:#fff}
.btn-primary{background:var(--indigo-500)} .btn-primary:hover{background:var(--indigo-400)}
.btn-success{background:var(--emerald-600)} .btn-success:hover{background:var(--emerald-500)}
.btn-rose{color:var(--rose-600);border-color:var(--rose-600)}
.btn-rose:hover{background:var(--rose-600);color:#fff}
.btn-gray{color:var(--slate-600);border-color:var(--slate-600)}
.btn-gray:hover{background:var(--slate-600);color:#fff}
.btn-orange{color:var(--orange-600);border-color:var(--orange-600)}
.btn-orange:hover{background:var(--orange-600);color:#fff}

/* Data Management Tools */
.modal-actions { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.modal-actions-left { 
    display: flex; 
    align-items: center; 
    gap: 12px;
}
/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Data Menu */
.data-menu-container {
    position: relative;
}

.data-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    background: var(--light-surface);
    color: var(--light-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.data-menu-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.data-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--light-surface);
    border: 1px solid var(--light-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 8px;
    min-width: 160px;
    z-index: 1000;
    backdrop-filter: blur(16px);
}

.data-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--light-text);
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: left;
}

.data-menu-item:hover {
    background: var(--primary-color-light, rgba(59, 130, 246, 0.1));
    color: var(--primary-color);
}

.data-menu-item svg {
    flex-shrink: 0;
}

/* Data Icon Button (in modal actions) */
.data-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background: var(--light-surface);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-icon-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.data-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 3 !important;
}

/* Adjust data menu positioning for actions placement */
.modal-actions .data-menu {
    bottom: 100%;
    top: auto;
    margin-bottom: 8px;
    margin-top: 0;
}

/* Template Gallery Modal */
.template-gallery-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    min-height: 0;
}
.template-gallery-search {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.template-search-input {
    padding: 12px 16px;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    font-size: 0.9em;
    background: var(--light-bg);
}
.template-categories {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 2px;
}
.template-category-tab {
    padding: 6px 12px;
    border: 1px solid var(--light-border);
    border-radius: 20px;
    background: var(--light-surface);
    color: var(--light-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 0.85em;
    font-weight: 500;
}
.template-category-tab:hover {
    background: var(--light-hover);
    border-color: var(--primary-color);
}
.template-category-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.template-gallery-content {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--light-border);
    border-radius: 8px;
    padding: 16px;
    background: var(--light-bg);
    min-height: 400px;
}
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.template-card {
    background: var(--light-surface);
    border: 1px solid var(--light-border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.template-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.template-card.selected {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.05);
    box-shadow: 0 0 0 1px var(--primary-color);
}
.template-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.template-card-emoji {
    font-size: 1.5em;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--light-hover);
}
.template-card-title {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--light-text);
    flex: 1;
}
.template-card-description {
    font-size: 0.8em;
    color: var(--light-text-secondary);
    line-height: 1.4;
}
.template-card-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--light-border);
    flex-shrink: 0;
}

/* Pill Size Normalize - Make ALL bottom modal buttons same size across modals */
.modal-actions button,
.modal-actions .modal-btn,
.modal-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  line-height: 1;
  font-weight: 600;
}
.modal-actions button svg,
.modal-actions .modal-btn svg,
.modal-actions .btn svg {
  width: 20px;
  height: 20px;
}

/* Final Pill Size Tweaks */
.modal-actions .modal-btn, .modal-actions .btn {
  font-weight: 600 !important;
  padding: 9px 16px !important;
}
.modal-actions .modal-btn svg, .modal-actions .btn svg {
  width: 18px !important;
  height: 18px !important;
}

/* Dark Theme Support */
html[data-theme="midnight"] .data-menu-btn {
    background: var(--midnight-surface);
    border-color: var(--midnight-border);
    color: var(--midnight-text-secondary);
}

html[data-theme="midnight"] .data-menu {
    background: var(--midnight-surface);
    border-color: var(--midnight-border);
}

html[data-theme="midnight"] .data-menu-item {
    color: var(--midnight-text);
}

html[data-theme="midnight"] .data-menu-item:hover {
    background: var(--primary-color-light, rgba(59, 130, 246, 0.15));
    color: var(--primary-color);
}

html[data-theme="midnight"] .data-icon-btn {
    background: var(--midnight-surface);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

html[data-theme="midnight"] .data-icon-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Import Options */
.import-options {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 8px 0 20px 0;
}

.import-option-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 2px solid var(--light-border);
    border-radius: 12px;
    background: var(--light-surface);
    cursor: pointer;
    transition: all 0.2s ease;
}

.import-option-card.compact {
    flex: 1;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    border-width: 1px;
    font-size: 14px;
    font-weight: 500;
}

.import-option-card:hover {
    border-color: var(--primary-color);
    background: var(--primary-color-light, rgba(59, 130, 246, 0.05));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.import-option-icon {
    flex-shrink: 0;
    color: var(--primary-color);
}

.import-option-icon svg {
    stroke-width: 3 !important;
}

.import-option-content {
    flex: 1;
}

.import-option-content h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--light-text);
}

.import-option-content p {
    margin: 0;
    font-size: 14px;
    color: var(--light-text-secondary);
    line-height: 1.4;
}

.import-option-arrow {
    flex-shrink: 0;
    font-size: 20px;
    color: var(--light-text-secondary);
    transition: transform 0.2s ease;
}

.import-option-card:hover .import-option-arrow {
    transform: translateX(4px);
    color: var(--primary-color);
}

/* Dark Theme for Import Options */
html[data-theme="midnight"] .import-option-card {
    background: var(--midnight-surface);
    border-color: var(--midnight-border);
}

html[data-theme="midnight"] .import-option-card:hover {
    border-color: var(--primary-color);
    background: var(--primary-color-light, rgba(59, 130, 246, 0.1));
}

html[data-theme="midnight"] .import-option-content h3 {
    color: var(--midnight-text);
}

html[data-theme="midnight"] .import-option-content p {
    color: var(--midnight-text-secondary);
}

html[data-theme="midnight"] .import-option-arrow {
    color: var(--midnight-text-secondary);
}

/* Import Expanded Content */
.import-expanded-content {
    margin-top: 20px;
    border-top: 1px solid var(--light-border);
    padding-top: 20px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}


.error-message {
    color: var(--error-color, #ef4444);
    font-size: 14px;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--error-bg, rgba(239, 68, 68, 0.1));
    border-radius: 6px;
    border-left: 3px solid var(--error-color, #ef4444);
}


/* Active option card state */
.import-option-card.active {
    border-color: var(--primary-color);
    background: var(--primary-color-light, rgba(59, 130, 246, 0.05));
}

.import-option-card.active .import-option-arrow {
    color: var(--primary-color);
    transform: translateX(4px) rotate(90deg);
}

/* Backup Import Workflow Styles */
.import-backup-section {
    margin-top: 20px;
}

.backup-step {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.file-upload-area {
    border: 2px dashed var(--light-border);
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--light-surface);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: var(--primary-color-light, rgba(59, 130, 246, 0.05));
}

.file-upload-area.drag-over {
    border-color: var(--primary-color);
    background: var(--primary-color-light, rgba(59, 130, 246, 0.05));
    border-style: solid;
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--light-text);
}

.file-upload-content svg {
    color: var(--primary-color);
}

.file-upload-content small {
    color: var(--light-text-secondary);
    font-size: 0.875rem;
}

.selected-file-info {
    margin-top: 12px;
    padding: 12px;
    background: var(--success-color-light, rgba(34, 197, 94, 0.1));
    border: 1px solid var(--success-color-light, rgba(34, 197, 94, 0.2));
    border-radius: 8px;
}

.file-info-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.clear-file-btn {
    background: none;
    border: none;
    font-size: 1.25em;
    color: var(--light-text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-file-btn:hover {
    color: var(--error-color);
    background: var(--error-color-light, rgba(239, 68, 68, 0.1));
}

.backup-confirmation-content h3 {
    margin-bottom: 16px;
    color: var(--warning-color);
    text-align: center;
}

.backup-details {
    background: var(--light-bg);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--light-border);
}

.backup-details .detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.backup-details .detail-row:last-child {
    margin-bottom: 0;
}

.backup-details .detail-label {
    font-weight: 600;
    color: var(--light-text-secondary);
}

.backup-details .detail-value {
    font-weight: 500;
    color: var(--light-text);
}



.backup-success-content h3 {
    margin-bottom: 16px;
    color: var(--success-color);
    text-align: center;
}

.backup-success-content {
    text-align: center;
    padding: 20px;
}

#backup-success-details {
    background: var(--success-color-light, rgba(34, 197, 94, 0.1));
    border: 1px solid var(--success-color-light, rgba(34, 197, 94, 0.2));
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

/* Dark theme support for backup elements */
html[data-theme="midnight"] .file-upload-area {
    background: var(--midnight-surface);
    border-color: var(--midnight-border);
}

html[data-theme="midnight"] .file-upload-content {
    color: var(--midnight-text);
}

html[data-theme="midnight"] .file-upload-content small {
    color: var(--midnight-text-secondary);
}

html[data-theme="midnight"] .backup-details {
    background: var(--midnight-bg);
    border-color: var(--midnight-border);
}

html[data-theme="midnight"] .backup-details .detail-label {
    color: var(--midnight-text-secondary);
}

html[data-theme="midnight"] .backup-details .detail-value {
    color: var(--midnight-text);
}

/* Dark theme for expanded content */
html[data-theme="midnight"] .import-expanded-content {
    border-top-color: var(--midnight-border);
}


html[data-theme="midnight"] .error-message {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Enhanced mobile stacking for search/sort/import controls */
@media (max-width: 600px) {
    .search-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-container {
        width: 100%;
    }
    
    .sort-dropdown {
        width: 100%;
    }
    
    /* Stack import controls vertically on mobile */
    .import-type-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .import-type-btn {
        width: 100%;
        justify-content: center;
    }
}