:root {
  /* LIGHT MODE PALETTE */
  --bg: #ffffff;
  --panel: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --danger: #ef4444;
  --success: #22c55e;
  
  --today-bg: rgba(239, 68, 68, 0.1); 
  --today-line: #ef4444;
  
  --row-h-task: 28px;
  --row-h-header: 24px;
  --side-w: 300px;
  
  --stripe-bg-odd: #ffffff;
  --stripe-bg-even: repeating-linear-gradient(
      45deg,
      #f1f5f9,
      #f1f5f9 10px,
      #f8fafc 10px,
      #f8fafc 20px
    );
}

* { box-sizing: border-box; }

body { 
  margin: 0; padding: 0; 
  background: var(--bg); color: var(--text); 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
  height: 100vh; overflow: hidden; font-size: 13px;
}

#app { display: flex; flex-direction: column; height: 100%; width: 100%; min-height: 0; }

/* HEADER */
header { background: #ffffff; border-bottom: 1px solid var(--border); padding: 10px 20px; flex-shrink: 0; box-shadow: 0 2px 4px rgba(0,0,0,0.02); z-index: 50; }
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
h1 { margin: 0; font-size: 20px; color: #0f172a; font-weight: 700; letter-spacing: -0.5px; }
.version-tag { font-size: 11px; color: #64748b; margin-top: 2px; }

.main-tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 3px; border-radius: 6px; }
.main-tab-btn { background: transparent; border: none; padding: 6px 16px; font-weight: 500; color: #64748b; cursor: pointer; border-radius: 4px; transition: all 0.2s; font-size: 13px; }
.main-tab-btn:hover { color: #334155; background: rgba(255,255,255,0.5); }
.main-tab-btn.active { background: white; color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.1); font-weight: 600; }

/* CONTROLS */
.controls-wrapper { display: flex; width: 100%; align-items: center; }
.controls { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.control-group { display: flex; flex-direction: column; gap: 3px; position: relative; }
label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }

input[type="text"], input[type="date"], select { 
    background: white; border: 1px solid #cbd5e1; color: var(--text); 
    padding: 0 8px; border-radius: 4px; font-size: 12px; height: 30px; 
    outline: none; transition: border 0.2s;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus { border-color: var(--accent); }
input[type="text"] { width: 120px; }

.group-box { display: flex; gap: 10px; border-left: 1px solid #e2e8f0; padding-left: 15px; border-right: 1px solid #e2e8f0; padding-right: 15px; }
.checkbox-group { justify-content: center; height: 30px; gap: 0; }
.cb-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; cursor: pointer; user-select: none; }
input[type="checkbox"] { margin: 0; cursor: pointer; accent-color: var(--accent); width: 14px; height: 14px; }

/* CUSTOM MULTI-SELECT */
.custom-select-container { position: relative; width: 140px; height: 30px; }
.custom-select-container.wide { width: 100%; height: 32px; } 

.custom-select-trigger {
    background: white; border: 1px solid #cbd5e1; border-radius: 4px;
    height: 100%; display: flex; align-items: center; padding: 0 8px;
    cursor: pointer; font-size: 12px; 
    justify-content: space-between; 
    white-space: nowrap; overflow: hidden;
}
.custom-select-trigger:hover { border-color: #94a3b8; }
.custom-select-trigger span { overflow: hidden; text-overflow: ellipsis; }
.custom-select-trigger::after { content: '▼'; font-size: 8px; color: #94a3b8; margin-left: 5px; }

.custom-dropdown {
    position: absolute; top: 105%; left: 0; width: 220px; 
    background: white; border: 1px solid #cbd5e1; border-radius: 6px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 9999;
    display: none; flex-direction: column; max-height: 300px;
    text-align: left; 
}
.custom-select-container.wide .custom-dropdown { width: 100%; }
.custom-dropdown.show { display: flex; }

.custom-dropdown-search { padding: 5px; border-bottom: 1px solid #f1f5f9; }
.custom-dropdown-search input { width: 100%; border: 1px solid #e2e8f0; }
.custom-dropdown-list { overflow-y: auto; max-height: 250px; padding: 5px 0; }

.custom-option {
    display: flex !important; align-items: center !important; justify-content: flex-start !important; 
    gap: 8px !important; padding: 6px 10px !important; 
    cursor: pointer; font-size: 12px; color: var(--text); width: 100% !important; box-sizing: border-box !important; text-align: left !important; background: transparent;
}
.custom-option:hover { background: #f1f5f9; }

.custom-option input[type="checkbox"] { 
    appearance: auto !important; width: 16px !important; height: 16px !important;     
    margin: 0 !important; padding: 0 !important; flex-shrink: 0 !important; 
    border: 1px solid #cbd5e1 !important; border-radius: 3px !important;
}
.custom-option span { 
    text-align: left !important; flex: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; line-height: 16px;
}

/* LAYOUTS */
.view-content { flex-grow: 1; overflow: hidden; position: relative; height: 100%; min-height: 0; }
.view-content.active { display: flex; }
#side-panel { width: var(--side-w); flex-shrink: 0; border-right: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; z-index: 20; }
.side-header { height: 34px; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding-left: 12px; font-weight: 700; background: #f8fafc; color: #475569; flex-shrink: 0; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
#project-list { overflow: hidden; flex-grow: 1; background: var(--bg); }

/* ROWS */
.row-label { display: flex; align-items: center; padding-left: 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text); background: transparent; }
.row-label.group { font-weight: 700; color: var(--accent); padding-left: 8px; font-size: 13px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.row-label.delivery { padding-left: 20px; font-style: italic; color: var(--accent); font-weight: 500; background: #fff; }
.row-label.item { padding-left: 40px; background: #fff; }

/* SVG */
#gantt-viewport { flex: 1; width: 100%; height: 100%; overflow: auto; position: relative; background: white; }
.timeline-wrapper { position: relative; min-width: 100%; height: 100%; }
.sticky-axis { position: sticky; top: 0; left: 0; z-index: 30; background: #f8fafc; height: 34px; border-bottom: 1px solid var(--border); }
text { fill: var(--text); font-family: inherit; }
.axis-label-main { font-weight: 700; font-size: 11px; fill: #334155; }
.axis-label-sub { font-size: 10px; fill: #94a3b8; }
.grid-line { stroke: #e2e8f0; stroke-width: 1; }
.row-line { stroke: #e2e8f0; stroke-width: 1; opacity: 1; }
.bg-rect-0 { fill: var(--stripe-bg-odd); }
.bg-rect-1 { fill: #f8fafc; } 
.today-rect { fill: var(--today-bg); }
.today-line-precise { stroke: var(--today-line); stroke-width: 1.5; stroke-dasharray: 4 2; }

/* BARS */
.bar { cursor: pointer; transition: opacity 0.2s; stroke: rgba(0,0,0,0.1); stroke-width: 1px; }
.bar:hover { opacity: 0.85; stroke: rgba(0,0,0,0.3); }
.bar-text { fill: #ffffff; font-size: 11px; text-shadow: 0 0 3px rgba(0,0,0,0.5); pointer-events: none; }
.alarm-icon { font-size: 12px; fill: red; font-weight: bold; }

/* SETTINGS & UI */
.sub-tabs-header { display: flex; gap: 0; border-bottom: 1px solid var(--border); background: #f8fafc; padding: 0 20px; flex-shrink: 0; }
.sub-tab-btn { padding: 12px 20px; background: transparent; border: none; border-bottom: 2px solid transparent; cursor: pointer; color: #64748b; font-weight: 500; font-size: 13px; }
.sub-tab-btn:hover { color: var(--accent); }
.sub-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.sub-tab-content { display: none; padding: 30px; overflow-y: auto; flex: 1; background: #fff; }
.sub-tab-content.active { display: block; }
.settings-container { max-width: 1100px; margin: 0 auto; }
h3 { margin-top: 0; color: #0f172a; border-bottom: 1px solid #f1f5f9; padding-bottom: 10px; margin-bottom: 20px; }
h4 { margin: 0 0 8px 0; color: #334155; }
.system-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.edit-form { padding: 0; border: none; background: transparent; }
.form-row { display: flex; gap: 20px; margin-bottom: 15px; flex-wrap: wrap; }
.form-inline { align-items: flex-end; }
.col { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 100px; }
.col input, .col select { width: 100%; }
.col.actions { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 10px; padding-bottom: 2px; }
.form-actions.right { text-align: right; margin-top: 20px; }

.btn-modern { padding: 0 16px; height: 32px; border-radius: 6px; font-weight: 600; font-size: 12px; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; box-shadow: 0 1px 2px rgba(0,0,0,0.05); white-space: nowrap; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-secondary { background: white; border-color: #cbd5e1; color: #475569; }
.btn-secondary:hover { border-color: #94a3b8; color: #334155; }
.btn-danger { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* TABLES & SORT */
.data-table-wrapper { border: 1px solid #e2e8f0; border-radius: 8px; overflow: visible; box-shadow: 0 2px 10px rgba(0,0,0,0.02); margin-bottom: 30px; }
table { width: 100%; border-collapse: collapse; table-layout: auto; }

th { 
    background: #f1f5f9; color: #475569; text-align: left; padding: 8px 12px; font-weight: 600; 
    border-bottom: 1px solid #e2e8f0; font-size: 11px; text-transform: uppercase; 
    cursor: pointer; user-select: none; vertical-align: top; 
}

th:last-child { 
    width: auto; 
    white-space: nowrap; 
    text-align: left; 
}

td:last-child { 
    width: auto; 
    white-space: nowrap; 
    text-align: right; 
}

/* 2. TOTO JE DŮLEŽITÉ: Přidá mezeru přímo tlačítkům */
td:last-child button {
    margin-left: 8px;
}

#data-table th:nth-child(1), #data-table th:nth-child(2), #data-table th:nth-child(3) { width: 20%; }
#people-table th:nth-child(1) { width: 34%; }
#people-table th:nth-child(2) { width: 34%; }

td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.th-filter-box { width: 100%; height: 30px; margin-top: 4px; position: relative; }
.sort-icon { font-size: 10px; margin-left: 4px; color: #94a3b8; float: right; }

/* PALETTE GRID */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.color-item { background: white; padding: 15px; border: 1px solid #e2e8f0; border-radius: 8px; display: flex; flex-direction: column; gap: 10px; }
.palette-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 5px; }
.color-swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: #1e293b; transform: scale(1.1); box-shadow: 0 0 0 2px white, 0 0 0 4px #1e293b; }
.color-swatch.disabled { opacity: 0.1; pointer-events: none; filter: grayscale(100%); }

footer { background: #fff; border-top: 1px solid var(--border); padding: 8px; flex-shrink: 0; min-height: 40px; }
.chips { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 6px; background: #f1f5f9; padding: 3px 10px; border-radius: 12px; font-size: 11px; color: #475569; border: 1px solid #e2e8f0; }
.dot { width: 8px; height: 8px; border-radius: 50%; }

/* TOGGLE */
.toggle-wrapper { display: flex; align-items: center; gap: 8px; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(16px); }

/* SYSTEM UI */
#tooltip { position: fixed; background: rgba(30, 41, 59, 0.95); color: white; padding: 10px 14px; border-radius: 6px; display: none; z-index: 1000; font-size: 12px; pointer-events: none; box-shadow: 0 10px 25px rgba(0,0,0,0.15); line-height: 1.5; border: 1px solid rgba(255,255,255,0.1); }

/* TOAST - Bottom Center */
#toast-container { 
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); 
    z-index: 10000; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.toast { background: #334155; color: white; padding: 12px 20px; border-radius: 6px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: fadeIn 0.3s; opacity: 0.95; white-space: nowrap; }
.toast.error { background: #ef4444; }
.toast.success { background: #22c55e; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 0.95; transform: translateY(0); } }

/* MODALS */
#modal-overlay, #import-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 5000; display: flex; justify-content: center; align-items: center; }
.modal-box { background: white; padding: 25px; border-radius: 8px; width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); max-height: 90vh; display: flex; flex-direction: column; }

/* MODAL LARGE - UPDATED WIDTH FOR IMPORT */
.modal-box.large { 
    width: 95vw;          /* 95% šířky obrazovky */
    max-width: 1600px;    /* Maximální šířka pro ultra-wide */
    height: 90vh;         /* Pevná výška (90% výšky okna) */
}

.modal-box h3 { margin-top: 0; margin-bottom: 10px; border-bottom: none; }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* IMPORT PREVIEW - UPDATED SCROLL BEHAVIOR */
.preview-scroll-area { 
    border: 1px solid #e2e8f0; 
    border-radius: 4px; 
    overflow-y: auto;     /* Vertikální posuvník */
    overflow-x: auto;     /* Horizontální jen když je nutné */
    flex: 1;              /* Zabere veškeré zbylé místo v .modal-box */
    min-height: 0;        /* Důležité pro flex kontejner */
    background: #f8fafc; 
}

.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview-table th { position: sticky; top: 0; background: #e2e8f0; z-index: 1; }
.preview-table td { background: white; border-bottom: 1px solid #f1f5f9; padding: 8px; }
.diff-bold { font-weight: bold; color: #000; background-color: #fefce8; }

/* MANUAL STYLES */
.manual-content h3 { color: var(--accent); margin-top: 0; margin-bottom: 15px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; }
.manual-content h4 { color: #334155; font-size: 14px; margin-top: 20px; margin-bottom: 8px; font-weight: 700; }
.manual-content p { line-height: 1.6; color: #475569; margin-bottom: 15px; }
.manual-content ul { padding-left: 20px; margin-bottom: 15px; }
.manual-content li { margin-bottom: 6px; line-height: 1.5; color: #475569; }
.manual-content blockquote { background: #f0f9ff; border-left: 4px solid var(--accent); margin: 20px 0; padding: 15px; color: #334155; font-style: italic; }
.manual-tip { background: #ecfdf5; border: 1px solid #d1fae5; border-radius: 6px; padding: 12px; margin: 10px 0; color: #065f46; font-size: 12px; }
.manual-tip strong { color: #047857; }
.manual-warning { background: #fef2f2; border: 1px solid #fee2e2; border-radius: 6px; padding: 12px; margin: 10px 0; color: #991b1b; font-size: 12px; }
.manual-warning strong { color: #b91c1c; }
.manual-intro { font-size: 14px; color: #1e293b; margin-bottom: 30px; background: #f8fafc; padding: 20px; border-radius: 8px; border: 1px solid #e2e8f0; }