*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --c-bg: #f5f6fa; --c-card: #fff; --c-border: #e0e3eb;
  --c-text: #1a1d26; --c-muted: #6b7280; --c-accent: #4f46e5;
  --c-day: #22c55e; --c-night: #8b5cf6; --c-bus: #f97316;
  --c-free: #06b6d4; --c-off: #9ca3af; --c-short: #eab308; --c-break-cover: #f472b6;
  /* Barvy pracovniku */
  --w0: #2563eb; --w0-light: #93bbfd; --w0-pale: #dbeafe;
  --w1: #dc2626; --w1-light: #f87171; --w1-pale: #fee2e2;
  --w2: #16a34a; --w2-light: #6ee7a0; --w2-pale: #dcfce7;
  --w3: #d97706; --w3-light: #fbbf24; --w3-pale: #fef3c7;
  --w4: #9333ea; --w4-light: #c084fc; --w4-pale: #f3e8ff;
  --w5: #0891b2; --w5-light: #67e8f9; --w5-pale: #cffafe;
  --c-err: #ef4444; --c-warn: #f59e0b; --c-ok: #22c55e;
  --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
body { font-family: 'Inter', system-ui, sans-serif; background: var(--c-bg); color: var(--c-text); line-height: 1.5; padding: 16px; }
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.subtitle { color: var(--c-muted); font-size: .85rem; margin-bottom: 16px; }
.card { background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 3px; }
.form-group label { font-size: .78rem; font-weight: 500; color: var(--c-muted); text-transform: uppercase; letter-spacing: .3px; }
input[type="datetime-local"], input[type="text"], input[type="number"], select {
  padding: 6px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: .88rem;
  font-family: inherit; background: #fff; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 2px rgba(79,70,229,.15); }
input[type="number"] { width: 70px; }
input[type="datetime-local"] { width: 200px; }
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border: none; border-radius: 6px; font-size: .82rem; font-weight: 500; cursor: pointer; font-family: inherit; transition: .15s; }
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn-danger { background: var(--c-err); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid var(--c-border); color: var(--c-text); }
.btn-outline:hover { background: #f3f4f6; }
.worker-list { display: flex; flex-direction: column; gap: 6px; }
.worker-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #f9fafb; border-radius: 6px; flex-wrap: wrap; }
.worker-item input, .worker-item select { font-size: .84rem; }
.worker-item .worker-name { flex: 1; min-width: 100px; }
.free-block-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #ecfdf5; border-radius: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.tabs { display: flex; gap: 0; margin-bottom: 0; border-bottom: 2px solid var(--c-border); }
.tab { padding: 8px 20px; font-size: .88rem; font-weight: 500; cursor: pointer; border: none; background: none; color: var(--c-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
.tab.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }

/* Gantt */
.gantt-wrap { overflow-x: scroll; margin-top: 12px; padding-bottom: 4px; max-height: 80vh; }
.gantt { display: grid; min-width: 600px; gap: 0; }
.gantt-header-cell { background: #f3f4f6; padding: 6px 8px; font-size: .78rem; font-weight: 600; text-align: center; border-bottom: 2px solid var(--c-border); border-right: 1px solid var(--c-border); }
.gantt-header-cell:first-child { text-align: left; position: sticky; left: 0; z-index: 11; background: #f3f4f6; }
.gantt-name { padding: 3px 5px; font-size: .78rem; font-weight: 600; background: #fff; border-bottom: 1px solid var(--c-border); border-right: 2px solid var(--c-border); display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 70px; position: sticky; left: 0; z-index: 10; }
.gantt-worker-name { font-size: .78rem; font-weight: 600; display: flex; align-items: center; white-space: nowrap; }
.worker-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.gantt-worker-btns { display: flex; flex-wrap: wrap; gap: 2px; }
.gantt-worker-btns .btn { font-size: .58rem; padding: 1px 4px; line-height: 1.4; }
.btn-night { background: var(--c-night); color: #fff; }
.gantt-cell { position: relative; height: 80px; border-bottom: 1px solid var(--c-border); border-right: 1px solid var(--c-border); background: #fff; }
.gantt-timeline { position: relative; height: 80px; border-bottom: 1px solid var(--c-border); background: #fff; }
.timeline-day-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--c-border); z-index: 0; pointer-events: none; }
.timeline-night-zone { position: absolute; top: 0; bottom: 0; background: rgba(139,92,246,.08); pointer-events: none; z-index: 0; }
.gantt-timeline.pending-active { outline: 2px dashed var(--c-accent); outline-offset: -2px; cursor: crosshair; }
.shift-block { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; font-size: .68rem; font-weight: 500; color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.2; overflow: hidden; cursor: grab; z-index: 1; min-width: 18px; padding: 1px 3px; text-shadow: 0 1px 1px rgba(0,0,0,.2); }
/* Barvy dle typu — fallback */
.shift-block.type-day { background: var(--c-day); }
.shift-block.type-night { background: var(--c-night); }
.shift-block.type-bus { background: var(--c-bus); }
.shift-block.type-free { background: var(--c-free); opacity: .7; cursor: default; }
.shift-block.type-off { background: var(--c-off); }
.shift-block.type-short { background: var(--c-short); color: #422006; text-shadow: none; }
.shift-block.type-break-cover { background: var(--c-break-cover); }
/* Barvy dle pracovnika — smena = syty, pohotovost = svetly, volno = bledý */
.shift-block.worker-0.type-day, .shift-block.worker-0.type-short, .shift-block.worker-0.type-bus { background: var(--w0); }
.shift-block.worker-0.type-night { background: var(--w0-light); }
.shift-block.worker-0.type-off { background: var(--w0-pale); color: var(--w0); text-shadow: none; }
.shift-block.worker-1.type-day, .shift-block.worker-1.type-short, .shift-block.worker-1.type-bus { background: var(--w1); }
.shift-block.worker-1.type-night { background: var(--w1-light); }
.shift-block.worker-1.type-off { background: var(--w1-pale); color: var(--w1); text-shadow: none; }
.shift-block.worker-2.type-day, .shift-block.worker-2.type-short, .shift-block.worker-2.type-bus { background: var(--w2); }
.shift-block.worker-2.type-night { background: var(--w2-light); }
.shift-block.worker-2.type-off { background: var(--w2-pale); color: var(--w2); text-shadow: none; }
.shift-block.worker-3.type-day, .shift-block.worker-3.type-short, .shift-block.worker-3.type-bus { background: var(--w3); }
.shift-block.worker-3.type-night { background: var(--w3-light); }
.shift-block.worker-3.type-off { background: var(--w3-pale); color: var(--w3); text-shadow: none; }
.shift-block.worker-4.type-day, .shift-block.worker-4.type-short, .shift-block.worker-4.type-bus { background: var(--w4); }
.shift-block.worker-4.type-night { background: var(--w4-light); }
.shift-block.worker-4.type-off { background: var(--w4-pale); color: var(--w4); text-shadow: none; }
.shift-block.worker-5.type-day, .shift-block.worker-5.type-short, .shift-block.worker-5.type-bus { background: var(--w5); }
.shift-block.worker-5.type-night { background: var(--w5-light); }
.shift-block.worker-5.type-off { background: var(--w5-pale); color: var(--w5); text-shadow: none; }
.shift-block { cursor: grab; }
.resize-handle { position: absolute; top: 0; bottom: 0; right: -3px; width: 10px; cursor: ew-resize; z-index: 3; background: rgba(0,0,0,.2); border-radius: 0 4px 4px 0; opacity: 0; transition: opacity .15s; }
.shift-block:hover .resize-handle { opacity: 1; }
.shift-delete { position: absolute; top: 1px; right: 1px; width: 14px; height: 14px; background: rgba(0,0,0,.35); color: #fff; border-radius: 50%; font-size: .55rem; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 4; line-height: 1; }
.shift-block:hover .shift-delete { opacity: 1; }
.shift-block .shift-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.shift-block .shift-hours { font-size: .62rem; opacity: .85; }
/* Info radek timeline */
.gantt-timeline.gantt-info-row { height: 32px !important; }
.gantt-info-row { min-height: 32px !important; height: 32px !important; background: #fef2f2 !important; font-size: .75rem !important; font-weight: 500 !important; }
.gantt-hour-row { min-height: 22px !important; height: 22px !important; background: #f9fafb !important; font-size: .65rem !important; color: var(--c-muted) !important; }
.hour-mark { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; font-size: .6rem; color: var(--c-muted); border-left: 1px solid #ddd; padding-left: 2px; z-index: 1; pointer-events: none; }
.tz-marker { position: absolute; top: -2px; transform: translateX(-50%); font-size: .6rem; font-weight: 700; color: #fff; padding: 1px 6px; border-radius: 3px; z-index: 5; pointer-events: none; white-space: nowrap; line-height: 1.3; }
.tz-marker-start { background: #7c3aed; border-left: 2px solid #5b21b6; transform: translateX(0); }
.tz-marker-end { background: #7c3aed; border-right: 2px solid #5b21b6; transform: translateX(-100%); }
.tz-arrow { font-size: .55rem; }
.gantt-info-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 600; color: var(--c-muted); z-index: 1; }

/* Table */
.table-view { overflow-x: auto; margin-top: 12px; }
.table-view table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.table-view th { background: #f3f4f6; padding: 8px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--c-border); white-space: nowrap; }
.table-view td { padding: 6px 8px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table-view tr:hover td { background: #f9fafb; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .75rem; font-weight: 500; color: #fff; margin: 1px 2px; white-space: nowrap; }
.tag-day { background: var(--c-day); }
.tag-night { background: var(--c-night); }
.tag-bus { background: var(--c-bus); }
.tag-free { background: var(--c-free); }
.tag-off { background: var(--c-off); }
.tag-short { background: var(--c-short); color: #422006; }

/* Shift grid tabulka */
.shift-grid-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.shift-grid-table th { background: #f3f4f6; padding: 6px 4px; text-align: center; font-weight: 600; font-size: .72rem; border: 1px solid var(--c-border); white-space: nowrap; }
.shift-grid-table td { padding: 2px; border: 1px solid var(--c-border); vertical-align: middle; min-width: 60px; }
.shift-grid-table tr:hover td { background: #fafafa; }
.grid-cell { text-align: center; }
.grid-cell-row { display: flex; gap: 0; }
.grid-worker { padding: 3px 4px; font-size: .7rem; font-weight: 600; text-align: center; white-space: nowrap; flex: 1; }
.tag-break-cover { background: var(--c-break-cover); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat-box { text-align: center; padding: 12px; }
.stat-box .stat-val { font-size: 1.3rem; font-weight: 700; color: var(--c-accent); }
.stat-box .stat-label { font-size: .75rem; color: var(--c-muted); }

/* Worker summary */
.worker-summary-section { padding: 10px 12px; margin-bottom: 12px; background: #fafbfc; border-radius: 6px; }
.worker-summary-name { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.worker-summary-day { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid #f0f1f3; }
.worker-summary-day:last-of-type { border-bottom: none; }
.worker-summary-day-label { font-size: .78rem; font-weight: 600; min-width: 70px; color: var(--c-text); }
.worker-summary-tag { font-size: .72rem; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.worker-summary-tag.type-day, .worker-summary-tag.type-short, .worker-summary-tag.type-bus { background: #dcfce7; color: #166534; }
.worker-summary-tag.type-night { background: #ede9fe; color: #5b21b6; }
.worker-summary-tag.type-free { background: #cffafe; color: #0e7490; }
.worker-summary-tag.type-off { background: #f3f4f6; color: #6b7280; }
.worker-summary-total { font-size: .78rem; font-weight: 600; margin-top: 6px; color: var(--c-muted); }

/* Warnings */
.warnings-list { display: flex; flex-direction: column; gap: 6px; }
.warning-item { padding: 8px 12px; border-radius: 6px; font-size: .84rem; display: flex; align-items: flex-start; gap: 8px; }
.warning-item.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.warning-item.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.warning-item.info { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.warning-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* Section toggle */
.section-toggle { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.section-toggle::before { content: '\25B8'; font-size: .8rem; transition: .15s; display: inline-block; }
.section-toggle.open::before { transform: rotate(90deg); }

/* Print */
@media print {
  body { padding: 0; background: #fff; font-size: 11px; }
  .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .gantt-cell { height: 40px; }
  .shift-block { font-size: .6rem; }
  .tab-content { display: block !important; }

  /* Tisk jen grid tabulky + rozpis po pracovnicich */
  body.print-grid-only > *:not(#output) { display: none !important; }
  body.print-grid-only #output > * { display: none !important; }
  body.print-grid-only #output > #shiftGridCard,
  body.print-grid-only #output > #workerSummaryCard { display: block !important; }
  body.print-grid-only #shiftGridCard,
  body.print-grid-only #workerSummaryCard { border: none; box-shadow: none; }
  body.print-grid-only .shift-grid-table { font-size: 9px; width: 100%; }
  body.print-grid-only .shift-grid-table th { padding: 3px 2px; font-size: 8px; }
  body.print-grid-only .shift-grid-table td { padding: 1px 2px; min-width: 0; }
  body.print-grid-only .grid-worker { font-size: 8px; padding: 2px 2px; }
  body.print-grid-only .worker-summary-section { padding: 6px 8px; margin-bottom: 14px; break-inside: avoid; border-bottom: 1px solid #ccc; padding-bottom: 12px; }
  body.print-grid-only .worker-summary-name { font-size: .85rem; margin-bottom: 3px; }
  body.print-grid-only .worker-summary-day { padding: 2px 0; gap: 4px; }
  body.print-grid-only .worker-summary-day-label { font-size: .7rem; min-width: 55px; }
  body.print-grid-only .worker-summary-tag { font-size: .65rem; padding: 1px 5px; }
  body.print-grid-only .worker-summary-total { display: none !important; }
  body.print-grid-only #workerSummaryCard h2 { font-size: .9rem; margin-bottom: 6px; }
}

@page {
  size: landscape;
  margin: 10mm;
}
